paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* OSPF VTY interface. |
| 2 | * Copyright (C) 2000 Toshiaki Takada |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | * 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "memory.h" |
| 25 | #include "thread.h" |
| 26 | #include "prefix.h" |
| 27 | #include "table.h" |
| 28 | #include "vty.h" |
| 29 | #include "command.h" |
| 30 | #include "plist.h" |
| 31 | #include "log.h" |
| 32 | #include "zclient.h" |
| 33 | |
| 34 | #include "ospfd/ospfd.h" |
| 35 | #include "ospfd/ospf_asbr.h" |
| 36 | #include "ospfd/ospf_lsa.h" |
| 37 | #include "ospfd/ospf_lsdb.h" |
| 38 | #include "ospfd/ospf_ism.h" |
| 39 | #include "ospfd/ospf_interface.h" |
| 40 | #include "ospfd/ospf_nsm.h" |
| 41 | #include "ospfd/ospf_neighbor.h" |
| 42 | #include "ospfd/ospf_flood.h" |
| 43 | #include "ospfd/ospf_abr.h" |
| 44 | #include "ospfd/ospf_spf.h" |
| 45 | #include "ospfd/ospf_route.h" |
| 46 | #include "ospfd/ospf_zebra.h" |
| 47 | /*#include "ospfd/ospf_routemap.h" */ |
| 48 | #include "ospfd/ospf_vty.h" |
| 49 | #include "ospfd/ospf_dump.h" |
| 50 | |
| 51 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 52 | const static char *ospf_network_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 53 | { |
| 54 | "Null", |
| 55 | "POINTOPOINT", |
| 56 | "BROADCAST", |
| 57 | "NBMA", |
| 58 | "POINTOMULTIPOINT", |
| 59 | "VIRTUALLINK", |
| 60 | "LOOPBACK" |
| 61 | }; |
| 62 | |
| 63 | |
| 64 | /* Utility functions. */ |
| 65 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 66 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 67 | { |
| 68 | char *endptr = NULL; |
| 69 | unsigned long ret; |
| 70 | |
| 71 | /* match "A.B.C.D". */ |
| 72 | if (strchr (str, '.') != NULL) |
| 73 | { |
| 74 | ret = inet_aton (str, area_id); |
| 75 | if (!ret) |
| 76 | return -1; |
| 77 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; |
| 78 | } |
| 79 | /* match "<0-4294967295>". */ |
| 80 | else |
| 81 | { |
| 82 | ret = strtoul (str, &endptr, 10); |
| 83 | if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE)) |
| 84 | return -1; |
| 85 | |
| 86 | area_id->s_addr = htonl (ret); |
| 87 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 88 | } |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 95 | str2distribute_source (const char *str, int *source) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 96 | { |
| 97 | /* Sanity check. */ |
| 98 | if (str == NULL) |
| 99 | return 0; |
| 100 | |
| 101 | if (strncmp (str, "k", 1) == 0) |
| 102 | *source = ZEBRA_ROUTE_KERNEL; |
| 103 | else if (strncmp (str, "c", 1) == 0) |
| 104 | *source = ZEBRA_ROUTE_CONNECT; |
| 105 | else if (strncmp (str, "s", 1) == 0) |
| 106 | *source = ZEBRA_ROUTE_STATIC; |
| 107 | else if (strncmp (str, "r", 1) == 0) |
| 108 | *source = ZEBRA_ROUTE_RIP; |
| 109 | else if (strncmp (str, "b", 1) == 0) |
| 110 | *source = ZEBRA_ROUTE_BGP; |
| 111 | else |
| 112 | return 0; |
| 113 | |
| 114 | return 1; |
| 115 | } |
| 116 | |
| 117 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 118 | str2metric (const char *str, int *metric) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | { |
| 120 | /* Sanity check. */ |
| 121 | if (str == NULL) |
| 122 | return 0; |
| 123 | |
| 124 | *metric = strtol (str, NULL, 10); |
| 125 | if (*metric < 0 && *metric > 16777214) |
| 126 | { |
| 127 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | return 1; |
| 132 | } |
| 133 | |
| 134 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 135 | str2metric_type (const char *str, int *metric_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 136 | { |
| 137 | /* Sanity check. */ |
| 138 | if (str == NULL) |
| 139 | return 0; |
| 140 | |
| 141 | if (strncmp (str, "1", 1) == 0) |
| 142 | *metric_type = EXTERNAL_METRIC_TYPE_1; |
| 143 | else if (strncmp (str, "2", 1) == 0) |
| 144 | *metric_type = EXTERNAL_METRIC_TYPE_2; |
| 145 | else |
| 146 | return 0; |
| 147 | |
| 148 | return 1; |
| 149 | } |
| 150 | |
| 151 | int |
| 152 | ospf_oi_count (struct interface *ifp) |
| 153 | { |
| 154 | struct route_node *rn; |
| 155 | int i = 0; |
| 156 | |
| 157 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 158 | if (rn->info) |
| 159 | i++; |
| 160 | |
| 161 | return i; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | DEFUN (router_ospf, |
| 166 | router_ospf_cmd, |
| 167 | "router ospf", |
| 168 | "Enable a routing process\n" |
| 169 | "Start OSPF configuration\n") |
| 170 | { |
| 171 | vty->node = OSPF_NODE; |
| 172 | vty->index = ospf_get (); |
| 173 | |
| 174 | return CMD_SUCCESS; |
| 175 | } |
| 176 | |
| 177 | DEFUN (no_router_ospf, |
| 178 | no_router_ospf_cmd, |
| 179 | "no router ospf", |
| 180 | NO_STR |
| 181 | "Enable a routing process\n" |
| 182 | "Start OSPF configuration\n") |
| 183 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 184 | struct ospf *ospf; |
| 185 | |
| 186 | ospf = ospf_lookup (); |
| 187 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 188 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 189 | vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 190 | return CMD_WARNING; |
| 191 | } |
| 192 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 193 | ospf_finish (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 194 | |
| 195 | return CMD_SUCCESS; |
| 196 | } |
| 197 | |
| 198 | DEFUN (ospf_router_id, |
| 199 | ospf_router_id_cmd, |
| 200 | "ospf router-id A.B.C.D", |
| 201 | "OSPF specific commands\n" |
| 202 | "router-id for the OSPF process\n" |
| 203 | "OSPF router-id in IP address format\n") |
| 204 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 205 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 206 | struct in_addr router_id; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 207 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 208 | |
| 209 | ret = inet_aton (argv[0], &router_id); |
| 210 | if (!ret) |
| 211 | { |
| 212 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); |
| 213 | return CMD_WARNING; |
| 214 | } |
| 215 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 216 | ospf->router_id_static = router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 218 | if (ospf->t_router_id_update == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 219 | OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer, |
| 220 | OSPF_ROUTER_ID_UPDATE_DELAY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | |
| 222 | return CMD_SUCCESS; |
| 223 | } |
| 224 | |
| 225 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 226 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 227 | "router-id A.B.C.D", |
| 228 | "router-id for the OSPF process\n" |
| 229 | "OSPF router-id in IP address format\n") |
| 230 | |
| 231 | DEFUN (no_ospf_router_id, |
| 232 | no_ospf_router_id_cmd, |
| 233 | "no ospf router-id", |
| 234 | NO_STR |
| 235 | "OSPF specific commands\n" |
| 236 | "router-id for the OSPF process\n") |
| 237 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 238 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 239 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 240 | ospf->router_id_static.s_addr = 0; |
| 241 | |
| 242 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 243 | |
| 244 | return CMD_SUCCESS; |
| 245 | } |
| 246 | |
| 247 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 248 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 249 | "no router-id", |
| 250 | NO_STR |
| 251 | "router-id for the OSPF process\n") |
| 252 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 253 | DEFUN (ospf_passive_interface, |
| 254 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | "passive-interface IFNAME A.B.C.D", |
| 256 | "Suppress routing updates on an interface\n" |
| 257 | "Interface's name\n") |
| 258 | { |
| 259 | struct interface *ifp; |
| 260 | struct in_addr addr; |
| 261 | int ret; |
| 262 | struct ospf_if_params *params; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 263 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 264 | |
| 265 | ifp = if_lookup_by_name (argv[0]); |
| 266 | |
| 267 | if (ifp == NULL) |
| 268 | { |
| 269 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 270 | return CMD_WARNING; |
| 271 | } |
| 272 | |
| 273 | params = IF_DEF_PARAMS (ifp); |
| 274 | |
| 275 | if (argc == 2) |
| 276 | { |
| 277 | ret = inet_aton(argv[1], &addr); |
| 278 | if (!ret) |
| 279 | { |
| 280 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 281 | VTY_NEWLINE); |
| 282 | return CMD_WARNING; |
| 283 | } |
| 284 | |
| 285 | params = ospf_get_if_params (ifp, addr); |
| 286 | ospf_if_update_params (ifp, addr); |
| 287 | } |
| 288 | |
| 289 | SET_IF_PARAM (params, passive_interface); |
| 290 | params->passive_interface = OSPF_IF_PASSIVE; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 291 | |
| 292 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 293 | * interfaces for which the passive property changed. It is too much |
| 294 | * work to determine this set, so we do this for every interface. |
| 295 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 296 | * record of joined groups to avoid systems calls if the desired |
| 297 | * memberships match the current memership. |
| 298 | */ |
| 299 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 300 | { |
| 301 | struct ospf_interface *oi = rn->info; |
| 302 | |
| 303 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
| 304 | ospf_if_set_multicast(oi); |
| 305 | } |
| 306 | /* |
| 307 | * XXX It is not clear what state transitions the interface needs to |
| 308 | * undergo when going from active to passive. Fixing this will |
| 309 | * require precise identification of interfaces having such a |
| 310 | * transition. |
| 311 | */ |
| 312 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 313 | return CMD_SUCCESS; |
| 314 | } |
| 315 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 316 | ALIAS (ospf_passive_interface, |
| 317 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 318 | "passive-interface IFNAME", |
| 319 | "Suppress routing updates on an interface\n" |
| 320 | "Interface's name\n") |
| 321 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 322 | DEFUN (no_ospf_passive_interface, |
| 323 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | "no passive-interface IFNAME A.B.C.D", |
| 325 | NO_STR |
| 326 | "Allow routing updates on an interface\n" |
| 327 | "Interface's name\n") |
| 328 | { |
| 329 | struct interface *ifp; |
| 330 | struct in_addr addr; |
| 331 | struct ospf_if_params *params; |
| 332 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 333 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 334 | |
| 335 | ifp = if_lookup_by_name (argv[0]); |
| 336 | |
| 337 | if (ifp == NULL) |
| 338 | { |
| 339 | vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE); |
| 340 | return CMD_WARNING; |
| 341 | } |
| 342 | |
| 343 | params = IF_DEF_PARAMS (ifp); |
| 344 | |
| 345 | if (argc == 2) |
| 346 | { |
| 347 | ret = inet_aton(argv[1], &addr); |
| 348 | if (!ret) |
| 349 | { |
| 350 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 351 | VTY_NEWLINE); |
| 352 | return CMD_WARNING; |
| 353 | } |
| 354 | |
| 355 | params = ospf_lookup_if_params (ifp, addr); |
| 356 | if (params == NULL) |
| 357 | return CMD_SUCCESS; |
| 358 | } |
| 359 | |
| 360 | UNSET_IF_PARAM (params, passive_interface); |
| 361 | params->passive_interface = OSPF_IF_ACTIVE; |
| 362 | |
| 363 | if (params != IF_DEF_PARAMS (ifp)) |
| 364 | { |
| 365 | ospf_free_if_params (ifp, addr); |
| 366 | ospf_if_update_params (ifp, addr); |
| 367 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 368 | |
| 369 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 370 | * interfaces for which the passive property changed. It is too much |
| 371 | * work to determine this set, so we do this for every interface. |
| 372 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 373 | * record of joined groups to avoid systems calls if the desired |
| 374 | * memberships match the current memership. |
| 375 | */ |
| 376 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 377 | { |
| 378 | struct ospf_interface *oi = rn->info; |
| 379 | |
| 380 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 381 | ospf_if_set_multicast(oi); |
| 382 | } |
| 383 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | return CMD_SUCCESS; |
| 385 | } |
| 386 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 387 | ALIAS (no_ospf_passive_interface, |
| 388 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 389 | "no passive-interface IFNAME", |
| 390 | NO_STR |
| 391 | "Allow routing updates on an interface\n" |
| 392 | "Interface's name\n") |
| 393 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 394 | DEFUN (ospf_network_area, |
| 395 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 396 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 397 | "Enable routing on an IP network\n" |
| 398 | "OSPF network prefix\n" |
| 399 | "Set the OSPF area ID\n" |
| 400 | "OSPF area ID in IP address format\n" |
| 401 | "OSPF area ID as a decimal value\n") |
| 402 | { |
| 403 | struct ospf *ospf= vty->index; |
| 404 | struct prefix_ipv4 p; |
| 405 | struct in_addr area_id; |
| 406 | int ret, format; |
| 407 | |
| 408 | /* Get network prefix and Area ID. */ |
| 409 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 410 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 411 | |
| 412 | ret = ospf_network_set (ospf, &p, area_id); |
| 413 | if (ret == 0) |
| 414 | { |
| 415 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 416 | return CMD_WARNING; |
| 417 | } |
| 418 | |
| 419 | return CMD_SUCCESS; |
| 420 | } |
| 421 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 422 | DEFUN (no_ospf_network_area, |
| 423 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 424 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 425 | NO_STR |
| 426 | "Enable routing on an IP network\n" |
| 427 | "OSPF network prefix\n" |
| 428 | "Set the OSPF area ID\n" |
| 429 | "OSPF area ID in IP address format\n" |
| 430 | "OSPF area ID as a decimal value\n") |
| 431 | { |
| 432 | struct ospf *ospf = (struct ospf *) vty->index; |
| 433 | struct prefix_ipv4 p; |
| 434 | struct in_addr area_id; |
| 435 | int ret, format; |
| 436 | |
| 437 | /* Get network prefix and Area ID. */ |
| 438 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 439 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 440 | |
| 441 | ret = ospf_network_unset (ospf, &p, area_id); |
| 442 | if (ret == 0) |
| 443 | { |
| 444 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 445 | VTY_NEWLINE); |
| 446 | return CMD_WARNING; |
| 447 | } |
| 448 | |
| 449 | return CMD_SUCCESS; |
| 450 | } |
| 451 | |
| 452 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 453 | DEFUN (ospf_area_range, |
| 454 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 455 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 456 | "OSPF area parameters\n" |
| 457 | "OSPF area ID in IP address format\n" |
| 458 | "OSPF area ID as a decimal value\n" |
| 459 | "Summarize routes matching address/mask (border routers only)\n" |
| 460 | "Area range prefix\n") |
| 461 | { |
| 462 | struct ospf *ospf = vty->index; |
| 463 | struct prefix_ipv4 p; |
| 464 | struct in_addr area_id; |
| 465 | int format; |
| 466 | u_int32_t cost; |
| 467 | |
| 468 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 469 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 470 | |
| 471 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 472 | if (argc > 2) |
| 473 | { |
| 474 | VTY_GET_UINT32 ("range cost", cost, argv[2]); |
| 475 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 476 | } |
| 477 | |
| 478 | return CMD_SUCCESS; |
| 479 | } |
| 480 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 481 | ALIAS (ospf_area_range, |
| 482 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 483 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 484 | "OSPF area parameters\n" |
| 485 | "OSPF area ID in IP address format\n" |
| 486 | "OSPF area ID as a decimal value\n" |
| 487 | "OSPF area range for route advertise (default)\n" |
| 488 | "Area range prefix\n" |
| 489 | "Advertise this range (default)\n") |
| 490 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 491 | ALIAS (ospf_area_range, |
| 492 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 493 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 494 | "OSPF area parameters\n" |
| 495 | "OSPF area ID in IP address format\n" |
| 496 | "OSPF area ID as a decimal value\n" |
| 497 | "Summarize routes matching address/mask (border routers only)\n" |
| 498 | "Area range prefix\n" |
| 499 | "User specified metric for this range\n" |
| 500 | "Advertised metric for this range\n") |
| 501 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 502 | ALIAS (ospf_area_range, |
| 503 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 504 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 505 | "OSPF area parameters\n" |
| 506 | "OSPF area ID in IP address format\n" |
| 507 | "OSPF area ID as a decimal value\n" |
| 508 | "Summarize routes matching address/mask (border routers only)\n" |
| 509 | "Area range prefix\n" |
| 510 | "Advertise this range (default)\n" |
| 511 | "User specified metric for this range\n" |
| 512 | "Advertised metric for this range\n") |
| 513 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 514 | DEFUN (ospf_area_range_not_advertise, |
| 515 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 517 | "OSPF area parameters\n" |
| 518 | "OSPF area ID in IP address format\n" |
| 519 | "OSPF area ID as a decimal value\n" |
| 520 | "Summarize routes matching address/mask (border routers only)\n" |
| 521 | "Area range prefix\n" |
| 522 | "DoNotAdvertise this range\n") |
| 523 | { |
| 524 | struct ospf *ospf = vty->index; |
| 525 | struct prefix_ipv4 p; |
| 526 | struct in_addr area_id; |
| 527 | int format; |
| 528 | |
| 529 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 530 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 531 | |
| 532 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 533 | |
| 534 | return CMD_SUCCESS; |
| 535 | } |
| 536 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 537 | DEFUN (no_ospf_area_range, |
| 538 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 539 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 540 | NO_STR |
| 541 | "OSPF area parameters\n" |
| 542 | "OSPF area ID in IP address format\n" |
| 543 | "OSPF area ID as a decimal value\n" |
| 544 | "Summarize routes matching address/mask (border routers only)\n" |
| 545 | "Area range prefix\n") |
| 546 | { |
| 547 | struct ospf *ospf = vty->index; |
| 548 | struct prefix_ipv4 p; |
| 549 | struct in_addr area_id; |
| 550 | int format; |
| 551 | |
| 552 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 553 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 554 | |
| 555 | ospf_area_range_unset (ospf, area_id, &p); |
| 556 | |
| 557 | return CMD_SUCCESS; |
| 558 | } |
| 559 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 560 | ALIAS (no_ospf_area_range, |
| 561 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 562 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 563 | NO_STR |
| 564 | "OSPF area parameters\n" |
| 565 | "OSPF area ID in IP address format\n" |
| 566 | "OSPF area ID as a decimal value\n" |
| 567 | "Summarize routes matching address/mask (border routers only)\n" |
| 568 | "Area range prefix\n" |
| 569 | "Advertise this range (default)\n" |
| 570 | "DoNotAdvertise this range\n") |
| 571 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 572 | ALIAS (no_ospf_area_range, |
| 573 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 574 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 575 | NO_STR |
| 576 | "OSPF area parameters\n" |
| 577 | "OSPF area ID in IP address format\n" |
| 578 | "OSPF area ID as a decimal value\n" |
| 579 | "Summarize routes matching address/mask (border routers only)\n" |
| 580 | "Area range prefix\n" |
| 581 | "User specified metric for this range\n" |
| 582 | "Advertised metric for this range\n") |
| 583 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 584 | ALIAS (no_ospf_area_range, |
| 585 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 587 | NO_STR |
| 588 | "OSPF area parameters\n" |
| 589 | "OSPF area ID in IP address format\n" |
| 590 | "OSPF area ID as a decimal value\n" |
| 591 | "Summarize routes matching address/mask (border routers only)\n" |
| 592 | "Area range prefix\n" |
| 593 | "Advertise this range (default)\n" |
| 594 | "User specified metric for this range\n" |
| 595 | "Advertised metric for this range\n") |
| 596 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 597 | DEFUN (ospf_area_range_substitute, |
| 598 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 599 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 600 | "OSPF area parameters\n" |
| 601 | "OSPF area ID in IP address format\n" |
| 602 | "OSPF area ID as a decimal value\n" |
| 603 | "Summarize routes matching address/mask (border routers only)\n" |
| 604 | "Area range prefix\n" |
| 605 | "Announce area range as another prefix\n" |
| 606 | "Network prefix to be announced instead of range\n") |
| 607 | { |
| 608 | struct ospf *ospf = vty->index; |
| 609 | struct prefix_ipv4 p, s; |
| 610 | struct in_addr area_id; |
| 611 | int format; |
| 612 | |
| 613 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 614 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 615 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 616 | |
| 617 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 618 | |
| 619 | return CMD_SUCCESS; |
| 620 | } |
| 621 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 622 | DEFUN (no_ospf_area_range_substitute, |
| 623 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 624 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 625 | NO_STR |
| 626 | "OSPF area parameters\n" |
| 627 | "OSPF area ID in IP address format\n" |
| 628 | "OSPF area ID as a decimal value\n" |
| 629 | "Summarize routes matching address/mask (border routers only)\n" |
| 630 | "Area range prefix\n" |
| 631 | "Announce area range as another prefix\n" |
| 632 | "Network prefix to be announced instead of range\n") |
| 633 | { |
| 634 | struct ospf *ospf = vty->index; |
| 635 | struct prefix_ipv4 p, s; |
| 636 | struct in_addr area_id; |
| 637 | int format; |
| 638 | |
| 639 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 640 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 641 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 642 | |
| 643 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 644 | |
| 645 | return CMD_SUCCESS; |
| 646 | } |
| 647 | |
| 648 | |
| 649 | /* Command Handler Logic in VLink stuff is delicate!! |
| 650 | |
| 651 | ALTER AT YOUR OWN RISK!!!! |
| 652 | |
| 653 | Various dummy values are used to represent 'NoChange' state for |
| 654 | VLink configuration NOT being changed by a VLink command, and |
| 655 | special syntax is used within the command strings so that the |
| 656 | typed in command verbs can be seen in the configuration command |
| 657 | bacckend handler. This is to drastically reduce the verbeage |
| 658 | required to coe up with a reasonably compatible Cisco VLink command |
| 659 | |
| 660 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 661 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 662 | */ |
| 663 | |
| 664 | |
| 665 | /* Configuration data for virtual links |
| 666 | */ |
| 667 | struct ospf_vl_config_data { |
| 668 | struct vty *vty; /* vty stuff */ |
| 669 | struct in_addr area_id; /* area ID from command line */ |
| 670 | int format; /* command line area ID format */ |
| 671 | struct in_addr vl_peer; /* command line vl_peer */ |
| 672 | int auth_type; /* Authehntication type, if given */ |
| 673 | char *auth_key; /* simple password if present */ |
| 674 | int crypto_key_id; /* Cryptographic key ID */ |
| 675 | char *md5_key; /* MD5 authentication key */ |
| 676 | int hello_interval; /* Obvious what these are... */ |
| 677 | int retransmit_interval; |
| 678 | int transmit_delay; |
| 679 | int dead_interval; |
| 680 | }; |
| 681 | |
| 682 | void |
| 683 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 684 | struct vty *vty) |
| 685 | { |
| 686 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 687 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 688 | vl_config->vty = vty; |
| 689 | } |
| 690 | |
| 691 | struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 692 | 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] | 693 | { |
| 694 | struct ospf_area *area; |
| 695 | struct ospf_vl_data *vl_data; |
| 696 | struct vty *vty; |
| 697 | struct in_addr area_id; |
| 698 | |
| 699 | vty = vl_config->vty; |
| 700 | area_id = vl_config->area_id; |
| 701 | |
| 702 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 703 | { |
| 704 | vty_out (vty, |
| 705 | "Configuring VLs over the backbone is not allowed%s", |
| 706 | VTY_NEWLINE); |
| 707 | return NULL; |
| 708 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 709 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 710 | |
| 711 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 712 | { |
| 713 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 714 | vty_out (vty, "Area %s is %s%s", |
| 715 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 716 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 717 | VTY_NEWLINE); |
| 718 | else |
| 719 | vty_out (vty, "Area %ld is %s%s", |
| 720 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 722 | VTY_NEWLINE); |
| 723 | return NULL; |
| 724 | } |
| 725 | |
| 726 | if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL) |
| 727 | { |
| 728 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 729 | if (vl_data->vl_oi == NULL) |
| 730 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 731 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 732 | ospf_vl_add (ospf, vl_data); |
| 733 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 734 | } |
| 735 | } |
| 736 | return vl_data; |
| 737 | } |
| 738 | |
| 739 | |
| 740 | int |
| 741 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 742 | struct ospf_vl_config_data *vl_config) |
| 743 | { |
| 744 | struct crypt_key *ck; |
| 745 | struct vty *vty; |
| 746 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 747 | |
| 748 | vty = vl_config->vty; |
| 749 | |
| 750 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 751 | { |
| 752 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 753 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 754 | } |
| 755 | |
| 756 | if (vl_config->auth_key) |
| 757 | { |
| 758 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 759 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 760 | OSPF_AUTH_SIMPLE_SIZE); |
| 761 | } |
| 762 | else if (vl_config->md5_key) |
| 763 | { |
| 764 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 765 | != NULL) |
| 766 | { |
| 767 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 768 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 769 | return CMD_WARNING; |
| 770 | } |
| 771 | ck = ospf_crypt_key_new (); |
| 772 | ck->key_id = vl_config->crypto_key_id; |
| 773 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 774 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | |
| 776 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 777 | } |
| 778 | else if (vl_config->crypto_key_id != 0) |
| 779 | { |
| 780 | /* Delete a key */ |
| 781 | |
| 782 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 783 | vl_config->crypto_key_id) == NULL) |
| 784 | { |
| 785 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 786 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 787 | return CMD_WARNING; |
| 788 | } |
| 789 | |
| 790 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 791 | |
| 792 | } |
| 793 | |
| 794 | return CMD_SUCCESS; |
| 795 | } |
| 796 | |
| 797 | |
| 798 | |
| 799 | int |
| 800 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 801 | struct ospf_vl_config_data *vl_config) |
| 802 | { |
| 803 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 804 | /* Virtual Link data initialised to defaults, so only set |
| 805 | if a value given */ |
| 806 | if (vl_config->hello_interval) |
| 807 | { |
| 808 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 809 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 810 | } |
| 811 | |
| 812 | if (vl_config->dead_interval) |
| 813 | { |
| 814 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 815 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 816 | } |
| 817 | |
| 818 | if (vl_config->retransmit_interval) |
| 819 | { |
| 820 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 821 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 822 | } |
| 823 | |
| 824 | if (vl_config->transmit_delay) |
| 825 | { |
| 826 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 827 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 828 | } |
| 829 | |
| 830 | return CMD_SUCCESS; |
| 831 | } |
| 832 | |
| 833 | |
| 834 | |
| 835 | /* The business end of all of the above */ |
| 836 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 837 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 838 | { |
| 839 | struct ospf_vl_data *vl_data; |
| 840 | int ret; |
| 841 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 842 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 843 | if (!vl_data) |
| 844 | return CMD_WARNING; |
| 845 | |
| 846 | /* Process this one first as it can have a fatal result, which can |
| 847 | only logically occur if the virtual link exists already |
| 848 | Thus a command error does not result in a change to the |
| 849 | running configuration such as unexpectedly altered timer |
| 850 | values etc.*/ |
| 851 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 852 | if (ret != CMD_SUCCESS) |
| 853 | return ret; |
| 854 | |
| 855 | /* Set any time based parameters, these area already range checked */ |
| 856 | |
| 857 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 858 | if (ret != CMD_SUCCESS) |
| 859 | return ret; |
| 860 | |
| 861 | return CMD_SUCCESS; |
| 862 | |
| 863 | } |
| 864 | |
| 865 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 866 | */ |
| 867 | #define VLINK_HELPSTR_IPADDR \ |
| 868 | "OSPF area parameters\n" \ |
| 869 | "OSPF area ID in IP address format\n" \ |
| 870 | "OSPF area ID as a decimal value\n" \ |
| 871 | "Configure a virtual link\n" \ |
| 872 | "Router ID of the remote ABR\n" |
| 873 | |
| 874 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 875 | "Enable authentication on this virtual link\n" \ |
| 876 | "dummy string \n" |
| 877 | |
| 878 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 879 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 880 | "Use null authentication\n" \ |
| 881 | "Use message-digest authentication\n" |
| 882 | |
| 883 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 884 | "Time between HELLO packets\n" \ |
| 885 | "Time between retransmitting lost link state advertisements\n" \ |
| 886 | "Link state transmit delay\n" \ |
| 887 | "Interval after which a neighbor is declared dead\n" |
| 888 | |
| 889 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 890 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 891 | "Seconds\n" |
| 892 | |
| 893 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 894 | "Authentication password (key)\n" \ |
| 895 | "The OSPF password (key)" |
| 896 | |
| 897 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 898 | "Message digest authentication password (key)\n" \ |
| 899 | "dummy string \n" \ |
| 900 | "Key ID\n" \ |
| 901 | "Use MD5 algorithm\n" \ |
| 902 | "The OSPF password (key)" |
| 903 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 904 | DEFUN (ospf_area_vlink, |
| 905 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 906 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 907 | VLINK_HELPSTR_IPADDR) |
| 908 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 909 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 910 | struct ospf_vl_config_data vl_config; |
| 911 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 912 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 913 | int i; |
| 914 | int ret; |
| 915 | |
| 916 | ospf_vl_config_data_init(&vl_config, vty); |
| 917 | |
| 918 | /* Read off first 2 parameters and check them */ |
| 919 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 920 | if (ret < 0) |
| 921 | { |
| 922 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 923 | return CMD_WARNING; |
| 924 | } |
| 925 | |
| 926 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 927 | if (! ret) |
| 928 | { |
| 929 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 930 | VTY_NEWLINE); |
| 931 | return CMD_WARNING; |
| 932 | } |
| 933 | |
| 934 | if (argc <=2) |
| 935 | { |
| 936 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 937 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 938 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 939 | } |
| 940 | |
| 941 | /* Deal with other parameters */ |
| 942 | for (i=2; i < argc; i++) |
| 943 | { |
| 944 | |
| 945 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 946 | |
| 947 | switch (argv[i][0]) |
| 948 | { |
| 949 | |
| 950 | case 'a': |
| 951 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 952 | { |
| 953 | /* authentication-key - this option can occur anywhere on |
| 954 | command line. At start of command line |
| 955 | must check for authentication option. */ |
| 956 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 957 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 958 | vl_config.auth_key = auth_key; |
| 959 | i++; |
| 960 | } |
| 961 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 962 | { |
| 963 | /* authentication - this option can only occur at start |
| 964 | of command line */ |
| 965 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 966 | if ((i+1) < argc) |
| 967 | { |
| 968 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 969 | { |
| 970 | /* "authentication null" */ |
| 971 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 972 | i++; |
| 973 | } |
| 974 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 975 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 976 | { |
| 977 | /* "authentication message-digest" */ |
| 978 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 979 | i++; |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | break; |
| 984 | |
| 985 | case 'm': |
| 986 | /* message-digest-key */ |
| 987 | i++; |
| 988 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 989 | if (vl_config.crypto_key_id < 0) |
| 990 | return CMD_WARNING; |
| 991 | i++; |
| 992 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 993 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 994 | vl_config.md5_key = md5_key; |
| 995 | break; |
| 996 | |
| 997 | case 'h': |
| 998 | /* Hello interval */ |
| 999 | i++; |
| 1000 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 1001 | if (vl_config.hello_interval < 0) |
| 1002 | return CMD_WARNING; |
| 1003 | break; |
| 1004 | |
| 1005 | case 'r': |
| 1006 | /* Retransmit Interval */ |
| 1007 | i++; |
| 1008 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1009 | if (vl_config.retransmit_interval < 0) |
| 1010 | return CMD_WARNING; |
| 1011 | break; |
| 1012 | |
| 1013 | case 't': |
| 1014 | /* Transmit Delay */ |
| 1015 | i++; |
| 1016 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1017 | if (vl_config.transmit_delay < 0) |
| 1018 | return CMD_WARNING; |
| 1019 | break; |
| 1020 | |
| 1021 | case 'd': |
| 1022 | /* Dead Interval */ |
| 1023 | i++; |
| 1024 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1025 | if (vl_config.dead_interval < 0) |
| 1026 | return CMD_WARNING; |
| 1027 | break; |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | |
| 1032 | /* Action configuration */ |
| 1033 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1034 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1035 | |
| 1036 | } |
| 1037 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1038 | DEFUN (no_ospf_area_vlink, |
| 1039 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1040 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1041 | NO_STR |
| 1042 | VLINK_HELPSTR_IPADDR) |
| 1043 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1044 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | struct ospf_area *area; |
| 1046 | struct ospf_vl_config_data vl_config; |
| 1047 | struct ospf_vl_data *vl_data = NULL; |
| 1048 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1049 | int i; |
| 1050 | int ret, format; |
| 1051 | |
| 1052 | ospf_vl_config_data_init(&vl_config, vty); |
| 1053 | |
| 1054 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1055 | if (ret < 0) |
| 1056 | { |
| 1057 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1058 | return CMD_WARNING; |
| 1059 | } |
| 1060 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1061 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1062 | if (!area) |
| 1063 | { |
| 1064 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1065 | return CMD_WARNING; |
| 1066 | } |
| 1067 | |
| 1068 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1069 | if (! ret) |
| 1070 | { |
| 1071 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1072 | VTY_NEWLINE); |
| 1073 | return CMD_WARNING; |
| 1074 | } |
| 1075 | |
| 1076 | if (argc <=2) |
| 1077 | { |
| 1078 | /* Basic VLink no command */ |
| 1079 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 1080 | if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1081 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1082 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1083 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | |
| 1085 | return CMD_SUCCESS; |
| 1086 | } |
| 1087 | |
| 1088 | /* If we are down here, we are reseting parameters */ |
| 1089 | |
| 1090 | /* Deal with other parameters */ |
| 1091 | for (i=2; i < argc; i++) |
| 1092 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1093 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1094 | |
| 1095 | switch (argv[i][0]) |
| 1096 | { |
| 1097 | |
| 1098 | case 'a': |
| 1099 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1100 | { |
| 1101 | /* authentication-key - this option can occur anywhere on |
| 1102 | command line. At start of command line |
| 1103 | must check for authentication option. */ |
| 1104 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1105 | vl_config.auth_key = auth_key; |
| 1106 | } |
| 1107 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1108 | { |
| 1109 | /* authentication - this option can only occur at start |
| 1110 | of command line */ |
| 1111 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1112 | } |
| 1113 | break; |
| 1114 | |
| 1115 | case 'm': |
| 1116 | /* message-digest-key */ |
| 1117 | /* Delete one key */ |
| 1118 | i++; |
| 1119 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1120 | if (vl_config.crypto_key_id < 0) |
| 1121 | return CMD_WARNING; |
| 1122 | vl_config.md5_key = NULL; |
| 1123 | break; |
| 1124 | |
| 1125 | case 'h': |
| 1126 | /* Hello interval */ |
| 1127 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1128 | break; |
| 1129 | |
| 1130 | case 'r': |
| 1131 | /* Retransmit Interval */ |
| 1132 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1133 | break; |
| 1134 | |
| 1135 | case 't': |
| 1136 | /* Transmit Delay */ |
| 1137 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1138 | break; |
| 1139 | |
| 1140 | case 'd': |
| 1141 | /* Dead Interval */ |
| 1142 | i++; |
| 1143 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1144 | break; |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | |
| 1149 | /* Action configuration */ |
| 1150 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1151 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1152 | } |
| 1153 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1154 | ALIAS (ospf_area_vlink, |
| 1155 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1156 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1157 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1158 | VLINK_HELPSTR_IPADDR |
| 1159 | VLINK_HELPSTR_TIME_PARAM) |
| 1160 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1161 | ALIAS (no_ospf_area_vlink, |
| 1162 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1163 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1164 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1165 | NO_STR |
| 1166 | VLINK_HELPSTR_IPADDR |
| 1167 | VLINK_HELPSTR_TIME_PARAM) |
| 1168 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1169 | ALIAS (ospf_area_vlink, |
| 1170 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1171 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1172 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1173 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1174 | VLINK_HELPSTR_IPADDR |
| 1175 | VLINK_HELPSTR_TIME_PARAM |
| 1176 | VLINK_HELPSTR_TIME_PARAM) |
| 1177 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1178 | ALIAS (no_ospf_area_vlink, |
| 1179 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1180 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1181 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1182 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1183 | NO_STR |
| 1184 | VLINK_HELPSTR_IPADDR |
| 1185 | VLINK_HELPSTR_TIME_PARAM |
| 1186 | VLINK_HELPSTR_TIME_PARAM) |
| 1187 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1188 | ALIAS (ospf_area_vlink, |
| 1189 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1190 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1191 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1192 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1193 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1194 | VLINK_HELPSTR_IPADDR |
| 1195 | VLINK_HELPSTR_TIME_PARAM |
| 1196 | VLINK_HELPSTR_TIME_PARAM |
| 1197 | VLINK_HELPSTR_TIME_PARAM) |
| 1198 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1199 | ALIAS (no_ospf_area_vlink, |
| 1200 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1201 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1202 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1203 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1204 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1205 | NO_STR |
| 1206 | VLINK_HELPSTR_IPADDR |
| 1207 | VLINK_HELPSTR_TIME_PARAM |
| 1208 | VLINK_HELPSTR_TIME_PARAM |
| 1209 | VLINK_HELPSTR_TIME_PARAM) |
| 1210 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1211 | ALIAS (ospf_area_vlink, |
| 1212 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1213 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 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 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1218 | VLINK_HELPSTR_IPADDR |
| 1219 | VLINK_HELPSTR_TIME_PARAM |
| 1220 | VLINK_HELPSTR_TIME_PARAM |
| 1221 | VLINK_HELPSTR_TIME_PARAM |
| 1222 | VLINK_HELPSTR_TIME_PARAM) |
| 1223 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1224 | ALIAS (no_ospf_area_vlink, |
| 1225 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1226 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 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 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1231 | NO_STR |
| 1232 | VLINK_HELPSTR_IPADDR |
| 1233 | VLINK_HELPSTR_TIME_PARAM |
| 1234 | VLINK_HELPSTR_TIME_PARAM |
| 1235 | VLINK_HELPSTR_TIME_PARAM |
| 1236 | VLINK_HELPSTR_TIME_PARAM) |
| 1237 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1238 | ALIAS (ospf_area_vlink, |
| 1239 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1240 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1241 | "(authentication|) (message-digest|null)", |
| 1242 | VLINK_HELPSTR_IPADDR |
| 1243 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1244 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1245 | ALIAS (ospf_area_vlink, |
| 1246 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1248 | "(authentication|)", |
| 1249 | VLINK_HELPSTR_IPADDR |
| 1250 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1251 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1252 | ALIAS (no_ospf_area_vlink, |
| 1253 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1254 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1255 | "(authentication|)", |
| 1256 | NO_STR |
| 1257 | VLINK_HELPSTR_IPADDR |
| 1258 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1259 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1260 | ALIAS (ospf_area_vlink, |
| 1261 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1262 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1263 | "(message-digest-key|) <1-255> md5 KEY", |
| 1264 | VLINK_HELPSTR_IPADDR |
| 1265 | VLINK_HELPSTR_AUTH_MD5) |
| 1266 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1267 | ALIAS (no_ospf_area_vlink, |
| 1268 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1269 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1270 | "(message-digest-key|) <1-255>", |
| 1271 | NO_STR |
| 1272 | VLINK_HELPSTR_IPADDR |
| 1273 | VLINK_HELPSTR_AUTH_MD5) |
| 1274 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1275 | ALIAS (ospf_area_vlink, |
| 1276 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1277 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1278 | "(authentication-key|) AUTH_KEY", |
| 1279 | VLINK_HELPSTR_IPADDR |
| 1280 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1281 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1282 | ALIAS (no_ospf_area_vlink, |
| 1283 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1284 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1285 | "(authentication-key|)", |
| 1286 | NO_STR |
| 1287 | VLINK_HELPSTR_IPADDR |
| 1288 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1289 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1290 | ALIAS (ospf_area_vlink, |
| 1291 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1292 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1293 | "(authentication|) (message-digest|null) " |
| 1294 | "(authentication-key|) AUTH_KEY", |
| 1295 | VLINK_HELPSTR_IPADDR |
| 1296 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1297 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1298 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1299 | ALIAS (ospf_area_vlink, |
| 1300 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1301 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1302 | "(authentication|) " |
| 1303 | "(authentication-key|) AUTH_KEY", |
| 1304 | VLINK_HELPSTR_IPADDR |
| 1305 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1306 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1307 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1308 | ALIAS (no_ospf_area_vlink, |
| 1309 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1310 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1311 | "(authentication|) " |
| 1312 | "(authentication-key|)", |
| 1313 | NO_STR |
| 1314 | VLINK_HELPSTR_IPADDR |
| 1315 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1316 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1317 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1318 | ALIAS (ospf_area_vlink, |
| 1319 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1320 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1321 | "(authentication|) (message-digest|null) " |
| 1322 | "(message-digest-key|) <1-255> md5 KEY", |
| 1323 | VLINK_HELPSTR_IPADDR |
| 1324 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1325 | VLINK_HELPSTR_AUTH_MD5) |
| 1326 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1327 | ALIAS (ospf_area_vlink, |
| 1328 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1329 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1330 | "(authentication|) " |
| 1331 | "(message-digest-key|) <1-255> md5 KEY", |
| 1332 | VLINK_HELPSTR_IPADDR |
| 1333 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1334 | VLINK_HELPSTR_AUTH_MD5) |
| 1335 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1336 | ALIAS (no_ospf_area_vlink, |
| 1337 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1338 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1339 | "(authentication|) " |
| 1340 | "(message-digest-key|)", |
| 1341 | NO_STR |
| 1342 | VLINK_HELPSTR_IPADDR |
| 1343 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1344 | VLINK_HELPSTR_AUTH_MD5) |
| 1345 | |
| 1346 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1347 | DEFUN (ospf_area_shortcut, |
| 1348 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1349 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1350 | "OSPF area parameters\n" |
| 1351 | "OSPF area ID in IP address format\n" |
| 1352 | "OSPF area ID as a decimal value\n" |
| 1353 | "Configure the area's shortcutting mode\n" |
| 1354 | "Set default shortcutting behavior\n" |
| 1355 | "Enable shortcutting through the area\n" |
| 1356 | "Disable shortcutting through the area\n") |
| 1357 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1358 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1359 | struct ospf_area *area; |
| 1360 | struct in_addr area_id; |
| 1361 | int mode; |
| 1362 | int format; |
| 1363 | |
| 1364 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1365 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1366 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1367 | |
| 1368 | if (strncmp (argv[1], "de", 2) == 0) |
| 1369 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1370 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1371 | mode = OSPF_SHORTCUT_DISABLE; |
| 1372 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1373 | mode = OSPF_SHORTCUT_ENABLE; |
| 1374 | else |
| 1375 | return CMD_WARNING; |
| 1376 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1377 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1378 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1379 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1380 | vty_out (vty, "Shortcut area setting will take effect " |
| 1381 | "only when the router is configured as Shortcut ABR%s", |
| 1382 | VTY_NEWLINE); |
| 1383 | |
| 1384 | return CMD_SUCCESS; |
| 1385 | } |
| 1386 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1387 | DEFUN (no_ospf_area_shortcut, |
| 1388 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1389 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1390 | NO_STR |
| 1391 | "OSPF area parameters\n" |
| 1392 | "OSPF area ID in IP address format\n" |
| 1393 | "OSPF area ID as a decimal value\n" |
| 1394 | "Deconfigure the area's shortcutting mode\n" |
| 1395 | "Deconfigure enabled shortcutting through the area\n" |
| 1396 | "Deconfigure disabled shortcutting through the area\n") |
| 1397 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1398 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1399 | struct ospf_area *area; |
| 1400 | struct in_addr area_id; |
| 1401 | int format; |
| 1402 | |
| 1403 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1404 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1405 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1406 | if (!area) |
| 1407 | return CMD_SUCCESS; |
| 1408 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1409 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1410 | |
| 1411 | return CMD_SUCCESS; |
| 1412 | } |
| 1413 | |
| 1414 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1415 | DEFUN (ospf_area_stub, |
| 1416 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1417 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1418 | "OSPF area parameters\n" |
| 1419 | "OSPF area ID in IP address format\n" |
| 1420 | "OSPF area ID as a decimal value\n" |
| 1421 | "Configure OSPF area as stub\n") |
| 1422 | { |
| 1423 | struct ospf *ospf = vty->index; |
| 1424 | struct in_addr area_id; |
| 1425 | int ret, format; |
| 1426 | |
| 1427 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1428 | |
| 1429 | ret = ospf_area_stub_set (ospf, area_id); |
| 1430 | if (ret == 0) |
| 1431 | { |
| 1432 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1433 | VTY_NEWLINE); |
| 1434 | return CMD_WARNING; |
| 1435 | } |
| 1436 | |
| 1437 | ospf_area_no_summary_unset (ospf, area_id); |
| 1438 | |
| 1439 | return CMD_SUCCESS; |
| 1440 | } |
| 1441 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1442 | DEFUN (ospf_area_stub_no_summary, |
| 1443 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1444 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1445 | "OSPF stub parameters\n" |
| 1446 | "OSPF area ID in IP address format\n" |
| 1447 | "OSPF area ID as a decimal value\n" |
| 1448 | "Configure OSPF area as stub\n" |
| 1449 | "Do not inject inter-area routes into stub\n") |
| 1450 | { |
| 1451 | struct ospf *ospf = vty->index; |
| 1452 | struct in_addr area_id; |
| 1453 | int ret, format; |
| 1454 | |
| 1455 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1456 | |
| 1457 | ret = ospf_area_stub_set (ospf, area_id); |
| 1458 | if (ret == 0) |
| 1459 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1460 | 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] | 1461 | VTY_NEWLINE); |
| 1462 | return CMD_WARNING; |
| 1463 | } |
| 1464 | |
| 1465 | ospf_area_no_summary_set (ospf, area_id); |
| 1466 | |
| 1467 | return CMD_SUCCESS; |
| 1468 | } |
| 1469 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1470 | DEFUN (no_ospf_area_stub, |
| 1471 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1472 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1473 | NO_STR |
| 1474 | "OSPF area parameters\n" |
| 1475 | "OSPF area ID in IP address format\n" |
| 1476 | "OSPF area ID as a decimal value\n" |
| 1477 | "Configure OSPF area as stub\n") |
| 1478 | { |
| 1479 | struct ospf *ospf = vty->index; |
| 1480 | struct in_addr area_id; |
| 1481 | int format; |
| 1482 | |
| 1483 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1484 | |
| 1485 | ospf_area_stub_unset (ospf, area_id); |
| 1486 | ospf_area_no_summary_unset (ospf, area_id); |
| 1487 | |
| 1488 | return CMD_SUCCESS; |
| 1489 | } |
| 1490 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1491 | DEFUN (no_ospf_area_stub_no_summary, |
| 1492 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1493 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1494 | NO_STR |
| 1495 | "OSPF area parameters\n" |
| 1496 | "OSPF area ID in IP address format\n" |
| 1497 | "OSPF area ID as a decimal value\n" |
| 1498 | "Configure OSPF area as stub\n" |
| 1499 | "Do not inject inter-area routes into area\n") |
| 1500 | { |
| 1501 | struct ospf *ospf = vty->index; |
| 1502 | struct in_addr area_id; |
| 1503 | int format; |
| 1504 | |
| 1505 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1506 | ospf_area_no_summary_unset (ospf, area_id); |
| 1507 | |
| 1508 | return CMD_SUCCESS; |
| 1509 | } |
| 1510 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1511 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1512 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1513 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1514 | { |
| 1515 | struct ospf *ospf = vty->index; |
| 1516 | struct in_addr area_id; |
| 1517 | int ret, format; |
| 1518 | |
| 1519 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1520 | |
| 1521 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1522 | if (ret == 0) |
| 1523 | { |
| 1524 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1525 | VTY_NEWLINE); |
| 1526 | return CMD_WARNING; |
| 1527 | } |
| 1528 | |
| 1529 | if (argc > 1) |
| 1530 | { |
| 1531 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1532 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1533 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1534 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1535 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | OSPF_NSSA_ROLE_NEVER); |
| 1537 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1538 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1539 | OSPF_NSSA_ROLE_ALWAYS); |
| 1540 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1541 | else |
| 1542 | { |
| 1543 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1544 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1545 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1546 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1547 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1548 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1549 | else |
| 1550 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1551 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1552 | ospf_schedule_abr_task (ospf); |
| 1553 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1554 | return CMD_SUCCESS; |
| 1555 | } |
| 1556 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1557 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1558 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1559 | "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] | 1560 | "OSPF area parameters\n" |
| 1561 | "OSPF area ID in IP address format\n" |
| 1562 | "OSPF area ID as a decimal value\n" |
| 1563 | "Configure OSPF area as nssa\n" |
| 1564 | "Configure NSSA-ABR for translate election (default)\n" |
| 1565 | "Configure NSSA-ABR to never translate\n" |
| 1566 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1567 | "Do not inject inter-area routes into nssa\n") |
| 1568 | { |
| 1569 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1570 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1571 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1572 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1573 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1574 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1575 | "OSPF area parameters\n" |
| 1576 | "OSPF area ID in IP address format\n" |
| 1577 | "OSPF area ID as a decimal value\n" |
| 1578 | "Configure OSPF area as nssa\n" |
| 1579 | "Configure NSSA-ABR for translate election (default)\n" |
| 1580 | "Configure NSSA-ABR to never translate\n" |
| 1581 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1582 | { |
| 1583 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1584 | } |
| 1585 | |
| 1586 | DEFUN (ospf_area_nssa, |
| 1587 | ospf_area_nssa_cmd, |
| 1588 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1589 | "OSPF area parameters\n" |
| 1590 | "OSPF area ID in IP address format\n" |
| 1591 | "OSPF area ID as a decimal value\n" |
| 1592 | "Configure OSPF area as nssa\n") |
| 1593 | { |
| 1594 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1595 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1597 | DEFUN (ospf_area_nssa_no_summary, |
| 1598 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1599 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1600 | "OSPF area parameters\n" |
| 1601 | "OSPF area ID in IP address format\n" |
| 1602 | "OSPF area ID as a decimal value\n" |
| 1603 | "Configure OSPF area as nssa\n" |
| 1604 | "Do not inject inter-area routes into nssa\n") |
| 1605 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1606 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1607 | } |
| 1608 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1609 | DEFUN (no_ospf_area_nssa, |
| 1610 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1611 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1612 | NO_STR |
| 1613 | "OSPF area parameters\n" |
| 1614 | "OSPF area ID in IP address format\n" |
| 1615 | "OSPF area ID as a decimal value\n" |
| 1616 | "Configure OSPF area as nssa\n") |
| 1617 | { |
| 1618 | struct ospf *ospf = vty->index; |
| 1619 | struct in_addr area_id; |
| 1620 | int format; |
| 1621 | |
| 1622 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1623 | |
| 1624 | ospf_area_nssa_unset (ospf, area_id); |
| 1625 | ospf_area_no_summary_unset (ospf, area_id); |
| 1626 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1627 | ospf_schedule_abr_task (ospf); |
| 1628 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1629 | return CMD_SUCCESS; |
| 1630 | } |
| 1631 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1632 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1633 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1634 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1635 | NO_STR |
| 1636 | "OSPF area parameters\n" |
| 1637 | "OSPF area ID in IP address format\n" |
| 1638 | "OSPF area ID as a decimal value\n" |
| 1639 | "Configure OSPF area as nssa\n" |
| 1640 | "Do not inject inter-area routes into nssa\n") |
| 1641 | { |
| 1642 | struct ospf *ospf = vty->index; |
| 1643 | struct in_addr area_id; |
| 1644 | int format; |
| 1645 | |
| 1646 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1647 | ospf_area_no_summary_unset (ospf, area_id); |
| 1648 | |
| 1649 | return CMD_SUCCESS; |
| 1650 | } |
| 1651 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1652 | DEFUN (ospf_area_default_cost, |
| 1653 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1654 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1655 | "OSPF area parameters\n" |
| 1656 | "OSPF area ID in IP address format\n" |
| 1657 | "OSPF area ID as a decimal value\n" |
| 1658 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1659 | "Stub's advertised default summary cost\n") |
| 1660 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1661 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1662 | struct ospf_area *area; |
| 1663 | struct in_addr area_id; |
| 1664 | u_int32_t cost; |
| 1665 | int format; |
| 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 | |
| 1680 | return CMD_SUCCESS; |
| 1681 | } |
| 1682 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1683 | DEFUN (no_ospf_area_default_cost, |
| 1684 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1685 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1686 | NO_STR |
| 1687 | "OSPF area parameters\n" |
| 1688 | "OSPF area ID in IP address format\n" |
| 1689 | "OSPF area ID as a decimal value\n" |
| 1690 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1691 | "Stub's advertised default summary cost\n") |
| 1692 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1693 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1694 | struct ospf_area *area; |
| 1695 | struct in_addr area_id; |
| 1696 | u_int32_t cost; |
| 1697 | int format; |
| 1698 | |
| 1699 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1700 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1701 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1702 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1703 | if (area == NULL) |
| 1704 | return CMD_SUCCESS; |
| 1705 | |
| 1706 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1707 | { |
| 1708 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1709 | return CMD_WARNING; |
| 1710 | } |
| 1711 | |
| 1712 | area->default_cost = 1; |
| 1713 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1714 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1715 | |
| 1716 | return CMD_SUCCESS; |
| 1717 | } |
| 1718 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1719 | DEFUN (ospf_area_export_list, |
| 1720 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1721 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1722 | "OSPF area parameters\n" |
| 1723 | "OSPF area ID in IP address format\n" |
| 1724 | "OSPF area ID as a decimal value\n" |
| 1725 | "Set the filter for networks announced to other areas\n" |
| 1726 | "Name of the access-list\n") |
| 1727 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1728 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1729 | struct ospf_area *area; |
| 1730 | struct in_addr area_id; |
| 1731 | int format; |
| 1732 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1733 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1734 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1735 | area = ospf_area_get (ospf, area_id, format); |
| 1736 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1737 | |
| 1738 | return CMD_SUCCESS; |
| 1739 | } |
| 1740 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1741 | DEFUN (no_ospf_area_export_list, |
| 1742 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1743 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1744 | NO_STR |
| 1745 | "OSPF area parameters\n" |
| 1746 | "OSPF area ID in IP address format\n" |
| 1747 | "OSPF area ID as a decimal value\n" |
| 1748 | "Unset the filter for networks announced to other areas\n" |
| 1749 | "Name of the access-list\n") |
| 1750 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1751 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1752 | struct ospf_area *area; |
| 1753 | struct in_addr area_id; |
| 1754 | int format; |
| 1755 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1756 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1757 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1758 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1759 | if (area == NULL) |
| 1760 | return CMD_SUCCESS; |
| 1761 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1762 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1763 | |
| 1764 | return CMD_SUCCESS; |
| 1765 | } |
| 1766 | |
| 1767 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1768 | DEFUN (ospf_area_import_list, |
| 1769 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1770 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1771 | "OSPF area parameters\n" |
| 1772 | "OSPF area ID in IP address format\n" |
| 1773 | "OSPF area ID as a decimal value\n" |
| 1774 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1775 | "Name of the access-list\n") |
| 1776 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1777 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1778 | struct ospf_area *area; |
| 1779 | struct in_addr area_id; |
| 1780 | int format; |
| 1781 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1782 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1783 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1784 | area = ospf_area_get (ospf, area_id, format); |
| 1785 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1786 | |
| 1787 | return CMD_SUCCESS; |
| 1788 | } |
| 1789 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1790 | DEFUN (no_ospf_area_import_list, |
| 1791 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1793 | NO_STR |
| 1794 | "OSPF area parameters\n" |
| 1795 | "OSPF area ID in IP address format\n" |
| 1796 | "OSPF area ID as a decimal value\n" |
| 1797 | "Unset the filter for networks announced to other areas\n" |
| 1798 | "Name of the access-list\n") |
| 1799 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1800 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1801 | struct ospf_area *area; |
| 1802 | struct in_addr area_id; |
| 1803 | int format; |
| 1804 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1805 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1806 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1807 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1808 | if (area == NULL) |
| 1809 | return CMD_SUCCESS; |
| 1810 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1811 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1812 | |
| 1813 | return CMD_SUCCESS; |
| 1814 | } |
| 1815 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1816 | DEFUN (ospf_area_filter_list, |
| 1817 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1819 | "OSPF area parameters\n" |
| 1820 | "OSPF area ID in IP address format\n" |
| 1821 | "OSPF area ID as a decimal value\n" |
| 1822 | "Filter networks between OSPF areas\n" |
| 1823 | "Filter prefixes between OSPF areas\n" |
| 1824 | "Name of an IP prefix-list\n" |
| 1825 | "Filter networks sent to this area\n" |
| 1826 | "Filter networks sent from this area\n") |
| 1827 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1828 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1829 | struct ospf_area *area; |
| 1830 | struct in_addr area_id; |
| 1831 | struct prefix_list *plist; |
| 1832 | int format; |
| 1833 | |
| 1834 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1835 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1836 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1837 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1838 | if (strncmp (argv[2], "in", 2) == 0) |
| 1839 | { |
| 1840 | PREFIX_LIST_IN (area) = plist; |
| 1841 | if (PREFIX_NAME_IN (area)) |
| 1842 | free (PREFIX_NAME_IN (area)); |
| 1843 | |
| 1844 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1845 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1846 | } |
| 1847 | else |
| 1848 | { |
| 1849 | PREFIX_LIST_OUT (area) = plist; |
| 1850 | if (PREFIX_NAME_OUT (area)) |
| 1851 | free (PREFIX_NAME_OUT (area)); |
| 1852 | |
| 1853 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1854 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1855 | } |
| 1856 | |
| 1857 | return CMD_SUCCESS; |
| 1858 | } |
| 1859 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1860 | DEFUN (no_ospf_area_filter_list, |
| 1861 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1862 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1863 | NO_STR |
| 1864 | "OSPF area parameters\n" |
| 1865 | "OSPF area ID in IP address format\n" |
| 1866 | "OSPF area ID as a decimal value\n" |
| 1867 | "Filter networks between OSPF areas\n" |
| 1868 | "Filter prefixes between OSPF areas\n" |
| 1869 | "Name of an IP prefix-list\n" |
| 1870 | "Filter networks sent to this area\n" |
| 1871 | "Filter networks sent from this area\n") |
| 1872 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1873 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1874 | struct ospf_area *area; |
| 1875 | struct in_addr area_id; |
| 1876 | struct prefix_list *plist; |
| 1877 | int format; |
| 1878 | |
| 1879 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1880 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1881 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1883 | if (strncmp (argv[2], "in", 2) == 0) |
| 1884 | { |
| 1885 | if (PREFIX_NAME_IN (area)) |
| 1886 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1887 | return CMD_SUCCESS; |
| 1888 | |
| 1889 | PREFIX_LIST_IN (area) = NULL; |
| 1890 | if (PREFIX_NAME_IN (area)) |
| 1891 | free (PREFIX_NAME_IN (area)); |
| 1892 | |
| 1893 | PREFIX_NAME_IN (area) = NULL; |
| 1894 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1895 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1896 | } |
| 1897 | else |
| 1898 | { |
| 1899 | if (PREFIX_NAME_OUT (area)) |
| 1900 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1901 | return CMD_SUCCESS; |
| 1902 | |
| 1903 | PREFIX_LIST_OUT (area) = NULL; |
| 1904 | if (PREFIX_NAME_OUT (area)) |
| 1905 | free (PREFIX_NAME_OUT (area)); |
| 1906 | |
| 1907 | PREFIX_NAME_OUT (area) = NULL; |
| 1908 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1909 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1910 | } |
| 1911 | |
| 1912 | return CMD_SUCCESS; |
| 1913 | } |
| 1914 | |
| 1915 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1916 | DEFUN (ospf_area_authentication_message_digest, |
| 1917 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1918 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1919 | "OSPF area parameters\n" |
| 1920 | "Enable authentication\n" |
| 1921 | "Use message-digest authentication\n") |
| 1922 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1923 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1924 | struct ospf_area *area; |
| 1925 | struct in_addr area_id; |
| 1926 | int format; |
| 1927 | |
| 1928 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1929 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1930 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1931 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1932 | |
| 1933 | return CMD_SUCCESS; |
| 1934 | } |
| 1935 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1936 | DEFUN (ospf_area_authentication, |
| 1937 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1938 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 1939 | "OSPF area parameters\n" |
| 1940 | "OSPF area ID in IP address format\n" |
| 1941 | "OSPF area ID as a decimal value\n" |
| 1942 | "Enable authentication\n") |
| 1943 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1944 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1945 | struct ospf_area *area; |
| 1946 | struct in_addr area_id; |
| 1947 | int format; |
| 1948 | |
| 1949 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1950 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1951 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1952 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 1953 | |
| 1954 | return CMD_SUCCESS; |
| 1955 | } |
| 1956 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1957 | DEFUN (no_ospf_area_authentication, |
| 1958 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1959 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 1960 | NO_STR |
| 1961 | "OSPF area parameters\n" |
| 1962 | "OSPF area ID in IP address format\n" |
| 1963 | "OSPF area ID as a decimal value\n" |
| 1964 | "Enable authentication\n") |
| 1965 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1966 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1967 | struct ospf_area *area; |
| 1968 | struct in_addr area_id; |
| 1969 | int format; |
| 1970 | |
| 1971 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1972 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1973 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1974 | if (area == NULL) |
| 1975 | return CMD_SUCCESS; |
| 1976 | |
| 1977 | area->auth_type = OSPF_AUTH_NULL; |
| 1978 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1979 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1980 | |
| 1981 | return CMD_SUCCESS; |
| 1982 | } |
| 1983 | |
| 1984 | |
| 1985 | DEFUN (ospf_abr_type, |
| 1986 | ospf_abr_type_cmd, |
| 1987 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 1988 | "OSPF specific commands\n" |
| 1989 | "Set OSPF ABR type\n" |
| 1990 | "Alternative ABR, cisco implementation\n" |
| 1991 | "Alternative ABR, IBM implementation\n" |
| 1992 | "Shortcut ABR\n" |
| 1993 | "Standard behavior (RFC2328)\n") |
| 1994 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1995 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1996 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 1997 | |
| 1998 | if (strncmp (argv[0], "c", 1) == 0) |
| 1999 | abr_type = OSPF_ABR_CISCO; |
| 2000 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2001 | abr_type = OSPF_ABR_IBM; |
| 2002 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2003 | abr_type = OSPF_ABR_SHORTCUT; |
| 2004 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2005 | abr_type = OSPF_ABR_STAND; |
| 2006 | else |
| 2007 | return CMD_WARNING; |
| 2008 | |
| 2009 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2010 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2011 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2012 | ospf->abr_type = abr_type; |
| 2013 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | return CMD_SUCCESS; |
| 2017 | } |
| 2018 | |
| 2019 | DEFUN (no_ospf_abr_type, |
| 2020 | no_ospf_abr_type_cmd, |
| 2021 | "no ospf abr-type (cisco|ibm|shortcut)", |
| 2022 | NO_STR |
| 2023 | "OSPF specific commands\n" |
| 2024 | "Set OSPF ABR type\n" |
| 2025 | "Alternative ABR, cisco implementation\n" |
| 2026 | "Alternative ABR, IBM implementation\n" |
| 2027 | "Shortcut ABR\n") |
| 2028 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2029 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2030 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2031 | |
| 2032 | if (strncmp (argv[0], "c", 1) == 0) |
| 2033 | abr_type = OSPF_ABR_CISCO; |
| 2034 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2035 | abr_type = OSPF_ABR_IBM; |
| 2036 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2037 | abr_type = OSPF_ABR_SHORTCUT; |
| 2038 | else |
| 2039 | return CMD_WARNING; |
| 2040 | |
| 2041 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2042 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2043 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2044 | ospf->abr_type = OSPF_ABR_STAND; |
| 2045 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2046 | } |
| 2047 | |
| 2048 | return CMD_SUCCESS; |
| 2049 | } |
| 2050 | |
| 2051 | DEFUN (ospf_compatible_rfc1583, |
| 2052 | ospf_compatible_rfc1583_cmd, |
| 2053 | "compatible rfc1583", |
| 2054 | "OSPF compatibility list\n" |
| 2055 | "compatible with RFC 1583\n") |
| 2056 | { |
| 2057 | struct ospf *ospf = vty->index; |
| 2058 | |
| 2059 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2060 | { |
| 2061 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2062 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | } |
| 2064 | return CMD_SUCCESS; |
| 2065 | } |
| 2066 | |
| 2067 | DEFUN (no_ospf_compatible_rfc1583, |
| 2068 | no_ospf_compatible_rfc1583_cmd, |
| 2069 | "no compatible rfc1583", |
| 2070 | NO_STR |
| 2071 | "OSPF compatibility list\n" |
| 2072 | "compatible with RFC 1583\n") |
| 2073 | { |
| 2074 | struct ospf *ospf = vty->index; |
| 2075 | |
| 2076 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2077 | { |
| 2078 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2079 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2080 | } |
| 2081 | return CMD_SUCCESS; |
| 2082 | } |
| 2083 | |
| 2084 | ALIAS (ospf_compatible_rfc1583, |
| 2085 | ospf_rfc1583_flag_cmd, |
| 2086 | "ospf rfc1583compatibility", |
| 2087 | "OSPF specific commands\n" |
| 2088 | "Enable the RFC1583Compatibility flag\n") |
| 2089 | |
| 2090 | ALIAS (no_ospf_compatible_rfc1583, |
| 2091 | no_ospf_rfc1583_flag_cmd, |
| 2092 | "no ospf rfc1583compatibility", |
| 2093 | NO_STR |
| 2094 | "OSPF specific commands\n" |
| 2095 | "Disable the RFC1583Compatibility flag\n") |
| 2096 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2097 | DEFUN (ospf_timers_spf, |
| 2098 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2099 | "timers spf <0-4294967295> <0-4294967295>", |
| 2100 | "Adjust routing timers\n" |
| 2101 | "OSPF SPF timers\n" |
| 2102 | "Delay between receiving a change to SPF calculation\n" |
| 2103 | "Hold time between consecutive SPF calculations\n") |
| 2104 | { |
| 2105 | struct ospf *ospf = vty->index; |
| 2106 | u_int32_t delay, hold; |
| 2107 | |
| 2108 | VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]); |
| 2109 | VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]); |
| 2110 | |
| 2111 | ospf_timers_spf_set (ospf, delay, hold); |
| 2112 | |
| 2113 | return CMD_SUCCESS; |
| 2114 | } |
| 2115 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2116 | DEFUN (no_ospf_timers_spf, |
| 2117 | no_ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | "no timers spf", |
| 2119 | NO_STR |
| 2120 | "Adjust routing timers\n" |
| 2121 | "OSPF SPF timers\n") |
| 2122 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2123 | struct ospf *ospf = vty->index; |
| 2124 | |
| 2125 | ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT; |
| 2126 | ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2127 | |
| 2128 | return CMD_SUCCESS; |
| 2129 | } |
| 2130 | |
| 2131 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2132 | DEFUN (ospf_neighbor, |
| 2133 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2134 | "neighbor A.B.C.D", |
| 2135 | NEIGHBOR_STR |
| 2136 | "Neighbor IP address\n") |
| 2137 | { |
| 2138 | struct ospf *ospf = vty->index; |
| 2139 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2140 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2141 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2142 | |
| 2143 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2144 | |
| 2145 | if (argc > 1) |
| 2146 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2147 | |
| 2148 | if (argc > 2) |
| 2149 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2150 | |
| 2151 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2152 | if (argc > 1) |
| 2153 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2154 | if (argc > 2) |
| 2155 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2156 | |
| 2157 | return CMD_SUCCESS; |
| 2158 | } |
| 2159 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2160 | ALIAS (ospf_neighbor, |
| 2161 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2162 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2163 | NEIGHBOR_STR |
| 2164 | "Neighbor IP address\n" |
| 2165 | "Neighbor Priority\n" |
| 2166 | "Priority\n" |
| 2167 | "Dead Neighbor Polling interval\n" |
| 2168 | "Seconds\n") |
| 2169 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2170 | ALIAS (ospf_neighbor, |
| 2171 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2172 | "neighbor A.B.C.D priority <0-255>", |
| 2173 | NEIGHBOR_STR |
| 2174 | "Neighbor IP address\n" |
| 2175 | "Neighbor Priority\n" |
| 2176 | "Seconds\n") |
| 2177 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2178 | DEFUN (ospf_neighbor_poll_interval, |
| 2179 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2180 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2181 | NEIGHBOR_STR |
| 2182 | "Neighbor IP address\n" |
| 2183 | "Dead Neighbor Polling interval\n" |
| 2184 | "Seconds\n") |
| 2185 | { |
| 2186 | struct ospf *ospf = vty->index; |
| 2187 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2188 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2189 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2190 | |
| 2191 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2192 | |
| 2193 | if (argc > 1) |
| 2194 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2195 | |
| 2196 | if (argc > 2) |
| 2197 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2198 | |
| 2199 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2200 | if (argc > 1) |
| 2201 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2202 | if (argc > 2) |
| 2203 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2204 | |
| 2205 | return CMD_SUCCESS; |
| 2206 | } |
| 2207 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2208 | ALIAS (ospf_neighbor_poll_interval, |
| 2209 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2211 | NEIGHBOR_STR |
| 2212 | "Neighbor address\n" |
| 2213 | "OSPF dead-router polling interval\n" |
| 2214 | "Seconds\n" |
| 2215 | "OSPF priority of non-broadcast neighbor\n" |
| 2216 | "Priority\n") |
| 2217 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2218 | DEFUN (no_ospf_neighbor, |
| 2219 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2220 | "no neighbor A.B.C.D", |
| 2221 | NO_STR |
| 2222 | NEIGHBOR_STR |
| 2223 | "Neighbor IP address\n") |
| 2224 | { |
| 2225 | struct ospf *ospf = vty->index; |
| 2226 | struct in_addr nbr_addr; |
| 2227 | int ret; |
| 2228 | |
| 2229 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2230 | |
| 2231 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2232 | |
| 2233 | return CMD_SUCCESS; |
| 2234 | } |
| 2235 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2236 | ALIAS (no_ospf_neighbor, |
| 2237 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2238 | "no neighbor A.B.C.D priority <0-255>", |
| 2239 | NO_STR |
| 2240 | NEIGHBOR_STR |
| 2241 | "Neighbor IP address\n" |
| 2242 | "Neighbor Priority\n" |
| 2243 | "Priority\n") |
| 2244 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2245 | ALIAS (no_ospf_neighbor, |
| 2246 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2247 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2248 | NO_STR |
| 2249 | NEIGHBOR_STR |
| 2250 | "Neighbor IP address\n" |
| 2251 | "Dead Neighbor Polling interval\n" |
| 2252 | "Seconds\n") |
| 2253 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2254 | ALIAS (no_ospf_neighbor, |
| 2255 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2257 | NO_STR |
| 2258 | NEIGHBOR_STR |
| 2259 | "Neighbor IP address\n" |
| 2260 | "Neighbor Priority\n" |
| 2261 | "Priority\n" |
| 2262 | "Dead Neighbor Polling interval\n" |
| 2263 | "Seconds\n") |
| 2264 | |
| 2265 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2266 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2267 | "refresh timer <10-1800>", |
| 2268 | "Adjust refresh parameters\n" |
| 2269 | "Set refresh timer\n" |
| 2270 | "Timer value in seconds\n") |
| 2271 | { |
| 2272 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2273 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2274 | |
| 2275 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2276 | interval = (interval / 10) * 10; |
| 2277 | |
| 2278 | ospf_timers_refresh_set (ospf, interval); |
| 2279 | |
| 2280 | return CMD_SUCCESS; |
| 2281 | } |
| 2282 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2283 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2284 | "no refresh timer <10-1800>", |
| 2285 | "Adjust refresh parameters\n" |
| 2286 | "Unset refresh timer\n" |
| 2287 | "Timer value in seconds\n") |
| 2288 | { |
| 2289 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2290 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2291 | |
| 2292 | if (argc == 1) |
| 2293 | { |
| 2294 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2295 | |
| 2296 | if (ospf->lsa_refresh_interval != interval || |
| 2297 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2298 | return CMD_SUCCESS; |
| 2299 | } |
| 2300 | |
| 2301 | ospf_timers_refresh_unset (ospf); |
| 2302 | |
| 2303 | return CMD_SUCCESS; |
| 2304 | } |
| 2305 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2306 | ALIAS (no_ospf_refresh_timer, |
| 2307 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2308 | "no refresh timer", |
| 2309 | "Adjust refresh parameters\n" |
| 2310 | "Unset refresh timer\n") |
| 2311 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2312 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2313 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2314 | "auto-cost reference-bandwidth <1-4294967>", |
| 2315 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2316 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2317 | "The reference bandwidth in terms of Mbits per second\n") |
| 2318 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2319 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2320 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2321 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2322 | |
| 2323 | refbw = strtol (argv[0], NULL, 10); |
| 2324 | if (refbw < 1 || refbw > 4294967) |
| 2325 | { |
| 2326 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2327 | return CMD_WARNING; |
| 2328 | } |
| 2329 | |
| 2330 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2331 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2332 | return CMD_SUCCESS; |
| 2333 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2334 | ospf->ref_bandwidth = refbw * 1000; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2335 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2336 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2337 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2338 | for (node = listhead (om->iflist); node; nextnode (node)) |
| 2339 | ospf_if_recalculate_output_cost (getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2340 | |
| 2341 | return CMD_SUCCESS; |
| 2342 | } |
| 2343 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2344 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2345 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2346 | "no auto-cost reference-bandwidth", |
| 2347 | NO_STR |
| 2348 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2349 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2350 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2351 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2352 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2353 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2354 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2355 | return CMD_SUCCESS; |
| 2356 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2357 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2358 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2359 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2360 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2361 | for (node = listhead (om->iflist); node; nextnode (node)) |
| 2362 | ospf_if_recalculate_output_cost (getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2363 | |
| 2364 | return CMD_SUCCESS; |
| 2365 | } |
| 2366 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2367 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2368 | { |
| 2369 | "Unknown", |
| 2370 | "Standard (RFC2328)", |
| 2371 | "Alternative IBM", |
| 2372 | "Alternative Cisco", |
| 2373 | "Alternative Shortcut" |
| 2374 | }; |
| 2375 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2376 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2377 | { |
| 2378 | "Default", |
| 2379 | "Enabled", |
| 2380 | "Disabled" |
| 2381 | }; |
| 2382 | |
| 2383 | |
| 2384 | |
| 2385 | void |
| 2386 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2387 | { |
| 2388 | /* Show Area ID. */ |
| 2389 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2390 | |
| 2391 | /* Show Area type/mode. */ |
| 2392 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2393 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2394 | else |
| 2395 | { |
| 2396 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2397 | vty_out (vty, " (Stub%s%s)", |
| 2398 | area->no_summary ? ", no summary" : "", |
| 2399 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2400 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2401 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2402 | vty_out (vty, " (NSSA%s%s)", |
| 2403 | area->no_summary ? ", no summary" : "", |
| 2404 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2405 | |
| 2406 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2407 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2408 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2409 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2410 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2411 | } |
| 2412 | |
| 2413 | /* Show number of interfaces. */ |
| 2414 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2415 | "Active: %d%s", listcount (area->oiflist), |
| 2416 | area->act_ints, VTY_NEWLINE); |
| 2417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2418 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2419 | { |
| 2420 | 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] | 2421 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2422 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2423 | VTY_NEWLINE); |
| 2424 | else if (area->NSSATranslatorState) |
| 2425 | { |
| 2426 | vty_out (vty, " We are an ABR and "); |
| 2427 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2428 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2429 | VTY_NEWLINE); |
| 2430 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2431 | vty_out (vty, "always an NSSA Translator. %s", |
| 2432 | VTY_NEWLINE); |
| 2433 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2434 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2435 | { |
| 2436 | vty_out (vty, " We are an ABR, but "); |
| 2437 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2438 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2439 | VTY_NEWLINE); |
| 2440 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2441 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2442 | VTY_NEWLINE); |
| 2443 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2444 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2445 | |
| 2446 | /* Show number of fully adjacent neighbors. */ |
| 2447 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2448 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2449 | |
| 2450 | /* Show authentication type. */ |
| 2451 | vty_out (vty, " Area has "); |
| 2452 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2453 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2454 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2455 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2456 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2457 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2458 | |
| 2459 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2460 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2461 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2462 | |
| 2463 | /* Show SPF calculation times. */ |
| 2464 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2465 | area->spf_calculation, VTY_NEWLINE); |
| 2466 | |
| 2467 | /* Show number of LSA. */ |
| 2468 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2469 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2470 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2471 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2472 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2473 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2474 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2475 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2476 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2477 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2478 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2479 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2480 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2481 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2482 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2483 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2484 | #ifdef HAVE_OPAQUE_LSA |
| 2485 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2486 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2487 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2488 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2489 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2490 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2491 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2492 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2493 | } |
| 2494 | |
| 2495 | DEFUN (show_ip_ospf, |
| 2496 | show_ip_ospf_cmd, |
| 2497 | "show ip ospf", |
| 2498 | SHOW_STR |
| 2499 | IP_STR |
| 2500 | "OSPF information\n") |
| 2501 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2502 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2503 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2504 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2505 | |
| 2506 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2507 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2508 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2509 | { |
| 2510 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2511 | return CMD_SUCCESS; |
| 2512 | } |
| 2513 | |
| 2514 | /* Show Router ID. */ |
| 2515 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2516 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2517 | VTY_NEWLINE); |
| 2518 | |
| 2519 | /* Show capability. */ |
| 2520 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2521 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2522 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2523 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2524 | "enabled" : "disabled", VTY_NEWLINE); |
| 2525 | #ifdef HAVE_OPAQUE_LSA |
| 2526 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2527 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2528 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2529 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | " (origination blocked)" : "", |
| 2531 | VTY_NEWLINE); |
| 2532 | #endif /* HAVE_OPAQUE_LSA */ |
| 2533 | |
| 2534 | /* Show SPF timers. */ |
| 2535 | 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] | 2536 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2537 | |
| 2538 | /* Show refresh parameters. */ |
| 2539 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2540 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2541 | |
| 2542 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2543 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2544 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2545 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2546 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2547 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2548 | vty_out (vty, " This router is an ASBR " |
| 2549 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2550 | |
| 2551 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2552 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2553 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2554 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2555 | #ifdef HAVE_OPAQUE_LSA |
| 2556 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2557 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2558 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2559 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2560 | /* Show number of areas attached. */ |
| 2561 | vty_out (vty, " Number of areas attached to this router: %d%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2562 | listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2563 | |
| 2564 | /* Show each area status. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2565 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | if ((area = getdata (node)) != NULL) |
| 2567 | show_ip_ospf_area (vty, area); |
| 2568 | |
| 2569 | return CMD_SUCCESS; |
| 2570 | } |
| 2571 | |
| 2572 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2573 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2574 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2575 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2577 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2579 | struct route_node *rn; |
| 2580 | char buf[9]; |
| 2581 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2582 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2583 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2584 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
| 2585 | vty_out (vty, " MTU %u bytes, BW %u Kbit%s", |
| 2586 | ifp->mtu, ifp->bandwidth, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2587 | |
| 2588 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2589 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2590 | { |
| 2591 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2592 | return; |
| 2593 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2594 | else if (!is_up) |
| 2595 | { |
| 2596 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2597 | VTY_NEWLINE); |
| 2598 | return; |
| 2599 | } |
| 2600 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2601 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2602 | { |
| 2603 | struct ospf_interface *oi = rn->info; |
| 2604 | |
| 2605 | if (oi == NULL) |
| 2606 | continue; |
| 2607 | |
| 2608 | /* Show OSPF interface information. */ |
| 2609 | vty_out (vty, " Internet Address %s/%d,", |
| 2610 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2611 | |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2612 | if (oi->connected->destination) |
| 2613 | vty_out (vty, " %s %s,", |
| 2614 | ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"), |
| 2615 | inet_ntoa (oi->connected->destination->u.prefix4)); |
| 2616 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2617 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2618 | VTY_NEWLINE); |
| 2619 | |
| 2620 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2621 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2622 | oi->output_cost, VTY_NEWLINE); |
| 2623 | |
| 2624 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2625 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2626 | PRIORITY (oi), VTY_NEWLINE); |
| 2627 | |
| 2628 | /* Show DR information. */ |
| 2629 | if (DR (oi).s_addr == 0) |
| 2630 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2631 | else |
| 2632 | { |
| 2633 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2634 | if (nbr == NULL) |
| 2635 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2636 | else |
| 2637 | { |
| 2638 | vty_out (vty, " Designated Router (ID) %s,", |
| 2639 | inet_ntoa (nbr->router_id)); |
| 2640 | vty_out (vty, " Interface Address %s%s", |
| 2641 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2642 | } |
| 2643 | } |
| 2644 | |
| 2645 | /* Show BDR information. */ |
| 2646 | if (BDR (oi).s_addr == 0) |
| 2647 | vty_out (vty, " No backup designated router on this network%s", |
| 2648 | VTY_NEWLINE); |
| 2649 | else |
| 2650 | { |
| 2651 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2652 | if (nbr == NULL) |
| 2653 | vty_out (vty, " No backup designated router on this network%s", |
| 2654 | VTY_NEWLINE); |
| 2655 | else |
| 2656 | { |
| 2657 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2658 | inet_ntoa (nbr->router_id)); |
| 2659 | vty_out (vty, " Interface Address %s%s", |
| 2660 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2661 | } |
| 2662 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2663 | |
| 2664 | vty_out (vty, " Multicast group memberships:"); |
| 2665 | if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS)) |
| 2666 | vty_out (vty, " OSPFAllRouters"); |
| 2667 | if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS)) |
| 2668 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2669 | if (!CHECK_FLAG(oi->multicast_memberships, |
| 2670 | MEMBER_ALLROUTERS|MEMBER_DROUTERS)) |
| 2671 | vty_out (vty, " <None>"); |
| 2672 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2673 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2674 | vty_out (vty, " Timer intervals configured,"); |
| 2675 | vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s", |
| 2676 | OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait), |
| 2677 | OSPF_IF_PARAM (oi, v_wait), |
| 2678 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2679 | VTY_NEWLINE); |
| 2680 | |
| 2681 | if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE) |
| 2682 | vty_out (vty, " Hello due in %s%s", |
| 2683 | ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE); |
| 2684 | else /* OSPF_IF_PASSIVE is set */ |
| 2685 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2686 | |
| 2687 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2688 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2689 | VTY_NEWLINE); |
| 2690 | } |
| 2691 | } |
| 2692 | |
| 2693 | DEFUN (show_ip_ospf_interface, |
| 2694 | show_ip_ospf_interface_cmd, |
| 2695 | "show ip ospf interface [INTERFACE]", |
| 2696 | SHOW_STR |
| 2697 | IP_STR |
| 2698 | "OSPF information\n" |
| 2699 | "Interface information\n" |
| 2700 | "Interface name\n") |
| 2701 | { |
| 2702 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2703 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2704 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2705 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2706 | ospf = ospf_lookup (); |
| 2707 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2708 | /* Show All Interfaces. */ |
| 2709 | if (argc == 0) |
| 2710 | for (node = listhead (iflist); node; nextnode (node)) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2711 | show_ip_ospf_interface_sub (vty, ospf, node->data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2712 | /* Interface name is specified. */ |
| 2713 | else |
| 2714 | { |
| 2715 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2716 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2717 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2718 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2719 | } |
| 2720 | |
| 2721 | return CMD_SUCCESS; |
| 2722 | } |
| 2723 | |
| 2724 | void |
| 2725 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 2726 | { |
| 2727 | struct route_node *rn; |
| 2728 | struct ospf_neighbor *nbr; |
| 2729 | char msgbuf[16]; |
| 2730 | char timebuf[9]; |
| 2731 | |
| 2732 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 2733 | if ((nbr = rn->info)) |
| 2734 | /* Do not show myself. */ |
| 2735 | if (nbr != oi->nbr_self) |
| 2736 | /* Down state is not shown. */ |
| 2737 | if (nbr->state != NSM_Down) |
| 2738 | { |
| 2739 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 2740 | |
| 2741 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2742 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2743 | "-", nbr->priority, |
| 2744 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2745 | else |
| 2746 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2747 | inet_ntoa (nbr->router_id), nbr->priority, |
| 2748 | msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9)); |
| 2749 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
| 2750 | vty_out (vty, "%-15s %5ld %5ld %5d%s", |
| 2751 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 2752 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 2753 | VTY_NEWLINE); |
| 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | DEFUN (show_ip_ospf_neighbor, |
| 2758 | show_ip_ospf_neighbor_cmd, |
| 2759 | "show ip ospf neighbor", |
| 2760 | SHOW_STR |
| 2761 | IP_STR |
| 2762 | "OSPF information\n" |
| 2763 | "Neighbor list\n") |
| 2764 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2765 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2766 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2767 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2768 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2769 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2770 | { |
| 2771 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2772 | return CMD_SUCCESS; |
| 2773 | } |
| 2774 | |
| 2775 | /* Show All neighbors. */ |
| 2776 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2777 | "Time Address Interface RXmtL " |
| 2778 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2779 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2780 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2781 | show_ip_ospf_neighbor_sub (vty, getdata (node)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2782 | |
| 2783 | return CMD_SUCCESS; |
| 2784 | } |
| 2785 | |
| 2786 | DEFUN (show_ip_ospf_neighbor_all, |
| 2787 | show_ip_ospf_neighbor_all_cmd, |
| 2788 | "show ip ospf neighbor all", |
| 2789 | SHOW_STR |
| 2790 | IP_STR |
| 2791 | "OSPF information\n" |
| 2792 | "Neighbor list\n" |
| 2793 | "include down status neighbor\n") |
| 2794 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2795 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2796 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2797 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2798 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2799 | { |
| 2800 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2801 | return CMD_SUCCESS; |
| 2802 | } |
| 2803 | |
| 2804 | /* Show All neighbors. */ |
| 2805 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2806 | "Time Address Interface RXmtL " |
| 2807 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2808 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2809 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2810 | { |
| 2811 | struct ospf_interface *oi = getdata (node); |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2812 | struct listnode *nbr_node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2813 | |
| 2814 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2815 | |
| 2816 | /* print Down neighbor status */ |
| 2817 | for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node)) |
| 2818 | { |
| 2819 | struct ospf_nbr_nbma *nbr_nbma; |
| 2820 | |
| 2821 | nbr_nbma = getdata (nbr_node); |
| 2822 | |
| 2823 | if (nbr_nbma->nbr == NULL |
| 2824 | || nbr_nbma->nbr->state == NSM_Down) |
| 2825 | { |
| 2826 | vty_out (vty, "%-15s %3d %-15s %8s ", |
| 2827 | "-", nbr_nbma->priority, "Down", "-"); |
| 2828 | vty_out (vty, "%-15s %-15s %5d %5d %5d%s", |
| 2829 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 2830 | 0, 0, 0, VTY_NEWLINE); |
| 2831 | } |
| 2832 | } |
| 2833 | } |
| 2834 | |
| 2835 | return CMD_SUCCESS; |
| 2836 | } |
| 2837 | |
| 2838 | DEFUN (show_ip_ospf_neighbor_int, |
| 2839 | show_ip_ospf_neighbor_int_cmd, |
| 2840 | "show ip ospf neighbor A.B.C.D", |
| 2841 | SHOW_STR |
| 2842 | IP_STR |
| 2843 | "OSPF information\n" |
| 2844 | "Neighbor list\n" |
| 2845 | "Interface name\n") |
| 2846 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2847 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2848 | struct ospf_interface *oi; |
| 2849 | struct in_addr addr; |
| 2850 | int ret; |
| 2851 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2852 | ret = inet_aton (argv[0], &addr); |
| 2853 | if (!ret) |
| 2854 | { |
| 2855 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 2856 | VTY_NEWLINE); |
| 2857 | return CMD_WARNING; |
| 2858 | } |
| 2859 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2860 | ospf = ospf_lookup (); |
| 2861 | if (ospf == NULL) |
| 2862 | { |
| 2863 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2864 | return CMD_SUCCESS; |
| 2865 | } |
| 2866 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2867 | if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2868 | vty_out (vty, "No such interface address%s", VTY_NEWLINE); |
| 2869 | else |
| 2870 | { |
| 2871 | vty_out (vty, "%sNeighbor ID Pri State Dead " |
| 2872 | "Time Address Interface RXmtL " |
| 2873 | "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE); |
| 2874 | show_ip_ospf_neighbor_sub (vty, oi); |
| 2875 | } |
| 2876 | |
| 2877 | return CMD_SUCCESS; |
| 2878 | } |
| 2879 | |
| 2880 | void |
| 2881 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2882 | struct ospf_nbr_nbma *nbr_nbma) |
| 2883 | { |
| 2884 | char timebuf[9]; |
| 2885 | |
| 2886 | /* Show neighbor ID. */ |
| 2887 | vty_out (vty, " Neighbor %s,", "-"); |
| 2888 | |
| 2889 | /* Show interface address. */ |
| 2890 | vty_out (vty, " interface address %s%s", |
| 2891 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 2892 | /* Show Area ID. */ |
| 2893 | vty_out (vty, " In the area %s via interface %s%s", |
| 2894 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 2895 | /* Show neighbor priority and state. */ |
| 2896 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2897 | nbr_nbma->priority, "Down"); |
| 2898 | /* Show state changes. */ |
| 2899 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 2900 | |
| 2901 | /* Show PollInterval */ |
| 2902 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 2903 | |
| 2904 | /* Show poll-interval timer. */ |
| 2905 | vty_out (vty, " Poll timer due in %s%s", |
| 2906 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE); |
| 2907 | |
| 2908 | /* Show poll-interval timer thread. */ |
| 2909 | vty_out (vty, " Thread Poll Timer %s%s", |
| 2910 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 2911 | } |
| 2912 | |
| 2913 | void |
| 2914 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 2915 | struct ospf_neighbor *nbr) |
| 2916 | { |
| 2917 | char timebuf[9]; |
| 2918 | |
| 2919 | /* Show neighbor ID. */ |
| 2920 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 2921 | vty_out (vty, " Neighbor %s,", "-"); |
| 2922 | else |
| 2923 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 2924 | |
| 2925 | /* Show interface address. */ |
| 2926 | vty_out (vty, " interface address %s%s", |
| 2927 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2928 | /* Show Area ID. */ |
| 2929 | vty_out (vty, " In the area %s via interface %s%s", |
| 2930 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 2931 | /* Show neighbor priority and state. */ |
| 2932 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 2933 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 2934 | /* Show state changes. */ |
| 2935 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
| 2936 | |
| 2937 | /* Show Designated Rotuer ID. */ |
| 2938 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 2939 | /* Show Backup Designated Rotuer ID. */ |
| 2940 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 2941 | /* Show options. */ |
| 2942 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 2943 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 2944 | /* Show Router Dead interval timer. */ |
| 2945 | vty_out (vty, " Dead timer due in %s%s", |
| 2946 | ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE); |
| 2947 | /* Show Database Summary list. */ |
| 2948 | vty_out (vty, " Database Summary List %d%s", |
| 2949 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 2950 | /* Show Link State Request list. */ |
| 2951 | vty_out (vty, " Link State Request List %ld%s", |
| 2952 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 2953 | /* Show Link State Retransmission list. */ |
| 2954 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 2955 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 2956 | /* Show inactivity timer thread. */ |
| 2957 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 2958 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 2959 | /* Show Database Description retransmission thread. */ |
| 2960 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 2961 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 2962 | /* Show Link State Request Retransmission thread. */ |
| 2963 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 2964 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 2965 | /* Show Link State Update Retransmission thread. */ |
| 2966 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 2967 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 2968 | } |
| 2969 | |
| 2970 | DEFUN (show_ip_ospf_neighbor_id, |
| 2971 | show_ip_ospf_neighbor_id_cmd, |
| 2972 | "show ip ospf neighbor A.B.C.D", |
| 2973 | SHOW_STR |
| 2974 | IP_STR |
| 2975 | "OSPF information\n" |
| 2976 | "Neighbor list\n" |
| 2977 | "Neighbor ID\n") |
| 2978 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2979 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2980 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2981 | struct ospf_neighbor *nbr; |
| 2982 | struct in_addr router_id; |
| 2983 | int ret; |
| 2984 | |
| 2985 | ret = inet_aton (argv[0], &router_id); |
| 2986 | if (!ret) |
| 2987 | { |
| 2988 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 2989 | return CMD_WARNING; |
| 2990 | } |
| 2991 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2992 | ospf = ospf_lookup (); |
| 2993 | if (ospf == NULL) |
| 2994 | { |
| 2995 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2996 | return CMD_SUCCESS; |
| 2997 | } |
| 2998 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2999 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3000 | { |
| 3001 | struct ospf_interface *oi = getdata (node); |
| 3002 | |
| 3003 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
| 3004 | { |
| 3005 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3006 | return CMD_SUCCESS; |
| 3007 | } |
| 3008 | } |
| 3009 | |
| 3010 | /* Nothing to show. */ |
| 3011 | return CMD_SUCCESS; |
| 3012 | } |
| 3013 | |
| 3014 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3015 | show_ip_ospf_neighbor_detail_cmd, |
| 3016 | "show ip ospf neighbor detail", |
| 3017 | SHOW_STR |
| 3018 | IP_STR |
| 3019 | "OSPF information\n" |
| 3020 | "Neighbor list\n" |
| 3021 | "detail of all neighbors\n") |
| 3022 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3023 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3024 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3025 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3026 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3027 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3028 | { |
| 3029 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3030 | return CMD_SUCCESS; |
| 3031 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3032 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3033 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3034 | { |
| 3035 | struct ospf_interface *oi = getdata (node); |
| 3036 | struct route_node *rn; |
| 3037 | struct ospf_neighbor *nbr; |
| 3038 | |
| 3039 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3040 | if ((nbr = rn->info)) |
| 3041 | if (nbr != oi->nbr_self) |
| 3042 | if (nbr->state != NSM_Down) |
| 3043 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3044 | } |
| 3045 | |
| 3046 | return CMD_SUCCESS; |
| 3047 | } |
| 3048 | |
| 3049 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3050 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3051 | "show ip ospf neighbor detail all", |
| 3052 | SHOW_STR |
| 3053 | IP_STR |
| 3054 | "OSPF information\n" |
| 3055 | "Neighbor list\n" |
| 3056 | "detail of all neighbors\n" |
| 3057 | "include down status neighbor\n") |
| 3058 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3059 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3060 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3061 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3062 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3063 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3064 | { |
| 3065 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3066 | return CMD_SUCCESS; |
| 3067 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3068 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3069 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3070 | { |
| 3071 | struct ospf_interface *oi = getdata (node); |
| 3072 | struct route_node *rn; |
| 3073 | struct ospf_neighbor *nbr; |
| 3074 | |
| 3075 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3076 | if ((nbr = rn->info)) |
| 3077 | if (nbr != oi->nbr_self) |
| 3078 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3079 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3080 | |
| 3081 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3082 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3083 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3084 | |
| 3085 | for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd)) |
| 3086 | { |
| 3087 | struct ospf_nbr_nbma *nbr_nbma = getdata (nd); |
| 3088 | if (nbr_nbma->nbr == NULL |
| 3089 | || nbr_nbma->nbr->state == NSM_Down) |
| 3090 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
| 3091 | } |
| 3092 | } |
| 3093 | } |
| 3094 | |
| 3095 | return CMD_SUCCESS; |
| 3096 | } |
| 3097 | |
| 3098 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3099 | show_ip_ospf_neighbor_int_detail_cmd, |
| 3100 | "show ip ospf neighbor A.B.C.D detail", |
| 3101 | SHOW_STR |
| 3102 | IP_STR |
| 3103 | "OSPF information\n" |
| 3104 | "Neighbor list\n" |
| 3105 | "Interface address\n" |
| 3106 | "detail of all neighbors") |
| 3107 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3108 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3109 | struct ospf_interface *oi; |
| 3110 | struct in_addr addr; |
| 3111 | int ret; |
| 3112 | |
| 3113 | ret = inet_aton (argv[0], &addr); |
| 3114 | if (!ret) |
| 3115 | { |
| 3116 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 3117 | VTY_NEWLINE); |
| 3118 | return CMD_WARNING; |
| 3119 | } |
| 3120 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3121 | ospf = ospf_lookup (); |
| 3122 | if (ospf == NULL) |
| 3123 | { |
| 3124 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3125 | return CMD_SUCCESS; |
| 3126 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3127 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3128 | if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3129 | vty_out (vty, "No such interface address%s", VTY_NEWLINE); |
| 3130 | else |
| 3131 | { |
| 3132 | struct route_node *rn; |
| 3133 | struct ospf_neighbor *nbr; |
| 3134 | |
| 3135 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3136 | if ((nbr = rn->info)) |
| 3137 | if (nbr != oi->nbr_self) |
| 3138 | if (nbr->state != NSM_Down) |
| 3139 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3140 | } |
| 3141 | |
| 3142 | return CMD_SUCCESS; |
| 3143 | } |
| 3144 | |
| 3145 | |
| 3146 | /* Show functions */ |
| 3147 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3148 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3149 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3150 | struct router_lsa *rl; |
| 3151 | struct summary_lsa *sl; |
| 3152 | struct as_external_lsa *asel; |
| 3153 | struct prefix_ipv4 p; |
| 3154 | |
| 3155 | if (lsa != NULL) |
| 3156 | /* If self option is set, check LSA self flag. */ |
| 3157 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3158 | { |
| 3159 | /* LSA common part show. */ |
| 3160 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3161 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3162 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3163 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3164 | /* LSA specific part show. */ |
| 3165 | switch (lsa->data->type) |
| 3166 | { |
| 3167 | case OSPF_ROUTER_LSA: |
| 3168 | rl = (struct router_lsa *) lsa->data; |
| 3169 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3170 | break; |
| 3171 | case OSPF_SUMMARY_LSA: |
| 3172 | sl = (struct summary_lsa *) lsa->data; |
| 3173 | |
| 3174 | p.family = AF_INET; |
| 3175 | p.prefix = sl->header.id; |
| 3176 | p.prefixlen = ip_masklen (sl->mask); |
| 3177 | apply_mask_ipv4 (&p); |
| 3178 | |
| 3179 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3180 | break; |
| 3181 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3182 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3183 | asel = (struct as_external_lsa *) lsa->data; |
| 3184 | |
| 3185 | p.family = AF_INET; |
| 3186 | p.prefix = asel->header.id; |
| 3187 | p.prefixlen = ip_masklen (asel->mask); |
| 3188 | apply_mask_ipv4 (&p); |
| 3189 | |
| 3190 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3191 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3192 | inet_ntoa (p.prefix), p.prefixlen, |
| 3193 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3194 | break; |
| 3195 | case OSPF_NETWORK_LSA: |
| 3196 | case OSPF_ASBR_SUMMARY_LSA: |
| 3197 | #ifdef HAVE_OPAQUE_LSA |
| 3198 | case OSPF_OPAQUE_LINK_LSA: |
| 3199 | case OSPF_OPAQUE_AREA_LSA: |
| 3200 | case OSPF_OPAQUE_AS_LSA: |
| 3201 | #endif /* HAVE_OPAQUE_LSA */ |
| 3202 | default: |
| 3203 | break; |
| 3204 | } |
| 3205 | vty_out (vty, VTY_NEWLINE); |
| 3206 | } |
| 3207 | |
| 3208 | return 0; |
| 3209 | } |
| 3210 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3211 | const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3212 | { |
| 3213 | "unknown", |
| 3214 | "Router Link States", |
| 3215 | "Net Link States", |
| 3216 | "Summary Link States", |
| 3217 | "ASBR-Summary Link States", |
| 3218 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3219 | "Group Membership LSA", |
| 3220 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3221 | #ifdef HAVE_OPAQUE_LSA |
| 3222 | "Type-8 LSA", |
| 3223 | "Link-Local Opaque-LSA", |
| 3224 | "Area-Local Opaque-LSA", |
| 3225 | "AS-external Opaque-LSA", |
| 3226 | #endif /* HAVE_OPAQUE_LSA */ |
| 3227 | }; |
| 3228 | |
| 3229 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3230 | "Link ID ADV Router Age Seq# CkSum" |
| 3231 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3232 | const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3233 | { |
| 3234 | "", |
| 3235 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3236 | "Link ID ADV Router Age Seq# CkSum", |
| 3237 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3238 | "Link ID ADV Router Age Seq# CkSum", |
| 3239 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3240 | " --- header for Group Member ----", |
| 3241 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3242 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3243 | " --- type-8 ---", |
| 3244 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3245 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3246 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3247 | #endif /* HAVE_OPAQUE_LSA */ |
| 3248 | }; |
| 3249 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3250 | const char *show_lsa_flags[] = |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3251 | { |
| 3252 | "Self-originated", |
| 3253 | "Checked", |
| 3254 | "Received", |
| 3255 | "Approved", |
| 3256 | "Discard", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3257 | "Translated", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3258 | }; |
| 3259 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3260 | void |
| 3261 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3262 | { |
| 3263 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3264 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3265 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3266 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3267 | lsa->data->options, |
| 3268 | ospf_options_dump(lsa->data->options), |
| 3269 | VTY_NEWLINE); |
| 3270 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3271 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3272 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3273 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3274 | |
| 3275 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3276 | { |
| 3277 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3278 | |
| 3279 | if (rlsa->flags) |
| 3280 | vty_out (vty, " :%s%s%s%s", |
| 3281 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3282 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3283 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3284 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3285 | |
| 3286 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3287 | } |
| 3288 | vty_out (vty, " LS Type: %s%s", |
| 3289 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3290 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3291 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3292 | vty_out (vty, " Advertising Router: %s%s", |
| 3293 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3294 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3295 | VTY_NEWLINE); |
| 3296 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3297 | VTY_NEWLINE); |
| 3298 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3299 | } |
| 3300 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3301 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3302 | { |
| 3303 | "(null)", |
| 3304 | "another Router (point-to-point)", |
| 3305 | "a Transit Network", |
| 3306 | "Stub Network", |
| 3307 | "a Virtual Link", |
| 3308 | }; |
| 3309 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3310 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3311 | { |
| 3312 | "(null)", |
| 3313 | "Neighboring Router ID", |
| 3314 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3315 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3316 | "Neighboring Router ID", |
| 3317 | }; |
| 3318 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3319 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3320 | { |
| 3321 | "(null)", |
| 3322 | "Router Interface address", |
| 3323 | "Router Interface address", |
| 3324 | "Network Mask", |
| 3325 | "Router Interface address", |
| 3326 | }; |
| 3327 | |
| 3328 | /* Show router-LSA each Link information. */ |
| 3329 | void |
| 3330 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3331 | struct router_lsa *rl) |
| 3332 | { |
| 3333 | int len, i, type; |
| 3334 | |
| 3335 | len = ntohs (rl->header.length) - 4; |
| 3336 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3337 | { |
| 3338 | type = rl->link[i].type; |
| 3339 | |
| 3340 | vty_out (vty, " Link connected to: %s%s", |
| 3341 | link_type_desc[type], VTY_NEWLINE); |
| 3342 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3343 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3344 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3345 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3346 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3347 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3348 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3349 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3350 | } |
| 3351 | } |
| 3352 | |
| 3353 | /* Show router-LSA detail information. */ |
| 3354 | int |
| 3355 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3356 | { |
| 3357 | if (lsa != NULL) |
| 3358 | { |
| 3359 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3360 | |
| 3361 | show_ip_ospf_database_header (vty, lsa); |
| 3362 | |
| 3363 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3364 | VTY_NEWLINE, VTY_NEWLINE); |
| 3365 | |
| 3366 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3367 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3368 | } |
| 3369 | |
| 3370 | return 0; |
| 3371 | } |
| 3372 | |
| 3373 | /* Show network-LSA detail information. */ |
| 3374 | int |
| 3375 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3376 | { |
| 3377 | int length, i; |
| 3378 | |
| 3379 | if (lsa != NULL) |
| 3380 | { |
| 3381 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3382 | |
| 3383 | show_ip_ospf_database_header (vty, lsa); |
| 3384 | |
| 3385 | vty_out (vty, " Network Mask: /%d%s", |
| 3386 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3387 | |
| 3388 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3389 | |
| 3390 | for (i = 0; length > 0; i++, length -= 4) |
| 3391 | vty_out (vty, " Attached Router: %s%s", |
| 3392 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3393 | |
| 3394 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3395 | } |
| 3396 | |
| 3397 | return 0; |
| 3398 | } |
| 3399 | |
| 3400 | /* Show summary-LSA detail information. */ |
| 3401 | int |
| 3402 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3403 | { |
| 3404 | if (lsa != NULL) |
| 3405 | { |
| 3406 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3407 | |
| 3408 | show_ip_ospf_database_header (vty, lsa); |
| 3409 | |
| 3410 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3411 | VTY_NEWLINE); |
| 3412 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3413 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3414 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3415 | } |
| 3416 | |
| 3417 | return 0; |
| 3418 | } |
| 3419 | |
| 3420 | /* Show summary-ASBR-LSA detail information. */ |
| 3421 | int |
| 3422 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3423 | { |
| 3424 | if (lsa != NULL) |
| 3425 | { |
| 3426 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3427 | |
| 3428 | show_ip_ospf_database_header (vty, lsa); |
| 3429 | |
| 3430 | vty_out (vty, " Network Mask: /%d%s", |
| 3431 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3432 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3433 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3434 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3435 | } |
| 3436 | |
| 3437 | return 0; |
| 3438 | } |
| 3439 | |
| 3440 | /* Show AS-external-LSA detail information. */ |
| 3441 | int |
| 3442 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3443 | { |
| 3444 | if (lsa != NULL) |
| 3445 | { |
| 3446 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3447 | |
| 3448 | show_ip_ospf_database_header (vty, lsa); |
| 3449 | |
| 3450 | vty_out (vty, " Network Mask: /%d%s", |
| 3451 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3452 | vty_out (vty, " Metric Type: %s%s", |
| 3453 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3454 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3455 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3456 | vty_out (vty, " Metric: %d%s", |
| 3457 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3458 | vty_out (vty, " Forward Address: %s%s", |
| 3459 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3460 | |
| 3461 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3462 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3463 | } |
| 3464 | |
| 3465 | return 0; |
| 3466 | } |
| 3467 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3468 | /* N.B. This function currently seems to be unused. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3469 | int |
| 3470 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3471 | { |
| 3472 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3473 | |
| 3474 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3475 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3476 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3477 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3478 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3479 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3480 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3481 | zlog_debug( " TOS: 0%s", "\n"); |
| 3482 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3483 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3484 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3485 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3486 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3487 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3488 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3489 | |
| 3490 | return 0; |
| 3491 | } |
| 3492 | |
| 3493 | /* Show AS-NSSA-LSA detail information. */ |
| 3494 | int |
| 3495 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3496 | { |
| 3497 | if (lsa != NULL) |
| 3498 | { |
| 3499 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3500 | |
| 3501 | show_ip_ospf_database_header (vty, lsa); |
| 3502 | |
| 3503 | vty_out (vty, " Network Mask: /%d%s", |
| 3504 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3505 | vty_out (vty, " Metric Type: %s%s", |
| 3506 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3507 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3508 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3509 | vty_out (vty, " Metric: %d%s", |
| 3510 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3511 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3512 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3513 | |
| 3514 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3515 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3516 | } |
| 3517 | |
| 3518 | return 0; |
| 3519 | } |
| 3520 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3521 | int |
| 3522 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3523 | { |
| 3524 | return 0; |
| 3525 | } |
| 3526 | |
| 3527 | #ifdef HAVE_OPAQUE_LSA |
| 3528 | int |
| 3529 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3530 | { |
| 3531 | if (lsa != NULL) |
| 3532 | { |
| 3533 | show_ip_ospf_database_header (vty, lsa); |
| 3534 | show_opaque_info_detail (vty, lsa); |
| 3535 | |
| 3536 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3537 | } |
| 3538 | return 0; |
| 3539 | } |
| 3540 | #endif /* HAVE_OPAQUE_LSA */ |
| 3541 | |
| 3542 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3543 | { |
| 3544 | NULL, |
| 3545 | show_router_lsa_detail, |
| 3546 | show_network_lsa_detail, |
| 3547 | show_summary_lsa_detail, |
| 3548 | show_summary_asbr_lsa_detail, |
| 3549 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3550 | show_func_dummy, |
| 3551 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3552 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3553 | NULL, /* type-8 */ |
| 3554 | show_opaque_lsa_detail, |
| 3555 | show_opaque_lsa_detail, |
| 3556 | show_opaque_lsa_detail, |
| 3557 | #endif /* HAVE_OPAQUE_LSA */ |
| 3558 | }; |
| 3559 | |
| 3560 | void |
| 3561 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3562 | struct in_addr *adv_router) |
| 3563 | { |
| 3564 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3565 | lp->family = 0; |
| 3566 | if (id == NULL) |
| 3567 | lp->prefixlen = 0; |
| 3568 | else if (adv_router == NULL) |
| 3569 | { |
| 3570 | lp->prefixlen = 32; |
| 3571 | lp->id = *id; |
| 3572 | } |
| 3573 | else |
| 3574 | { |
| 3575 | lp->prefixlen = 64; |
| 3576 | lp->id = *id; |
| 3577 | lp->adv_router = *adv_router; |
| 3578 | } |
| 3579 | } |
| 3580 | |
| 3581 | void |
| 3582 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3583 | struct in_addr *id, struct in_addr *adv_router) |
| 3584 | { |
| 3585 | struct prefix_ls lp; |
| 3586 | struct route_node *rn, *start; |
| 3587 | struct ospf_lsa *lsa; |
| 3588 | |
| 3589 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3590 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3591 | if (start) |
| 3592 | { |
| 3593 | route_lock_node (start); |
| 3594 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3595 | if ((lsa = rn->info)) |
| 3596 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3597 | if (show_function[lsa->data->type] != NULL) |
| 3598 | show_function[lsa->data->type] (vty, lsa); |
| 3599 | } |
| 3600 | route_unlock_node (start); |
| 3601 | } |
| 3602 | } |
| 3603 | |
| 3604 | /* Show detail LSA information |
| 3605 | -- if id is NULL then show all LSAs. */ |
| 3606 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3607 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3608 | struct in_addr *id, struct in_addr *adv_router) |
| 3609 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3610 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3611 | |
| 3612 | switch (type) |
| 3613 | { |
| 3614 | case OSPF_AS_EXTERNAL_LSA: |
| 3615 | #ifdef HAVE_OPAQUE_LSA |
| 3616 | case OSPF_OPAQUE_AS_LSA: |
| 3617 | #endif /* HAVE_OPAQUE_LSA */ |
| 3618 | vty_out (vty, " %s %s%s", |
| 3619 | show_database_desc[type], |
| 3620 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3621 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3622 | break; |
| 3623 | default: |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3624 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | { |
| 3626 | struct ospf_area *area = node->data; |
| 3627 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3628 | VTY_NEWLINE, show_database_desc[type], |
| 3629 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3630 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3631 | } |
| 3632 | break; |
| 3633 | } |
| 3634 | } |
| 3635 | |
| 3636 | void |
| 3637 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3638 | struct in_addr *adv_router) |
| 3639 | { |
| 3640 | struct route_node *rn; |
| 3641 | struct ospf_lsa *lsa; |
| 3642 | |
| 3643 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3644 | if ((lsa = rn->info)) |
| 3645 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3646 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3647 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3648 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3649 | if (show_function[lsa->data->type] != NULL) |
| 3650 | show_function[lsa->data->type] (vty, lsa); |
| 3651 | } |
| 3652 | } |
| 3653 | |
| 3654 | /* Show detail LSA information. */ |
| 3655 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3656 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3657 | struct in_addr *adv_router) |
| 3658 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3659 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3660 | |
| 3661 | switch (type) |
| 3662 | { |
| 3663 | case OSPF_AS_EXTERNAL_LSA: |
| 3664 | #ifdef HAVE_OPAQUE_LSA |
| 3665 | case OSPF_OPAQUE_AS_LSA: |
| 3666 | #endif /* HAVE_OPAQUE_LSA */ |
| 3667 | vty_out (vty, " %s %s%s", |
| 3668 | show_database_desc[type], |
| 3669 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3670 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3671 | adv_router); |
| 3672 | break; |
| 3673 | default: |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3674 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3675 | { |
| 3676 | struct ospf_area *area = node->data; |
| 3677 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3678 | VTY_NEWLINE, show_database_desc[type], |
| 3679 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3680 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3681 | adv_router); |
| 3682 | } |
| 3683 | break; |
| 3684 | } |
| 3685 | } |
| 3686 | |
| 3687 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3688 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3689 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3690 | struct ospf_lsa *lsa; |
| 3691 | struct route_node *rn; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3692 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3693 | int type; |
| 3694 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3695 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3696 | { |
| 3697 | struct ospf_area *area = node->data; |
| 3698 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3699 | { |
| 3700 | switch (type) |
| 3701 | { |
| 3702 | case OSPF_AS_EXTERNAL_LSA: |
| 3703 | #ifdef HAVE_OPAQUE_LSA |
| 3704 | case OSPF_OPAQUE_AS_LSA: |
| 3705 | #endif /* HAVE_OPAQUE_LSA */ |
| 3706 | continue; |
| 3707 | default: |
| 3708 | break; |
| 3709 | } |
| 3710 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3711 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3712 | { |
| 3713 | vty_out (vty, " %s (Area %s)%s%s", |
| 3714 | show_database_desc[type], |
| 3715 | ospf_area_desc_string (area), |
| 3716 | VTY_NEWLINE, VTY_NEWLINE); |
| 3717 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3718 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3719 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3720 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3721 | |
| 3722 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3723 | } |
| 3724 | } |
| 3725 | } |
| 3726 | |
| 3727 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3728 | { |
| 3729 | switch (type) |
| 3730 | { |
| 3731 | case OSPF_AS_EXTERNAL_LSA: |
| 3732 | #ifdef HAVE_OPAQUE_LSA |
| 3733 | case OSPF_OPAQUE_AS_LSA: |
| 3734 | #endif /* HAVE_OPAQUE_LSA */ |
| 3735 | break;; |
| 3736 | default: |
| 3737 | continue; |
| 3738 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3739 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 3740 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3741 | { |
| 3742 | vty_out (vty, " %s%s%s", |
| 3743 | show_database_desc[type], |
| 3744 | VTY_NEWLINE, VTY_NEWLINE); |
| 3745 | vty_out (vty, "%s%s", show_database_header[type], |
| 3746 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3747 | |
| 3748 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 3749 | show_lsa_summary (vty, lsa, self); |
| 3750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3751 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3752 | } |
| 3753 | } |
| 3754 | |
| 3755 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3756 | } |
| 3757 | |
| 3758 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3759 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3760 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3761 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3762 | struct ospf_lsa *lsa; |
| 3763 | |
| 3764 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 3765 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 3766 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3767 | for (node = listhead (ospf->maxage_lsa); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3768 | if ((lsa = node->data) != NULL) |
| 3769 | { |
| 3770 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 3771 | vty_out (vty, "Link State ID: %s%s", |
| 3772 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 3773 | vty_out (vty, "Advertising Router: %s%s", |
| 3774 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3775 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 3776 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3777 | } |
| 3778 | } |
| 3779 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3780 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 3781 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3782 | |
| 3783 | #ifdef HAVE_OPAQUE_LSA |
| 3784 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 3785 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 3786 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 3787 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 3788 | #else /* HAVE_OPAQUE_LSA */ |
| 3789 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 3790 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 3791 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 3792 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 3793 | #endif /* HAVE_OPAQUE_LSA */ |
| 3794 | |
| 3795 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 3796 | "asbr-summary|external|network|router|summary" \ |
| 3797 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 3798 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 3799 | |
| 3800 | #define OSPF_LSA_TYPES_DESC \ |
| 3801 | "ASBR summary link states\n" \ |
| 3802 | "External link states\n" \ |
| 3803 | "Network link states\n" \ |
| 3804 | "Router link states\n" \ |
| 3805 | "Network summary link states\n" \ |
| 3806 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 3807 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 3808 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 3809 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 3810 | |
| 3811 | DEFUN (show_ip_ospf_database, |
| 3812 | show_ip_ospf_database_cmd, |
| 3813 | "show ip ospf database", |
| 3814 | SHOW_STR |
| 3815 | IP_STR |
| 3816 | "OSPF information\n" |
| 3817 | "Database summary\n") |
| 3818 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3819 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3820 | int type, ret; |
| 3821 | struct in_addr id, adv_router; |
| 3822 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3823 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3824 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3825 | return CMD_SUCCESS; |
| 3826 | |
| 3827 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3828 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3829 | |
| 3830 | /* Show all LSA. */ |
| 3831 | if (argc == 0) |
| 3832 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3833 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3834 | return CMD_SUCCESS; |
| 3835 | } |
| 3836 | |
| 3837 | /* Set database type to show. */ |
| 3838 | if (strncmp (argv[0], "r", 1) == 0) |
| 3839 | type = OSPF_ROUTER_LSA; |
| 3840 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3841 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3842 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3843 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3844 | else if (strncmp (argv[0], "su", 2) == 0) |
| 3845 | type = OSPF_SUMMARY_LSA; |
| 3846 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3847 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3848 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3849 | type = OSPF_AS_EXTERNAL_LSA; |
| 3850 | else if (strncmp (argv[0], "se", 2) == 0) |
| 3851 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3852 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3853 | return CMD_SUCCESS; |
| 3854 | } |
| 3855 | else if (strncmp (argv[0], "m", 1) == 0) |
| 3856 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3857 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3858 | return CMD_SUCCESS; |
| 3859 | } |
| 3860 | #ifdef HAVE_OPAQUE_LSA |
| 3861 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3862 | type = OSPF_OPAQUE_LINK_LSA; |
| 3863 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3864 | type = OSPF_OPAQUE_AREA_LSA; |
| 3865 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3866 | type = OSPF_OPAQUE_AS_LSA; |
| 3867 | #endif /* HAVE_OPAQUE_LSA */ |
| 3868 | else |
| 3869 | return CMD_WARNING; |
| 3870 | |
| 3871 | /* `show ip ospf database LSA'. */ |
| 3872 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3873 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3874 | else if (argc >= 2) |
| 3875 | { |
| 3876 | ret = inet_aton (argv[1], &id); |
| 3877 | if (!ret) |
| 3878 | return CMD_WARNING; |
| 3879 | |
| 3880 | /* `show ip ospf database LSA ID'. */ |
| 3881 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3882 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3883 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 3884 | else if (argc == 3) |
| 3885 | { |
| 3886 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3887 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3888 | else |
| 3889 | { |
| 3890 | ret = inet_aton (argv[2], &adv_router); |
| 3891 | if (!ret) |
| 3892 | return CMD_WARNING; |
| 3893 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3894 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3895 | } |
| 3896 | } |
| 3897 | |
| 3898 | return CMD_SUCCESS; |
| 3899 | } |
| 3900 | |
| 3901 | ALIAS (show_ip_ospf_database, |
| 3902 | show_ip_ospf_database_type_cmd, |
| 3903 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 3904 | SHOW_STR |
| 3905 | IP_STR |
| 3906 | "OSPF information\n" |
| 3907 | "Database summary\n" |
| 3908 | OSPF_LSA_TYPES_DESC |
| 3909 | "LSAs in MaxAge list\n" |
| 3910 | "Self-originated link states\n") |
| 3911 | |
| 3912 | ALIAS (show_ip_ospf_database, |
| 3913 | show_ip_ospf_database_type_id_cmd, |
| 3914 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 3915 | SHOW_STR |
| 3916 | IP_STR |
| 3917 | "OSPF information\n" |
| 3918 | "Database summary\n" |
| 3919 | OSPF_LSA_TYPES_DESC |
| 3920 | "Link State ID (as an IP address)\n") |
| 3921 | |
| 3922 | ALIAS (show_ip_ospf_database, |
| 3923 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 3924 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 3925 | SHOW_STR |
| 3926 | IP_STR |
| 3927 | "OSPF information\n" |
| 3928 | "Database summary\n" |
| 3929 | OSPF_LSA_TYPES_DESC |
| 3930 | "Link State ID (as an IP address)\n" |
| 3931 | "Advertising Router link states\n" |
| 3932 | "Advertising Router (as an IP address)\n") |
| 3933 | |
| 3934 | ALIAS (show_ip_ospf_database, |
| 3935 | show_ip_ospf_database_type_id_self_cmd, |
| 3936 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 3937 | SHOW_STR |
| 3938 | IP_STR |
| 3939 | "OSPF information\n" |
| 3940 | "Database summary\n" |
| 3941 | OSPF_LSA_TYPES_DESC |
| 3942 | "Link State ID (as an IP address)\n" |
| 3943 | "Self-originated link states\n" |
| 3944 | "\n") |
| 3945 | |
| 3946 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 3947 | show_ip_ospf_database_type_adv_router_cmd, |
| 3948 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 3949 | SHOW_STR |
| 3950 | IP_STR |
| 3951 | "OSPF information\n" |
| 3952 | "Database summary\n" |
| 3953 | OSPF_LSA_TYPES_DESC |
| 3954 | "Advertising Router link states\n" |
| 3955 | "Advertising Router (as an IP address)\n") |
| 3956 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3957 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3958 | int type, ret; |
| 3959 | struct in_addr adv_router; |
| 3960 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3961 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3962 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3963 | return CMD_SUCCESS; |
| 3964 | |
| 3965 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3966 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3967 | |
| 3968 | if (argc != 2) |
| 3969 | return CMD_WARNING; |
| 3970 | |
| 3971 | /* Set database type to show. */ |
| 3972 | if (strncmp (argv[0], "r", 1) == 0) |
| 3973 | type = OSPF_ROUTER_LSA; |
| 3974 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 3975 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3976 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 3977 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3978 | else if (strncmp (argv[0], "s", 1) == 0) |
| 3979 | type = OSPF_SUMMARY_LSA; |
| 3980 | else if (strncmp (argv[0], "a", 1) == 0) |
| 3981 | type = OSPF_ASBR_SUMMARY_LSA; |
| 3982 | else if (strncmp (argv[0], "e", 1) == 0) |
| 3983 | type = OSPF_AS_EXTERNAL_LSA; |
| 3984 | #ifdef HAVE_OPAQUE_LSA |
| 3985 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 3986 | type = OSPF_OPAQUE_LINK_LSA; |
| 3987 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 3988 | type = OSPF_OPAQUE_AREA_LSA; |
| 3989 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 3990 | type = OSPF_OPAQUE_AS_LSA; |
| 3991 | #endif /* HAVE_OPAQUE_LSA */ |
| 3992 | else |
| 3993 | return CMD_WARNING; |
| 3994 | |
| 3995 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 3996 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3997 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3998 | else |
| 3999 | { |
| 4000 | ret = inet_aton (argv[1], &adv_router); |
| 4001 | if (!ret) |
| 4002 | return CMD_WARNING; |
| 4003 | } |
| 4004 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4005 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4006 | |
| 4007 | return CMD_SUCCESS; |
| 4008 | } |
| 4009 | |
| 4010 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4011 | show_ip_ospf_database_type_self_cmd, |
| 4012 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4013 | SHOW_STR |
| 4014 | IP_STR |
| 4015 | "OSPF information\n" |
| 4016 | "Database summary\n" |
| 4017 | OSPF_LSA_TYPES_DESC |
| 4018 | "Self-originated link states\n") |
| 4019 | |
| 4020 | |
| 4021 | DEFUN (ip_ospf_authentication_args, |
| 4022 | ip_ospf_authentication_args_addr_cmd, |
| 4023 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4024 | "IP Information\n" |
| 4025 | "OSPF interface commands\n" |
| 4026 | "Enable authentication on this interface\n" |
| 4027 | "Use null authentication\n" |
| 4028 | "Use message-digest authentication\n" |
| 4029 | "Address of interface") |
| 4030 | { |
| 4031 | struct interface *ifp; |
| 4032 | struct in_addr addr; |
| 4033 | int ret; |
| 4034 | struct ospf_if_params *params; |
| 4035 | |
| 4036 | ifp = vty->index; |
| 4037 | params = IF_DEF_PARAMS (ifp); |
| 4038 | |
| 4039 | if (argc == 2) |
| 4040 | { |
| 4041 | ret = inet_aton(argv[1], &addr); |
| 4042 | if (!ret) |
| 4043 | { |
| 4044 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4045 | VTY_NEWLINE); |
| 4046 | return CMD_WARNING; |
| 4047 | } |
| 4048 | |
| 4049 | params = ospf_get_if_params (ifp, addr); |
| 4050 | ospf_if_update_params (ifp, addr); |
| 4051 | } |
| 4052 | |
| 4053 | /* Handle null authentication */ |
| 4054 | if ( argv[0][0] == 'n' ) |
| 4055 | { |
| 4056 | SET_IF_PARAM (params, auth_type); |
| 4057 | params->auth_type = OSPF_AUTH_NULL; |
| 4058 | return CMD_SUCCESS; |
| 4059 | } |
| 4060 | |
| 4061 | /* Handle message-digest authentication */ |
| 4062 | if ( argv[0][0] == 'm' ) |
| 4063 | { |
| 4064 | SET_IF_PARAM (params, auth_type); |
| 4065 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4066 | return CMD_SUCCESS; |
| 4067 | } |
| 4068 | |
| 4069 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4070 | return CMD_WARNING; |
| 4071 | } |
| 4072 | |
| 4073 | ALIAS (ip_ospf_authentication_args, |
| 4074 | ip_ospf_authentication_args_cmd, |
| 4075 | "ip ospf authentication (null|message-digest)", |
| 4076 | "IP Information\n" |
| 4077 | "OSPF interface commands\n" |
| 4078 | "Enable authentication on this interface\n" |
| 4079 | "Use null authentication\n" |
| 4080 | "Use message-digest authentication\n") |
| 4081 | |
| 4082 | DEFUN (ip_ospf_authentication, |
| 4083 | ip_ospf_authentication_addr_cmd, |
| 4084 | "ip ospf authentication A.B.C.D", |
| 4085 | "IP Information\n" |
| 4086 | "OSPF interface commands\n" |
| 4087 | "Enable authentication on this interface\n" |
| 4088 | "Address of interface") |
| 4089 | { |
| 4090 | struct interface *ifp; |
| 4091 | struct in_addr addr; |
| 4092 | int ret; |
| 4093 | struct ospf_if_params *params; |
| 4094 | |
| 4095 | ifp = vty->index; |
| 4096 | params = IF_DEF_PARAMS (ifp); |
| 4097 | |
| 4098 | if (argc == 1) |
| 4099 | { |
| 4100 | ret = inet_aton(argv[1], &addr); |
| 4101 | if (!ret) |
| 4102 | { |
| 4103 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4104 | VTY_NEWLINE); |
| 4105 | return CMD_WARNING; |
| 4106 | } |
| 4107 | |
| 4108 | params = ospf_get_if_params (ifp, addr); |
| 4109 | ospf_if_update_params (ifp, addr); |
| 4110 | } |
| 4111 | |
| 4112 | SET_IF_PARAM (params, auth_type); |
| 4113 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4114 | |
| 4115 | return CMD_SUCCESS; |
| 4116 | } |
| 4117 | |
| 4118 | ALIAS (ip_ospf_authentication, |
| 4119 | ip_ospf_authentication_cmd, |
| 4120 | "ip ospf authentication", |
| 4121 | "IP Information\n" |
| 4122 | "OSPF interface commands\n" |
| 4123 | "Enable authentication on this interface\n") |
| 4124 | |
| 4125 | DEFUN (no_ip_ospf_authentication, |
| 4126 | no_ip_ospf_authentication_addr_cmd, |
| 4127 | "no ip ospf authentication A.B.C.D", |
| 4128 | NO_STR |
| 4129 | "IP Information\n" |
| 4130 | "OSPF interface commands\n" |
| 4131 | "Enable authentication on this interface\n" |
| 4132 | "Address of interface") |
| 4133 | { |
| 4134 | struct interface *ifp; |
| 4135 | struct in_addr addr; |
| 4136 | int ret; |
| 4137 | struct ospf_if_params *params; |
| 4138 | |
| 4139 | ifp = vty->index; |
| 4140 | params = IF_DEF_PARAMS (ifp); |
| 4141 | |
| 4142 | if (argc == 1) |
| 4143 | { |
| 4144 | ret = inet_aton(argv[1], &addr); |
| 4145 | if (!ret) |
| 4146 | { |
| 4147 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4148 | VTY_NEWLINE); |
| 4149 | return CMD_WARNING; |
| 4150 | } |
| 4151 | |
| 4152 | params = ospf_lookup_if_params (ifp, addr); |
| 4153 | if (params == NULL) |
| 4154 | return CMD_SUCCESS; |
| 4155 | } |
| 4156 | |
| 4157 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4158 | UNSET_IF_PARAM (params, auth_type); |
| 4159 | |
| 4160 | if (params != IF_DEF_PARAMS (ifp)) |
| 4161 | { |
| 4162 | ospf_free_if_params (ifp, addr); |
| 4163 | ospf_if_update_params (ifp, addr); |
| 4164 | } |
| 4165 | |
| 4166 | return CMD_SUCCESS; |
| 4167 | } |
| 4168 | |
| 4169 | ALIAS (no_ip_ospf_authentication, |
| 4170 | no_ip_ospf_authentication_cmd, |
| 4171 | "no ip ospf authentication", |
| 4172 | NO_STR |
| 4173 | "IP Information\n" |
| 4174 | "OSPF interface commands\n" |
| 4175 | "Enable authentication on this interface\n") |
| 4176 | |
| 4177 | DEFUN (ip_ospf_authentication_key, |
| 4178 | ip_ospf_authentication_key_addr_cmd, |
| 4179 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4180 | "IP Information\n" |
| 4181 | "OSPF interface commands\n" |
| 4182 | "Authentication password (key)\n" |
| 4183 | "The OSPF password (key)\n" |
| 4184 | "Address of interface") |
| 4185 | { |
| 4186 | struct interface *ifp; |
| 4187 | struct in_addr addr; |
| 4188 | int ret; |
| 4189 | struct ospf_if_params *params; |
| 4190 | |
| 4191 | ifp = vty->index; |
| 4192 | params = IF_DEF_PARAMS (ifp); |
| 4193 | |
| 4194 | if (argc == 2) |
| 4195 | { |
| 4196 | ret = inet_aton(argv[1], &addr); |
| 4197 | if (!ret) |
| 4198 | { |
| 4199 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4200 | VTY_NEWLINE); |
| 4201 | return CMD_WARNING; |
| 4202 | } |
| 4203 | |
| 4204 | params = ospf_get_if_params (ifp, addr); |
| 4205 | ospf_if_update_params (ifp, addr); |
| 4206 | } |
| 4207 | |
| 4208 | |
| 4209 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4210 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4211 | SET_IF_PARAM (params, auth_simple); |
| 4212 | |
| 4213 | return CMD_SUCCESS; |
| 4214 | } |
| 4215 | |
| 4216 | ALIAS (ip_ospf_authentication_key, |
| 4217 | ip_ospf_authentication_key_cmd, |
| 4218 | "ip ospf authentication-key AUTH_KEY", |
| 4219 | "IP Information\n" |
| 4220 | "OSPF interface commands\n" |
| 4221 | "Authentication password (key)\n" |
| 4222 | "The OSPF password (key)") |
| 4223 | |
| 4224 | ALIAS (ip_ospf_authentication_key, |
| 4225 | ospf_authentication_key_cmd, |
| 4226 | "ospf authentication-key AUTH_KEY", |
| 4227 | "OSPF interface commands\n" |
| 4228 | "Authentication password (key)\n" |
| 4229 | "The OSPF password (key)") |
| 4230 | |
| 4231 | DEFUN (no_ip_ospf_authentication_key, |
| 4232 | no_ip_ospf_authentication_key_addr_cmd, |
| 4233 | "no ip ospf authentication-key A.B.C.D", |
| 4234 | NO_STR |
| 4235 | "IP Information\n" |
| 4236 | "OSPF interface commands\n" |
| 4237 | "Authentication password (key)\n" |
| 4238 | "Address of interface") |
| 4239 | { |
| 4240 | struct interface *ifp; |
| 4241 | struct in_addr addr; |
| 4242 | int ret; |
| 4243 | struct ospf_if_params *params; |
| 4244 | |
| 4245 | ifp = vty->index; |
| 4246 | params = IF_DEF_PARAMS (ifp); |
| 4247 | |
| 4248 | if (argc == 2) |
| 4249 | { |
| 4250 | ret = inet_aton(argv[1], &addr); |
| 4251 | if (!ret) |
| 4252 | { |
| 4253 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4254 | VTY_NEWLINE); |
| 4255 | return CMD_WARNING; |
| 4256 | } |
| 4257 | |
| 4258 | params = ospf_lookup_if_params (ifp, addr); |
| 4259 | if (params == NULL) |
| 4260 | return CMD_SUCCESS; |
| 4261 | } |
| 4262 | |
| 4263 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4264 | UNSET_IF_PARAM (params, auth_simple); |
| 4265 | |
| 4266 | if (params != IF_DEF_PARAMS (ifp)) |
| 4267 | { |
| 4268 | ospf_free_if_params (ifp, addr); |
| 4269 | ospf_if_update_params (ifp, addr); |
| 4270 | } |
| 4271 | |
| 4272 | return CMD_SUCCESS; |
| 4273 | } |
| 4274 | |
| 4275 | ALIAS (no_ip_ospf_authentication_key, |
| 4276 | no_ip_ospf_authentication_key_cmd, |
| 4277 | "no ip ospf authentication-key", |
| 4278 | NO_STR |
| 4279 | "IP Information\n" |
| 4280 | "OSPF interface commands\n" |
| 4281 | "Authentication password (key)\n") |
| 4282 | |
| 4283 | ALIAS (no_ip_ospf_authentication_key, |
| 4284 | no_ospf_authentication_key_cmd, |
| 4285 | "no ospf authentication-key", |
| 4286 | NO_STR |
| 4287 | "OSPF interface commands\n" |
| 4288 | "Authentication password (key)\n") |
| 4289 | |
| 4290 | DEFUN (ip_ospf_message_digest_key, |
| 4291 | ip_ospf_message_digest_key_addr_cmd, |
| 4292 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4293 | "IP Information\n" |
| 4294 | "OSPF interface commands\n" |
| 4295 | "Message digest authentication password (key)\n" |
| 4296 | "Key ID\n" |
| 4297 | "Use MD5 algorithm\n" |
| 4298 | "The OSPF password (key)" |
| 4299 | "Address of interface") |
| 4300 | { |
| 4301 | struct interface *ifp; |
| 4302 | struct crypt_key *ck; |
| 4303 | u_char key_id; |
| 4304 | struct in_addr addr; |
| 4305 | int ret; |
| 4306 | struct ospf_if_params *params; |
| 4307 | |
| 4308 | ifp = vty->index; |
| 4309 | params = IF_DEF_PARAMS (ifp); |
| 4310 | |
| 4311 | if (argc == 3) |
| 4312 | { |
| 4313 | ret = inet_aton(argv[2], &addr); |
| 4314 | if (!ret) |
| 4315 | { |
| 4316 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4317 | VTY_NEWLINE); |
| 4318 | return CMD_WARNING; |
| 4319 | } |
| 4320 | |
| 4321 | params = ospf_get_if_params (ifp, addr); |
| 4322 | ospf_if_update_params (ifp, addr); |
| 4323 | } |
| 4324 | |
| 4325 | key_id = strtol (argv[0], NULL, 10); |
| 4326 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4327 | { |
| 4328 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4329 | return CMD_WARNING; |
| 4330 | } |
| 4331 | |
| 4332 | ck = ospf_crypt_key_new (); |
| 4333 | ck->key_id = (u_char) key_id; |
| 4334 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4335 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4336 | |
| 4337 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4338 | SET_IF_PARAM (params, auth_crypt); |
| 4339 | |
| 4340 | return CMD_SUCCESS; |
| 4341 | } |
| 4342 | |
| 4343 | ALIAS (ip_ospf_message_digest_key, |
| 4344 | ip_ospf_message_digest_key_cmd, |
| 4345 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4346 | "IP Information\n" |
| 4347 | "OSPF interface commands\n" |
| 4348 | "Message digest authentication password (key)\n" |
| 4349 | "Key ID\n" |
| 4350 | "Use MD5 algorithm\n" |
| 4351 | "The OSPF password (key)") |
| 4352 | |
| 4353 | ALIAS (ip_ospf_message_digest_key, |
| 4354 | ospf_message_digest_key_cmd, |
| 4355 | "ospf message-digest-key <1-255> md5 KEY", |
| 4356 | "OSPF interface commands\n" |
| 4357 | "Message digest authentication password (key)\n" |
| 4358 | "Key ID\n" |
| 4359 | "Use MD5 algorithm\n" |
| 4360 | "The OSPF password (key)") |
| 4361 | |
| 4362 | DEFUN (no_ip_ospf_message_digest_key, |
| 4363 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4364 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4365 | NO_STR |
| 4366 | "IP Information\n" |
| 4367 | "OSPF interface commands\n" |
| 4368 | "Message digest authentication password (key)\n" |
| 4369 | "Key ID\n" |
| 4370 | "Address of interface") |
| 4371 | { |
| 4372 | struct interface *ifp; |
| 4373 | struct crypt_key *ck; |
| 4374 | int key_id; |
| 4375 | struct in_addr addr; |
| 4376 | int ret; |
| 4377 | struct ospf_if_params *params; |
| 4378 | |
| 4379 | ifp = vty->index; |
| 4380 | params = IF_DEF_PARAMS (ifp); |
| 4381 | |
| 4382 | if (argc == 2) |
| 4383 | { |
| 4384 | ret = inet_aton(argv[1], &addr); |
| 4385 | if (!ret) |
| 4386 | { |
| 4387 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4388 | VTY_NEWLINE); |
| 4389 | return CMD_WARNING; |
| 4390 | } |
| 4391 | |
| 4392 | params = ospf_lookup_if_params (ifp, addr); |
| 4393 | if (params == NULL) |
| 4394 | return CMD_SUCCESS; |
| 4395 | } |
| 4396 | |
| 4397 | key_id = strtol (argv[0], NULL, 10); |
| 4398 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4399 | if (ck == NULL) |
| 4400 | { |
| 4401 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4402 | return CMD_WARNING; |
| 4403 | } |
| 4404 | |
| 4405 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4406 | |
| 4407 | if (params != IF_DEF_PARAMS (ifp)) |
| 4408 | { |
| 4409 | ospf_free_if_params (ifp, addr); |
| 4410 | ospf_if_update_params (ifp, addr); |
| 4411 | } |
| 4412 | |
| 4413 | return CMD_SUCCESS; |
| 4414 | } |
| 4415 | |
| 4416 | ALIAS (no_ip_ospf_message_digest_key, |
| 4417 | no_ip_ospf_message_digest_key_cmd, |
| 4418 | "no ip ospf message-digest-key <1-255>", |
| 4419 | NO_STR |
| 4420 | "IP Information\n" |
| 4421 | "OSPF interface commands\n" |
| 4422 | "Message digest authentication password (key)\n" |
| 4423 | "Key ID\n") |
| 4424 | |
| 4425 | ALIAS (no_ip_ospf_message_digest_key, |
| 4426 | no_ospf_message_digest_key_cmd, |
| 4427 | "no ospf message-digest-key <1-255>", |
| 4428 | NO_STR |
| 4429 | "OSPF interface commands\n" |
| 4430 | "Message digest authentication password (key)\n" |
| 4431 | "Key ID\n") |
| 4432 | |
| 4433 | DEFUN (ip_ospf_cost, |
| 4434 | ip_ospf_cost_addr_cmd, |
| 4435 | "ip ospf cost <1-65535> A.B.C.D", |
| 4436 | "IP Information\n" |
| 4437 | "OSPF interface commands\n" |
| 4438 | "Interface cost\n" |
| 4439 | "Cost\n" |
| 4440 | "Address of interface") |
| 4441 | { |
| 4442 | struct interface *ifp = vty->index; |
| 4443 | u_int32_t cost; |
| 4444 | struct in_addr addr; |
| 4445 | int ret; |
| 4446 | struct ospf_if_params *params; |
| 4447 | |
| 4448 | params = IF_DEF_PARAMS (ifp); |
| 4449 | |
| 4450 | cost = strtol (argv[0], NULL, 10); |
| 4451 | |
| 4452 | /* cost range is <1-65535>. */ |
| 4453 | if (cost < 1 || cost > 65535) |
| 4454 | { |
| 4455 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4456 | return CMD_WARNING; |
| 4457 | } |
| 4458 | |
| 4459 | if (argc == 2) |
| 4460 | { |
| 4461 | ret = inet_aton(argv[1], &addr); |
| 4462 | if (!ret) |
| 4463 | { |
| 4464 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4465 | VTY_NEWLINE); |
| 4466 | return CMD_WARNING; |
| 4467 | } |
| 4468 | |
| 4469 | params = ospf_get_if_params (ifp, addr); |
| 4470 | ospf_if_update_params (ifp, addr); |
| 4471 | } |
| 4472 | |
| 4473 | SET_IF_PARAM (params, output_cost_cmd); |
| 4474 | params->output_cost_cmd = cost; |
| 4475 | |
| 4476 | ospf_if_recalculate_output_cost (ifp); |
| 4477 | |
| 4478 | return CMD_SUCCESS; |
| 4479 | } |
| 4480 | |
| 4481 | ALIAS (ip_ospf_cost, |
| 4482 | ip_ospf_cost_cmd, |
| 4483 | "ip ospf cost <1-65535>", |
| 4484 | "IP Information\n" |
| 4485 | "OSPF interface commands\n" |
| 4486 | "Interface cost\n" |
| 4487 | "Cost") |
| 4488 | |
| 4489 | ALIAS (ip_ospf_cost, |
| 4490 | ospf_cost_cmd, |
| 4491 | "ospf cost <1-65535>", |
| 4492 | "OSPF interface commands\n" |
| 4493 | "Interface cost\n" |
| 4494 | "Cost") |
| 4495 | |
| 4496 | DEFUN (no_ip_ospf_cost, |
| 4497 | no_ip_ospf_cost_addr_cmd, |
| 4498 | "no ip ospf cost A.B.C.D", |
| 4499 | NO_STR |
| 4500 | "IP Information\n" |
| 4501 | "OSPF interface commands\n" |
| 4502 | "Interface cost\n" |
| 4503 | "Address of interface") |
| 4504 | { |
| 4505 | struct interface *ifp = vty->index; |
| 4506 | struct in_addr addr; |
| 4507 | int ret; |
| 4508 | struct ospf_if_params *params; |
| 4509 | |
| 4510 | ifp = vty->index; |
| 4511 | params = IF_DEF_PARAMS (ifp); |
| 4512 | |
| 4513 | if (argc == 1) |
| 4514 | { |
| 4515 | ret = inet_aton(argv[0], &addr); |
| 4516 | if (!ret) |
| 4517 | { |
| 4518 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4519 | VTY_NEWLINE); |
| 4520 | return CMD_WARNING; |
| 4521 | } |
| 4522 | |
| 4523 | params = ospf_lookup_if_params (ifp, addr); |
| 4524 | if (params == NULL) |
| 4525 | return CMD_SUCCESS; |
| 4526 | } |
| 4527 | |
| 4528 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4529 | |
| 4530 | if (params != IF_DEF_PARAMS (ifp)) |
| 4531 | { |
| 4532 | ospf_free_if_params (ifp, addr); |
| 4533 | ospf_if_update_params (ifp, addr); |
| 4534 | } |
| 4535 | |
| 4536 | ospf_if_recalculate_output_cost (ifp); |
| 4537 | |
| 4538 | return CMD_SUCCESS; |
| 4539 | } |
| 4540 | |
| 4541 | ALIAS (no_ip_ospf_cost, |
| 4542 | no_ip_ospf_cost_cmd, |
| 4543 | "no ip ospf cost", |
| 4544 | NO_STR |
| 4545 | "IP Information\n" |
| 4546 | "OSPF interface commands\n" |
| 4547 | "Interface cost\n") |
| 4548 | |
| 4549 | ALIAS (no_ip_ospf_cost, |
| 4550 | no_ospf_cost_cmd, |
| 4551 | "no ospf cost", |
| 4552 | NO_STR |
| 4553 | "OSPF interface commands\n" |
| 4554 | "Interface cost\n") |
| 4555 | |
| 4556 | void |
| 4557 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4558 | { |
| 4559 | struct route_node *rn; |
| 4560 | struct ospf_neighbor *nbr; |
| 4561 | |
| 4562 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4563 | if ((nbr = rn->info)) |
| 4564 | { |
| 4565 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4566 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4567 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4568 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4569 | } |
| 4570 | } |
| 4571 | |
| 4572 | DEFUN (ip_ospf_dead_interval, |
| 4573 | ip_ospf_dead_interval_addr_cmd, |
| 4574 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4575 | "IP Information\n" |
| 4576 | "OSPF interface commands\n" |
| 4577 | "Interval after which a neighbor is declared dead\n" |
| 4578 | "Seconds\n" |
| 4579 | "Address of interface") |
| 4580 | { |
| 4581 | struct interface *ifp = vty->index; |
| 4582 | u_int32_t seconds; |
| 4583 | struct in_addr addr; |
| 4584 | int ret; |
| 4585 | struct ospf_if_params *params; |
| 4586 | struct ospf_interface *oi; |
| 4587 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4588 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4589 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4590 | ospf = ospf_lookup (); |
| 4591 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4592 | params = IF_DEF_PARAMS (ifp); |
| 4593 | |
| 4594 | seconds = strtol (argv[0], NULL, 10); |
| 4595 | |
| 4596 | /* dead_interval range is <1-65535>. */ |
| 4597 | if (seconds < 1 || seconds > 65535) |
| 4598 | { |
| 4599 | vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE); |
| 4600 | return CMD_WARNING; |
| 4601 | } |
| 4602 | |
| 4603 | if (argc == 2) |
| 4604 | { |
| 4605 | ret = inet_aton(argv[1], &addr); |
| 4606 | if (!ret) |
| 4607 | { |
| 4608 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4609 | VTY_NEWLINE); |
| 4610 | return CMD_WARNING; |
| 4611 | } |
| 4612 | |
| 4613 | params = ospf_get_if_params (ifp, addr); |
| 4614 | ospf_if_update_params (ifp, addr); |
| 4615 | } |
| 4616 | |
| 4617 | SET_IF_PARAM (params, v_wait); |
| 4618 | params->v_wait = seconds; |
| 4619 | |
| 4620 | /* Update timer values in neighbor structure. */ |
| 4621 | if (argc == 2) |
| 4622 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4623 | if (ospf) |
| 4624 | { |
| 4625 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4626 | if (oi) |
| 4627 | ospf_nbr_timer_update (oi); |
| 4628 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4629 | } |
| 4630 | else |
| 4631 | { |
| 4632 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4633 | if ((oi = rn->info)) |
| 4634 | ospf_nbr_timer_update (oi); |
| 4635 | } |
| 4636 | |
| 4637 | return CMD_SUCCESS; |
| 4638 | } |
| 4639 | |
| 4640 | ALIAS (ip_ospf_dead_interval, |
| 4641 | ip_ospf_dead_interval_cmd, |
| 4642 | "ip ospf dead-interval <1-65535>", |
| 4643 | "IP Information\n" |
| 4644 | "OSPF interface commands\n" |
| 4645 | "Interval after which a neighbor is declared dead\n" |
| 4646 | "Seconds\n") |
| 4647 | |
| 4648 | ALIAS (ip_ospf_dead_interval, |
| 4649 | ospf_dead_interval_cmd, |
| 4650 | "ospf dead-interval <1-65535>", |
| 4651 | "OSPF interface commands\n" |
| 4652 | "Interval after which a neighbor is declared dead\n" |
| 4653 | "Seconds\n") |
| 4654 | |
| 4655 | DEFUN (no_ip_ospf_dead_interval, |
| 4656 | no_ip_ospf_dead_interval_addr_cmd, |
| 4657 | "no ip ospf dead-interval A.B.C.D", |
| 4658 | NO_STR |
| 4659 | "IP Information\n" |
| 4660 | "OSPF interface commands\n" |
| 4661 | "Interval after which a neighbor is declared dead\n" |
| 4662 | "Address of interface") |
| 4663 | { |
| 4664 | struct interface *ifp = vty->index; |
| 4665 | struct in_addr addr; |
| 4666 | int ret; |
| 4667 | struct ospf_if_params *params; |
| 4668 | struct ospf_interface *oi; |
| 4669 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4670 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4671 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4672 | ospf = ospf_lookup (); |
| 4673 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4674 | ifp = vty->index; |
| 4675 | params = IF_DEF_PARAMS (ifp); |
| 4676 | |
| 4677 | if (argc == 1) |
| 4678 | { |
| 4679 | ret = inet_aton(argv[0], &addr); |
| 4680 | if (!ret) |
| 4681 | { |
| 4682 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4683 | VTY_NEWLINE); |
| 4684 | return CMD_WARNING; |
| 4685 | } |
| 4686 | |
| 4687 | params = ospf_lookup_if_params (ifp, addr); |
| 4688 | if (params == NULL) |
| 4689 | return CMD_SUCCESS; |
| 4690 | } |
| 4691 | |
| 4692 | UNSET_IF_PARAM (params, v_wait); |
| 4693 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4694 | |
| 4695 | if (params != IF_DEF_PARAMS (ifp)) |
| 4696 | { |
| 4697 | ospf_free_if_params (ifp, addr); |
| 4698 | ospf_if_update_params (ifp, addr); |
| 4699 | } |
| 4700 | |
| 4701 | /* Update timer values in neighbor structure. */ |
| 4702 | if (argc == 1) |
| 4703 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4704 | if (ospf) |
| 4705 | { |
| 4706 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4707 | if (oi) |
| 4708 | ospf_nbr_timer_update (oi); |
| 4709 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4710 | } |
| 4711 | else |
| 4712 | { |
| 4713 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4714 | if ((oi = rn->info)) |
| 4715 | ospf_nbr_timer_update (oi); |
| 4716 | } |
| 4717 | |
| 4718 | return CMD_SUCCESS; |
| 4719 | } |
| 4720 | |
| 4721 | ALIAS (no_ip_ospf_dead_interval, |
| 4722 | no_ip_ospf_dead_interval_cmd, |
| 4723 | "no ip ospf dead-interval", |
| 4724 | NO_STR |
| 4725 | "IP Information\n" |
| 4726 | "OSPF interface commands\n" |
| 4727 | "Interval after which a neighbor is declared dead\n") |
| 4728 | |
| 4729 | ALIAS (no_ip_ospf_dead_interval, |
| 4730 | no_ospf_dead_interval_cmd, |
| 4731 | "no ospf dead-interval", |
| 4732 | NO_STR |
| 4733 | "OSPF interface commands\n" |
| 4734 | "Interval after which a neighbor is declared dead\n") |
| 4735 | |
| 4736 | DEFUN (ip_ospf_hello_interval, |
| 4737 | ip_ospf_hello_interval_addr_cmd, |
| 4738 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 4739 | "IP Information\n" |
| 4740 | "OSPF interface commands\n" |
| 4741 | "Time between HELLO packets\n" |
| 4742 | "Seconds\n" |
| 4743 | "Address of interface") |
| 4744 | { |
| 4745 | struct interface *ifp = vty->index; |
| 4746 | u_int32_t seconds; |
| 4747 | struct in_addr addr; |
| 4748 | int ret; |
| 4749 | struct ospf_if_params *params; |
| 4750 | |
| 4751 | params = IF_DEF_PARAMS (ifp); |
| 4752 | |
| 4753 | seconds = strtol (argv[0], NULL, 10); |
| 4754 | |
| 4755 | /* HelloInterval range is <1-65535>. */ |
| 4756 | if (seconds < 1 || seconds > 65535) |
| 4757 | { |
| 4758 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 4759 | return CMD_WARNING; |
| 4760 | } |
| 4761 | |
| 4762 | if (argc == 2) |
| 4763 | { |
| 4764 | ret = inet_aton(argv[1], &addr); |
| 4765 | if (!ret) |
| 4766 | { |
| 4767 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4768 | VTY_NEWLINE); |
| 4769 | return CMD_WARNING; |
| 4770 | } |
| 4771 | |
| 4772 | params = ospf_get_if_params (ifp, addr); |
| 4773 | ospf_if_update_params (ifp, addr); |
| 4774 | } |
| 4775 | |
| 4776 | SET_IF_PARAM (params, v_hello); |
| 4777 | params->v_hello = seconds; |
| 4778 | |
| 4779 | return CMD_SUCCESS; |
| 4780 | } |
| 4781 | |
| 4782 | ALIAS (ip_ospf_hello_interval, |
| 4783 | ip_ospf_hello_interval_cmd, |
| 4784 | "ip ospf hello-interval <1-65535>", |
| 4785 | "IP Information\n" |
| 4786 | "OSPF interface commands\n" |
| 4787 | "Time between HELLO packets\n" |
| 4788 | "Seconds\n") |
| 4789 | |
| 4790 | ALIAS (ip_ospf_hello_interval, |
| 4791 | ospf_hello_interval_cmd, |
| 4792 | "ospf hello-interval <1-65535>", |
| 4793 | "OSPF interface commands\n" |
| 4794 | "Time between HELLO packets\n" |
| 4795 | "Seconds\n") |
| 4796 | |
| 4797 | DEFUN (no_ip_ospf_hello_interval, |
| 4798 | no_ip_ospf_hello_interval_addr_cmd, |
| 4799 | "no ip ospf hello-interval A.B.C.D", |
| 4800 | NO_STR |
| 4801 | "IP Information\n" |
| 4802 | "OSPF interface commands\n" |
| 4803 | "Time between HELLO packets\n" |
| 4804 | "Address of interface") |
| 4805 | { |
| 4806 | struct interface *ifp = vty->index; |
| 4807 | struct in_addr addr; |
| 4808 | int ret; |
| 4809 | struct ospf_if_params *params; |
| 4810 | |
| 4811 | ifp = vty->index; |
| 4812 | params = IF_DEF_PARAMS (ifp); |
| 4813 | |
| 4814 | if (argc == 1) |
| 4815 | { |
| 4816 | ret = inet_aton(argv[0], &addr); |
| 4817 | if (!ret) |
| 4818 | { |
| 4819 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4820 | VTY_NEWLINE); |
| 4821 | return CMD_WARNING; |
| 4822 | } |
| 4823 | |
| 4824 | params = ospf_lookup_if_params (ifp, addr); |
| 4825 | if (params == NULL) |
| 4826 | return CMD_SUCCESS; |
| 4827 | } |
| 4828 | |
| 4829 | UNSET_IF_PARAM (params, v_hello); |
| 4830 | params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 4831 | |
| 4832 | if (params != IF_DEF_PARAMS (ifp)) |
| 4833 | { |
| 4834 | ospf_free_if_params (ifp, addr); |
| 4835 | ospf_if_update_params (ifp, addr); |
| 4836 | } |
| 4837 | |
| 4838 | return CMD_SUCCESS; |
| 4839 | } |
| 4840 | |
| 4841 | ALIAS (no_ip_ospf_hello_interval, |
| 4842 | no_ip_ospf_hello_interval_cmd, |
| 4843 | "no ip ospf hello-interval", |
| 4844 | NO_STR |
| 4845 | "IP Information\n" |
| 4846 | "OSPF interface commands\n" |
| 4847 | "Time between HELLO packets\n") |
| 4848 | |
| 4849 | ALIAS (no_ip_ospf_hello_interval, |
| 4850 | no_ospf_hello_interval_cmd, |
| 4851 | "no ospf hello-interval", |
| 4852 | NO_STR |
| 4853 | "OSPF interface commands\n" |
| 4854 | "Time between HELLO packets\n") |
| 4855 | |
| 4856 | DEFUN (ip_ospf_network, |
| 4857 | ip_ospf_network_cmd, |
| 4858 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4859 | "IP Information\n" |
| 4860 | "OSPF interface commands\n" |
| 4861 | "Network type\n" |
| 4862 | "Specify OSPF broadcast multi-access network\n" |
| 4863 | "Specify OSPF NBMA network\n" |
| 4864 | "Specify OSPF point-to-multipoint network\n" |
| 4865 | "Specify OSPF point-to-point network\n") |
| 4866 | { |
| 4867 | struct interface *ifp = vty->index; |
| 4868 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4869 | struct route_node *rn; |
| 4870 | |
| 4871 | if (strncmp (argv[0], "b", 1) == 0) |
| 4872 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 4873 | else if (strncmp (argv[0], "n", 1) == 0) |
| 4874 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 4875 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 4876 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 4877 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 4878 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 4879 | |
| 4880 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4881 | return CMD_SUCCESS; |
| 4882 | |
| 4883 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 4884 | |
| 4885 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4886 | { |
| 4887 | struct ospf_interface *oi = rn->info; |
| 4888 | |
| 4889 | if (!oi) |
| 4890 | continue; |
| 4891 | |
| 4892 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4893 | |
| 4894 | if (oi->state > ISM_Down) |
| 4895 | { |
| 4896 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4897 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4898 | } |
| 4899 | } |
| 4900 | |
| 4901 | return CMD_SUCCESS; |
| 4902 | } |
| 4903 | |
| 4904 | ALIAS (ip_ospf_network, |
| 4905 | ospf_network_cmd, |
| 4906 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 4907 | "OSPF interface commands\n" |
| 4908 | "Network type\n" |
| 4909 | "Specify OSPF broadcast multi-access network\n" |
| 4910 | "Specify OSPF NBMA network\n" |
| 4911 | "Specify OSPF point-to-multipoint network\n" |
| 4912 | "Specify OSPF point-to-point network\n") |
| 4913 | |
| 4914 | DEFUN (no_ip_ospf_network, |
| 4915 | no_ip_ospf_network_cmd, |
| 4916 | "no ip ospf network", |
| 4917 | NO_STR |
| 4918 | "IP Information\n" |
| 4919 | "OSPF interface commands\n" |
| 4920 | "Network type\n") |
| 4921 | { |
| 4922 | struct interface *ifp = vty->index; |
| 4923 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 4924 | struct route_node *rn; |
| 4925 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 4926 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4927 | |
| 4928 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 4929 | return CMD_SUCCESS; |
| 4930 | |
| 4931 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4932 | { |
| 4933 | struct ospf_interface *oi = rn->info; |
| 4934 | |
| 4935 | if (!oi) |
| 4936 | continue; |
| 4937 | |
| 4938 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 4939 | |
| 4940 | if (oi->state > ISM_Down) |
| 4941 | { |
| 4942 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 4943 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 4944 | } |
| 4945 | } |
| 4946 | |
| 4947 | return CMD_SUCCESS; |
| 4948 | } |
| 4949 | |
| 4950 | ALIAS (no_ip_ospf_network, |
| 4951 | no_ospf_network_cmd, |
| 4952 | "no ospf network", |
| 4953 | NO_STR |
| 4954 | "OSPF interface commands\n" |
| 4955 | "Network type\n") |
| 4956 | |
| 4957 | DEFUN (ip_ospf_priority, |
| 4958 | ip_ospf_priority_addr_cmd, |
| 4959 | "ip ospf priority <0-255> A.B.C.D", |
| 4960 | "IP Information\n" |
| 4961 | "OSPF interface commands\n" |
| 4962 | "Router priority\n" |
| 4963 | "Priority\n" |
| 4964 | "Address of interface") |
| 4965 | { |
| 4966 | struct interface *ifp = vty->index; |
| 4967 | u_int32_t priority; |
| 4968 | struct route_node *rn; |
| 4969 | struct in_addr addr; |
| 4970 | int ret; |
| 4971 | struct ospf_if_params *params; |
| 4972 | |
| 4973 | params = IF_DEF_PARAMS (ifp); |
| 4974 | |
| 4975 | priority = strtol (argv[0], NULL, 10); |
| 4976 | |
| 4977 | /* Router Priority range is <0-255>. */ |
| 4978 | if (priority < 0 || priority > 255) |
| 4979 | { |
| 4980 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 4981 | return CMD_WARNING; |
| 4982 | } |
| 4983 | |
| 4984 | if (argc == 2) |
| 4985 | { |
| 4986 | ret = inet_aton(argv[1], &addr); |
| 4987 | if (!ret) |
| 4988 | { |
| 4989 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4990 | VTY_NEWLINE); |
| 4991 | return CMD_WARNING; |
| 4992 | } |
| 4993 | |
| 4994 | params = ospf_get_if_params (ifp, addr); |
| 4995 | ospf_if_update_params (ifp, addr); |
| 4996 | } |
| 4997 | |
| 4998 | SET_IF_PARAM (params, priority); |
| 4999 | params->priority = priority; |
| 5000 | |
| 5001 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5002 | { |
| 5003 | struct ospf_interface *oi = rn->info; |
| 5004 | |
| 5005 | if (!oi) |
| 5006 | continue; |
| 5007 | |
| 5008 | |
| 5009 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5010 | { |
| 5011 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5012 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5013 | } |
| 5014 | } |
| 5015 | |
| 5016 | return CMD_SUCCESS; |
| 5017 | } |
| 5018 | |
| 5019 | ALIAS (ip_ospf_priority, |
| 5020 | ip_ospf_priority_cmd, |
| 5021 | "ip ospf priority <0-255>", |
| 5022 | "IP Information\n" |
| 5023 | "OSPF interface commands\n" |
| 5024 | "Router priority\n" |
| 5025 | "Priority\n") |
| 5026 | |
| 5027 | ALIAS (ip_ospf_priority, |
| 5028 | ospf_priority_cmd, |
| 5029 | "ospf priority <0-255>", |
| 5030 | "OSPF interface commands\n" |
| 5031 | "Router priority\n" |
| 5032 | "Priority\n") |
| 5033 | |
| 5034 | DEFUN (no_ip_ospf_priority, |
| 5035 | no_ip_ospf_priority_addr_cmd, |
| 5036 | "no ip ospf priority A.B.C.D", |
| 5037 | NO_STR |
| 5038 | "IP Information\n" |
| 5039 | "OSPF interface commands\n" |
| 5040 | "Router priority\n" |
| 5041 | "Address of interface") |
| 5042 | { |
| 5043 | struct interface *ifp = vty->index; |
| 5044 | struct route_node *rn; |
| 5045 | struct in_addr addr; |
| 5046 | int ret; |
| 5047 | struct ospf_if_params *params; |
| 5048 | |
| 5049 | ifp = vty->index; |
| 5050 | params = IF_DEF_PARAMS (ifp); |
| 5051 | |
| 5052 | if (argc == 1) |
| 5053 | { |
| 5054 | ret = inet_aton(argv[0], &addr); |
| 5055 | if (!ret) |
| 5056 | { |
| 5057 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5058 | VTY_NEWLINE); |
| 5059 | return CMD_WARNING; |
| 5060 | } |
| 5061 | |
| 5062 | params = ospf_lookup_if_params (ifp, addr); |
| 5063 | if (params == NULL) |
| 5064 | return CMD_SUCCESS; |
| 5065 | } |
| 5066 | |
| 5067 | UNSET_IF_PARAM (params, priority); |
| 5068 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5069 | |
| 5070 | if (params != IF_DEF_PARAMS (ifp)) |
| 5071 | { |
| 5072 | ospf_free_if_params (ifp, addr); |
| 5073 | ospf_if_update_params (ifp, addr); |
| 5074 | } |
| 5075 | |
| 5076 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5077 | { |
| 5078 | struct ospf_interface *oi = rn->info; |
| 5079 | |
| 5080 | if (!oi) |
| 5081 | continue; |
| 5082 | |
| 5083 | |
| 5084 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5085 | { |
| 5086 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5087 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5088 | } |
| 5089 | } |
| 5090 | |
| 5091 | return CMD_SUCCESS; |
| 5092 | } |
| 5093 | |
| 5094 | ALIAS (no_ip_ospf_priority, |
| 5095 | no_ip_ospf_priority_cmd, |
| 5096 | "no ip ospf priority", |
| 5097 | NO_STR |
| 5098 | "IP Information\n" |
| 5099 | "OSPF interface commands\n" |
| 5100 | "Router priority\n") |
| 5101 | |
| 5102 | ALIAS (no_ip_ospf_priority, |
| 5103 | no_ospf_priority_cmd, |
| 5104 | "no ospf priority", |
| 5105 | NO_STR |
| 5106 | "OSPF interface commands\n" |
| 5107 | "Router priority\n") |
| 5108 | |
| 5109 | DEFUN (ip_ospf_retransmit_interval, |
| 5110 | ip_ospf_retransmit_interval_addr_cmd, |
| 5111 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5112 | "IP Information\n" |
| 5113 | "OSPF interface commands\n" |
| 5114 | "Time between retransmitting lost link state advertisements\n" |
| 5115 | "Seconds\n" |
| 5116 | "Address of interface") |
| 5117 | { |
| 5118 | struct interface *ifp = vty->index; |
| 5119 | u_int32_t seconds; |
| 5120 | struct in_addr addr; |
| 5121 | int ret; |
| 5122 | struct ospf_if_params *params; |
| 5123 | |
| 5124 | params = IF_DEF_PARAMS (ifp); |
| 5125 | seconds = strtol (argv[0], NULL, 10); |
| 5126 | |
| 5127 | /* Retransmit Interval range is <3-65535>. */ |
| 5128 | if (seconds < 3 || seconds > 65535) |
| 5129 | { |
| 5130 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5131 | return CMD_WARNING; |
| 5132 | } |
| 5133 | |
| 5134 | |
| 5135 | if (argc == 2) |
| 5136 | { |
| 5137 | ret = inet_aton(argv[1], &addr); |
| 5138 | if (!ret) |
| 5139 | { |
| 5140 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5141 | VTY_NEWLINE); |
| 5142 | return CMD_WARNING; |
| 5143 | } |
| 5144 | |
| 5145 | params = ospf_get_if_params (ifp, addr); |
| 5146 | ospf_if_update_params (ifp, addr); |
| 5147 | } |
| 5148 | |
| 5149 | SET_IF_PARAM (params, retransmit_interval); |
| 5150 | params->retransmit_interval = seconds; |
| 5151 | |
| 5152 | return CMD_SUCCESS; |
| 5153 | } |
| 5154 | |
| 5155 | ALIAS (ip_ospf_retransmit_interval, |
| 5156 | ip_ospf_retransmit_interval_cmd, |
| 5157 | "ip ospf retransmit-interval <3-65535>", |
| 5158 | "IP Information\n" |
| 5159 | "OSPF interface commands\n" |
| 5160 | "Time between retransmitting lost link state advertisements\n" |
| 5161 | "Seconds\n") |
| 5162 | |
| 5163 | ALIAS (ip_ospf_retransmit_interval, |
| 5164 | ospf_retransmit_interval_cmd, |
| 5165 | "ospf retransmit-interval <3-65535>", |
| 5166 | "OSPF interface commands\n" |
| 5167 | "Time between retransmitting lost link state advertisements\n" |
| 5168 | "Seconds\n") |
| 5169 | |
| 5170 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5171 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5172 | "no ip ospf retransmit-interval A.B.C.D", |
| 5173 | NO_STR |
| 5174 | "IP Information\n" |
| 5175 | "OSPF interface commands\n" |
| 5176 | "Time between retransmitting lost link state advertisements\n" |
| 5177 | "Address of interface") |
| 5178 | { |
| 5179 | struct interface *ifp = vty->index; |
| 5180 | struct in_addr addr; |
| 5181 | int ret; |
| 5182 | struct ospf_if_params *params; |
| 5183 | |
| 5184 | ifp = vty->index; |
| 5185 | params = IF_DEF_PARAMS (ifp); |
| 5186 | |
| 5187 | if (argc == 1) |
| 5188 | { |
| 5189 | ret = inet_aton(argv[0], &addr); |
| 5190 | if (!ret) |
| 5191 | { |
| 5192 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5193 | VTY_NEWLINE); |
| 5194 | return CMD_WARNING; |
| 5195 | } |
| 5196 | |
| 5197 | params = ospf_lookup_if_params (ifp, addr); |
| 5198 | if (params == NULL) |
| 5199 | return CMD_SUCCESS; |
| 5200 | } |
| 5201 | |
| 5202 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5203 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5204 | |
| 5205 | if (params != IF_DEF_PARAMS (ifp)) |
| 5206 | { |
| 5207 | ospf_free_if_params (ifp, addr); |
| 5208 | ospf_if_update_params (ifp, addr); |
| 5209 | } |
| 5210 | |
| 5211 | return CMD_SUCCESS; |
| 5212 | } |
| 5213 | |
| 5214 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5215 | no_ip_ospf_retransmit_interval_cmd, |
| 5216 | "no ip ospf retransmit-interval", |
| 5217 | NO_STR |
| 5218 | "IP Information\n" |
| 5219 | "OSPF interface commands\n" |
| 5220 | "Time between retransmitting lost link state advertisements\n") |
| 5221 | |
| 5222 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5223 | no_ospf_retransmit_interval_cmd, |
| 5224 | "no ospf retransmit-interval", |
| 5225 | NO_STR |
| 5226 | "OSPF interface commands\n" |
| 5227 | "Time between retransmitting lost link state advertisements\n") |
| 5228 | |
| 5229 | DEFUN (ip_ospf_transmit_delay, |
| 5230 | ip_ospf_transmit_delay_addr_cmd, |
| 5231 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5232 | "IP Information\n" |
| 5233 | "OSPF interface commands\n" |
| 5234 | "Link state transmit delay\n" |
| 5235 | "Seconds\n" |
| 5236 | "Address of interface") |
| 5237 | { |
| 5238 | struct interface *ifp = vty->index; |
| 5239 | u_int32_t seconds; |
| 5240 | struct in_addr addr; |
| 5241 | int ret; |
| 5242 | struct ospf_if_params *params; |
| 5243 | |
| 5244 | params = IF_DEF_PARAMS (ifp); |
| 5245 | seconds = strtol (argv[0], NULL, 10); |
| 5246 | |
| 5247 | /* Transmit Delay range is <1-65535>. */ |
| 5248 | if (seconds < 1 || seconds > 65535) |
| 5249 | { |
| 5250 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5251 | return CMD_WARNING; |
| 5252 | } |
| 5253 | |
| 5254 | if (argc == 2) |
| 5255 | { |
| 5256 | ret = inet_aton(argv[1], &addr); |
| 5257 | if (!ret) |
| 5258 | { |
| 5259 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5260 | VTY_NEWLINE); |
| 5261 | return CMD_WARNING; |
| 5262 | } |
| 5263 | |
| 5264 | params = ospf_get_if_params (ifp, addr); |
| 5265 | ospf_if_update_params (ifp, addr); |
| 5266 | } |
| 5267 | |
| 5268 | SET_IF_PARAM (params, transmit_delay); |
| 5269 | params->transmit_delay = seconds; |
| 5270 | |
| 5271 | return CMD_SUCCESS; |
| 5272 | } |
| 5273 | |
| 5274 | ALIAS (ip_ospf_transmit_delay, |
| 5275 | ip_ospf_transmit_delay_cmd, |
| 5276 | "ip ospf transmit-delay <1-65535>", |
| 5277 | "IP Information\n" |
| 5278 | "OSPF interface commands\n" |
| 5279 | "Link state transmit delay\n" |
| 5280 | "Seconds\n") |
| 5281 | |
| 5282 | ALIAS (ip_ospf_transmit_delay, |
| 5283 | ospf_transmit_delay_cmd, |
| 5284 | "ospf transmit-delay <1-65535>", |
| 5285 | "OSPF interface commands\n" |
| 5286 | "Link state transmit delay\n" |
| 5287 | "Seconds\n") |
| 5288 | |
| 5289 | DEFUN (no_ip_ospf_transmit_delay, |
| 5290 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5291 | "no ip ospf transmit-delay A.B.C.D", |
| 5292 | NO_STR |
| 5293 | "IP Information\n" |
| 5294 | "OSPF interface commands\n" |
| 5295 | "Link state transmit delay\n" |
| 5296 | "Address of interface") |
| 5297 | { |
| 5298 | struct interface *ifp = vty->index; |
| 5299 | struct in_addr addr; |
| 5300 | int ret; |
| 5301 | struct ospf_if_params *params; |
| 5302 | |
| 5303 | ifp = vty->index; |
| 5304 | params = IF_DEF_PARAMS (ifp); |
| 5305 | |
| 5306 | if (argc == 1) |
| 5307 | { |
| 5308 | ret = inet_aton(argv[0], &addr); |
| 5309 | if (!ret) |
| 5310 | { |
| 5311 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5312 | VTY_NEWLINE); |
| 5313 | return CMD_WARNING; |
| 5314 | } |
| 5315 | |
| 5316 | params = ospf_lookup_if_params (ifp, addr); |
| 5317 | if (params == NULL) |
| 5318 | return CMD_SUCCESS; |
| 5319 | } |
| 5320 | |
| 5321 | UNSET_IF_PARAM (params, transmit_delay); |
| 5322 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5323 | |
| 5324 | if (params != IF_DEF_PARAMS (ifp)) |
| 5325 | { |
| 5326 | ospf_free_if_params (ifp, addr); |
| 5327 | ospf_if_update_params (ifp, addr); |
| 5328 | } |
| 5329 | |
| 5330 | return CMD_SUCCESS; |
| 5331 | } |
| 5332 | |
| 5333 | ALIAS (no_ip_ospf_transmit_delay, |
| 5334 | no_ip_ospf_transmit_delay_cmd, |
| 5335 | "no ip ospf transmit-delay", |
| 5336 | NO_STR |
| 5337 | "IP Information\n" |
| 5338 | "OSPF interface commands\n" |
| 5339 | "Link state transmit delay\n") |
| 5340 | |
| 5341 | ALIAS (no_ip_ospf_transmit_delay, |
| 5342 | no_ospf_transmit_delay_cmd, |
| 5343 | "no ospf transmit-delay", |
| 5344 | NO_STR |
| 5345 | "OSPF interface commands\n" |
| 5346 | "Link state transmit delay\n") |
| 5347 | |
| 5348 | |
| 5349 | DEFUN (ospf_redistribute_source_metric_type, |
| 5350 | ospf_redistribute_source_metric_type_routemap_cmd, |
| 5351 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5352 | "Redistribute information from another routing protocol\n" |
| 5353 | "Kernel routes\n" |
| 5354 | "Connected\n" |
| 5355 | "Static routes\n" |
| 5356 | "Routing Information Protocol (RIP)\n" |
| 5357 | "Border Gateway Protocol (BGP)\n" |
| 5358 | "Metric for redistributed routes\n" |
| 5359 | "OSPF default metric\n" |
| 5360 | "OSPF exterior metric type for redistributed routes\n" |
| 5361 | "Set OSPF External Type 1 metrics\n" |
| 5362 | "Set OSPF External Type 2 metrics\n" |
| 5363 | "Route map reference\n" |
| 5364 | "Pointer to route-map entries\n") |
| 5365 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5366 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5367 | int source; |
| 5368 | int type = -1; |
| 5369 | int metric = -1; |
| 5370 | |
| 5371 | /* Get distribute source. */ |
| 5372 | if (!str2distribute_source (argv[0], &source)) |
| 5373 | return CMD_WARNING; |
| 5374 | |
| 5375 | /* Get metric value. */ |
| 5376 | if (argc >= 2) |
| 5377 | if (!str2metric (argv[1], &metric)) |
| 5378 | return CMD_WARNING; |
| 5379 | |
| 5380 | /* Get metric type. */ |
| 5381 | if (argc >= 3) |
| 5382 | if (!str2metric_type (argv[2], &type)) |
| 5383 | return CMD_WARNING; |
| 5384 | |
| 5385 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5386 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5387 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5388 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5389 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5390 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5391 | } |
| 5392 | |
| 5393 | ALIAS (ospf_redistribute_source_metric_type, |
| 5394 | ospf_redistribute_source_metric_type_cmd, |
| 5395 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)", |
| 5396 | "Redistribute information from another routing protocol\n" |
| 5397 | "Kernel routes\n" |
| 5398 | "Connected\n" |
| 5399 | "Static routes\n" |
| 5400 | "Routing Information Protocol (RIP)\n" |
| 5401 | "Border Gateway Protocol (BGP)\n" |
| 5402 | "Metric for redistributed routes\n" |
| 5403 | "OSPF default metric\n" |
| 5404 | "OSPF exterior metric type for redistributed routes\n" |
| 5405 | "Set OSPF External Type 1 metrics\n" |
| 5406 | "Set OSPF External Type 2 metrics\n") |
| 5407 | |
| 5408 | ALIAS (ospf_redistribute_source_metric_type, |
| 5409 | ospf_redistribute_source_metric_cmd, |
| 5410 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>", |
| 5411 | "Redistribute information from another routing protocol\n" |
| 5412 | "Kernel routes\n" |
| 5413 | "Connected\n" |
| 5414 | "Static routes\n" |
| 5415 | "Routing Information Protocol (RIP)\n" |
| 5416 | "Border Gateway Protocol (BGP)\n" |
| 5417 | "Metric for redistributed routes\n" |
| 5418 | "OSPF default metric\n") |
| 5419 | |
| 5420 | DEFUN (ospf_redistribute_source_type_metric, |
| 5421 | ospf_redistribute_source_type_metric_routemap_cmd, |
| 5422 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5423 | "Redistribute information from another routing protocol\n" |
| 5424 | "Kernel routes\n" |
| 5425 | "Connected\n" |
| 5426 | "Static routes\n" |
| 5427 | "Routing Information Protocol (RIP)\n" |
| 5428 | "Border Gateway Protocol (BGP)\n" |
| 5429 | "OSPF exterior metric type for redistributed routes\n" |
| 5430 | "Set OSPF External Type 1 metrics\n" |
| 5431 | "Set OSPF External Type 2 metrics\n" |
| 5432 | "Metric for redistributed routes\n" |
| 5433 | "OSPF default metric\n" |
| 5434 | "Route map reference\n" |
| 5435 | "Pointer to route-map entries\n") |
| 5436 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5437 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5438 | int source; |
| 5439 | int type = -1; |
| 5440 | int metric = -1; |
| 5441 | |
| 5442 | /* Get distribute source. */ |
| 5443 | if (!str2distribute_source (argv[0], &source)) |
| 5444 | return CMD_WARNING; |
| 5445 | |
| 5446 | /* Get metric value. */ |
| 5447 | if (argc >= 2) |
| 5448 | if (!str2metric_type (argv[1], &type)) |
| 5449 | return CMD_WARNING; |
| 5450 | |
| 5451 | /* Get metric type. */ |
| 5452 | if (argc >= 3) |
| 5453 | if (!str2metric (argv[2], &metric)) |
| 5454 | return CMD_WARNING; |
| 5455 | |
| 5456 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5457 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5458 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5459 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5460 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5461 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5462 | } |
| 5463 | |
| 5464 | ALIAS (ospf_redistribute_source_type_metric, |
| 5465 | ospf_redistribute_source_type_metric_cmd, |
| 5466 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>", |
| 5467 | "Redistribute information from another routing protocol\n" |
| 5468 | "Kernel routes\n" |
| 5469 | "Connected\n" |
| 5470 | "Static routes\n" |
| 5471 | "Routing Information Protocol (RIP)\n" |
| 5472 | "Border Gateway Protocol (BGP)\n" |
| 5473 | "OSPF exterior metric type for redistributed routes\n" |
| 5474 | "Set OSPF External Type 1 metrics\n" |
| 5475 | "Set OSPF External Type 2 metrics\n" |
| 5476 | "Metric for redistributed routes\n" |
| 5477 | "OSPF default metric\n") |
| 5478 | |
| 5479 | ALIAS (ospf_redistribute_source_type_metric, |
| 5480 | ospf_redistribute_source_type_cmd, |
| 5481 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)", |
| 5482 | "Redistribute information from another routing protocol\n" |
| 5483 | "Kernel routes\n" |
| 5484 | "Connected\n" |
| 5485 | "Static routes\n" |
| 5486 | "Routing Information Protocol (RIP)\n" |
| 5487 | "Border Gateway Protocol (BGP)\n" |
| 5488 | "OSPF exterior metric type for redistributed routes\n" |
| 5489 | "Set OSPF External Type 1 metrics\n" |
| 5490 | "Set OSPF External Type 2 metrics\n") |
| 5491 | |
| 5492 | ALIAS (ospf_redistribute_source_type_metric, |
| 5493 | ospf_redistribute_source_cmd, |
| 5494 | "redistribute (kernel|connected|static|rip|bgp)", |
| 5495 | "Redistribute information from another routing protocol\n" |
| 5496 | "Kernel routes\n" |
| 5497 | "Connected\n" |
| 5498 | "Static routes\n" |
| 5499 | "Routing Information Protocol (RIP)\n" |
| 5500 | "Border Gateway Protocol (BGP)\n") |
| 5501 | |
| 5502 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5503 | ospf_redistribute_source_metric_routemap_cmd, |
| 5504 | "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD", |
| 5505 | "Redistribute information from another routing protocol\n" |
| 5506 | "Kernel routes\n" |
| 5507 | "Connected\n" |
| 5508 | "Static routes\n" |
| 5509 | "Routing Information Protocol (RIP)\n" |
| 5510 | "Border Gateway Protocol (BGP)\n" |
| 5511 | "Metric for redistributed routes\n" |
| 5512 | "OSPF default metric\n" |
| 5513 | "Route map reference\n" |
| 5514 | "Pointer to route-map entries\n") |
| 5515 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5516 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5517 | int source; |
| 5518 | int metric = -1; |
| 5519 | |
| 5520 | /* Get distribute source. */ |
| 5521 | if (!str2distribute_source (argv[0], &source)) |
| 5522 | return CMD_WARNING; |
| 5523 | |
| 5524 | /* Get metric value. */ |
| 5525 | if (argc >= 2) |
| 5526 | if (!str2metric (argv[1], &metric)) |
| 5527 | return CMD_WARNING; |
| 5528 | |
| 5529 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5530 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5531 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5532 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5533 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5534 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5535 | } |
| 5536 | |
| 5537 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5538 | ospf_redistribute_source_type_routemap_cmd, |
| 5539 | "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD", |
| 5540 | "Redistribute information from another routing protocol\n" |
| 5541 | "Kernel routes\n" |
| 5542 | "Connected\n" |
| 5543 | "Static routes\n" |
| 5544 | "Routing Information Protocol (RIP)\n" |
| 5545 | "Border Gateway Protocol (BGP)\n" |
| 5546 | "OSPF exterior metric type for redistributed routes\n" |
| 5547 | "Set OSPF External Type 1 metrics\n" |
| 5548 | "Set OSPF External Type 2 metrics\n" |
| 5549 | "Route map reference\n" |
| 5550 | "Pointer to route-map entries\n") |
| 5551 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5552 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5553 | int source; |
| 5554 | int type = -1; |
| 5555 | |
| 5556 | /* Get distribute source. */ |
| 5557 | if (!str2distribute_source (argv[0], &source)) |
| 5558 | return CMD_WARNING; |
| 5559 | |
| 5560 | /* Get metric value. */ |
| 5561 | if (argc >= 2) |
| 5562 | if (!str2metric_type (argv[1], &type)) |
| 5563 | return CMD_WARNING; |
| 5564 | |
| 5565 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5566 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5567 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5568 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5569 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5570 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5571 | } |
| 5572 | |
| 5573 | DEFUN (ospf_redistribute_source_routemap, |
| 5574 | ospf_redistribute_source_routemap_cmd, |
| 5575 | "redistribute (kernel|connected|static|rip|bgp) route-map WORD", |
| 5576 | "Redistribute information from another routing protocol\n" |
| 5577 | "Kernel routes\n" |
| 5578 | "Connected\n" |
| 5579 | "Static routes\n" |
| 5580 | "Routing Information Protocol (RIP)\n" |
| 5581 | "Border Gateway Protocol (BGP)\n" |
| 5582 | "Route map reference\n" |
| 5583 | "Pointer to route-map entries\n") |
| 5584 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5585 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5586 | int source; |
| 5587 | |
| 5588 | /* Get distribute source. */ |
| 5589 | if (!str2distribute_source (argv[0], &source)) |
| 5590 | return CMD_WARNING; |
| 5591 | |
| 5592 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5593 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5594 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5595 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5596 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5597 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5598 | } |
| 5599 | |
| 5600 | DEFUN (no_ospf_redistribute_source, |
| 5601 | no_ospf_redistribute_source_cmd, |
| 5602 | "no redistribute (kernel|connected|static|rip|bgp)", |
| 5603 | NO_STR |
| 5604 | "Redistribute information from another routing protocol\n" |
| 5605 | "Kernel routes\n" |
| 5606 | "Connected\n" |
| 5607 | "Static routes\n" |
| 5608 | "Routing Information Protocol (RIP)\n" |
| 5609 | "Border Gateway Protocol (BGP)\n") |
| 5610 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5611 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5612 | int source; |
| 5613 | |
| 5614 | if (!str2distribute_source (argv[0], &source)) |
| 5615 | return CMD_WARNING; |
| 5616 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5617 | ospf_routemap_unset (ospf, source); |
| 5618 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5619 | } |
| 5620 | |
| 5621 | DEFUN (ospf_distribute_list_out, |
| 5622 | ospf_distribute_list_out_cmd, |
| 5623 | "distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5624 | "Filter networks in routing updates\n" |
| 5625 | "Access-list name\n" |
| 5626 | OUT_STR |
| 5627 | "Kernel routes\n" |
| 5628 | "Connected\n" |
| 5629 | "Static routes\n" |
| 5630 | "Routing Information Protocol (RIP)\n" |
| 5631 | "Border Gateway Protocol (BGP)\n") |
| 5632 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5633 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5634 | int source; |
| 5635 | |
| 5636 | /* Get distribute source. */ |
| 5637 | if (!str2distribute_source (argv[1], &source)) |
| 5638 | return CMD_WARNING; |
| 5639 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5640 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5641 | } |
| 5642 | |
| 5643 | DEFUN (no_ospf_distribute_list_out, |
| 5644 | no_ospf_distribute_list_out_cmd, |
| 5645 | "no distribute-list WORD out (kernel|connected|static|rip|bgp)", |
| 5646 | NO_STR |
| 5647 | "Filter networks in routing updates\n" |
| 5648 | "Access-list name\n" |
| 5649 | OUT_STR |
| 5650 | "Kernel routes\n" |
| 5651 | "Connected\n" |
| 5652 | "Static routes\n" |
| 5653 | "Routing Information Protocol (RIP)\n" |
| 5654 | "Border Gateway Protocol (BGP)\n") |
| 5655 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5656 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5657 | int source; |
| 5658 | |
| 5659 | if (!str2distribute_source (argv[1], &source)) |
| 5660 | return CMD_WARNING; |
| 5661 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5662 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5663 | } |
| 5664 | |
| 5665 | /* Default information originate. */ |
| 5666 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5667 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5668 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5669 | "Control distribution of default information\n" |
| 5670 | "Distribute a default route\n" |
| 5671 | "OSPF default metric\n" |
| 5672 | "OSPF metric\n" |
| 5673 | "OSPF metric type for default routes\n" |
| 5674 | "Set OSPF External Type 1 metrics\n" |
| 5675 | "Set OSPF External Type 2 metrics\n" |
| 5676 | "Route map reference\n" |
| 5677 | "Pointer to route-map entries\n") |
| 5678 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5679 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5680 | int type = -1; |
| 5681 | int metric = -1; |
| 5682 | |
| 5683 | /* Get metric value. */ |
| 5684 | if (argc >= 1) |
| 5685 | if (!str2metric (argv[0], &metric)) |
| 5686 | return CMD_WARNING; |
| 5687 | |
| 5688 | /* Get metric type. */ |
| 5689 | if (argc >= 2) |
| 5690 | if (!str2metric_type (argv[1], &type)) |
| 5691 | return CMD_WARNING; |
| 5692 | |
| 5693 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5694 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5695 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5696 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5697 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5698 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5699 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5700 | } |
| 5701 | |
| 5702 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5703 | ospf_default_information_originate_metric_type_cmd, |
| 5704 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 5705 | "Control distribution of default information\n" |
| 5706 | "Distribute a default route\n" |
| 5707 | "OSPF default metric\n" |
| 5708 | "OSPF metric\n" |
| 5709 | "OSPF metric type for default routes\n" |
| 5710 | "Set OSPF External Type 1 metrics\n" |
| 5711 | "Set OSPF External Type 2 metrics\n") |
| 5712 | |
| 5713 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5714 | ospf_default_information_originate_metric_cmd, |
| 5715 | "default-information originate metric <0-16777214>", |
| 5716 | "Control distribution of default information\n" |
| 5717 | "Distribute a default route\n" |
| 5718 | "OSPF default metric\n" |
| 5719 | "OSPF metric\n") |
| 5720 | |
| 5721 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 5722 | ospf_default_information_originate_cmd, |
| 5723 | "default-information originate", |
| 5724 | "Control distribution of default information\n" |
| 5725 | "Distribute a default route\n") |
| 5726 | |
| 5727 | /* Default information originate. */ |
| 5728 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 5729 | ospf_default_information_originate_metric_routemap_cmd, |
| 5730 | "default-information originate metric <0-16777214> route-map WORD", |
| 5731 | "Control distribution of default information\n" |
| 5732 | "Distribute a default route\n" |
| 5733 | "OSPF default metric\n" |
| 5734 | "OSPF metric\n" |
| 5735 | "Route map reference\n" |
| 5736 | "Pointer to route-map entries\n") |
| 5737 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5738 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5739 | int metric = -1; |
| 5740 | |
| 5741 | /* Get metric value. */ |
| 5742 | if (argc >= 1) |
| 5743 | if (!str2metric (argv[0], &metric)) |
| 5744 | return CMD_WARNING; |
| 5745 | |
| 5746 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5747 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5748 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5749 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5750 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5751 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5752 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5753 | } |
| 5754 | |
| 5755 | /* Default information originate. */ |
| 5756 | DEFUN (ospf_default_information_originate_routemap, |
| 5757 | ospf_default_information_originate_routemap_cmd, |
| 5758 | "default-information originate route-map WORD", |
| 5759 | "Control distribution of default information\n" |
| 5760 | "Distribute a default route\n" |
| 5761 | "Route map reference\n" |
| 5762 | "Pointer to route-map entries\n") |
| 5763 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5764 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5765 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5766 | if (argc == 1) |
| 5767 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5768 | else |
| 5769 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5770 | |
| 5771 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5772 | } |
| 5773 | |
| 5774 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 5775 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 5776 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5777 | "Control distribution of default information\n" |
| 5778 | "Distribute a default route\n" |
| 5779 | "OSPF metric type for default routes\n" |
| 5780 | "Set OSPF External Type 1 metrics\n" |
| 5781 | "Set OSPF External Type 2 metrics\n" |
| 5782 | "OSPF default metric\n" |
| 5783 | "OSPF metric\n" |
| 5784 | "Route map reference\n" |
| 5785 | "Pointer to route-map entries\n") |
| 5786 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5787 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5788 | int type = -1; |
| 5789 | int metric = -1; |
| 5790 | |
| 5791 | /* Get metric type. */ |
| 5792 | if (argc >= 1) |
| 5793 | if (!str2metric_type (argv[0], &type)) |
| 5794 | return CMD_WARNING; |
| 5795 | |
| 5796 | /* Get metric value. */ |
| 5797 | if (argc >= 2) |
| 5798 | if (!str2metric (argv[1], &metric)) |
| 5799 | return CMD_WARNING; |
| 5800 | |
| 5801 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5802 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5803 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5804 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5805 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5806 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5807 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5808 | } |
| 5809 | |
| 5810 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5811 | ospf_default_information_originate_type_metric_cmd, |
| 5812 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 5813 | "Control distribution of default information\n" |
| 5814 | "Distribute a default route\n" |
| 5815 | "OSPF metric type for default routes\n" |
| 5816 | "Set OSPF External Type 1 metrics\n" |
| 5817 | "Set OSPF External Type 2 metrics\n" |
| 5818 | "OSPF default metric\n" |
| 5819 | "OSPF metric\n") |
| 5820 | |
| 5821 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 5822 | ospf_default_information_originate_type_cmd, |
| 5823 | "default-information originate metric-type (1|2)", |
| 5824 | "Control distribution of default information\n" |
| 5825 | "Distribute a default route\n" |
| 5826 | "OSPF metric type for default routes\n" |
| 5827 | "Set OSPF External Type 1 metrics\n" |
| 5828 | "Set OSPF External Type 2 metrics\n") |
| 5829 | |
| 5830 | DEFUN (ospf_default_information_originate_type_routemap, |
| 5831 | ospf_default_information_originate_type_routemap_cmd, |
| 5832 | "default-information originate metric-type (1|2) route-map WORD", |
| 5833 | "Control distribution of default information\n" |
| 5834 | "Distribute a default route\n" |
| 5835 | "OSPF metric type for default routes\n" |
| 5836 | "Set OSPF External Type 1 metrics\n" |
| 5837 | "Set OSPF External Type 2 metrics\n" |
| 5838 | "Route map reference\n" |
| 5839 | "Pointer to route-map entries\n") |
| 5840 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5841 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5842 | int type = -1; |
| 5843 | |
| 5844 | /* Get metric type. */ |
| 5845 | if (argc >= 1) |
| 5846 | if (!str2metric_type (argv[0], &type)) |
| 5847 | return CMD_WARNING; |
| 5848 | |
| 5849 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5850 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5851 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5852 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5853 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5854 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 5855 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5856 | } |
| 5857 | |
| 5858 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 5859 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 5860 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5861 | "Control distribution of default information\n" |
| 5862 | "Distribute a default route\n" |
| 5863 | "Always advertise default route\n" |
| 5864 | "OSPF default metric\n" |
| 5865 | "OSPF metric\n" |
| 5866 | "OSPF metric type for default routes\n" |
| 5867 | "Set OSPF External Type 1 metrics\n" |
| 5868 | "Set OSPF External Type 2 metrics\n" |
| 5869 | "Route map reference\n" |
| 5870 | "Pointer to route-map entries\n") |
| 5871 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5872 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5873 | int type = -1; |
| 5874 | int metric = -1; |
| 5875 | |
| 5876 | /* Get metric value. */ |
| 5877 | if (argc >= 1) |
| 5878 | if (!str2metric (argv[0], &metric)) |
| 5879 | return CMD_WARNING; |
| 5880 | |
| 5881 | /* Get metric type. */ |
| 5882 | if (argc >= 2) |
| 5883 | if (!str2metric_type (argv[1], &type)) |
| 5884 | return CMD_WARNING; |
| 5885 | |
| 5886 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5887 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5888 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5889 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5890 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5891 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5892 | type, metric); |
| 5893 | } |
| 5894 | |
| 5895 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5896 | ospf_default_information_originate_always_metric_type_cmd, |
| 5897 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 5898 | "Control distribution of default information\n" |
| 5899 | "Distribute a default route\n" |
| 5900 | "Always advertise default route\n" |
| 5901 | "OSPF default metric\n" |
| 5902 | "OSPF metric\n" |
| 5903 | "OSPF metric type for default routes\n" |
| 5904 | "Set OSPF External Type 1 metrics\n" |
| 5905 | "Set OSPF External Type 2 metrics\n") |
| 5906 | |
| 5907 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5908 | ospf_default_information_originate_always_metric_cmd, |
| 5909 | "default-information originate always metric <0-16777214>", |
| 5910 | "Control distribution of default information\n" |
| 5911 | "Distribute a default route\n" |
| 5912 | "Always advertise default route\n" |
| 5913 | "OSPF default metric\n" |
| 5914 | "OSPF metric\n" |
| 5915 | "OSPF metric type for default routes\n") |
| 5916 | |
| 5917 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 5918 | ospf_default_information_originate_always_cmd, |
| 5919 | "default-information originate always", |
| 5920 | "Control distribution of default information\n" |
| 5921 | "Distribute a default route\n" |
| 5922 | "Always advertise default route\n") |
| 5923 | |
| 5924 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 5925 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 5926 | "default-information originate always metric <0-16777214> route-map WORD", |
| 5927 | "Control distribution of default information\n" |
| 5928 | "Distribute a default route\n" |
| 5929 | "Always advertise default route\n" |
| 5930 | "OSPF default metric\n" |
| 5931 | "OSPF metric\n" |
| 5932 | "Route map reference\n" |
| 5933 | "Pointer to route-map entries\n") |
| 5934 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5935 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5936 | int metric = -1; |
| 5937 | |
| 5938 | /* Get metric value. */ |
| 5939 | if (argc >= 1) |
| 5940 | if (!str2metric (argv[0], &metric)) |
| 5941 | return CMD_WARNING; |
| 5942 | |
| 5943 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5944 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5945 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5946 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5947 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5948 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 5949 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5950 | } |
| 5951 | |
| 5952 | DEFUN (ospf_default_information_originate_always_routemap, |
| 5953 | ospf_default_information_originate_always_routemap_cmd, |
| 5954 | "default-information originate always route-map WORD", |
| 5955 | "Control distribution of default information\n" |
| 5956 | "Distribute a default route\n" |
| 5957 | "Always advertise default route\n" |
| 5958 | "Route map reference\n" |
| 5959 | "Pointer to route-map entries\n") |
| 5960 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5961 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5962 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5963 | if (argc == 1) |
| 5964 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 5965 | else |
| 5966 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5967 | |
| 5968 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5969 | } |
| 5970 | |
| 5971 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 5972 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 5973 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5974 | "Control distribution of default information\n" |
| 5975 | "Distribute a default route\n" |
| 5976 | "Always advertise default route\n" |
| 5977 | "OSPF metric type for default routes\n" |
| 5978 | "Set OSPF External Type 1 metrics\n" |
| 5979 | "Set OSPF External Type 2 metrics\n" |
| 5980 | "OSPF default metric\n" |
| 5981 | "OSPF metric\n" |
| 5982 | "Route map reference\n" |
| 5983 | "Pointer to route-map entries\n") |
| 5984 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5985 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5986 | int type = -1; |
| 5987 | int metric = -1; |
| 5988 | |
| 5989 | /* Get metric type. */ |
| 5990 | if (argc >= 1) |
| 5991 | if (!str2metric_type (argv[0], &type)) |
| 5992 | return CMD_WARNING; |
| 5993 | |
| 5994 | /* Get metric value. */ |
| 5995 | if (argc >= 2) |
| 5996 | if (!str2metric (argv[1], &metric)) |
| 5997 | return CMD_WARNING; |
| 5998 | |
| 5999 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6000 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6001 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6002 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6003 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6004 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6005 | type, metric); |
| 6006 | } |
| 6007 | |
| 6008 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6009 | ospf_default_information_originate_always_type_metric_cmd, |
| 6010 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 6011 | "Control distribution of default information\n" |
| 6012 | "Distribute a default route\n" |
| 6013 | "Always advertise default route\n" |
| 6014 | "OSPF metric type for default routes\n" |
| 6015 | "Set OSPF External Type 1 metrics\n" |
| 6016 | "Set OSPF External Type 2 metrics\n" |
| 6017 | "OSPF default metric\n" |
| 6018 | "OSPF metric\n") |
| 6019 | |
| 6020 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6021 | ospf_default_information_originate_always_type_cmd, |
| 6022 | "default-information originate always metric-type (1|2)", |
| 6023 | "Control distribution of default information\n" |
| 6024 | "Distribute a default route\n" |
| 6025 | "Always advertise default route\n" |
| 6026 | "OSPF metric type for default routes\n" |
| 6027 | "Set OSPF External Type 1 metrics\n" |
| 6028 | "Set OSPF External Type 2 metrics\n") |
| 6029 | |
| 6030 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 6031 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6032 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6033 | "Control distribution of default information\n" |
| 6034 | "Distribute a default route\n" |
| 6035 | "Always advertise default route\n" |
| 6036 | "OSPF metric type for default routes\n" |
| 6037 | "Set OSPF External Type 1 metrics\n" |
| 6038 | "Set OSPF External Type 2 metrics\n" |
| 6039 | "Route map reference\n" |
| 6040 | "Pointer to route-map entries\n") |
| 6041 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6042 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6043 | int type = -1; |
| 6044 | |
| 6045 | /* Get metric type. */ |
| 6046 | if (argc >= 1) |
| 6047 | if (!str2metric_type (argv[0], &type)) |
| 6048 | return CMD_WARNING; |
| 6049 | |
| 6050 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6051 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6052 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6053 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6054 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6055 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6056 | type, -1); |
| 6057 | } |
| 6058 | |
| 6059 | DEFUN (no_ospf_default_information_originate, |
| 6060 | no_ospf_default_information_originate_cmd, |
| 6061 | "no default-information originate", |
| 6062 | NO_STR |
| 6063 | "Control distribution of default information\n" |
| 6064 | "Distribute a default route\n") |
| 6065 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6066 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | struct prefix_ipv4 p; |
| 6068 | struct in_addr nexthop; |
| 6069 | |
| 6070 | p.family = AF_INET; |
| 6071 | p.prefix.s_addr = 0; |
| 6072 | p.prefixlen = 0; |
| 6073 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6074 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6075 | |
| 6076 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6077 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6078 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6079 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6080 | } |
| 6081 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6082 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6083 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6084 | } |
| 6085 | |
| 6086 | DEFUN (ospf_default_metric, |
| 6087 | ospf_default_metric_cmd, |
| 6088 | "default-metric <0-16777214>", |
| 6089 | "Set metric of redistributed routes\n" |
| 6090 | "Default metric\n") |
| 6091 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6092 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6093 | int metric = -1; |
| 6094 | |
| 6095 | if (!str2metric (argv[0], &metric)) |
| 6096 | return CMD_WARNING; |
| 6097 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6098 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6099 | |
| 6100 | return CMD_SUCCESS; |
| 6101 | } |
| 6102 | |
| 6103 | DEFUN (no_ospf_default_metric, |
| 6104 | no_ospf_default_metric_cmd, |
| 6105 | "no default-metric", |
| 6106 | NO_STR |
| 6107 | "Set metric of redistributed routes\n") |
| 6108 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6109 | struct ospf *ospf = vty->index; |
| 6110 | |
| 6111 | ospf->default_metric = -1; |
| 6112 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | return CMD_SUCCESS; |
| 6114 | } |
| 6115 | |
| 6116 | ALIAS (no_ospf_default_metric, |
| 6117 | no_ospf_default_metric_val_cmd, |
| 6118 | "no default-metric <0-16777214>", |
| 6119 | NO_STR |
| 6120 | "Set metric of redistributed routes\n" |
| 6121 | "Default metric\n") |
| 6122 | |
| 6123 | DEFUN (ospf_distance, |
| 6124 | ospf_distance_cmd, |
| 6125 | "distance <1-255>", |
| 6126 | "Define an administrative distance\n" |
| 6127 | "OSPF Administrative distance\n") |
| 6128 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6129 | struct ospf *ospf = vty->index; |
| 6130 | |
| 6131 | ospf->distance_all = atoi (argv[0]); |
| 6132 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6133 | return CMD_SUCCESS; |
| 6134 | } |
| 6135 | |
| 6136 | DEFUN (no_ospf_distance, |
| 6137 | no_ospf_distance_cmd, |
| 6138 | "no distance <1-255>", |
| 6139 | NO_STR |
| 6140 | "Define an administrative distance\n" |
| 6141 | "OSPF Administrative distance\n") |
| 6142 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6143 | struct ospf *ospf = vty->index; |
| 6144 | |
| 6145 | ospf->distance_all = 0; |
| 6146 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6147 | return CMD_SUCCESS; |
| 6148 | } |
| 6149 | |
| 6150 | DEFUN (no_ospf_distance_ospf, |
| 6151 | no_ospf_distance_ospf_cmd, |
| 6152 | "no distance ospf", |
| 6153 | NO_STR |
| 6154 | "Define an administrative distance\n" |
| 6155 | "OSPF Administrative distance\n" |
| 6156 | "OSPF Distance\n") |
| 6157 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6158 | struct ospf *ospf = vty->index; |
| 6159 | |
| 6160 | ospf->distance_intra = 0; |
| 6161 | ospf->distance_inter = 0; |
| 6162 | ospf->distance_external = 0; |
| 6163 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6164 | return CMD_SUCCESS; |
| 6165 | } |
| 6166 | |
| 6167 | DEFUN (ospf_distance_ospf_intra, |
| 6168 | ospf_distance_ospf_intra_cmd, |
| 6169 | "distance ospf intra-area <1-255>", |
| 6170 | "Define an administrative distance\n" |
| 6171 | "OSPF Administrative distance\n" |
| 6172 | "Intra-area routes\n" |
| 6173 | "Distance for intra-area routes\n") |
| 6174 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6175 | struct ospf *ospf = vty->index; |
| 6176 | |
| 6177 | ospf->distance_intra = atoi (argv[0]); |
| 6178 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6179 | return CMD_SUCCESS; |
| 6180 | } |
| 6181 | |
| 6182 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6183 | ospf_distance_ospf_intra_inter_cmd, |
| 6184 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6185 | "Define an administrative distance\n" |
| 6186 | "OSPF Administrative distance\n" |
| 6187 | "Intra-area routes\n" |
| 6188 | "Distance for intra-area routes\n" |
| 6189 | "Inter-area routes\n" |
| 6190 | "Distance for inter-area routes\n") |
| 6191 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6192 | struct ospf *ospf = vty->index; |
| 6193 | |
| 6194 | ospf->distance_intra = atoi (argv[0]); |
| 6195 | ospf->distance_inter = atoi (argv[1]); |
| 6196 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6197 | return CMD_SUCCESS; |
| 6198 | } |
| 6199 | |
| 6200 | DEFUN (ospf_distance_ospf_intra_external, |
| 6201 | ospf_distance_ospf_intra_external_cmd, |
| 6202 | "distance ospf intra-area <1-255> external <1-255>", |
| 6203 | "Define an administrative distance\n" |
| 6204 | "OSPF Administrative distance\n" |
| 6205 | "Intra-area routes\n" |
| 6206 | "Distance for intra-area routes\n" |
| 6207 | "External routes\n" |
| 6208 | "Distance for external routes\n") |
| 6209 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6210 | struct ospf *ospf = vty->index; |
| 6211 | |
| 6212 | ospf->distance_intra = atoi (argv[0]); |
| 6213 | ospf->distance_external = atoi (argv[1]); |
| 6214 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6215 | return CMD_SUCCESS; |
| 6216 | } |
| 6217 | |
| 6218 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6219 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6220 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6221 | "Define an administrative distance\n" |
| 6222 | "OSPF Administrative distance\n" |
| 6223 | "Intra-area routes\n" |
| 6224 | "Distance for intra-area routes\n" |
| 6225 | "Inter-area routes\n" |
| 6226 | "Distance for inter-area routes\n" |
| 6227 | "External routes\n" |
| 6228 | "Distance for external routes\n") |
| 6229 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6230 | struct ospf *ospf = vty->index; |
| 6231 | |
| 6232 | ospf->distance_intra = atoi (argv[0]); |
| 6233 | ospf->distance_inter = atoi (argv[1]); |
| 6234 | ospf->distance_external = atoi (argv[2]); |
| 6235 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6236 | return CMD_SUCCESS; |
| 6237 | } |
| 6238 | |
| 6239 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6240 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6241 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6242 | "Define an administrative distance\n" |
| 6243 | "OSPF Administrative distance\n" |
| 6244 | "Intra-area routes\n" |
| 6245 | "Distance for intra-area routes\n" |
| 6246 | "External routes\n" |
| 6247 | "Distance for external routes\n" |
| 6248 | "Inter-area routes\n" |
| 6249 | "Distance for inter-area routes\n") |
| 6250 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6251 | struct ospf *ospf = vty->index; |
| 6252 | |
| 6253 | ospf->distance_intra = atoi (argv[0]); |
| 6254 | ospf->distance_external = atoi (argv[1]); |
| 6255 | ospf->distance_inter = atoi (argv[2]); |
| 6256 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6257 | return CMD_SUCCESS; |
| 6258 | } |
| 6259 | |
| 6260 | DEFUN (ospf_distance_ospf_inter, |
| 6261 | ospf_distance_ospf_inter_cmd, |
| 6262 | "distance ospf inter-area <1-255>", |
| 6263 | "Define an administrative distance\n" |
| 6264 | "OSPF Administrative distance\n" |
| 6265 | "Inter-area routes\n" |
| 6266 | "Distance for inter-area routes\n") |
| 6267 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6268 | struct ospf *ospf = vty->index; |
| 6269 | |
| 6270 | ospf->distance_inter = atoi (argv[0]); |
| 6271 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6272 | return CMD_SUCCESS; |
| 6273 | } |
| 6274 | |
| 6275 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6276 | ospf_distance_ospf_inter_intra_cmd, |
| 6277 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6278 | "Define an administrative distance\n" |
| 6279 | "OSPF Administrative distance\n" |
| 6280 | "Inter-area routes\n" |
| 6281 | "Distance for inter-area routes\n" |
| 6282 | "Intra-area routes\n" |
| 6283 | "Distance for intra-area routes\n") |
| 6284 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6285 | struct ospf *ospf = vty->index; |
| 6286 | |
| 6287 | ospf->distance_inter = atoi (argv[0]); |
| 6288 | ospf->distance_intra = atoi (argv[1]); |
| 6289 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6290 | return CMD_SUCCESS; |
| 6291 | } |
| 6292 | |
| 6293 | DEFUN (ospf_distance_ospf_inter_external, |
| 6294 | ospf_distance_ospf_inter_external_cmd, |
| 6295 | "distance ospf inter-area <1-255> external <1-255>", |
| 6296 | "Define an administrative distance\n" |
| 6297 | "OSPF Administrative distance\n" |
| 6298 | "Inter-area routes\n" |
| 6299 | "Distance for inter-area routes\n" |
| 6300 | "External routes\n" |
| 6301 | "Distance for external routes\n") |
| 6302 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6303 | struct ospf *ospf = vty->index; |
| 6304 | |
| 6305 | ospf->distance_inter = atoi (argv[0]); |
| 6306 | ospf->distance_external = atoi (argv[1]); |
| 6307 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6308 | return CMD_SUCCESS; |
| 6309 | } |
| 6310 | |
| 6311 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6312 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6313 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6314 | "Define an administrative distance\n" |
| 6315 | "OSPF Administrative distance\n" |
| 6316 | "Inter-area routes\n" |
| 6317 | "Distance for inter-area routes\n" |
| 6318 | "Intra-area routes\n" |
| 6319 | "Distance for intra-area routes\n" |
| 6320 | "External routes\n" |
| 6321 | "Distance for external routes\n") |
| 6322 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6323 | struct ospf *ospf = vty->index; |
| 6324 | |
| 6325 | ospf->distance_inter = atoi (argv[0]); |
| 6326 | ospf->distance_intra = atoi (argv[1]); |
| 6327 | ospf->distance_external = atoi (argv[2]); |
| 6328 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6329 | return CMD_SUCCESS; |
| 6330 | } |
| 6331 | |
| 6332 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6333 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6334 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6335 | "Define an administrative distance\n" |
| 6336 | "OSPF Administrative distance\n" |
| 6337 | "Inter-area routes\n" |
| 6338 | "Distance for inter-area routes\n" |
| 6339 | "External routes\n" |
| 6340 | "Distance for external routes\n" |
| 6341 | "Intra-area routes\n" |
| 6342 | "Distance for intra-area routes\n") |
| 6343 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6344 | struct ospf *ospf = vty->index; |
| 6345 | |
| 6346 | ospf->distance_inter = atoi (argv[0]); |
| 6347 | ospf->distance_external = atoi (argv[1]); |
| 6348 | ospf->distance_intra = atoi (argv[2]); |
| 6349 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6350 | return CMD_SUCCESS; |
| 6351 | } |
| 6352 | |
| 6353 | DEFUN (ospf_distance_ospf_external, |
| 6354 | ospf_distance_ospf_external_cmd, |
| 6355 | "distance ospf external <1-255>", |
| 6356 | "Define an administrative distance\n" |
| 6357 | "OSPF Administrative distance\n" |
| 6358 | "External routes\n" |
| 6359 | "Distance for external routes\n") |
| 6360 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6361 | struct ospf *ospf = vty->index; |
| 6362 | |
| 6363 | ospf->distance_external = atoi (argv[0]); |
| 6364 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6365 | return CMD_SUCCESS; |
| 6366 | } |
| 6367 | |
| 6368 | DEFUN (ospf_distance_ospf_external_intra, |
| 6369 | ospf_distance_ospf_external_intra_cmd, |
| 6370 | "distance ospf external <1-255> intra-area <1-255>", |
| 6371 | "Define an administrative distance\n" |
| 6372 | "OSPF Administrative distance\n" |
| 6373 | "External routes\n" |
| 6374 | "Distance for external routes\n" |
| 6375 | "Intra-area routes\n" |
| 6376 | "Distance for intra-area routes\n") |
| 6377 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6378 | struct ospf *ospf = vty->index; |
| 6379 | |
| 6380 | ospf->distance_external = atoi (argv[0]); |
| 6381 | ospf->distance_intra = atoi (argv[1]); |
| 6382 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6383 | return CMD_SUCCESS; |
| 6384 | } |
| 6385 | |
| 6386 | DEFUN (ospf_distance_ospf_external_inter, |
| 6387 | ospf_distance_ospf_external_inter_cmd, |
| 6388 | "distance ospf external <1-255> inter-area <1-255>", |
| 6389 | "Define an administrative distance\n" |
| 6390 | "OSPF Administrative distance\n" |
| 6391 | "External routes\n" |
| 6392 | "Distance for external routes\n" |
| 6393 | "Inter-area routes\n" |
| 6394 | "Distance for inter-area routes\n") |
| 6395 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6396 | struct ospf *ospf = vty->index; |
| 6397 | |
| 6398 | ospf->distance_external = atoi (argv[0]); |
| 6399 | ospf->distance_inter = atoi (argv[1]); |
| 6400 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6401 | return CMD_SUCCESS; |
| 6402 | } |
| 6403 | |
| 6404 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6405 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6406 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6407 | "Define an administrative distance\n" |
| 6408 | "OSPF Administrative distance\n" |
| 6409 | "External routes\n" |
| 6410 | "Distance for external routes\n" |
| 6411 | "Intra-area routes\n" |
| 6412 | "Distance for intra-area routes\n" |
| 6413 | "Inter-area routes\n" |
| 6414 | "Distance for inter-area routes\n") |
| 6415 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6416 | struct ospf *ospf = vty->index; |
| 6417 | |
| 6418 | ospf->distance_external = atoi (argv[0]); |
| 6419 | ospf->distance_intra = atoi (argv[1]); |
| 6420 | ospf->distance_inter = atoi (argv[2]); |
| 6421 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6422 | return CMD_SUCCESS; |
| 6423 | } |
| 6424 | |
| 6425 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6426 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6427 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6428 | "Define an administrative distance\n" |
| 6429 | "OSPF Administrative distance\n" |
| 6430 | "External routes\n" |
| 6431 | "Distance for external routes\n" |
| 6432 | "Inter-area routes\n" |
| 6433 | "Distance for inter-area routes\n" |
| 6434 | "Intra-area routes\n" |
| 6435 | "Distance for intra-area routes\n") |
| 6436 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6437 | struct ospf *ospf = vty->index; |
| 6438 | |
| 6439 | ospf->distance_external = atoi (argv[0]); |
| 6440 | ospf->distance_inter = atoi (argv[1]); |
| 6441 | ospf->distance_intra = atoi (argv[2]); |
| 6442 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6443 | return CMD_SUCCESS; |
| 6444 | } |
| 6445 | |
| 6446 | DEFUN (ospf_distance_source, |
| 6447 | ospf_distance_source_cmd, |
| 6448 | "distance <1-255> A.B.C.D/M", |
| 6449 | "Administrative distance\n" |
| 6450 | "Distance value\n" |
| 6451 | "IP source prefix\n") |
| 6452 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6453 | struct ospf *ospf = vty->index; |
| 6454 | |
| 6455 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6456 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6457 | return CMD_SUCCESS; |
| 6458 | } |
| 6459 | |
| 6460 | DEFUN (no_ospf_distance_source, |
| 6461 | no_ospf_distance_source_cmd, |
| 6462 | "no distance <1-255> A.B.C.D/M", |
| 6463 | NO_STR |
| 6464 | "Administrative distance\n" |
| 6465 | "Distance value\n" |
| 6466 | "IP source prefix\n") |
| 6467 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6468 | struct ospf *ospf = vty->index; |
| 6469 | |
| 6470 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6471 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6472 | return CMD_SUCCESS; |
| 6473 | } |
| 6474 | |
| 6475 | DEFUN (ospf_distance_source_access_list, |
| 6476 | ospf_distance_source_access_list_cmd, |
| 6477 | "distance <1-255> A.B.C.D/M WORD", |
| 6478 | "Administrative distance\n" |
| 6479 | "Distance value\n" |
| 6480 | "IP source prefix\n" |
| 6481 | "Access list name\n") |
| 6482 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6483 | struct ospf *ospf = vty->index; |
| 6484 | |
| 6485 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6486 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6487 | return CMD_SUCCESS; |
| 6488 | } |
| 6489 | |
| 6490 | DEFUN (no_ospf_distance_source_access_list, |
| 6491 | no_ospf_distance_source_access_list_cmd, |
| 6492 | "no distance <1-255> A.B.C.D/M WORD", |
| 6493 | NO_STR |
| 6494 | "Administrative distance\n" |
| 6495 | "Distance value\n" |
| 6496 | "IP source prefix\n" |
| 6497 | "Access list name\n") |
| 6498 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6499 | struct ospf *ospf = vty->index; |
| 6500 | |
| 6501 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6502 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6503 | return CMD_SUCCESS; |
| 6504 | } |
| 6505 | |
| 6506 | void |
| 6507 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6508 | { |
| 6509 | struct route_node *rn; |
| 6510 | struct ospf_route *or; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6511 | struct listnode *pnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6512 | struct ospf_path *path; |
| 6513 | |
| 6514 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6515 | VTY_NEWLINE); |
| 6516 | |
| 6517 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6518 | if ((or = rn->info) != NULL) |
| 6519 | { |
| 6520 | char buf1[19]; |
| 6521 | snprintf (buf1, 19, "%s/%d", |
| 6522 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6523 | |
| 6524 | switch (or->path_type) |
| 6525 | { |
| 6526 | case OSPF_PATH_INTER_AREA: |
| 6527 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6528 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6529 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6530 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6531 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6532 | break; |
| 6533 | case OSPF_PATH_INTRA_AREA: |
| 6534 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6535 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6536 | break; |
| 6537 | default: |
| 6538 | break; |
| 6539 | } |
| 6540 | |
| 6541 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6542 | LIST_LOOP (or->paths, path, pnode) |
| 6543 | { |
| 6544 | if (path->oi != NULL) |
| 6545 | { |
| 6546 | if (path->nexthop.s_addr == 0) |
| 6547 | vty_out (vty, "%24s directly attached to %s%s", |
| 6548 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6549 | else |
| 6550 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6551 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6552 | VTY_NEWLINE); |
| 6553 | } |
| 6554 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6555 | } |
| 6556 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6557 | } |
| 6558 | |
| 6559 | void |
| 6560 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6561 | { |
| 6562 | struct route_node *rn; |
| 6563 | struct ospf_route *or; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6564 | struct listnode *pn, *nn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6565 | struct ospf_path *path; |
| 6566 | |
| 6567 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6568 | VTY_NEWLINE); |
| 6569 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6570 | if (rn->info) |
| 6571 | { |
| 6572 | int flag = 0; |
| 6573 | |
| 6574 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6575 | |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6576 | for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6577 | if ((or = getdata (nn)) != NULL) |
| 6578 | { |
| 6579 | if (flag++) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 6580 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6581 | |
| 6582 | /* Show path. */ |
| 6583 | vty_out (vty, "%s [%d] area: %s", |
| 6584 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6585 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6586 | /* Show flags. */ |
| 6587 | vty_out (vty, "%s%s%s", |
| 6588 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6589 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6590 | VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6591 | |
| 6592 | LIST_LOOP (or->paths, path, pn) |
| 6593 | { |
| 6594 | if (path->nexthop.s_addr == 0) |
| 6595 | vty_out (vty, "%24s directly attached to %s%s", |
| 6596 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6597 | else |
| 6598 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6599 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6600 | VTY_NEWLINE); |
| 6601 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6602 | } |
| 6603 | } |
| 6604 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6605 | } |
| 6606 | |
| 6607 | void |
| 6608 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6609 | { |
| 6610 | struct route_node *rn; |
| 6611 | struct ospf_route *er; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6612 | struct listnode *pnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6613 | struct ospf_path *path; |
| 6614 | |
| 6615 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6616 | VTY_NEWLINE); |
| 6617 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6618 | if ((er = rn->info) != NULL) |
| 6619 | { |
| 6620 | char buf1[19]; |
| 6621 | snprintf (buf1, 19, "%s/%d", |
| 6622 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6623 | |
| 6624 | switch (er->path_type) |
| 6625 | { |
| 6626 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6627 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6628 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6629 | break; |
| 6630 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6631 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6632 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6633 | break; |
| 6634 | } |
| 6635 | |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6636 | LIST_LOOP (er->paths, path, pnode) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6637 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6638 | if (path->oi != NULL) |
| 6639 | { |
| 6640 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6641 | vty_out (vty, "%24s directly attached to %s%s", |
| 6642 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 6643 | else |
| 6644 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6645 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 6646 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6647 | } |
| 6648 | } |
| 6649 | } |
| 6650 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6651 | } |
| 6652 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6653 | DEFUN (show_ip_ospf_border_routers, |
| 6654 | show_ip_ospf_border_routers_cmd, |
| 6655 | "show ip ospf border-routers", |
| 6656 | SHOW_STR |
| 6657 | IP_STR |
| 6658 | "show all the ABR's and ASBR's\n" |
| 6659 | "for this area\n") |
| 6660 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6661 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6662 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6663 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6664 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6665 | { |
| 6666 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6667 | return CMD_SUCCESS; |
| 6668 | } |
| 6669 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6670 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6671 | { |
| 6672 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6673 | return CMD_SUCCESS; |
| 6674 | } |
| 6675 | |
| 6676 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6677 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6678 | |
| 6679 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6680 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6681 | |
| 6682 | return CMD_SUCCESS; |
| 6683 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6684 | |
| 6685 | DEFUN (show_ip_ospf_route, |
| 6686 | show_ip_ospf_route_cmd, |
| 6687 | "show ip ospf route", |
| 6688 | SHOW_STR |
| 6689 | IP_STR |
| 6690 | "OSPF information\n" |
| 6691 | "OSPF routing table\n") |
| 6692 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6693 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6694 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6695 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6696 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6697 | { |
| 6698 | vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE); |
| 6699 | return CMD_SUCCESS; |
| 6700 | } |
| 6701 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6702 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6703 | { |
| 6704 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6705 | return CMD_SUCCESS; |
| 6706 | } |
| 6707 | |
| 6708 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6709 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6710 | |
| 6711 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6712 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6713 | |
| 6714 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6715 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6716 | |
| 6717 | return CMD_SUCCESS; |
| 6718 | } |
| 6719 | |
| 6720 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6721 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6722 | { |
| 6723 | "unknown", |
| 6724 | "standard", |
| 6725 | "ibm", |
| 6726 | "cisco", |
| 6727 | "shortcut" |
| 6728 | }; |
| 6729 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6730 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6731 | { |
| 6732 | "default", |
| 6733 | "enable", |
| 6734 | "disable" |
| 6735 | }; |
| 6736 | |
| 6737 | |
| 6738 | void |
| 6739 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6740 | { |
| 6741 | memset (buf, 0, length); |
| 6742 | |
| 6743 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6744 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6745 | else |
| 6746 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6747 | } |
| 6748 | |
| 6749 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6750 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6751 | { |
| 6752 | "unknown", /* should never be used. */ |
| 6753 | "point-to-point", |
| 6754 | "broadcast", |
| 6755 | "non-broadcast", |
| 6756 | "point-to-multipoint", |
| 6757 | "virtual-link", /* should never be used. */ |
| 6758 | "loopback" |
| 6759 | }; |
| 6760 | |
| 6761 | /* Configuration write function for ospfd. */ |
| 6762 | int |
| 6763 | config_write_interface (struct vty *vty) |
| 6764 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6765 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6766 | struct interface *ifp; |
| 6767 | struct crypt_key *ck; |
| 6768 | int write = 0; |
| 6769 | struct route_node *rn = NULL; |
| 6770 | struct ospf_if_params *params; |
| 6771 | |
| 6772 | for (n1 = listhead (iflist); n1; nextnode (n1)) |
| 6773 | { |
| 6774 | ifp = getdata (n1); |
| 6775 | |
| 6776 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6777 | continue; |
| 6778 | |
| 6779 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6780 | vty_out (vty, "interface %s%s", ifp->name, |
| 6781 | VTY_NEWLINE); |
| 6782 | if (ifp->desc) |
| 6783 | vty_out (vty, " description %s%s", ifp->desc, |
| 6784 | VTY_NEWLINE); |
| 6785 | |
| 6786 | write++; |
| 6787 | |
| 6788 | params = IF_DEF_PARAMS (ifp); |
| 6789 | |
| 6790 | do { |
| 6791 | /* Interface Network print. */ |
| 6792 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6793 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6794 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 6795 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 6796 | { |
| 6797 | vty_out (vty, " ip ospf network %s", |
| 6798 | ospf_int_type_str[params->type]); |
| 6799 | if (params != IF_DEF_PARAMS (ifp)) |
| 6800 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6801 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6802 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6803 | } |
| 6804 | |
| 6805 | /* OSPF interface authentication print */ |
| 6806 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6807 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6808 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6809 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6810 | |
| 6811 | /* Translation tables are not that much help here due to syntax |
| 6812 | of the simple option */ |
| 6813 | switch (params->auth_type) |
| 6814 | { |
| 6815 | |
| 6816 | case OSPF_AUTH_NULL: |
| 6817 | auth_str = " null"; |
| 6818 | break; |
| 6819 | |
| 6820 | case OSPF_AUTH_SIMPLE: |
| 6821 | auth_str = ""; |
| 6822 | break; |
| 6823 | |
| 6824 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6825 | auth_str = " message-digest"; |
| 6826 | break; |
| 6827 | |
| 6828 | default: |
| 6829 | auth_str = ""; |
| 6830 | break; |
| 6831 | } |
| 6832 | |
| 6833 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6834 | if (params != IF_DEF_PARAMS (ifp)) |
| 6835 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6836 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6837 | } |
| 6838 | |
| 6839 | /* Simple Authentication Password print. */ |
| 6840 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6841 | params->auth_simple[0] != '\0') |
| 6842 | { |
| 6843 | vty_out (vty, " ip ospf authentication-key %s", |
| 6844 | params->auth_simple); |
| 6845 | if (params != IF_DEF_PARAMS (ifp)) |
| 6846 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6847 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6848 | } |
| 6849 | |
| 6850 | /* Cryptographic Authentication Key print. */ |
| 6851 | for (n2 = listhead (params->auth_crypt); n2; nextnode (n2)) |
| 6852 | { |
| 6853 | ck = getdata (n2); |
| 6854 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6855 | ck->key_id, ck->auth_key); |
| 6856 | if (params != IF_DEF_PARAMS (ifp)) |
| 6857 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6858 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6859 | } |
| 6860 | |
| 6861 | /* Interface Output Cost print. */ |
| 6862 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6863 | { |
| 6864 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6865 | if (params != IF_DEF_PARAMS (ifp)) |
| 6866 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6867 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6868 | } |
| 6869 | |
| 6870 | /* Hello Interval print. */ |
| 6871 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6872 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6873 | { |
| 6874 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6875 | if (params != IF_DEF_PARAMS (ifp)) |
| 6876 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6877 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6878 | } |
| 6879 | |
| 6880 | |
| 6881 | /* Router Dead Interval print. */ |
| 6882 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6883 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6884 | { |
| 6885 | vty_out (vty, " ip ospf dead-interval %u", params->v_wait); |
| 6886 | if (params != IF_DEF_PARAMS (ifp)) |
| 6887 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6888 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6889 | } |
| 6890 | |
| 6891 | /* Router Priority print. */ |
| 6892 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 6893 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 6894 | { |
| 6895 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 6896 | if (params != IF_DEF_PARAMS (ifp)) |
| 6897 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6898 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6899 | } |
| 6900 | |
| 6901 | /* Retransmit Interval print. */ |
| 6902 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 6903 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 6904 | { |
| 6905 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 6906 | params->retransmit_interval); |
| 6907 | if (params != IF_DEF_PARAMS (ifp)) |
| 6908 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6909 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6910 | } |
| 6911 | |
| 6912 | /* Transmit Delay print. */ |
| 6913 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 6914 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 6915 | { |
| 6916 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 6917 | if (params != IF_DEF_PARAMS (ifp)) |
| 6918 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6919 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6920 | } |
| 6921 | |
| 6922 | while (1) |
| 6923 | { |
| 6924 | if (rn == NULL) |
| 6925 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 6926 | else |
| 6927 | rn = route_next (rn); |
| 6928 | |
| 6929 | if (rn == NULL) |
| 6930 | break; |
| 6931 | params = rn->info; |
| 6932 | if (params != NULL) |
| 6933 | break; |
| 6934 | } |
| 6935 | } while (rn); |
| 6936 | |
| 6937 | #ifdef HAVE_OPAQUE_LSA |
| 6938 | ospf_opaque_config_write_if (vty, ifp); |
| 6939 | #endif /* HAVE_OPAQUE_LSA */ |
| 6940 | } |
| 6941 | |
| 6942 | return write; |
| 6943 | } |
| 6944 | |
| 6945 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6946 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6947 | { |
| 6948 | struct route_node *rn; |
| 6949 | u_char buf[INET_ADDRSTRLEN]; |
| 6950 | |
| 6951 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6952 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6953 | if (rn->info) |
| 6954 | { |
| 6955 | struct ospf_network *n = rn->info; |
| 6956 | |
| 6957 | memset (buf, 0, INET_ADDRSTRLEN); |
| 6958 | |
| 6959 | /* Create Area ID string by specified Area ID format. */ |
| 6960 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 6961 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6962 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 6963 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6964 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 6965 | |
| 6966 | /* Network print. */ |
| 6967 | vty_out (vty, " network %s/%d area %s%s", |
| 6968 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 6969 | buf, VTY_NEWLINE); |
| 6970 | } |
| 6971 | |
| 6972 | return 0; |
| 6973 | } |
| 6974 | |
| 6975 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6976 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6977 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6978 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6979 | u_char buf[INET_ADDRSTRLEN]; |
| 6980 | |
| 6981 | /* Area configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6982 | for (node = listhead (ospf->areas); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6983 | { |
| 6984 | struct ospf_area *area = getdata (node); |
| 6985 | struct route_node *rn1; |
| 6986 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 6987 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6988 | |
| 6989 | if (area->auth_type != OSPF_AUTH_NULL) |
| 6990 | { |
| 6991 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 6992 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 6993 | else |
| 6994 | vty_out (vty, " area %s authentication message-digest%s", |
| 6995 | buf, VTY_NEWLINE); |
| 6996 | } |
| 6997 | |
| 6998 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 6999 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7000 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7001 | VTY_NEWLINE); |
| 7002 | |
| 7003 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7004 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7005 | ) |
| 7006 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7007 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7008 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7009 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7010 | { |
| 7011 | vty_out (vty, " area %s nssa", buf); |
| 7012 | switch (area->NSSATranslatorRole) |
| 7013 | { |
| 7014 | case OSPF_NSSA_ROLE_NEVER: |
| 7015 | vty_out (vty, " translate-never"); |
| 7016 | break; |
| 7017 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7018 | vty_out (vty, " translate-always"); |
| 7019 | break; |
| 7020 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7021 | default: |
| 7022 | vty_out (vty, " translate-candidate"); |
| 7023 | } |
| 7024 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7025 | |
| 7026 | if (area->no_summary) |
| 7027 | vty_out (vty, " no-summary"); |
| 7028 | |
| 7029 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7030 | |
| 7031 | if (area->default_cost != 1) |
| 7032 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7033 | area->default_cost, VTY_NEWLINE); |
| 7034 | } |
| 7035 | |
| 7036 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7037 | if (rn1->info) |
| 7038 | { |
| 7039 | struct ospf_area_range *range = rn1->info; |
| 7040 | |
| 7041 | vty_out (vty, " area %s range %s/%d", buf, |
| 7042 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7043 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7044 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7045 | vty_out (vty, " cost %d", range->cost_config); |
| 7046 | |
| 7047 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7048 | vty_out (vty, " not-advertise"); |
| 7049 | |
| 7050 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7051 | vty_out (vty, " substitute %s/%d", |
| 7052 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7053 | |
| 7054 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7055 | } |
| 7056 | |
| 7057 | if (EXPORT_NAME (area)) |
| 7058 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7059 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7060 | |
| 7061 | if (IMPORT_NAME (area)) |
| 7062 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7063 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7064 | |
| 7065 | if (PREFIX_NAME_IN (area)) |
| 7066 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7067 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7068 | |
| 7069 | if (PREFIX_NAME_OUT (area)) |
| 7070 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7071 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7072 | } |
| 7073 | |
| 7074 | return 0; |
| 7075 | } |
| 7076 | |
| 7077 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7078 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7079 | { |
| 7080 | struct ospf_nbr_nbma *nbr_nbma; |
| 7081 | struct route_node *rn; |
| 7082 | |
| 7083 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7084 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7085 | if ((nbr_nbma = rn->info)) |
| 7086 | { |
| 7087 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7088 | |
| 7089 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7090 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7091 | |
| 7092 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7093 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7094 | |
| 7095 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7096 | } |
| 7097 | |
| 7098 | return 0; |
| 7099 | } |
| 7100 | |
| 7101 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7102 | config_write_virtual_link (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 | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7105 | u_char buf[INET_ADDRSTRLEN]; |
| 7106 | |
| 7107 | /* Virtual-Link print */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7108 | for (node = listhead (ospf->vlinks); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7109 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7110 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7111 | struct crypt_key *ck; |
| 7112 | struct ospf_vl_data *vl_data = getdata (node); |
| 7113 | struct ospf_interface *oi; |
| 7114 | |
| 7115 | if (vl_data != NULL) |
| 7116 | { |
| 7117 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7118 | |
| 7119 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7120 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7121 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7122 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7123 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7124 | oi = vl_data->vl_oi; |
| 7125 | |
| 7126 | /* timers */ |
| 7127 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7128 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7129 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7130 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7131 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7132 | buf, |
| 7133 | inet_ntoa (vl_data->vl_peer), |
| 7134 | OSPF_IF_PARAM (oi, v_hello), |
| 7135 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7136 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7137 | OSPF_IF_PARAM (oi, v_wait), |
| 7138 | VTY_NEWLINE); |
| 7139 | else |
| 7140 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7141 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7142 | /* Auth key */ |
| 7143 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7144 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7145 | buf, |
| 7146 | inet_ntoa (vl_data->vl_peer), |
| 7147 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7148 | VTY_NEWLINE); |
| 7149 | /* md5 keys */ |
| 7150 | for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2)) |
| 7151 | { |
| 7152 | ck = getdata (n2); |
| 7153 | vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s", |
| 7154 | buf, |
| 7155 | inet_ntoa (vl_data->vl_peer), |
| 7156 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
| 7157 | } |
| 7158 | |
| 7159 | } |
| 7160 | } |
| 7161 | |
| 7162 | return 0; |
| 7163 | } |
| 7164 | |
| 7165 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7166 | const char *distribute_str[] = { "system", "kernel", "connected", "static", |
| 7167 | "rip", "ripng", "ospf", "ospf6", "isis", "bgp"}; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7168 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7169 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7170 | { |
| 7171 | int type; |
| 7172 | |
| 7173 | /* redistribute print. */ |
| 7174 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7175 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7176 | { |
| 7177 | vty_out (vty, " redistribute %s", distribute_str[type]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7178 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7179 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7180 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7181 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7182 | vty_out (vty, " metric-type 1"); |
| 7183 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7184 | if (ROUTEMAP_NAME (ospf, type)) |
| 7185 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7186 | |
| 7187 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7188 | } |
| 7189 | |
| 7190 | return 0; |
| 7191 | } |
| 7192 | |
| 7193 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7194 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7195 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7196 | if (ospf->default_metric != -1) |
| 7197 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7198 | VTY_NEWLINE); |
| 7199 | return 0; |
| 7200 | } |
| 7201 | |
| 7202 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7203 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7204 | { |
| 7205 | int type; |
| 7206 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7207 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7208 | { |
| 7209 | /* distribute-list print. */ |
| 7210 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7211 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7212 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7213 | ospf->dlist[type].name, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7214 | distribute_str[type], VTY_NEWLINE); |
| 7215 | |
| 7216 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7217 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7218 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7219 | if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7220 | vty_out (vty, " default-information originate"); |
| 7221 | else |
| 7222 | vty_out (vty, " default-information originate always"); |
| 7223 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7224 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7225 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7226 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7227 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7228 | vty_out (vty, " metric-type 1"); |
| 7229 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7230 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7231 | vty_out (vty, " route-map %s", |
| 7232 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7233 | |
| 7234 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7235 | } |
| 7236 | |
| 7237 | } |
| 7238 | |
| 7239 | return 0; |
| 7240 | } |
| 7241 | |
| 7242 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7243 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7244 | { |
| 7245 | struct route_node *rn; |
| 7246 | struct ospf_distance *odistance; |
| 7247 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7248 | if (ospf->distance_all) |
| 7249 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7250 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7251 | if (ospf->distance_intra |
| 7252 | || ospf->distance_inter |
| 7253 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7254 | { |
| 7255 | vty_out (vty, " distance ospf"); |
| 7256 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7257 | if (ospf->distance_intra) |
| 7258 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7259 | if (ospf->distance_inter) |
| 7260 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7261 | if (ospf->distance_external) |
| 7262 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7263 | |
| 7264 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7265 | } |
| 7266 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7267 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7268 | if ((odistance = rn->info) != NULL) |
| 7269 | { |
| 7270 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7271 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7272 | odistance->access_list ? odistance->access_list : "", |
| 7273 | VTY_NEWLINE); |
| 7274 | } |
| 7275 | return 0; |
| 7276 | } |
| 7277 | |
| 7278 | /* OSPF configuration write function. */ |
| 7279 | int |
| 7280 | ospf_config_write (struct vty *vty) |
| 7281 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7282 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7283 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7284 | int write = 0; |
| 7285 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7286 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7287 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7288 | { |
| 7289 | /* `router ospf' print. */ |
| 7290 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7291 | |
| 7292 | write++; |
| 7293 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7294 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7295 | return write; |
| 7296 | |
| 7297 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7298 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7299 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7300 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7301 | |
| 7302 | /* ABR type print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7303 | if (ospf->abr_type != OSPF_ABR_STAND) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7304 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7305 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7306 | |
| 7307 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7308 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7309 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7310 | |
| 7311 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7312 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7313 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7314 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7315 | |
| 7316 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7317 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
| 7318 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7319 | vty_out (vty, " timers spf %d %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7320 | ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7321 | |
| 7322 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7323 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7324 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7325 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7326 | |
| 7327 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7328 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7329 | |
| 7330 | /* passive-interface print. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7331 | for (node = listhead (om->iflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7332 | { |
| 7333 | struct interface *ifp = getdata (node); |
| 7334 | |
| 7335 | if (!ifp) |
| 7336 | continue; |
| 7337 | if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE) |
| 7338 | vty_out (vty, " passive-interface %s%s", |
| 7339 | ifp->name, VTY_NEWLINE); |
| 7340 | } |
| 7341 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7342 | for (node = listhead (ospf->oiflist); node; nextnode (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7343 | { |
| 7344 | struct ospf_interface *oi = getdata (node); |
| 7345 | |
| 7346 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) && |
| 7347 | oi->params->passive_interface == OSPF_IF_PASSIVE) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7348 | vty_out (vty, " passive-interface %s %s%s", |
| 7349 | oi->ifp->name, |
paul | 5fdc1e5 | 2003-08-06 22:41:29 +0000 | [diff] [blame] | 7350 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7351 | } |
| 7352 | |
| 7353 | |
| 7354 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7355 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7356 | |
| 7357 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7358 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7359 | |
| 7360 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7361 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7362 | |
| 7363 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7364 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7365 | |
| 7366 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7367 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7368 | |
| 7369 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7370 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7371 | |
| 7372 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7373 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7374 | |
| 7375 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7376 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7377 | #endif /* HAVE_OPAQUE_LSA */ |
| 7378 | } |
| 7379 | |
| 7380 | return write; |
| 7381 | } |
| 7382 | |
| 7383 | void |
| 7384 | ospf_vty_show_init () |
| 7385 | { |
| 7386 | /* "show ip ospf" commands. */ |
| 7387 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7388 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7389 | |
| 7390 | /* "show ip ospf database" commands. */ |
| 7391 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7392 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7393 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7394 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7395 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7396 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7397 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7398 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7399 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7400 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7401 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7402 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7403 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7404 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7405 | |
| 7406 | /* "show ip ospf interface" commands. */ |
| 7407 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7408 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7409 | |
| 7410 | /* "show ip ospf neighbor" commands. */ |
| 7411 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7412 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7413 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7414 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7415 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7416 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7417 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7418 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7419 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7420 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7421 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7422 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7423 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7424 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7425 | |
| 7426 | /* "show ip ospf route" commands. */ |
| 7427 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7428 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7429 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7430 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7431 | } |
| 7432 | |
| 7433 | |
| 7434 | /* ospfd's interface node. */ |
| 7435 | struct cmd_node interface_node = |
| 7436 | { |
| 7437 | INTERFACE_NODE, |
| 7438 | "%s(config-if)# ", |
| 7439 | 1 |
| 7440 | }; |
| 7441 | |
| 7442 | /* Initialization of OSPF interface. */ |
| 7443 | void |
| 7444 | ospf_vty_if_init () |
| 7445 | { |
| 7446 | /* Install interface node. */ |
| 7447 | install_node (&interface_node, config_write_interface); |
| 7448 | |
| 7449 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7450 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7451 | install_default (INTERFACE_NODE); |
| 7452 | |
| 7453 | /* "description" commands. */ |
| 7454 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7455 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7456 | |
| 7457 | /* "ip ospf authentication" commands. */ |
| 7458 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7459 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7460 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7461 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7462 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7463 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7464 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7465 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7466 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7467 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7468 | |
| 7469 | /* "ip ospf message-digest-key" commands. */ |
| 7470 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7471 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7472 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7473 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7474 | |
| 7475 | /* "ip ospf cost" commands. */ |
| 7476 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 7477 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 7478 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 7479 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7480 | |
| 7481 | /* "ip ospf dead-interval" commands. */ |
| 7482 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7483 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
| 7484 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7485 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
| 7486 | |
| 7487 | /* "ip ospf hello-interval" commands. */ |
| 7488 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7489 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7490 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7491 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7492 | |
| 7493 | /* "ip ospf network" commands. */ |
| 7494 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7495 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7496 | |
| 7497 | /* "ip ospf priority" commands. */ |
| 7498 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7499 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7500 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7501 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7502 | |
| 7503 | /* "ip ospf retransmit-interval" commands. */ |
| 7504 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7505 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7506 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7507 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7508 | |
| 7509 | /* "ip ospf transmit-delay" commands. */ |
| 7510 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7511 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7512 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7513 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7514 | |
| 7515 | /* These commands are compatibitliy for previous version. */ |
| 7516 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7517 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7518 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7519 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 7520 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 7521 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 7522 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7523 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7524 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7525 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7526 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7527 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7528 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7529 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7530 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7531 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7532 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7533 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7534 | } |
| 7535 | |
| 7536 | /* Zebra node structure. */ |
| 7537 | struct cmd_node zebra_node = |
| 7538 | { |
| 7539 | ZEBRA_NODE, |
| 7540 | "%s(config-router)#", |
| 7541 | }; |
| 7542 | |
| 7543 | void |
| 7544 | ospf_vty_zebra_init () |
| 7545 | { |
| 7546 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 7547 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 7548 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 7549 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 7550 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 7551 | install_element (OSPF_NODE, |
| 7552 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 7553 | install_element (OSPF_NODE, |
| 7554 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 7555 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 7556 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 7557 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 7558 | |
| 7559 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7560 | |
| 7561 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7562 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7563 | |
| 7564 | install_element (OSPF_NODE, |
| 7565 | &ospf_default_information_originate_metric_type_cmd); |
| 7566 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 7567 | install_element (OSPF_NODE, |
| 7568 | &ospf_default_information_originate_type_metric_cmd); |
| 7569 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 7570 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 7571 | install_element (OSPF_NODE, |
| 7572 | &ospf_default_information_originate_always_metric_type_cmd); |
| 7573 | install_element (OSPF_NODE, |
| 7574 | &ospf_default_information_originate_always_metric_cmd); |
| 7575 | install_element (OSPF_NODE, |
| 7576 | &ospf_default_information_originate_always_cmd); |
| 7577 | install_element (OSPF_NODE, |
| 7578 | &ospf_default_information_originate_always_type_metric_cmd); |
| 7579 | install_element (OSPF_NODE, |
| 7580 | &ospf_default_information_originate_always_type_cmd); |
| 7581 | |
| 7582 | install_element (OSPF_NODE, |
| 7583 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 7584 | install_element (OSPF_NODE, |
| 7585 | &ospf_default_information_originate_metric_routemap_cmd); |
| 7586 | install_element (OSPF_NODE, |
| 7587 | &ospf_default_information_originate_routemap_cmd); |
| 7588 | install_element (OSPF_NODE, |
| 7589 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 7590 | install_element (OSPF_NODE, |
| 7591 | &ospf_default_information_originate_type_routemap_cmd); |
| 7592 | install_element (OSPF_NODE, |
| 7593 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 7594 | install_element (OSPF_NODE, |
| 7595 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 7596 | install_element (OSPF_NODE, |
| 7597 | &ospf_default_information_originate_always_routemap_cmd); |
| 7598 | install_element (OSPF_NODE, |
| 7599 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 7600 | install_element (OSPF_NODE, |
| 7601 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 7602 | |
| 7603 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7604 | |
| 7605 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7606 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7607 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7608 | |
| 7609 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7610 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7611 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 7612 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 7613 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 7614 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 7615 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 7616 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 7617 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 7618 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 7619 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 7620 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 7621 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 7622 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 7623 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 7624 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 7625 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 7626 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 7627 | #if 0 |
| 7628 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7629 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7630 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7631 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7632 | #endif /* 0 */ |
| 7633 | } |
| 7634 | |
| 7635 | struct cmd_node ospf_node = |
| 7636 | { |
| 7637 | OSPF_NODE, |
| 7638 | "%s(config-router)# ", |
| 7639 | 1 |
| 7640 | }; |
| 7641 | |
| 7642 | |
| 7643 | /* Install OSPF related vty commands. */ |
| 7644 | void |
| 7645 | ospf_vty_init () |
| 7646 | { |
| 7647 | /* Install ospf top node. */ |
| 7648 | install_node (&ospf_node, ospf_config_write); |
| 7649 | |
| 7650 | /* "router ospf" commands. */ |
| 7651 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7652 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7653 | |
| 7654 | install_default (OSPF_NODE); |
| 7655 | |
| 7656 | /* "ospf router-id" commands. */ |
| 7657 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7658 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7659 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7660 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7661 | |
| 7662 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7663 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7664 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
| 7665 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7666 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7667 | |
| 7668 | /* "ospf abr-type" commands. */ |
| 7669 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7670 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7671 | |
| 7672 | /* "ospf rfc1583-compatible" commands. */ |
| 7673 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7674 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7675 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7676 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7677 | |
| 7678 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7679 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7680 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7681 | |
| 7682 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7683 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7684 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7685 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7686 | |
| 7687 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7688 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7689 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7690 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7691 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7692 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7693 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7694 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7695 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7696 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7697 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7698 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7699 | |
| 7700 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7701 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7702 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7703 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7704 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7705 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7706 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7707 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7708 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7709 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7710 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7711 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7712 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7713 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7714 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7715 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7716 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7717 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7718 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7719 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7720 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7721 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7722 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7723 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7724 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7725 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7726 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7727 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7728 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7729 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7730 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7731 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7732 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7733 | |
| 7734 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7735 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7736 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7737 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7738 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7739 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7740 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7741 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7742 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7743 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7744 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7745 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7746 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7747 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7748 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7749 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7750 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7751 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7752 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7753 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7754 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 7755 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7756 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7757 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 7758 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7759 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7760 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 7761 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7762 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7763 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 7764 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7765 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7766 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 7767 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7768 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7769 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7770 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 7771 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7772 | |
| 7773 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7774 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7775 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7776 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7777 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7778 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7779 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7780 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7781 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7782 | |
| 7783 | /* Init interface related vty commands. */ |
| 7784 | ospf_vty_if_init (); |
| 7785 | |
| 7786 | /* Init zebra related vty commands. */ |
| 7787 | ospf_vty_zebra_init (); |
| 7788 | } |