paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* OSPF VTY interface. |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * Copyright (C) 2000 Toshiaki Takada |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 20 | * 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "memory.h" |
| 26 | #include "thread.h" |
| 27 | #include "prefix.h" |
| 28 | #include "table.h" |
| 29 | #include "vty.h" |
| 30 | #include "command.h" |
| 31 | #include "plist.h" |
| 32 | #include "log.h" |
| 33 | #include "zclient.h" |
| 34 | |
| 35 | #include "ospfd/ospfd.h" |
| 36 | #include "ospfd/ospf_asbr.h" |
| 37 | #include "ospfd/ospf_lsa.h" |
| 38 | #include "ospfd/ospf_lsdb.h" |
| 39 | #include "ospfd/ospf_ism.h" |
| 40 | #include "ospfd/ospf_interface.h" |
| 41 | #include "ospfd/ospf_nsm.h" |
| 42 | #include "ospfd/ospf_neighbor.h" |
| 43 | #include "ospfd/ospf_flood.h" |
| 44 | #include "ospfd/ospf_abr.h" |
| 45 | #include "ospfd/ospf_spf.h" |
| 46 | #include "ospfd/ospf_route.h" |
| 47 | #include "ospfd/ospf_zebra.h" |
| 48 | /*#include "ospfd/ospf_routemap.h" */ |
| 49 | #include "ospfd/ospf_vty.h" |
| 50 | #include "ospfd/ospf_dump.h" |
| 51 | |
| 52 | |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame^] | 53 | static const char *ospf_network_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 54 | { |
| 55 | "Null", |
| 56 | "POINTOPOINT", |
| 57 | "BROADCAST", |
| 58 | "NBMA", |
| 59 | "POINTOMULTIPOINT", |
| 60 | "VIRTUALLINK", |
| 61 | "LOOPBACK" |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | /* Utility functions. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 66 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 67 | ospf_str2area_id (const char *str, struct in_addr *area_id, int *format) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | { |
| 69 | char *endptr = NULL; |
| 70 | unsigned long ret; |
| 71 | |
| 72 | /* match "A.B.C.D". */ |
| 73 | if (strchr (str, '.') != NULL) |
| 74 | { |
| 75 | ret = inet_aton (str, area_id); |
| 76 | if (!ret) |
| 77 | return -1; |
| 78 | *format = OSPF_AREA_ID_FORMAT_ADDRESS; |
| 79 | } |
| 80 | /* match "<0-4294967295>". */ |
| 81 | else |
| 82 | { |
| 83 | ret = strtoul (str, &endptr, 10); |
| 84 | if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE)) |
| 85 | return -1; |
| 86 | |
| 87 | area_id->s_addr = htonl (ret); |
| 88 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 95 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 96 | str2distribute_source (const char *str, int *source) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 97 | { |
| 98 | /* Sanity check. */ |
| 99 | if (str == NULL) |
| 100 | return 0; |
| 101 | |
| 102 | if (strncmp (str, "k", 1) == 0) |
| 103 | *source = ZEBRA_ROUTE_KERNEL; |
| 104 | else if (strncmp (str, "c", 1) == 0) |
| 105 | *source = ZEBRA_ROUTE_CONNECT; |
| 106 | else if (strncmp (str, "s", 1) == 0) |
| 107 | *source = ZEBRA_ROUTE_STATIC; |
| 108 | else if (strncmp (str, "r", 1) == 0) |
| 109 | *source = ZEBRA_ROUTE_RIP; |
| 110 | else if (strncmp (str, "b", 1) == 0) |
| 111 | *source = ZEBRA_ROUTE_BGP; |
| 112 | else |
| 113 | return 0; |
| 114 | |
| 115 | return 1; |
| 116 | } |
| 117 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 118 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 119 | str2metric (const char *str, int *metric) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 120 | { |
| 121 | /* Sanity check. */ |
| 122 | if (str == NULL) |
| 123 | return 0; |
| 124 | |
| 125 | *metric = strtol (str, NULL, 10); |
| 126 | if (*metric < 0 && *metric > 16777214) |
| 127 | { |
| 128 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | return 1; |
| 133 | } |
| 134 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 135 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 136 | str2metric_type (const char *str, int *metric_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | { |
| 138 | /* Sanity check. */ |
| 139 | if (str == NULL) |
| 140 | return 0; |
| 141 | |
| 142 | if (strncmp (str, "1", 1) == 0) |
| 143 | *metric_type = EXTERNAL_METRIC_TYPE_1; |
| 144 | else if (strncmp (str, "2", 1) == 0) |
| 145 | *metric_type = EXTERNAL_METRIC_TYPE_2; |
| 146 | else |
| 147 | return 0; |
| 148 | |
| 149 | return 1; |
| 150 | } |
| 151 | |
| 152 | int |
| 153 | ospf_oi_count (struct interface *ifp) |
| 154 | { |
| 155 | struct route_node *rn; |
| 156 | int i = 0; |
| 157 | |
| 158 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 159 | if (rn->info) |
| 160 | i++; |
| 161 | |
| 162 | return i; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | DEFUN (router_ospf, |
| 167 | router_ospf_cmd, |
| 168 | "router ospf", |
| 169 | "Enable a routing process\n" |
| 170 | "Start OSPF configuration\n") |
| 171 | { |
| 172 | vty->node = OSPF_NODE; |
| 173 | vty->index = ospf_get (); |
| 174 | |
| 175 | return CMD_SUCCESS; |
| 176 | } |
| 177 | |
| 178 | DEFUN (no_router_ospf, |
| 179 | no_router_ospf_cmd, |
| 180 | "no router ospf", |
| 181 | NO_STR |
| 182 | "Enable a routing process\n" |
| 183 | "Start OSPF configuration\n") |
| 184 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 185 | struct ospf *ospf; |
| 186 | |
| 187 | ospf = ospf_lookup (); |
| 188 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 190 | vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 191 | return CMD_WARNING; |
| 192 | } |
| 193 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 194 | ospf_finish (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 195 | |
| 196 | return CMD_SUCCESS; |
| 197 | } |
| 198 | |
| 199 | DEFUN (ospf_router_id, |
| 200 | ospf_router_id_cmd, |
| 201 | "ospf router-id A.B.C.D", |
| 202 | "OSPF specific commands\n" |
| 203 | "router-id for the OSPF process\n" |
| 204 | "OSPF router-id in IP address format\n") |
| 205 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 206 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | struct in_addr router_id; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 208 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 209 | |
| 210 | ret = inet_aton (argv[0], &router_id); |
| 211 | if (!ret) |
| 212 | { |
| 213 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); |
| 214 | return CMD_WARNING; |
| 215 | } |
| 216 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 217 | ospf->router_id_static = router_id; |
paul | b29800a | 2005-11-20 14:50:45 +0000 | [diff] [blame] | 218 | |
| 219 | ospf_router_id_update (ospf); |
| 220 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 221 | return CMD_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 225 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 226 | "router-id A.B.C.D", |
| 227 | "router-id for the OSPF process\n" |
| 228 | "OSPF router-id in IP address format\n") |
| 229 | |
| 230 | DEFUN (no_ospf_router_id, |
| 231 | no_ospf_router_id_cmd, |
| 232 | "no ospf router-id", |
| 233 | NO_STR |
| 234 | "OSPF specific commands\n" |
| 235 | "router-id for the OSPF process\n") |
| 236 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 237 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 239 | ospf->router_id_static.s_addr = 0; |
| 240 | |
| 241 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 242 | |
| 243 | return CMD_SUCCESS; |
| 244 | } |
| 245 | |
| 246 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 247 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | "no router-id", |
| 249 | NO_STR |
| 250 | "router-id for the OSPF process\n") |
| 251 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 252 | static void |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 253 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 254 | { |
| 255 | struct listnode *ln; |
| 256 | struct interface *ifp; |
| 257 | struct ospf_interface *oi; |
| 258 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 259 | ospf->passive_interface_default = newval; |
| 260 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 261 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
| 262 | { |
| 263 | if (ifp && |
| 264 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) |
| 265 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); |
| 266 | } |
| 267 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) |
| 268 | { |
| 269 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) |
| 270 | UNSET_IF_PARAM (oi->params, passive_interface); |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 271 | /* update multicast memberships */ |
| 272 | ospf_if_set_multicast(oi); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | |
| 276 | static void |
| 277 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, |
| 278 | struct in_addr addr, |
| 279 | struct ospf_if_params *params, u_char value) |
| 280 | { |
| 281 | u_char dflt; |
| 282 | |
| 283 | params->passive_interface = value; |
| 284 | if (params != IF_DEF_PARAMS (ifp)) |
| 285 | { |
| 286 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) |
| 287 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; |
| 288 | else |
| 289 | dflt = ospf->passive_interface_default; |
| 290 | |
| 291 | if (value != dflt) |
| 292 | SET_IF_PARAM (params, passive_interface); |
| 293 | else |
| 294 | UNSET_IF_PARAM (params, passive_interface); |
| 295 | |
| 296 | ospf_free_if_params (ifp, addr); |
| 297 | ospf_if_update_params (ifp, addr); |
| 298 | } |
| 299 | else |
| 300 | { |
| 301 | if (value != ospf->passive_interface_default) |
| 302 | SET_IF_PARAM (params, passive_interface); |
| 303 | else |
| 304 | UNSET_IF_PARAM (params, passive_interface); |
| 305 | } |
| 306 | } |
| 307 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 308 | DEFUN (ospf_passive_interface, |
| 309 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 310 | "passive-interface IFNAME A.B.C.D", |
| 311 | "Suppress routing updates on an interface\n" |
| 312 | "Interface's name\n") |
| 313 | { |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 314 | struct interface *ifp; |
| 315 | struct in_addr addr; |
| 316 | int ret; |
| 317 | struct ospf_if_params *params; |
| 318 | struct route_node *rn; |
| 319 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 320 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 321 | if (argc == 0) |
| 322 | { |
| 323 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); |
| 324 | return CMD_SUCCESS; |
| 325 | } |
| 326 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 327 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 328 | |
| 329 | params = IF_DEF_PARAMS (ifp); |
| 330 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 331 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 332 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 333 | ret = inet_aton(argv[1], &addr); |
| 334 | if (!ret) |
| 335 | { |
| 336 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 337 | VTY_NEWLINE); |
| 338 | return CMD_WARNING; |
| 339 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 340 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 341 | params = ospf_get_if_params (ifp, addr); |
| 342 | ospf_if_update_params (ifp, addr); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 343 | } |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 344 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); |
| 345 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 346 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 347 | * interfaces for which the passive property changed. It is too much |
| 348 | * work to determine this set, so we do this for every interface. |
| 349 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 350 | * record of joined groups to avoid systems calls if the desired |
| 351 | * memberships match the current memership. |
| 352 | */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 353 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 354 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 355 | { |
| 356 | struct ospf_interface *oi = rn->info; |
| 357 | |
| 358 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 359 | ospf_if_set_multicast(oi); |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 360 | } |
| 361 | /* |
| 362 | * XXX It is not clear what state transitions the interface needs to |
| 363 | * undergo when going from active to passive. Fixing this will |
| 364 | * require precise identification of interfaces having such a |
| 365 | * transition. |
| 366 | */ |
| 367 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 368 | return CMD_SUCCESS; |
| 369 | } |
| 370 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 371 | ALIAS (ospf_passive_interface, |
| 372 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 373 | "passive-interface IFNAME", |
| 374 | "Suppress routing updates on an interface\n" |
| 375 | "Interface's name\n") |
| 376 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 377 | ALIAS (ospf_passive_interface, |
| 378 | ospf_passive_interface_default_cmd, |
| 379 | "passive-interface default", |
| 380 | "Suppress routing updates on an interface\n" |
| 381 | "Suppress routing updates on interfaces by default\n") |
| 382 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 383 | DEFUN (no_ospf_passive_interface, |
| 384 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 385 | "no passive-interface IFNAME A.B.C.D", |
| 386 | NO_STR |
| 387 | "Allow routing updates on an interface\n" |
| 388 | "Interface's name\n") |
| 389 | { |
| 390 | struct interface *ifp; |
| 391 | struct in_addr addr; |
| 392 | struct ospf_if_params *params; |
| 393 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 394 | struct route_node *rn; |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 395 | struct ospf *ospf = vty->index; |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 396 | |
| 397 | if (argc == 0) |
| 398 | { |
| 399 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); |
| 400 | return CMD_SUCCESS; |
| 401 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 402 | |
Andrew J. Schorr | 6e72cb6 | 2006-06-18 00:45:48 +0000 | [diff] [blame] | 403 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 404 | |
| 405 | params = IF_DEF_PARAMS (ifp); |
| 406 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 407 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 408 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 409 | ret = inet_aton(argv[1], &addr); |
| 410 | if (!ret) |
| 411 | { |
| 412 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 413 | VTY_NEWLINE); |
| 414 | return CMD_WARNING; |
| 415 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 416 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 417 | params = ospf_lookup_if_params (ifp, addr); |
| 418 | if (params == NULL) |
| 419 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 420 | } |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 421 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 422 | |
| 423 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 424 | * interfaces for which the passive property changed. It is too much |
| 425 | * work to determine this set, so we do this for every interface. |
| 426 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 427 | * record of joined groups to avoid systems calls if the desired |
| 428 | * memberships match the current memership. |
| 429 | */ |
| 430 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 431 | { |
| 432 | struct ospf_interface *oi = rn->info; |
| 433 | |
| 434 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 435 | ospf_if_set_multicast(oi); |
| 436 | } |
| 437 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 438 | return CMD_SUCCESS; |
| 439 | } |
| 440 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 441 | ALIAS (no_ospf_passive_interface, |
| 442 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 443 | "no passive-interface IFNAME", |
| 444 | NO_STR |
| 445 | "Allow routing updates on an interface\n" |
| 446 | "Interface's name\n") |
| 447 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 448 | ALIAS (no_ospf_passive_interface, |
| 449 | no_ospf_passive_interface_default_cmd, |
| 450 | "no passive-interface default", |
| 451 | NO_STR |
| 452 | "Allow routing updates on an interface\n" |
| 453 | "Allow routing updates on interfaces by default\n") |
| 454 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 455 | DEFUN (ospf_network_area, |
| 456 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 457 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 458 | "Enable routing on an IP network\n" |
| 459 | "OSPF network prefix\n" |
| 460 | "Set the OSPF area ID\n" |
| 461 | "OSPF area ID in IP address format\n" |
| 462 | "OSPF area ID as a decimal value\n") |
| 463 | { |
| 464 | struct ospf *ospf= vty->index; |
| 465 | struct prefix_ipv4 p; |
| 466 | struct in_addr area_id; |
| 467 | int ret, format; |
| 468 | |
| 469 | /* Get network prefix and Area ID. */ |
| 470 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 471 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 472 | |
| 473 | ret = ospf_network_set (ospf, &p, area_id); |
| 474 | if (ret == 0) |
| 475 | { |
| 476 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 477 | return CMD_WARNING; |
| 478 | } |
| 479 | |
| 480 | return CMD_SUCCESS; |
| 481 | } |
| 482 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 483 | DEFUN (no_ospf_network_area, |
| 484 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 485 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 486 | NO_STR |
| 487 | "Enable routing on an IP network\n" |
| 488 | "OSPF network prefix\n" |
| 489 | "Set the OSPF area ID\n" |
| 490 | "OSPF area ID in IP address format\n" |
| 491 | "OSPF area ID as a decimal value\n") |
| 492 | { |
| 493 | struct ospf *ospf = (struct ospf *) vty->index; |
| 494 | struct prefix_ipv4 p; |
| 495 | struct in_addr area_id; |
| 496 | int ret, format; |
| 497 | |
| 498 | /* Get network prefix and Area ID. */ |
| 499 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 500 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 501 | |
| 502 | ret = ospf_network_unset (ospf, &p, area_id); |
| 503 | if (ret == 0) |
| 504 | { |
| 505 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 506 | VTY_NEWLINE); |
| 507 | return CMD_WARNING; |
| 508 | } |
| 509 | |
| 510 | return CMD_SUCCESS; |
| 511 | } |
| 512 | |
| 513 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 514 | DEFUN (ospf_area_range, |
| 515 | ospf_area_range_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", |
| 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 | { |
| 523 | struct ospf *ospf = vty->index; |
| 524 | struct prefix_ipv4 p; |
| 525 | struct in_addr area_id; |
| 526 | int format; |
| 527 | u_int32_t cost; |
| 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, OSPF_AREA_RANGE_ADVERTISE); |
| 533 | if (argc > 2) |
| 534 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 535 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 537 | } |
| 538 | |
| 539 | return CMD_SUCCESS; |
| 540 | } |
| 541 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 542 | ALIAS (ospf_area_range, |
| 543 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 545 | "OSPF area parameters\n" |
| 546 | "OSPF area ID in IP address format\n" |
| 547 | "OSPF area ID as a decimal value\n" |
| 548 | "OSPF area range for route advertise (default)\n" |
| 549 | "Area range prefix\n" |
| 550 | "Advertise this range (default)\n") |
| 551 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 552 | ALIAS (ospf_area_range, |
| 553 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 554 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 555 | "OSPF area parameters\n" |
| 556 | "OSPF area ID in IP address format\n" |
| 557 | "OSPF area ID as a decimal value\n" |
| 558 | "Summarize routes matching address/mask (border routers only)\n" |
| 559 | "Area range prefix\n" |
| 560 | "User specified metric for this range\n" |
| 561 | "Advertised metric for this range\n") |
| 562 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 563 | ALIAS (ospf_area_range, |
| 564 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 565 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 566 | "OSPF area parameters\n" |
| 567 | "OSPF area ID in IP address format\n" |
| 568 | "OSPF area ID as a decimal value\n" |
| 569 | "Summarize routes matching address/mask (border routers only)\n" |
| 570 | "Area range prefix\n" |
| 571 | "Advertise this range (default)\n" |
| 572 | "User specified metric for this range\n" |
| 573 | "Advertised metric for this range\n") |
| 574 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 575 | DEFUN (ospf_area_range_not_advertise, |
| 576 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 577 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 578 | "OSPF area parameters\n" |
| 579 | "OSPF area ID in IP address format\n" |
| 580 | "OSPF area ID as a decimal value\n" |
| 581 | "Summarize routes matching address/mask (border routers only)\n" |
| 582 | "Area range prefix\n" |
| 583 | "DoNotAdvertise this range\n") |
| 584 | { |
| 585 | struct ospf *ospf = vty->index; |
| 586 | struct prefix_ipv4 p; |
| 587 | struct in_addr area_id; |
| 588 | int format; |
| 589 | |
| 590 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 591 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 592 | |
| 593 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 594 | |
| 595 | return CMD_SUCCESS; |
| 596 | } |
| 597 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 598 | DEFUN (no_ospf_area_range, |
| 599 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 600 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 601 | NO_STR |
| 602 | "OSPF area parameters\n" |
| 603 | "OSPF area ID in IP address format\n" |
| 604 | "OSPF area ID as a decimal value\n" |
| 605 | "Summarize routes matching address/mask (border routers only)\n" |
| 606 | "Area range prefix\n") |
| 607 | { |
| 608 | struct ospf *ospf = vty->index; |
| 609 | struct prefix_ipv4 p; |
| 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 | |
| 616 | ospf_area_range_unset (ospf, area_id, &p); |
| 617 | |
| 618 | return CMD_SUCCESS; |
| 619 | } |
| 620 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 621 | ALIAS (no_ospf_area_range, |
| 622 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 623 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 624 | NO_STR |
| 625 | "OSPF area parameters\n" |
| 626 | "OSPF area ID in IP address format\n" |
| 627 | "OSPF area ID as a decimal value\n" |
| 628 | "Summarize routes matching address/mask (border routers only)\n" |
| 629 | "Area range prefix\n" |
| 630 | "Advertise this range (default)\n" |
| 631 | "DoNotAdvertise this range\n") |
| 632 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 633 | ALIAS (no_ospf_area_range, |
| 634 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 635 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 636 | NO_STR |
| 637 | "OSPF area parameters\n" |
| 638 | "OSPF area ID in IP address format\n" |
| 639 | "OSPF area ID as a decimal value\n" |
| 640 | "Summarize routes matching address/mask (border routers only)\n" |
| 641 | "Area range prefix\n" |
| 642 | "User specified metric for this range\n" |
| 643 | "Advertised metric for this range\n") |
| 644 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 645 | ALIAS (no_ospf_area_range, |
| 646 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 648 | NO_STR |
| 649 | "OSPF area parameters\n" |
| 650 | "OSPF area ID in IP address format\n" |
| 651 | "OSPF area ID as a decimal value\n" |
| 652 | "Summarize routes matching address/mask (border routers only)\n" |
| 653 | "Area range prefix\n" |
| 654 | "Advertise this range (default)\n" |
| 655 | "User specified metric for this range\n" |
| 656 | "Advertised metric for this range\n") |
| 657 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 658 | DEFUN (ospf_area_range_substitute, |
| 659 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 660 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 661 | "OSPF area parameters\n" |
| 662 | "OSPF area ID in IP address format\n" |
| 663 | "OSPF area ID as a decimal value\n" |
| 664 | "Summarize routes matching address/mask (border routers only)\n" |
| 665 | "Area range prefix\n" |
| 666 | "Announce area range as another prefix\n" |
| 667 | "Network prefix to be announced instead of range\n") |
| 668 | { |
| 669 | struct ospf *ospf = vty->index; |
| 670 | struct prefix_ipv4 p, s; |
| 671 | struct in_addr area_id; |
| 672 | int format; |
| 673 | |
| 674 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 675 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 676 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 677 | |
| 678 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 679 | |
| 680 | return CMD_SUCCESS; |
| 681 | } |
| 682 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 683 | DEFUN (no_ospf_area_range_substitute, |
| 684 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 685 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 686 | NO_STR |
| 687 | "OSPF area parameters\n" |
| 688 | "OSPF area ID in IP address format\n" |
| 689 | "OSPF area ID as a decimal value\n" |
| 690 | "Summarize routes matching address/mask (border routers only)\n" |
| 691 | "Area range prefix\n" |
| 692 | "Announce area range as another prefix\n" |
| 693 | "Network prefix to be announced instead of range\n") |
| 694 | { |
| 695 | struct ospf *ospf = vty->index; |
| 696 | struct prefix_ipv4 p, s; |
| 697 | struct in_addr area_id; |
| 698 | int format; |
| 699 | |
| 700 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 701 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 702 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 703 | |
| 704 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 705 | |
| 706 | return CMD_SUCCESS; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | /* Command Handler Logic in VLink stuff is delicate!! |
| 711 | |
| 712 | ALTER AT YOUR OWN RISK!!!! |
| 713 | |
| 714 | Various dummy values are used to represent 'NoChange' state for |
| 715 | VLink configuration NOT being changed by a VLink command, and |
| 716 | special syntax is used within the command strings so that the |
| 717 | typed in command verbs can be seen in the configuration command |
| 718 | bacckend handler. This is to drastically reduce the verbeage |
| 719 | required to coe up with a reasonably compatible Cisco VLink command |
| 720 | |
| 721 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 722 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 723 | */ |
| 724 | |
| 725 | |
| 726 | /* Configuration data for virtual links |
| 727 | */ |
| 728 | struct ospf_vl_config_data { |
| 729 | struct vty *vty; /* vty stuff */ |
| 730 | struct in_addr area_id; /* area ID from command line */ |
| 731 | int format; /* command line area ID format */ |
| 732 | struct in_addr vl_peer; /* command line vl_peer */ |
| 733 | int auth_type; /* Authehntication type, if given */ |
| 734 | char *auth_key; /* simple password if present */ |
| 735 | int crypto_key_id; /* Cryptographic key ID */ |
| 736 | char *md5_key; /* MD5 authentication key */ |
| 737 | int hello_interval; /* Obvious what these are... */ |
| 738 | int retransmit_interval; |
| 739 | int transmit_delay; |
| 740 | int dead_interval; |
| 741 | }; |
| 742 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 743 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 744 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 745 | struct vty *vty) |
| 746 | { |
| 747 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 748 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 749 | vl_config->vty = vty; |
| 750 | } |
| 751 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 752 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 753 | 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] | 754 | { |
| 755 | struct ospf_area *area; |
| 756 | struct ospf_vl_data *vl_data; |
| 757 | struct vty *vty; |
| 758 | struct in_addr area_id; |
| 759 | |
| 760 | vty = vl_config->vty; |
| 761 | area_id = vl_config->area_id; |
| 762 | |
| 763 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 764 | { |
| 765 | vty_out (vty, |
| 766 | "Configuring VLs over the backbone is not allowed%s", |
| 767 | VTY_NEWLINE); |
| 768 | return NULL; |
| 769 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 770 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 771 | |
| 772 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 773 | { |
| 774 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 775 | vty_out (vty, "Area %s is %s%s", |
| 776 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 777 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 778 | VTY_NEWLINE); |
| 779 | else |
| 780 | vty_out (vty, "Area %ld is %s%s", |
| 781 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 782 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 783 | VTY_NEWLINE); |
| 784 | return NULL; |
| 785 | } |
| 786 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 787 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 788 | { |
| 789 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 790 | if (vl_data->vl_oi == NULL) |
| 791 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 792 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 793 | ospf_vl_add (ospf, vl_data); |
| 794 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 795 | } |
| 796 | } |
| 797 | return vl_data; |
| 798 | } |
| 799 | |
| 800 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 801 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 802 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 803 | struct ospf_vl_config_data *vl_config) |
| 804 | { |
| 805 | struct crypt_key *ck; |
| 806 | struct vty *vty; |
| 807 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 808 | |
| 809 | vty = vl_config->vty; |
| 810 | |
| 811 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 812 | { |
| 813 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 814 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 815 | } |
| 816 | |
| 817 | if (vl_config->auth_key) |
| 818 | { |
| 819 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 820 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 821 | OSPF_AUTH_SIMPLE_SIZE); |
| 822 | } |
| 823 | else if (vl_config->md5_key) |
| 824 | { |
| 825 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 826 | != NULL) |
| 827 | { |
| 828 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 829 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 830 | return CMD_WARNING; |
| 831 | } |
| 832 | ck = ospf_crypt_key_new (); |
| 833 | ck->key_id = vl_config->crypto_key_id; |
| 834 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 835 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 836 | |
| 837 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 838 | } |
| 839 | else if (vl_config->crypto_key_id != 0) |
| 840 | { |
| 841 | /* Delete a key */ |
| 842 | |
| 843 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 844 | vl_config->crypto_key_id) == NULL) |
| 845 | { |
| 846 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 847 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 848 | return CMD_WARNING; |
| 849 | } |
| 850 | |
| 851 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 852 | |
| 853 | } |
| 854 | |
| 855 | return CMD_SUCCESS; |
| 856 | } |
| 857 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 858 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 859 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 860 | struct ospf_vl_config_data *vl_config) |
| 861 | { |
| 862 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 863 | /* Virtual Link data initialised to defaults, so only set |
| 864 | if a value given */ |
| 865 | if (vl_config->hello_interval) |
| 866 | { |
| 867 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 868 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 869 | } |
| 870 | |
| 871 | if (vl_config->dead_interval) |
| 872 | { |
| 873 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 874 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 875 | } |
| 876 | |
| 877 | if (vl_config->retransmit_interval) |
| 878 | { |
| 879 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 880 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 881 | } |
| 882 | |
| 883 | if (vl_config->transmit_delay) |
| 884 | { |
| 885 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 886 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 887 | } |
| 888 | |
| 889 | return CMD_SUCCESS; |
| 890 | } |
| 891 | |
| 892 | |
| 893 | |
| 894 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 895 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 896 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | { |
| 898 | struct ospf_vl_data *vl_data; |
| 899 | int ret; |
| 900 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 901 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 902 | if (!vl_data) |
| 903 | return CMD_WARNING; |
| 904 | |
| 905 | /* Process this one first as it can have a fatal result, which can |
| 906 | only logically occur if the virtual link exists already |
| 907 | Thus a command error does not result in a change to the |
| 908 | running configuration such as unexpectedly altered timer |
| 909 | values etc.*/ |
| 910 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 911 | if (ret != CMD_SUCCESS) |
| 912 | return ret; |
| 913 | |
| 914 | /* Set any time based parameters, these area already range checked */ |
| 915 | |
| 916 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 917 | if (ret != CMD_SUCCESS) |
| 918 | return ret; |
| 919 | |
| 920 | return CMD_SUCCESS; |
| 921 | |
| 922 | } |
| 923 | |
| 924 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 925 | */ |
| 926 | #define VLINK_HELPSTR_IPADDR \ |
| 927 | "OSPF area parameters\n" \ |
| 928 | "OSPF area ID in IP address format\n" \ |
| 929 | "OSPF area ID as a decimal value\n" \ |
| 930 | "Configure a virtual link\n" \ |
| 931 | "Router ID of the remote ABR\n" |
| 932 | |
| 933 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 934 | "Enable authentication on this virtual link\n" \ |
| 935 | "dummy string \n" |
| 936 | |
| 937 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 938 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 939 | "Use null authentication\n" \ |
| 940 | "Use message-digest authentication\n" |
| 941 | |
| 942 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 943 | "Time between HELLO packets\n" \ |
| 944 | "Time between retransmitting lost link state advertisements\n" \ |
| 945 | "Link state transmit delay\n" \ |
| 946 | "Interval after which a neighbor is declared dead\n" |
| 947 | |
| 948 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 949 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 950 | "Seconds\n" |
| 951 | |
| 952 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 953 | "Authentication password (key)\n" \ |
| 954 | "The OSPF password (key)" |
| 955 | |
| 956 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 957 | "Message digest authentication password (key)\n" \ |
| 958 | "dummy string \n" \ |
| 959 | "Key ID\n" \ |
| 960 | "Use MD5 algorithm\n" \ |
| 961 | "The OSPF password (key)" |
| 962 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 963 | DEFUN (ospf_area_vlink, |
| 964 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 965 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 966 | VLINK_HELPSTR_IPADDR) |
| 967 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 968 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | struct ospf_vl_config_data vl_config; |
| 970 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 971 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 972 | int i; |
| 973 | int ret; |
| 974 | |
| 975 | ospf_vl_config_data_init(&vl_config, vty); |
| 976 | |
| 977 | /* Read off first 2 parameters and check them */ |
| 978 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 979 | if (ret < 0) |
| 980 | { |
| 981 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 982 | return CMD_WARNING; |
| 983 | } |
| 984 | |
| 985 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 986 | if (! ret) |
| 987 | { |
| 988 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 989 | VTY_NEWLINE); |
| 990 | return CMD_WARNING; |
| 991 | } |
| 992 | |
| 993 | if (argc <=2) |
| 994 | { |
| 995 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 996 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 997 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | /* Deal with other parameters */ |
| 1001 | for (i=2; i < argc; i++) |
| 1002 | { |
| 1003 | |
| 1004 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1005 | |
| 1006 | switch (argv[i][0]) |
| 1007 | { |
| 1008 | |
| 1009 | case 'a': |
| 1010 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1011 | { |
| 1012 | /* authentication-key - this option can occur anywhere on |
| 1013 | command line. At start of command line |
| 1014 | must check for authentication option. */ |
| 1015 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1016 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 1017 | vl_config.auth_key = auth_key; |
| 1018 | i++; |
| 1019 | } |
| 1020 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1021 | { |
| 1022 | /* authentication - this option can only occur at start |
| 1023 | of command line */ |
| 1024 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 1025 | if ((i+1) < argc) |
| 1026 | { |
| 1027 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 1028 | { |
| 1029 | /* "authentication null" */ |
| 1030 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 1031 | i++; |
| 1032 | } |
| 1033 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 1034 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 1035 | { |
| 1036 | /* "authentication message-digest" */ |
| 1037 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1038 | i++; |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 | break; |
| 1043 | |
| 1044 | case 'm': |
| 1045 | /* message-digest-key */ |
| 1046 | i++; |
| 1047 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1048 | if (vl_config.crypto_key_id < 0) |
| 1049 | return CMD_WARNING; |
| 1050 | i++; |
| 1051 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 1052 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 1053 | vl_config.md5_key = md5_key; |
| 1054 | break; |
| 1055 | |
| 1056 | case 'h': |
| 1057 | /* Hello interval */ |
| 1058 | i++; |
| 1059 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 1060 | if (vl_config.hello_interval < 0) |
| 1061 | return CMD_WARNING; |
| 1062 | break; |
| 1063 | |
| 1064 | case 'r': |
| 1065 | /* Retransmit Interval */ |
| 1066 | i++; |
| 1067 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1068 | if (vl_config.retransmit_interval < 0) |
| 1069 | return CMD_WARNING; |
| 1070 | break; |
| 1071 | |
| 1072 | case 't': |
| 1073 | /* Transmit Delay */ |
| 1074 | i++; |
| 1075 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1076 | if (vl_config.transmit_delay < 0) |
| 1077 | return CMD_WARNING; |
| 1078 | break; |
| 1079 | |
| 1080 | case 'd': |
| 1081 | /* Dead Interval */ |
| 1082 | i++; |
| 1083 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1084 | if (vl_config.dead_interval < 0) |
| 1085 | return CMD_WARNING; |
| 1086 | break; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | |
| 1091 | /* Action configuration */ |
| 1092 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1093 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1094 | |
| 1095 | } |
| 1096 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1097 | DEFUN (no_ospf_area_vlink, |
| 1098 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1099 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1100 | NO_STR |
| 1101 | VLINK_HELPSTR_IPADDR) |
| 1102 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1103 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | struct ospf_area *area; |
| 1105 | struct ospf_vl_config_data vl_config; |
| 1106 | struct ospf_vl_data *vl_data = NULL; |
| 1107 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1108 | int i; |
| 1109 | int ret, format; |
| 1110 | |
| 1111 | ospf_vl_config_data_init(&vl_config, vty); |
| 1112 | |
| 1113 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1114 | if (ret < 0) |
| 1115 | { |
| 1116 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1117 | return CMD_WARNING; |
| 1118 | } |
| 1119 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1120 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1121 | if (!area) |
| 1122 | { |
| 1123 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1124 | return CMD_WARNING; |
| 1125 | } |
| 1126 | |
| 1127 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1128 | if (! ret) |
| 1129 | { |
| 1130 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1131 | VTY_NEWLINE); |
| 1132 | return CMD_WARNING; |
| 1133 | } |
| 1134 | |
| 1135 | if (argc <=2) |
| 1136 | { |
| 1137 | /* Basic VLink no command */ |
| 1138 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 1139 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1140 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1141 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1142 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1143 | |
| 1144 | return CMD_SUCCESS; |
| 1145 | } |
| 1146 | |
| 1147 | /* If we are down here, we are reseting parameters */ |
| 1148 | |
| 1149 | /* Deal with other parameters */ |
| 1150 | for (i=2; i < argc; i++) |
| 1151 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1152 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1153 | |
| 1154 | switch (argv[i][0]) |
| 1155 | { |
| 1156 | |
| 1157 | case 'a': |
| 1158 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1159 | { |
| 1160 | /* authentication-key - this option can occur anywhere on |
| 1161 | command line. At start of command line |
| 1162 | must check for authentication option. */ |
| 1163 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1164 | vl_config.auth_key = auth_key; |
| 1165 | } |
| 1166 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1167 | { |
| 1168 | /* authentication - this option can only occur at start |
| 1169 | of command line */ |
| 1170 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1171 | } |
| 1172 | break; |
| 1173 | |
| 1174 | case 'm': |
| 1175 | /* message-digest-key */ |
| 1176 | /* Delete one key */ |
| 1177 | i++; |
| 1178 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1179 | if (vl_config.crypto_key_id < 0) |
| 1180 | return CMD_WARNING; |
| 1181 | vl_config.md5_key = NULL; |
| 1182 | break; |
| 1183 | |
| 1184 | case 'h': |
| 1185 | /* Hello interval */ |
| 1186 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1187 | break; |
| 1188 | |
| 1189 | case 'r': |
| 1190 | /* Retransmit Interval */ |
| 1191 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1192 | break; |
| 1193 | |
| 1194 | case 't': |
| 1195 | /* Transmit Delay */ |
| 1196 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1197 | break; |
| 1198 | |
| 1199 | case 'd': |
| 1200 | /* Dead Interval */ |
| 1201 | i++; |
| 1202 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1203 | break; |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | |
| 1208 | /* Action configuration */ |
| 1209 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1210 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1211 | } |
| 1212 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1213 | ALIAS (ospf_area_vlink, |
| 1214 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1215 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1216 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1217 | VLINK_HELPSTR_IPADDR |
| 1218 | VLINK_HELPSTR_TIME_PARAM) |
| 1219 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1220 | ALIAS (no_ospf_area_vlink, |
| 1221 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1222 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1223 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1224 | NO_STR |
| 1225 | VLINK_HELPSTR_IPADDR |
| 1226 | VLINK_HELPSTR_TIME_PARAM) |
| 1227 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1228 | ALIAS (ospf_area_vlink, |
| 1229 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1230 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1231 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1232 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1233 | VLINK_HELPSTR_IPADDR |
| 1234 | VLINK_HELPSTR_TIME_PARAM |
| 1235 | VLINK_HELPSTR_TIME_PARAM) |
| 1236 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1237 | ALIAS (no_ospf_area_vlink, |
| 1238 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1239 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1240 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1241 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1242 | NO_STR |
| 1243 | VLINK_HELPSTR_IPADDR |
| 1244 | VLINK_HELPSTR_TIME_PARAM |
| 1245 | VLINK_HELPSTR_TIME_PARAM) |
| 1246 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1247 | ALIAS (ospf_area_vlink, |
| 1248 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1249 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1250 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1251 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1252 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1253 | VLINK_HELPSTR_IPADDR |
| 1254 | VLINK_HELPSTR_TIME_PARAM |
| 1255 | VLINK_HELPSTR_TIME_PARAM |
| 1256 | VLINK_HELPSTR_TIME_PARAM) |
| 1257 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1258 | ALIAS (no_ospf_area_vlink, |
| 1259 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1260 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1261 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1262 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1263 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1264 | NO_STR |
| 1265 | VLINK_HELPSTR_IPADDR |
| 1266 | VLINK_HELPSTR_TIME_PARAM |
| 1267 | VLINK_HELPSTR_TIME_PARAM |
| 1268 | VLINK_HELPSTR_TIME_PARAM) |
| 1269 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1270 | ALIAS (ospf_area_vlink, |
| 1271 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1272 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1273 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1274 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1275 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1276 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1277 | VLINK_HELPSTR_IPADDR |
| 1278 | VLINK_HELPSTR_TIME_PARAM |
| 1279 | VLINK_HELPSTR_TIME_PARAM |
| 1280 | VLINK_HELPSTR_TIME_PARAM |
| 1281 | VLINK_HELPSTR_TIME_PARAM) |
| 1282 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1283 | ALIAS (no_ospf_area_vlink, |
| 1284 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1285 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1286 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1287 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1288 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1289 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1290 | NO_STR |
| 1291 | VLINK_HELPSTR_IPADDR |
| 1292 | VLINK_HELPSTR_TIME_PARAM |
| 1293 | VLINK_HELPSTR_TIME_PARAM |
| 1294 | VLINK_HELPSTR_TIME_PARAM |
| 1295 | VLINK_HELPSTR_TIME_PARAM) |
| 1296 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1297 | ALIAS (ospf_area_vlink, |
| 1298 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1299 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1300 | "(authentication|) (message-digest|null)", |
| 1301 | VLINK_HELPSTR_IPADDR |
| 1302 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1303 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1304 | ALIAS (ospf_area_vlink, |
| 1305 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1306 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1307 | "(authentication|)", |
| 1308 | VLINK_HELPSTR_IPADDR |
| 1309 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1310 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1311 | ALIAS (no_ospf_area_vlink, |
| 1312 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1314 | "(authentication|)", |
| 1315 | NO_STR |
| 1316 | VLINK_HELPSTR_IPADDR |
| 1317 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1318 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1319 | ALIAS (ospf_area_vlink, |
| 1320 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1321 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1322 | "(message-digest-key|) <1-255> md5 KEY", |
| 1323 | VLINK_HELPSTR_IPADDR |
| 1324 | VLINK_HELPSTR_AUTH_MD5) |
| 1325 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1326 | ALIAS (no_ospf_area_vlink, |
| 1327 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1328 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1329 | "(message-digest-key|) <1-255>", |
| 1330 | NO_STR |
| 1331 | VLINK_HELPSTR_IPADDR |
| 1332 | VLINK_HELPSTR_AUTH_MD5) |
| 1333 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1334 | ALIAS (ospf_area_vlink, |
| 1335 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1336 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1337 | "(authentication-key|) AUTH_KEY", |
| 1338 | VLINK_HELPSTR_IPADDR |
| 1339 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1340 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1341 | ALIAS (no_ospf_area_vlink, |
| 1342 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1343 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1344 | "(authentication-key|)", |
| 1345 | NO_STR |
| 1346 | VLINK_HELPSTR_IPADDR |
| 1347 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1348 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1349 | ALIAS (ospf_area_vlink, |
| 1350 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1351 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1352 | "(authentication|) (message-digest|null) " |
| 1353 | "(authentication-key|) AUTH_KEY", |
| 1354 | VLINK_HELPSTR_IPADDR |
| 1355 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1356 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1357 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1358 | ALIAS (ospf_area_vlink, |
| 1359 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1360 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1361 | "(authentication|) " |
| 1362 | "(authentication-key|) AUTH_KEY", |
| 1363 | VLINK_HELPSTR_IPADDR |
| 1364 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1365 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1366 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1367 | ALIAS (no_ospf_area_vlink, |
| 1368 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1369 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1370 | "(authentication|) " |
| 1371 | "(authentication-key|)", |
| 1372 | NO_STR |
| 1373 | VLINK_HELPSTR_IPADDR |
| 1374 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1375 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1376 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1377 | ALIAS (ospf_area_vlink, |
| 1378 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1379 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1380 | "(authentication|) (message-digest|null) " |
| 1381 | "(message-digest-key|) <1-255> md5 KEY", |
| 1382 | VLINK_HELPSTR_IPADDR |
| 1383 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1384 | VLINK_HELPSTR_AUTH_MD5) |
| 1385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1386 | ALIAS (ospf_area_vlink, |
| 1387 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1388 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1389 | "(authentication|) " |
| 1390 | "(message-digest-key|) <1-255> md5 KEY", |
| 1391 | VLINK_HELPSTR_IPADDR |
| 1392 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1393 | VLINK_HELPSTR_AUTH_MD5) |
| 1394 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1395 | ALIAS (no_ospf_area_vlink, |
| 1396 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1397 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1398 | "(authentication|) " |
| 1399 | "(message-digest-key|)", |
| 1400 | NO_STR |
| 1401 | VLINK_HELPSTR_IPADDR |
| 1402 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1403 | VLINK_HELPSTR_AUTH_MD5) |
| 1404 | |
| 1405 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1406 | DEFUN (ospf_area_shortcut, |
| 1407 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1408 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1409 | "OSPF area parameters\n" |
| 1410 | "OSPF area ID in IP address format\n" |
| 1411 | "OSPF area ID as a decimal value\n" |
| 1412 | "Configure the area's shortcutting mode\n" |
| 1413 | "Set default shortcutting behavior\n" |
| 1414 | "Enable shortcutting through the area\n" |
| 1415 | "Disable shortcutting through the area\n") |
| 1416 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1417 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | struct ospf_area *area; |
| 1419 | struct in_addr area_id; |
| 1420 | int mode; |
| 1421 | int format; |
| 1422 | |
| 1423 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1424 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1425 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1426 | |
| 1427 | if (strncmp (argv[1], "de", 2) == 0) |
| 1428 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1429 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1430 | mode = OSPF_SHORTCUT_DISABLE; |
| 1431 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1432 | mode = OSPF_SHORTCUT_ENABLE; |
| 1433 | else |
| 1434 | return CMD_WARNING; |
| 1435 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1436 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1437 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1438 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1439 | vty_out (vty, "Shortcut area setting will take effect " |
| 1440 | "only when the router is configured as Shortcut ABR%s", |
| 1441 | VTY_NEWLINE); |
| 1442 | |
| 1443 | return CMD_SUCCESS; |
| 1444 | } |
| 1445 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1446 | DEFUN (no_ospf_area_shortcut, |
| 1447 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1448 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1449 | NO_STR |
| 1450 | "OSPF area parameters\n" |
| 1451 | "OSPF area ID in IP address format\n" |
| 1452 | "OSPF area ID as a decimal value\n" |
| 1453 | "Deconfigure the area's shortcutting mode\n" |
| 1454 | "Deconfigure enabled shortcutting through the area\n" |
| 1455 | "Deconfigure disabled shortcutting through the area\n") |
| 1456 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1457 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1458 | struct ospf_area *area; |
| 1459 | struct in_addr area_id; |
| 1460 | int format; |
| 1461 | |
| 1462 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1463 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1464 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1465 | if (!area) |
| 1466 | return CMD_SUCCESS; |
| 1467 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1468 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1469 | |
| 1470 | return CMD_SUCCESS; |
| 1471 | } |
| 1472 | |
| 1473 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1474 | DEFUN (ospf_area_stub, |
| 1475 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1476 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1477 | "OSPF area parameters\n" |
| 1478 | "OSPF area ID in IP address format\n" |
| 1479 | "OSPF area ID as a decimal value\n" |
| 1480 | "Configure OSPF area as stub\n") |
| 1481 | { |
| 1482 | struct ospf *ospf = vty->index; |
| 1483 | struct in_addr area_id; |
| 1484 | int ret, format; |
| 1485 | |
| 1486 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1487 | |
| 1488 | ret = ospf_area_stub_set (ospf, area_id); |
| 1489 | if (ret == 0) |
| 1490 | { |
| 1491 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1492 | VTY_NEWLINE); |
| 1493 | return CMD_WARNING; |
| 1494 | } |
| 1495 | |
| 1496 | ospf_area_no_summary_unset (ospf, area_id); |
| 1497 | |
| 1498 | return CMD_SUCCESS; |
| 1499 | } |
| 1500 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1501 | DEFUN (ospf_area_stub_no_summary, |
| 1502 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1503 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1504 | "OSPF stub parameters\n" |
| 1505 | "OSPF area ID in IP address format\n" |
| 1506 | "OSPF area ID as a decimal value\n" |
| 1507 | "Configure OSPF area as stub\n" |
| 1508 | "Do not inject inter-area routes into stub\n") |
| 1509 | { |
| 1510 | struct ospf *ospf = vty->index; |
| 1511 | struct in_addr area_id; |
| 1512 | int ret, format; |
| 1513 | |
| 1514 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1515 | |
| 1516 | ret = ospf_area_stub_set (ospf, area_id); |
| 1517 | if (ret == 0) |
| 1518 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1519 | 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] | 1520 | VTY_NEWLINE); |
| 1521 | return CMD_WARNING; |
| 1522 | } |
| 1523 | |
| 1524 | ospf_area_no_summary_set (ospf, area_id); |
| 1525 | |
| 1526 | return CMD_SUCCESS; |
| 1527 | } |
| 1528 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1529 | DEFUN (no_ospf_area_stub, |
| 1530 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1531 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1532 | NO_STR |
| 1533 | "OSPF area parameters\n" |
| 1534 | "OSPF area ID in IP address format\n" |
| 1535 | "OSPF area ID as a decimal value\n" |
| 1536 | "Configure OSPF area as stub\n") |
| 1537 | { |
| 1538 | struct ospf *ospf = vty->index; |
| 1539 | struct in_addr area_id; |
| 1540 | int format; |
| 1541 | |
| 1542 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1543 | |
| 1544 | ospf_area_stub_unset (ospf, area_id); |
| 1545 | ospf_area_no_summary_unset (ospf, area_id); |
| 1546 | |
| 1547 | return CMD_SUCCESS; |
| 1548 | } |
| 1549 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1550 | DEFUN (no_ospf_area_stub_no_summary, |
| 1551 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1552 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1553 | NO_STR |
| 1554 | "OSPF area parameters\n" |
| 1555 | "OSPF area ID in IP address format\n" |
| 1556 | "OSPF area ID as a decimal value\n" |
| 1557 | "Configure OSPF area as stub\n" |
| 1558 | "Do not inject inter-area routes into area\n") |
| 1559 | { |
| 1560 | struct ospf *ospf = vty->index; |
| 1561 | struct in_addr area_id; |
| 1562 | int format; |
| 1563 | |
| 1564 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1565 | ospf_area_no_summary_unset (ospf, area_id); |
| 1566 | |
| 1567 | return CMD_SUCCESS; |
| 1568 | } |
| 1569 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1570 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1571 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1572 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1573 | { |
| 1574 | struct ospf *ospf = vty->index; |
| 1575 | struct in_addr area_id; |
| 1576 | int ret, format; |
| 1577 | |
| 1578 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1579 | |
| 1580 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1581 | if (ret == 0) |
| 1582 | { |
| 1583 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1584 | VTY_NEWLINE); |
| 1585 | return CMD_WARNING; |
| 1586 | } |
| 1587 | |
| 1588 | if (argc > 1) |
| 1589 | { |
| 1590 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1591 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1592 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1593 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1594 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1595 | OSPF_NSSA_ROLE_NEVER); |
| 1596 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1597 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | OSPF_NSSA_ROLE_ALWAYS); |
| 1599 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1600 | else |
| 1601 | { |
| 1602 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1603 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1604 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1605 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1606 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1607 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1608 | else |
| 1609 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1610 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1611 | ospf_schedule_abr_task (ospf); |
| 1612 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1613 | return CMD_SUCCESS; |
| 1614 | } |
| 1615 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1616 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1617 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1618 | "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] | 1619 | "OSPF area parameters\n" |
| 1620 | "OSPF area ID in IP address format\n" |
| 1621 | "OSPF area ID as a decimal value\n" |
| 1622 | "Configure OSPF area as nssa\n" |
| 1623 | "Configure NSSA-ABR for translate election (default)\n" |
| 1624 | "Configure NSSA-ABR to never translate\n" |
| 1625 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1626 | "Do not inject inter-area routes into nssa\n") |
| 1627 | { |
| 1628 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1629 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1630 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1631 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1632 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1633 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1634 | "OSPF area parameters\n" |
| 1635 | "OSPF area ID in IP address format\n" |
| 1636 | "OSPF area ID as a decimal value\n" |
| 1637 | "Configure OSPF area as nssa\n" |
| 1638 | "Configure NSSA-ABR for translate election (default)\n" |
| 1639 | "Configure NSSA-ABR to never translate\n" |
| 1640 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1641 | { |
| 1642 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1643 | } |
| 1644 | |
| 1645 | DEFUN (ospf_area_nssa, |
| 1646 | ospf_area_nssa_cmd, |
| 1647 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1648 | "OSPF area parameters\n" |
| 1649 | "OSPF area ID in IP address format\n" |
| 1650 | "OSPF area ID as a decimal value\n" |
| 1651 | "Configure OSPF area as nssa\n") |
| 1652 | { |
| 1653 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1654 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1655 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1656 | DEFUN (ospf_area_nssa_no_summary, |
| 1657 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1658 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1659 | "OSPF area parameters\n" |
| 1660 | "OSPF area ID in IP address format\n" |
| 1661 | "OSPF area ID as a decimal value\n" |
| 1662 | "Configure OSPF area as nssa\n" |
| 1663 | "Do not inject inter-area routes into nssa\n") |
| 1664 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1665 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1666 | } |
| 1667 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1668 | DEFUN (no_ospf_area_nssa, |
| 1669 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1670 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1671 | NO_STR |
| 1672 | "OSPF area parameters\n" |
| 1673 | "OSPF area ID in IP address format\n" |
| 1674 | "OSPF area ID as a decimal value\n" |
| 1675 | "Configure OSPF area as nssa\n") |
| 1676 | { |
| 1677 | struct ospf *ospf = vty->index; |
| 1678 | struct in_addr area_id; |
| 1679 | int format; |
| 1680 | |
| 1681 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1682 | |
| 1683 | ospf_area_nssa_unset (ospf, area_id); |
| 1684 | ospf_area_no_summary_unset (ospf, area_id); |
| 1685 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1686 | ospf_schedule_abr_task (ospf); |
| 1687 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1688 | return CMD_SUCCESS; |
| 1689 | } |
| 1690 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1691 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1692 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1693 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1694 | NO_STR |
| 1695 | "OSPF area parameters\n" |
| 1696 | "OSPF area ID in IP address format\n" |
| 1697 | "OSPF area ID as a decimal value\n" |
| 1698 | "Configure OSPF area as nssa\n" |
| 1699 | "Do not inject inter-area routes into nssa\n") |
| 1700 | { |
| 1701 | struct ospf *ospf = vty->index; |
| 1702 | struct in_addr area_id; |
| 1703 | int format; |
| 1704 | |
| 1705 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1706 | ospf_area_no_summary_unset (ospf, area_id); |
| 1707 | |
| 1708 | return CMD_SUCCESS; |
| 1709 | } |
| 1710 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1711 | DEFUN (ospf_area_default_cost, |
| 1712 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1713 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1714 | "OSPF area parameters\n" |
| 1715 | "OSPF area ID in IP address format\n" |
| 1716 | "OSPF area ID as a decimal value\n" |
| 1717 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1718 | "Stub's advertised default summary cost\n") |
| 1719 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1720 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1721 | struct ospf_area *area; |
| 1722 | struct in_addr area_id; |
| 1723 | u_int32_t cost; |
| 1724 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1725 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1726 | |
| 1727 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1728 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1729 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1730 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1731 | |
| 1732 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1733 | { |
| 1734 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1735 | return CMD_WARNING; |
| 1736 | } |
| 1737 | |
| 1738 | area->default_cost = cost; |
| 1739 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1740 | p.family = AF_INET; |
| 1741 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1742 | p.prefixlen = 0; |
| 1743 | if (IS_DEBUG_OSPF_EVENT) |
| 1744 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1745 | "announcing 0.0.0.0/0 to area %s", |
| 1746 | inet_ntoa (area->area_id)); |
| 1747 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1748 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1749 | return CMD_SUCCESS; |
| 1750 | } |
| 1751 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1752 | DEFUN (no_ospf_area_default_cost, |
| 1753 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1754 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1755 | NO_STR |
| 1756 | "OSPF area parameters\n" |
| 1757 | "OSPF area ID in IP address format\n" |
| 1758 | "OSPF area ID as a decimal value\n" |
| 1759 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1760 | "Stub's advertised default summary cost\n") |
| 1761 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1762 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1763 | struct ospf_area *area; |
| 1764 | struct in_addr area_id; |
| 1765 | u_int32_t cost; |
| 1766 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1767 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1768 | |
| 1769 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1770 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1771 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1772 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1773 | if (area == NULL) |
| 1774 | return CMD_SUCCESS; |
| 1775 | |
| 1776 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1777 | { |
| 1778 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1779 | return CMD_WARNING; |
| 1780 | } |
| 1781 | |
| 1782 | area->default_cost = 1; |
| 1783 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1784 | p.family = AF_INET; |
| 1785 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1786 | p.prefixlen = 0; |
| 1787 | if (IS_DEBUG_OSPF_EVENT) |
| 1788 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1789 | "announcing 0.0.0.0/0 to area %s", |
| 1790 | inet_ntoa (area->area_id)); |
| 1791 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1792 | |
| 1793 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1794 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1795 | |
| 1796 | return CMD_SUCCESS; |
| 1797 | } |
| 1798 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1799 | DEFUN (ospf_area_export_list, |
| 1800 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1801 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1802 | "OSPF area parameters\n" |
| 1803 | "OSPF area ID in IP address format\n" |
| 1804 | "OSPF area ID as a decimal value\n" |
| 1805 | "Set the filter for networks announced to other areas\n" |
| 1806 | "Name of the access-list\n") |
| 1807 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1808 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1809 | struct ospf_area *area; |
| 1810 | struct in_addr area_id; |
| 1811 | int format; |
| 1812 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1813 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1814 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1815 | area = ospf_area_get (ospf, area_id, format); |
| 1816 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1817 | |
| 1818 | return CMD_SUCCESS; |
| 1819 | } |
| 1820 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1821 | DEFUN (no_ospf_area_export_list, |
| 1822 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1823 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1824 | NO_STR |
| 1825 | "OSPF area parameters\n" |
| 1826 | "OSPF area ID in IP address format\n" |
| 1827 | "OSPF area ID as a decimal value\n" |
| 1828 | "Unset the filter for networks announced to other areas\n" |
| 1829 | "Name of the access-list\n") |
| 1830 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1831 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1832 | struct ospf_area *area; |
| 1833 | struct in_addr area_id; |
| 1834 | int format; |
| 1835 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1836 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1837 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1838 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1839 | if (area == NULL) |
| 1840 | return CMD_SUCCESS; |
| 1841 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1842 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | |
| 1844 | return CMD_SUCCESS; |
| 1845 | } |
| 1846 | |
| 1847 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1848 | DEFUN (ospf_area_import_list, |
| 1849 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1850 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1851 | "OSPF area parameters\n" |
| 1852 | "OSPF area ID in IP address format\n" |
| 1853 | "OSPF area ID as a decimal value\n" |
| 1854 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1855 | "Name of the access-list\n") |
| 1856 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1857 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1858 | struct ospf_area *area; |
| 1859 | struct in_addr area_id; |
| 1860 | int format; |
| 1861 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1862 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1863 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1864 | area = ospf_area_get (ospf, area_id, format); |
| 1865 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1866 | |
| 1867 | return CMD_SUCCESS; |
| 1868 | } |
| 1869 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1870 | DEFUN (no_ospf_area_import_list, |
| 1871 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1872 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1873 | NO_STR |
| 1874 | "OSPF area parameters\n" |
| 1875 | "OSPF area ID in IP address format\n" |
| 1876 | "OSPF area ID as a decimal value\n" |
| 1877 | "Unset the filter for networks announced to other areas\n" |
| 1878 | "Name of the access-list\n") |
| 1879 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1880 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1881 | struct ospf_area *area; |
| 1882 | struct in_addr area_id; |
| 1883 | int format; |
| 1884 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1885 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1886 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1887 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1888 | if (area == NULL) |
| 1889 | return CMD_SUCCESS; |
| 1890 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1891 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1892 | |
| 1893 | return CMD_SUCCESS; |
| 1894 | } |
| 1895 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1896 | DEFUN (ospf_area_filter_list, |
| 1897 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1898 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1899 | "OSPF area parameters\n" |
| 1900 | "OSPF area ID in IP address format\n" |
| 1901 | "OSPF area ID as a decimal value\n" |
| 1902 | "Filter networks between OSPF areas\n" |
| 1903 | "Filter prefixes between OSPF areas\n" |
| 1904 | "Name of an IP prefix-list\n" |
| 1905 | "Filter networks sent to this area\n" |
| 1906 | "Filter networks sent from this area\n") |
| 1907 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1908 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1909 | struct ospf_area *area; |
| 1910 | struct in_addr area_id; |
| 1911 | struct prefix_list *plist; |
| 1912 | int format; |
| 1913 | |
| 1914 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1915 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1916 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1917 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1918 | if (strncmp (argv[2], "in", 2) == 0) |
| 1919 | { |
| 1920 | PREFIX_LIST_IN (area) = plist; |
| 1921 | if (PREFIX_NAME_IN (area)) |
| 1922 | free (PREFIX_NAME_IN (area)); |
| 1923 | |
| 1924 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1925 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1926 | } |
| 1927 | else |
| 1928 | { |
| 1929 | PREFIX_LIST_OUT (area) = plist; |
| 1930 | if (PREFIX_NAME_OUT (area)) |
| 1931 | free (PREFIX_NAME_OUT (area)); |
| 1932 | |
| 1933 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1934 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1935 | } |
| 1936 | |
| 1937 | return CMD_SUCCESS; |
| 1938 | } |
| 1939 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1940 | DEFUN (no_ospf_area_filter_list, |
| 1941 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1942 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1943 | NO_STR |
| 1944 | "OSPF area parameters\n" |
| 1945 | "OSPF area ID in IP address format\n" |
| 1946 | "OSPF area ID as a decimal value\n" |
| 1947 | "Filter networks between OSPF areas\n" |
| 1948 | "Filter prefixes between OSPF areas\n" |
| 1949 | "Name of an IP prefix-list\n" |
| 1950 | "Filter networks sent to this area\n" |
| 1951 | "Filter networks sent from this area\n") |
| 1952 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1953 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1954 | struct ospf_area *area; |
| 1955 | struct in_addr area_id; |
| 1956 | struct prefix_list *plist; |
| 1957 | int format; |
| 1958 | |
| 1959 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1960 | |
Paul Jakma | 1a8ec2b | 2006-05-11 13:34:08 +0000 | [diff] [blame] | 1961 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
| 1962 | return CMD_SUCCESS; |
| 1963 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1964 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1965 | if (strncmp (argv[2], "in", 2) == 0) |
| 1966 | { |
| 1967 | if (PREFIX_NAME_IN (area)) |
| 1968 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1969 | return CMD_SUCCESS; |
| 1970 | |
| 1971 | PREFIX_LIST_IN (area) = NULL; |
| 1972 | if (PREFIX_NAME_IN (area)) |
| 1973 | free (PREFIX_NAME_IN (area)); |
| 1974 | |
| 1975 | PREFIX_NAME_IN (area) = NULL; |
| 1976 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1977 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1978 | } |
| 1979 | else |
| 1980 | { |
| 1981 | if (PREFIX_NAME_OUT (area)) |
| 1982 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1983 | return CMD_SUCCESS; |
| 1984 | |
| 1985 | PREFIX_LIST_OUT (area) = NULL; |
| 1986 | if (PREFIX_NAME_OUT (area)) |
| 1987 | free (PREFIX_NAME_OUT (area)); |
| 1988 | |
| 1989 | PREFIX_NAME_OUT (area) = NULL; |
| 1990 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1991 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1992 | } |
| 1993 | |
| 1994 | return CMD_SUCCESS; |
| 1995 | } |
| 1996 | |
| 1997 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1998 | DEFUN (ospf_area_authentication_message_digest, |
| 1999 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2000 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 2001 | "OSPF area parameters\n" |
| 2002 | "Enable authentication\n" |
| 2003 | "Use message-digest authentication\n") |
| 2004 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2005 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2006 | struct ospf_area *area; |
| 2007 | struct in_addr area_id; |
| 2008 | int format; |
| 2009 | |
| 2010 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2011 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2012 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2013 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 2014 | |
| 2015 | return CMD_SUCCESS; |
| 2016 | } |
| 2017 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2018 | DEFUN (ospf_area_authentication, |
| 2019 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2020 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 2021 | "OSPF area parameters\n" |
| 2022 | "OSPF area ID in IP address format\n" |
| 2023 | "OSPF area ID as a decimal value\n" |
| 2024 | "Enable authentication\n") |
| 2025 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2026 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2027 | struct ospf_area *area; |
| 2028 | struct in_addr area_id; |
| 2029 | int format; |
| 2030 | |
| 2031 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2032 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2033 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2034 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 2035 | |
| 2036 | return CMD_SUCCESS; |
| 2037 | } |
| 2038 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2039 | DEFUN (no_ospf_area_authentication, |
| 2040 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2041 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 2042 | NO_STR |
| 2043 | "OSPF area parameters\n" |
| 2044 | "OSPF area ID in IP address format\n" |
| 2045 | "OSPF area ID as a decimal value\n" |
| 2046 | "Enable authentication\n") |
| 2047 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2048 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2049 | struct ospf_area *area; |
| 2050 | struct in_addr area_id; |
| 2051 | int format; |
| 2052 | |
| 2053 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2054 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2055 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2056 | if (area == NULL) |
| 2057 | return CMD_SUCCESS; |
| 2058 | |
| 2059 | area->auth_type = OSPF_AUTH_NULL; |
| 2060 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2061 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2062 | |
| 2063 | return CMD_SUCCESS; |
| 2064 | } |
| 2065 | |
| 2066 | |
| 2067 | DEFUN (ospf_abr_type, |
| 2068 | ospf_abr_type_cmd, |
| 2069 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 2070 | "OSPF specific commands\n" |
| 2071 | "Set OSPF ABR type\n" |
| 2072 | "Alternative ABR, cisco implementation\n" |
| 2073 | "Alternative ABR, IBM implementation\n" |
| 2074 | "Shortcut ABR\n" |
| 2075 | "Standard behavior (RFC2328)\n") |
| 2076 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2077 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2078 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2079 | |
| 2080 | if (strncmp (argv[0], "c", 1) == 0) |
| 2081 | abr_type = OSPF_ABR_CISCO; |
| 2082 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2083 | abr_type = OSPF_ABR_IBM; |
| 2084 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2085 | abr_type = OSPF_ABR_SHORTCUT; |
| 2086 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2087 | abr_type = OSPF_ABR_STAND; |
| 2088 | else |
| 2089 | return CMD_WARNING; |
| 2090 | |
| 2091 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2092 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2093 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2094 | ospf->abr_type = abr_type; |
| 2095 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2096 | } |
| 2097 | |
| 2098 | return CMD_SUCCESS; |
| 2099 | } |
| 2100 | |
| 2101 | DEFUN (no_ospf_abr_type, |
| 2102 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2103 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2104 | NO_STR |
| 2105 | "OSPF specific commands\n" |
| 2106 | "Set OSPF ABR type\n" |
| 2107 | "Alternative ABR, cisco implementation\n" |
| 2108 | "Alternative ABR, IBM implementation\n" |
| 2109 | "Shortcut ABR\n") |
| 2110 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2111 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2112 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2113 | |
| 2114 | if (strncmp (argv[0], "c", 1) == 0) |
| 2115 | abr_type = OSPF_ABR_CISCO; |
| 2116 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2117 | abr_type = OSPF_ABR_IBM; |
| 2118 | else if (strncmp (argv[0], "s", 1) == 0) |
| 2119 | abr_type = OSPF_ABR_SHORTCUT; |
| 2120 | else |
| 2121 | return CMD_WARNING; |
| 2122 | |
| 2123 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2124 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2125 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2126 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2127 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | } |
| 2129 | |
| 2130 | return CMD_SUCCESS; |
| 2131 | } |
| 2132 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2133 | DEFUN (ospf_log_adjacency_changes, |
| 2134 | ospf_log_adjacency_changes_cmd, |
| 2135 | "log-adjacency-changes", |
| 2136 | "Log changes in adjacency state\n") |
| 2137 | { |
| 2138 | struct ospf *ospf = vty->index; |
| 2139 | |
| 2140 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2141 | return CMD_SUCCESS; |
| 2142 | } |
| 2143 | |
| 2144 | DEFUN (ospf_log_adjacency_changes_detail, |
| 2145 | ospf_log_adjacency_changes_detail_cmd, |
| 2146 | "log-adjacency-changes detail", |
| 2147 | "Log changes in adjacency state\n" |
| 2148 | "Log all state changes\n") |
| 2149 | { |
| 2150 | struct ospf *ospf = vty->index; |
| 2151 | |
| 2152 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2153 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2154 | return CMD_SUCCESS; |
| 2155 | } |
| 2156 | |
| 2157 | DEFUN (no_ospf_log_adjacency_changes, |
| 2158 | no_ospf_log_adjacency_changes_cmd, |
| 2159 | "no log-adjacency-changes", |
| 2160 | NO_STR |
| 2161 | "Log changes in adjacency state\n") |
| 2162 | { |
| 2163 | struct ospf *ospf = vty->index; |
| 2164 | |
| 2165 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2166 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2167 | return CMD_SUCCESS; |
| 2168 | } |
| 2169 | |
| 2170 | DEFUN (no_ospf_log_adjacency_changes_detail, |
| 2171 | no_ospf_log_adjacency_changes_detail_cmd, |
| 2172 | "no log-adjacency-changes detail", |
| 2173 | NO_STR |
| 2174 | "Log changes in adjacency state\n" |
| 2175 | "Log all state changes\n") |
| 2176 | { |
| 2177 | struct ospf *ospf = vty->index; |
| 2178 | |
| 2179 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2180 | return CMD_SUCCESS; |
| 2181 | } |
| 2182 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2183 | DEFUN (ospf_compatible_rfc1583, |
| 2184 | ospf_compatible_rfc1583_cmd, |
| 2185 | "compatible rfc1583", |
| 2186 | "OSPF compatibility list\n" |
| 2187 | "compatible with RFC 1583\n") |
| 2188 | { |
| 2189 | struct ospf *ospf = vty->index; |
| 2190 | |
| 2191 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2192 | { |
| 2193 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2194 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | } |
| 2196 | return CMD_SUCCESS; |
| 2197 | } |
| 2198 | |
| 2199 | DEFUN (no_ospf_compatible_rfc1583, |
| 2200 | no_ospf_compatible_rfc1583_cmd, |
| 2201 | "no compatible rfc1583", |
| 2202 | NO_STR |
| 2203 | "OSPF compatibility list\n" |
| 2204 | "compatible with RFC 1583\n") |
| 2205 | { |
| 2206 | struct ospf *ospf = vty->index; |
| 2207 | |
| 2208 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2209 | { |
| 2210 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2211 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2212 | } |
| 2213 | return CMD_SUCCESS; |
| 2214 | } |
| 2215 | |
| 2216 | ALIAS (ospf_compatible_rfc1583, |
| 2217 | ospf_rfc1583_flag_cmd, |
| 2218 | "ospf rfc1583compatibility", |
| 2219 | "OSPF specific commands\n" |
| 2220 | "Enable the RFC1583Compatibility flag\n") |
| 2221 | |
| 2222 | ALIAS (no_ospf_compatible_rfc1583, |
| 2223 | no_ospf_rfc1583_flag_cmd, |
| 2224 | "no ospf rfc1583compatibility", |
| 2225 | NO_STR |
| 2226 | "OSPF specific commands\n" |
| 2227 | "Disable the RFC1583Compatibility flag\n") |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2228 | |
| 2229 | static int |
| 2230 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2231 | unsigned int hold, |
| 2232 | unsigned int max) |
| 2233 | { |
| 2234 | struct ospf *ospf = vty->index; |
| 2235 | |
| 2236 | ospf->spf_delay = delay; |
| 2237 | ospf->spf_holdtime = hold; |
| 2238 | ospf->spf_max_holdtime = max; |
| 2239 | |
| 2240 | return CMD_SUCCESS; |
| 2241 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2243 | DEFUN (ospf_timers_throttle_spf, |
| 2244 | ospf_timers_throttle_spf_cmd, |
| 2245 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2246 | "Adjust routing timers\n" |
| 2247 | "Throttling adaptive timer\n" |
| 2248 | "OSPF SPF timers\n" |
| 2249 | "Delay (msec) from first change received till SPF calculation\n" |
| 2250 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2251 | "Maximum hold time (msec)\n") |
| 2252 | { |
| 2253 | unsigned int delay, hold, max; |
| 2254 | |
| 2255 | if (argc != 3) |
| 2256 | { |
| 2257 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2258 | return CMD_WARNING; |
| 2259 | } |
| 2260 | |
| 2261 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2262 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2263 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2264 | |
| 2265 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2266 | } |
| 2267 | |
| 2268 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2269 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | "timers spf <0-4294967295> <0-4294967295>", |
| 2271 | "Adjust routing timers\n" |
| 2272 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2273 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2274 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2275 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2276 | unsigned int delay, hold; |
| 2277 | |
| 2278 | if (argc != 2) |
| 2279 | { |
| 2280 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2281 | return CMD_WARNING; |
| 2282 | } |
| 2283 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2284 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2285 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2286 | |
| 2287 | /* truncate down the second values if they're greater than 600000ms */ |
| 2288 | if (delay > (600000 / 1000)) |
| 2289 | delay = 600000; |
| 2290 | else if (delay == 0) |
| 2291 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2292 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2293 | if (hold > (600000 / 1000)) |
| 2294 | hold = 600000; |
| 2295 | |
| 2296 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2297 | } |
| 2298 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2299 | DEFUN (no_ospf_timers_throttle_spf, |
| 2300 | no_ospf_timers_throttle_spf_cmd, |
| 2301 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2302 | NO_STR |
| 2303 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2304 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2305 | "OSPF SPF timers\n") |
| 2306 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2307 | return ospf_timers_spf_set (vty, |
| 2308 | OSPF_SPF_DELAY_DEFAULT, |
| 2309 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2310 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2313 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2314 | no_ospf_timers_spf_cmd, |
| 2315 | "no timers spf", |
| 2316 | NO_STR |
| 2317 | "Adjust routing timers\n" |
| 2318 | "OSPF SPF timers\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2319 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2320 | DEFUN (ospf_neighbor, |
| 2321 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2322 | "neighbor A.B.C.D", |
| 2323 | NEIGHBOR_STR |
| 2324 | "Neighbor IP address\n") |
| 2325 | { |
| 2326 | struct ospf *ospf = vty->index; |
| 2327 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2328 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2329 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2330 | |
| 2331 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2332 | |
| 2333 | if (argc > 1) |
| 2334 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2335 | |
| 2336 | if (argc > 2) |
| 2337 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2338 | |
| 2339 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2340 | if (argc > 1) |
| 2341 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2342 | if (argc > 2) |
| 2343 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority); |
| 2344 | |
| 2345 | return CMD_SUCCESS; |
| 2346 | } |
| 2347 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2348 | ALIAS (ospf_neighbor, |
| 2349 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2350 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2351 | NEIGHBOR_STR |
| 2352 | "Neighbor IP address\n" |
| 2353 | "Neighbor Priority\n" |
| 2354 | "Priority\n" |
| 2355 | "Dead Neighbor Polling interval\n" |
| 2356 | "Seconds\n") |
| 2357 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2358 | ALIAS (ospf_neighbor, |
| 2359 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2360 | "neighbor A.B.C.D priority <0-255>", |
| 2361 | NEIGHBOR_STR |
| 2362 | "Neighbor IP address\n" |
| 2363 | "Neighbor Priority\n" |
| 2364 | "Seconds\n") |
| 2365 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2366 | DEFUN (ospf_neighbor_poll_interval, |
| 2367 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2368 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2369 | NEIGHBOR_STR |
| 2370 | "Neighbor IP address\n" |
| 2371 | "Dead Neighbor Polling interval\n" |
| 2372 | "Seconds\n") |
| 2373 | { |
| 2374 | struct ospf *ospf = vty->index; |
| 2375 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2376 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2377 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2378 | |
| 2379 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2380 | |
| 2381 | if (argc > 1) |
| 2382 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2383 | |
| 2384 | if (argc > 2) |
| 2385 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2386 | |
| 2387 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2388 | if (argc > 1) |
| 2389 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2390 | if (argc > 2) |
| 2391 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2392 | |
| 2393 | return CMD_SUCCESS; |
| 2394 | } |
| 2395 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2396 | ALIAS (ospf_neighbor_poll_interval, |
| 2397 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2398 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2399 | NEIGHBOR_STR |
| 2400 | "Neighbor address\n" |
| 2401 | "OSPF dead-router polling interval\n" |
| 2402 | "Seconds\n" |
| 2403 | "OSPF priority of non-broadcast neighbor\n" |
| 2404 | "Priority\n") |
| 2405 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2406 | DEFUN (no_ospf_neighbor, |
| 2407 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2408 | "no neighbor A.B.C.D", |
| 2409 | NO_STR |
| 2410 | NEIGHBOR_STR |
| 2411 | "Neighbor IP address\n") |
| 2412 | { |
| 2413 | struct ospf *ospf = vty->index; |
| 2414 | struct in_addr nbr_addr; |
| 2415 | int ret; |
| 2416 | |
| 2417 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2418 | |
| 2419 | ret = ospf_nbr_nbma_unset (ospf, nbr_addr); |
| 2420 | |
| 2421 | return CMD_SUCCESS; |
| 2422 | } |
| 2423 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2424 | ALIAS (no_ospf_neighbor, |
| 2425 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2426 | "no neighbor A.B.C.D priority <0-255>", |
| 2427 | NO_STR |
| 2428 | NEIGHBOR_STR |
| 2429 | "Neighbor IP address\n" |
| 2430 | "Neighbor Priority\n" |
| 2431 | "Priority\n") |
| 2432 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2433 | ALIAS (no_ospf_neighbor, |
| 2434 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2435 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2436 | NO_STR |
| 2437 | NEIGHBOR_STR |
| 2438 | "Neighbor IP address\n" |
| 2439 | "Dead Neighbor Polling interval\n" |
| 2440 | "Seconds\n") |
| 2441 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2442 | ALIAS (no_ospf_neighbor, |
| 2443 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2444 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2445 | NO_STR |
| 2446 | NEIGHBOR_STR |
| 2447 | "Neighbor IP address\n" |
| 2448 | "Neighbor Priority\n" |
| 2449 | "Priority\n" |
| 2450 | "Dead Neighbor Polling interval\n" |
| 2451 | "Seconds\n") |
| 2452 | |
| 2453 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2454 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2455 | "refresh timer <10-1800>", |
| 2456 | "Adjust refresh parameters\n" |
| 2457 | "Set refresh timer\n" |
| 2458 | "Timer value in seconds\n") |
| 2459 | { |
| 2460 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2461 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2462 | |
| 2463 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2464 | interval = (interval / 10) * 10; |
| 2465 | |
| 2466 | ospf_timers_refresh_set (ospf, interval); |
| 2467 | |
| 2468 | return CMD_SUCCESS; |
| 2469 | } |
| 2470 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2471 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2472 | "no refresh timer <10-1800>", |
| 2473 | "Adjust refresh parameters\n" |
| 2474 | "Unset refresh timer\n" |
| 2475 | "Timer value in seconds\n") |
| 2476 | { |
| 2477 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2478 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2479 | |
| 2480 | if (argc == 1) |
| 2481 | { |
| 2482 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2483 | |
| 2484 | if (ospf->lsa_refresh_interval != interval || |
| 2485 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2486 | return CMD_SUCCESS; |
| 2487 | } |
| 2488 | |
| 2489 | ospf_timers_refresh_unset (ospf); |
| 2490 | |
| 2491 | return CMD_SUCCESS; |
| 2492 | } |
| 2493 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2494 | ALIAS (no_ospf_refresh_timer, |
| 2495 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2496 | "no refresh timer", |
| 2497 | "Adjust refresh parameters\n" |
| 2498 | "Unset refresh timer\n") |
| 2499 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2500 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2501 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2502 | "auto-cost reference-bandwidth <1-4294967>", |
| 2503 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2504 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2505 | "The reference bandwidth in terms of Mbits per second\n") |
| 2506 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2507 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2508 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2509 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2510 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2511 | |
| 2512 | refbw = strtol (argv[0], NULL, 10); |
| 2513 | if (refbw < 1 || refbw > 4294967) |
| 2514 | { |
| 2515 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2516 | return CMD_WARNING; |
| 2517 | } |
| 2518 | |
| 2519 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2520 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2521 | return CMD_SUCCESS; |
| 2522 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2523 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2524 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2525 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2526 | |
| 2527 | return CMD_SUCCESS; |
| 2528 | } |
| 2529 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2530 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2531 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2532 | "no auto-cost reference-bandwidth", |
| 2533 | NO_STR |
| 2534 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2535 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2536 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2537 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2538 | struct listnode *node, *nnode; |
| 2539 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2540 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2541 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2542 | return CMD_SUCCESS; |
| 2543 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2544 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2545 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2546 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2547 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2548 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2549 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2550 | |
| 2551 | return CMD_SUCCESS; |
| 2552 | } |
| 2553 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2554 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2555 | { |
| 2556 | "Unknown", |
| 2557 | "Standard (RFC2328)", |
| 2558 | "Alternative IBM", |
| 2559 | "Alternative Cisco", |
| 2560 | "Alternative Shortcut" |
| 2561 | }; |
| 2562 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2563 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2564 | { |
| 2565 | "Default", |
| 2566 | "Enabled", |
| 2567 | "Disabled" |
| 2568 | }; |
| 2569 | |
| 2570 | |
| 2571 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2572 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2573 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2574 | { |
| 2575 | /* Show Area ID. */ |
| 2576 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2577 | |
| 2578 | /* Show Area type/mode. */ |
| 2579 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2580 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2581 | else |
| 2582 | { |
| 2583 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2584 | vty_out (vty, " (Stub%s%s)", |
| 2585 | area->no_summary ? ", no summary" : "", |
| 2586 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2587 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2588 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2589 | vty_out (vty, " (NSSA%s%s)", |
| 2590 | area->no_summary ? ", no summary" : "", |
| 2591 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2592 | |
| 2593 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2594 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2595 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2596 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2597 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2598 | } |
| 2599 | |
| 2600 | /* Show number of interfaces. */ |
| 2601 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2602 | "Active: %d%s", listcount (area->oiflist), |
| 2603 | area->act_ints, VTY_NEWLINE); |
| 2604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2605 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2606 | { |
| 2607 | 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] | 2608 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2609 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2610 | VTY_NEWLINE); |
| 2611 | else if (area->NSSATranslatorState) |
| 2612 | { |
| 2613 | vty_out (vty, " We are an ABR and "); |
| 2614 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2615 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2616 | VTY_NEWLINE); |
| 2617 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2618 | vty_out (vty, "always an NSSA Translator. %s", |
| 2619 | VTY_NEWLINE); |
| 2620 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2621 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2622 | { |
| 2623 | vty_out (vty, " We are an ABR, but "); |
| 2624 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2625 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2626 | VTY_NEWLINE); |
| 2627 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2628 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2629 | VTY_NEWLINE); |
| 2630 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2631 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2632 | /* Stub-router state for this area */ |
| 2633 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2634 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2635 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2636 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2637 | VTY_NEWLINE); |
| 2638 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2639 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2640 | VTY_NEWLINE); |
| 2641 | if (area->t_stub_router) |
| 2642 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2643 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2644 | sizeof(timebuf)), VTY_NEWLINE); |
| 2645 | } |
| 2646 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2647 | /* Show number of fully adjacent neighbors. */ |
| 2648 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2649 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2650 | |
| 2651 | /* Show authentication type. */ |
| 2652 | vty_out (vty, " Area has "); |
| 2653 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2654 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2655 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2656 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2657 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2658 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2659 | |
| 2660 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2661 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2662 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2663 | |
| 2664 | /* Show SPF calculation times. */ |
| 2665 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2666 | area->spf_calculation, VTY_NEWLINE); |
| 2667 | |
| 2668 | /* Show number of LSA. */ |
| 2669 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2670 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2671 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2672 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2673 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2674 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2675 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2676 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2677 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2678 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2679 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2680 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2681 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2682 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2683 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2684 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2685 | #ifdef HAVE_OPAQUE_LSA |
| 2686 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2687 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2688 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2689 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2690 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2691 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2692 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2693 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2694 | } |
| 2695 | |
| 2696 | DEFUN (show_ip_ospf, |
| 2697 | show_ip_ospf_cmd, |
| 2698 | "show ip ospf", |
| 2699 | SHOW_STR |
| 2700 | IP_STR |
| 2701 | "OSPF information\n") |
| 2702 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2703 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2704 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2705 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2706 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2707 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2708 | |
| 2709 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2710 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2711 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2712 | { |
| 2713 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2714 | return CMD_SUCCESS; |
| 2715 | } |
| 2716 | |
| 2717 | /* Show Router ID. */ |
| 2718 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2719 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2720 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2721 | |
| 2722 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2723 | if (ospf->t_deferred_shutdown) |
| 2724 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2725 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2726 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2727 | /* Show capability. */ |
| 2728 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2729 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2730 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2731 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2732 | "enabled" : "disabled", VTY_NEWLINE); |
| 2733 | #ifdef HAVE_OPAQUE_LSA |
| 2734 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2735 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2736 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2737 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2738 | " (origination blocked)" : "", |
| 2739 | VTY_NEWLINE); |
| 2740 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2741 | |
| 2742 | /* Show stub-router configuration */ |
| 2743 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2744 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2745 | { |
| 2746 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2747 | VTY_NEWLINE); |
| 2748 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2749 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2750 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2751 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2752 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2753 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2754 | } |
| 2755 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2756 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2757 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2758 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2759 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2760 | " Hold time multiplier is currently %d%s", |
| 2761 | ospf->spf_delay, VTY_NEWLINE, |
| 2762 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2763 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2764 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2765 | vty_out (vty, " SPF algorithm "); |
| 2766 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2767 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 2768 | result = tv_sub (recent_relative_time (), ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2769 | vty_out (vty, "last executed %s ago%s", |
| 2770 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2771 | VTY_NEWLINE); |
| 2772 | } |
| 2773 | else |
| 2774 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2775 | vty_out (vty, " SPF timer %s%s%s", |
| 2776 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2777 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2778 | VTY_NEWLINE); |
| 2779 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2780 | /* Show refresh parameters. */ |
| 2781 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2782 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2783 | |
| 2784 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2785 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2786 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2787 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2788 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2789 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2790 | vty_out (vty, " This router is an ASBR " |
| 2791 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2792 | |
| 2793 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2794 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2795 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2796 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2797 | #ifdef HAVE_OPAQUE_LSA |
| 2798 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2799 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2800 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2801 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2802 | /* Show number of areas attached. */ |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2803 | vty_out (vty, " Number of areas attached to this router: %d%s", |
| 2804 | listcount (ospf->areas), VTY_NEWLINE); |
| 2805 | |
| 2806 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 2807 | { |
| 2808 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 2809 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); |
| 2810 | else |
| 2811 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); |
| 2812 | } |
| 2813 | |
| 2814 | vty_out (vty, "%s",VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2815 | |
| 2816 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2817 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2818 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2819 | |
| 2820 | return CMD_SUCCESS; |
| 2821 | } |
| 2822 | |
| 2823 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2824 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2825 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2826 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2827 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2828 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2829 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2830 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2831 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2832 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2833 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2834 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2835 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2836 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2837 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2838 | |
| 2839 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2840 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2841 | { |
| 2842 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2843 | return; |
| 2844 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2845 | else if (!is_up) |
| 2846 | { |
| 2847 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2848 | VTY_NEWLINE); |
| 2849 | return; |
| 2850 | } |
| 2851 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2852 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2853 | { |
| 2854 | struct ospf_interface *oi = rn->info; |
| 2855 | |
| 2856 | if (oi == NULL) |
| 2857 | continue; |
| 2858 | |
| 2859 | /* Show OSPF interface information. */ |
| 2860 | vty_out (vty, " Internet Address %s/%d,", |
| 2861 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2862 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2863 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2864 | { |
| 2865 | struct in_addr *dest; |
| 2866 | const char *dstr; |
| 2867 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 2868 | if (CONNECTED_PEER(oi->connected) |
| 2869 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2870 | dstr = "Peer"; |
| 2871 | else |
| 2872 | dstr = "Broadcast"; |
| 2873 | |
| 2874 | /* For Vlinks, showing the peer address is probably more |
| 2875 | * informative than the local interface that is being used |
| 2876 | */ |
| 2877 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2878 | dest = &oi->vl_data->peer_addr; |
| 2879 | else |
| 2880 | dest = &oi->connected->destination->u.prefix4; |
| 2881 | |
| 2882 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); |
| 2883 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2884 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2885 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2886 | VTY_NEWLINE); |
| 2887 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2888 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2889 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2890 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2891 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2892 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2893 | oi->output_cost, VTY_NEWLINE); |
| 2894 | |
| 2895 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2896 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2897 | PRIORITY (oi), VTY_NEWLINE); |
| 2898 | |
| 2899 | /* Show DR information. */ |
| 2900 | if (DR (oi).s_addr == 0) |
| 2901 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2902 | else |
| 2903 | { |
| 2904 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2905 | if (nbr == NULL) |
| 2906 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2907 | else |
| 2908 | { |
| 2909 | vty_out (vty, " Designated Router (ID) %s,", |
| 2910 | inet_ntoa (nbr->router_id)); |
| 2911 | vty_out (vty, " Interface Address %s%s", |
| 2912 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2913 | } |
| 2914 | } |
| 2915 | |
| 2916 | /* Show BDR information. */ |
| 2917 | if (BDR (oi).s_addr == 0) |
| 2918 | vty_out (vty, " No backup designated router on this network%s", |
| 2919 | VTY_NEWLINE); |
| 2920 | else |
| 2921 | { |
| 2922 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2923 | if (nbr == NULL) |
| 2924 | vty_out (vty, " No backup designated router on this network%s", |
| 2925 | VTY_NEWLINE); |
| 2926 | else |
| 2927 | { |
| 2928 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2929 | inet_ntoa (nbr->router_id)); |
| 2930 | vty_out (vty, " Interface Address %s%s", |
| 2931 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2932 | } |
| 2933 | } |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2934 | |
| 2935 | vty_out (vty, " Multicast group memberships:"); |
Paul Jakma | 429ac78 | 2006-06-15 18:40:49 +0000 | [diff] [blame] | 2936 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
| 2937 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2938 | { |
| 2939 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) |
| 2940 | vty_out (vty, " OSPFAllRouters"); |
| 2941 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2942 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2943 | } |
| 2944 | else |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2945 | vty_out (vty, " <None>"); |
| 2946 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2947 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2948 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2949 | vty_out (vty, " Hello "); |
| 2950 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 2951 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 2952 | else |
| 2953 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 2954 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 2955 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2956 | OSPF_IF_PARAM (oi, v_wait), |
| 2957 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2958 | VTY_NEWLINE); |
| 2959 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 2960 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2961 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2962 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2963 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2964 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2965 | VTY_NEWLINE); |
| 2966 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 2967 | else /* passive-interface is set */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2968 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2969 | |
| 2970 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2971 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2972 | VTY_NEWLINE); |
| 2973 | } |
| 2974 | } |
| 2975 | |
| 2976 | DEFUN (show_ip_ospf_interface, |
| 2977 | show_ip_ospf_interface_cmd, |
| 2978 | "show ip ospf interface [INTERFACE]", |
| 2979 | SHOW_STR |
| 2980 | IP_STR |
| 2981 | "OSPF information\n" |
| 2982 | "Interface information\n" |
| 2983 | "Interface name\n") |
| 2984 | { |
| 2985 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2986 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2987 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2988 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2989 | ospf = ospf_lookup (); |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 2990 | if (ospf == NULL) |
| 2991 | { |
| 2992 | vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2993 | return CMD_SUCCESS; |
| 2994 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2995 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2996 | /* Show All Interfaces. */ |
| 2997 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2998 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 2999 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3000 | /* Interface name is specified. */ |
| 3001 | else |
| 3002 | { |
| 3003 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 3004 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 3005 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3006 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3007 | } |
| 3008 | |
| 3009 | return CMD_SUCCESS; |
| 3010 | } |
| 3011 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3012 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3013 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 3014 | { |
| 3015 | vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
| 3016 | VTY_NEWLINE, |
| 3017 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 3018 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 3019 | VTY_NEWLINE); |
| 3020 | } |
| 3021 | |
| 3022 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3023 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 3024 | { |
| 3025 | struct route_node *rn; |
| 3026 | struct ospf_neighbor *nbr; |
| 3027 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3028 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3029 | |
| 3030 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3031 | if ((nbr = rn->info)) |
| 3032 | /* Do not show myself. */ |
| 3033 | if (nbr != oi->nbr_self) |
| 3034 | /* Down state is not shown. */ |
| 3035 | if (nbr->state != NSM_Down) |
| 3036 | { |
| 3037 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 3038 | |
| 3039 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3040 | vty_out (vty, "%-15s %3d %-15s ", |
| 3041 | "-", nbr->priority, |
| 3042 | msgbuf); |
| 3043 | else |
| 3044 | vty_out (vty, "%-15s %3d %-15s ", |
| 3045 | inet_ntoa (nbr->router_id), nbr->priority, |
| 3046 | msgbuf); |
| 3047 | |
| 3048 | vty_out (vty, "%9s ", |
| 3049 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 3050 | sizeof(timebuf))); |
| 3051 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3052 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3053 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3054 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 3055 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 3056 | VTY_NEWLINE); |
| 3057 | } |
| 3058 | } |
| 3059 | |
| 3060 | DEFUN (show_ip_ospf_neighbor, |
| 3061 | show_ip_ospf_neighbor_cmd, |
| 3062 | "show ip ospf neighbor", |
| 3063 | SHOW_STR |
| 3064 | IP_STR |
| 3065 | "OSPF information\n" |
| 3066 | "Neighbor list\n") |
| 3067 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3068 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3069 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3070 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3071 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3072 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3073 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3074 | { |
| 3075 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3076 | return CMD_SUCCESS; |
| 3077 | } |
| 3078 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3079 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3080 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3081 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3082 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3083 | |
| 3084 | return CMD_SUCCESS; |
| 3085 | } |
| 3086 | |
| 3087 | DEFUN (show_ip_ospf_neighbor_all, |
| 3088 | show_ip_ospf_neighbor_all_cmd, |
| 3089 | "show ip ospf neighbor all", |
| 3090 | SHOW_STR |
| 3091 | IP_STR |
| 3092 | "OSPF information\n" |
| 3093 | "Neighbor list\n" |
| 3094 | "include down status neighbor\n") |
| 3095 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3096 | struct ospf *ospf = vty->index; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3097 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3098 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3099 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3100 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3101 | { |
| 3102 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3103 | return CMD_SUCCESS; |
| 3104 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3105 | |
| 3106 | show_ip_ospf_neighbour_header (vty); |
| 3107 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3108 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3109 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3110 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3111 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3112 | |
| 3113 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3114 | |
| 3115 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3116 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3117 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3118 | if (nbr_nbma->nbr == NULL |
| 3119 | || nbr_nbma->nbr->state == NSM_Down) |
| 3120 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3121 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3122 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3123 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3124 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 3125 | 0, 0, 0, VTY_NEWLINE); |
| 3126 | } |
| 3127 | } |
| 3128 | } |
| 3129 | |
| 3130 | return CMD_SUCCESS; |
| 3131 | } |
| 3132 | |
| 3133 | DEFUN (show_ip_ospf_neighbor_int, |
| 3134 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3135 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3136 | SHOW_STR |
| 3137 | IP_STR |
| 3138 | "OSPF information\n" |
| 3139 | "Neighbor list\n" |
| 3140 | "Interface name\n") |
| 3141 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3142 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3143 | struct interface *ifp; |
| 3144 | struct route_node *rn; |
| 3145 | |
| 3146 | ifp = if_lookup_by_name (argv[0]); |
| 3147 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3148 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3149 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3150 | return CMD_WARNING; |
| 3151 | } |
| 3152 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3153 | ospf = ospf_lookup (); |
| 3154 | if (ospf == NULL) |
| 3155 | { |
| 3156 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3157 | return CMD_SUCCESS; |
| 3158 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3159 | |
| 3160 | show_ip_ospf_neighbour_header (vty); |
| 3161 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3162 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3163 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3164 | struct ospf_interface *oi = rn->info; |
| 3165 | |
| 3166 | if (oi == NULL) |
| 3167 | continue; |
| 3168 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3169 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3170 | } |
| 3171 | |
| 3172 | return CMD_SUCCESS; |
| 3173 | } |
| 3174 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3175 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3176 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3177 | struct ospf_nbr_nbma *nbr_nbma) |
| 3178 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3179 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3180 | |
| 3181 | /* Show neighbor ID. */ |
| 3182 | vty_out (vty, " Neighbor %s,", "-"); |
| 3183 | |
| 3184 | /* Show interface address. */ |
| 3185 | vty_out (vty, " interface address %s%s", |
| 3186 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3187 | /* Show Area ID. */ |
| 3188 | vty_out (vty, " In the area %s via interface %s%s", |
| 3189 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3190 | /* Show neighbor priority and state. */ |
| 3191 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3192 | nbr_nbma->priority, "Down"); |
| 3193 | /* Show state changes. */ |
| 3194 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3195 | |
| 3196 | /* Show PollInterval */ |
| 3197 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3198 | |
| 3199 | /* Show poll-interval timer. */ |
| 3200 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3201 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3202 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3203 | |
| 3204 | /* Show poll-interval timer thread. */ |
| 3205 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3206 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3207 | } |
| 3208 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3209 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3210 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3211 | struct ospf_neighbor *nbr) |
| 3212 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3213 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3214 | |
| 3215 | /* Show neighbor ID. */ |
| 3216 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3217 | vty_out (vty, " Neighbor %s,", "-"); |
| 3218 | else |
| 3219 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3220 | |
| 3221 | /* Show interface address. */ |
| 3222 | vty_out (vty, " interface address %s%s", |
| 3223 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3224 | /* Show Area ID. */ |
| 3225 | vty_out (vty, " In the area %s via interface %s%s", |
| 3226 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3227 | /* Show neighbor priority and state. */ |
| 3228 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3229 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3230 | /* Show state changes. */ |
| 3231 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3232 | if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec) |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3233 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3234 | struct timeval res |
| 3235 | = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3236 | vty_out (vty, " Most recent state change statistics:%s", |
| 3237 | VTY_NEWLINE); |
| 3238 | vty_out (vty, " Progressive change %s ago%s", |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3239 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3240 | VTY_NEWLINE); |
| 3241 | } |
| 3242 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
| 3243 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3244 | struct timeval res |
| 3245 | = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3246 | vty_out (vty, " Regressive change %s ago, due to %s%s", |
| 3247 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
| 3248 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3249 | VTY_NEWLINE); |
| 3250 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3251 | /* Show Designated Rotuer ID. */ |
| 3252 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3253 | /* Show Backup Designated Rotuer ID. */ |
| 3254 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3255 | /* Show options. */ |
| 3256 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3257 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3258 | /* Show Router Dead interval timer. */ |
| 3259 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3260 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3261 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3262 | /* Show Database Summary list. */ |
| 3263 | vty_out (vty, " Database Summary List %d%s", |
| 3264 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3265 | /* Show Link State Request list. */ |
| 3266 | vty_out (vty, " Link State Request List %ld%s", |
| 3267 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3268 | /* Show Link State Retransmission list. */ |
| 3269 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3270 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3271 | /* Show inactivity timer thread. */ |
| 3272 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3273 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3274 | /* Show Database Description retransmission thread. */ |
| 3275 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3276 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3277 | /* Show Link State Request Retransmission thread. */ |
| 3278 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3279 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3280 | /* Show Link State Update Retransmission thread. */ |
| 3281 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3282 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3283 | } |
| 3284 | |
| 3285 | DEFUN (show_ip_ospf_neighbor_id, |
| 3286 | show_ip_ospf_neighbor_id_cmd, |
| 3287 | "show ip ospf neighbor A.B.C.D", |
| 3288 | SHOW_STR |
| 3289 | IP_STR |
| 3290 | "OSPF information\n" |
| 3291 | "Neighbor list\n" |
| 3292 | "Neighbor ID\n") |
| 3293 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3294 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3295 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3296 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3297 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3298 | struct in_addr router_id; |
| 3299 | int ret; |
| 3300 | |
| 3301 | ret = inet_aton (argv[0], &router_id); |
| 3302 | if (!ret) |
| 3303 | { |
| 3304 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3305 | return CMD_WARNING; |
| 3306 | } |
| 3307 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3308 | ospf = ospf_lookup (); |
| 3309 | if (ospf == NULL) |
| 3310 | { |
| 3311 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3312 | return CMD_SUCCESS; |
| 3313 | } |
| 3314 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3315 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3316 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
Andrew J. Schorr | 1c066bf | 2006-06-30 16:53:47 +0000 | [diff] [blame] | 3317 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3318 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3319 | return CMD_SUCCESS; |
| 3320 | } |
| 3321 | |
| 3322 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3323 | show_ip_ospf_neighbor_detail_cmd, |
| 3324 | "show ip ospf neighbor detail", |
| 3325 | SHOW_STR |
| 3326 | IP_STR |
| 3327 | "OSPF information\n" |
| 3328 | "Neighbor list\n" |
| 3329 | "detail of all neighbors\n") |
| 3330 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3331 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3332 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3333 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3334 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3335 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3336 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3337 | { |
| 3338 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3339 | return CMD_SUCCESS; |
| 3340 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3341 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3342 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3343 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3344 | struct route_node *rn; |
| 3345 | struct ospf_neighbor *nbr; |
| 3346 | |
| 3347 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3348 | if ((nbr = rn->info)) |
| 3349 | if (nbr != oi->nbr_self) |
| 3350 | if (nbr->state != NSM_Down) |
| 3351 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3352 | } |
| 3353 | |
| 3354 | return CMD_SUCCESS; |
| 3355 | } |
| 3356 | |
| 3357 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3358 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3359 | "show ip ospf neighbor detail all", |
| 3360 | SHOW_STR |
| 3361 | IP_STR |
| 3362 | "OSPF information\n" |
| 3363 | "Neighbor list\n" |
| 3364 | "detail of all neighbors\n" |
| 3365 | "include down status neighbor\n") |
| 3366 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3367 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3368 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3369 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3370 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3371 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3372 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3373 | { |
| 3374 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3375 | return CMD_SUCCESS; |
| 3376 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3377 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3378 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3379 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3380 | struct route_node *rn; |
| 3381 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3382 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3383 | |
| 3384 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3385 | if ((nbr = rn->info)) |
| 3386 | if (nbr != oi->nbr_self) |
| 3387 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3388 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3389 | |
| 3390 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3391 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3392 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3393 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3394 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3395 | if (nbr_nbma->nbr == NULL |
| 3396 | || nbr_nbma->nbr->state == NSM_Down) |
| 3397 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3398 | } |
| 3399 | } |
| 3400 | |
| 3401 | return CMD_SUCCESS; |
| 3402 | } |
| 3403 | |
| 3404 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3405 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3406 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3407 | SHOW_STR |
| 3408 | IP_STR |
| 3409 | "OSPF information\n" |
| 3410 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3411 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3412 | "detail of all neighbors") |
| 3413 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3414 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3415 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3416 | struct interface *ifp; |
| 3417 | struct route_node *rn, *nrn; |
| 3418 | struct ospf_neighbor *nbr; |
| 3419 | |
| 3420 | ifp = if_lookup_by_name (argv[0]); |
| 3421 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3422 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3423 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3424 | return CMD_WARNING; |
| 3425 | } |
| 3426 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3427 | ospf = ospf_lookup (); |
| 3428 | if (ospf == NULL) |
| 3429 | { |
| 3430 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3431 | return CMD_SUCCESS; |
| 3432 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3433 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3434 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3435 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3436 | if ((oi = rn->info)) |
| 3437 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3438 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3439 | if (nbr != oi->nbr_self) |
| 3440 | if (nbr->state != NSM_Down) |
| 3441 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3442 | |
| 3443 | return CMD_SUCCESS; |
| 3444 | } |
| 3445 | |
| 3446 | |
| 3447 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3448 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3449 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3450 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3451 | struct router_lsa *rl; |
| 3452 | struct summary_lsa *sl; |
| 3453 | struct as_external_lsa *asel; |
| 3454 | struct prefix_ipv4 p; |
| 3455 | |
| 3456 | if (lsa != NULL) |
| 3457 | /* If self option is set, check LSA self flag. */ |
| 3458 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3459 | { |
| 3460 | /* LSA common part show. */ |
| 3461 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3462 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3463 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3464 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3465 | /* LSA specific part show. */ |
| 3466 | switch (lsa->data->type) |
| 3467 | { |
| 3468 | case OSPF_ROUTER_LSA: |
| 3469 | rl = (struct router_lsa *) lsa->data; |
| 3470 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3471 | break; |
| 3472 | case OSPF_SUMMARY_LSA: |
| 3473 | sl = (struct summary_lsa *) lsa->data; |
| 3474 | |
| 3475 | p.family = AF_INET; |
| 3476 | p.prefix = sl->header.id; |
| 3477 | p.prefixlen = ip_masklen (sl->mask); |
| 3478 | apply_mask_ipv4 (&p); |
| 3479 | |
| 3480 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3481 | break; |
| 3482 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3483 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3484 | asel = (struct as_external_lsa *) lsa->data; |
| 3485 | |
| 3486 | p.family = AF_INET; |
| 3487 | p.prefix = asel->header.id; |
| 3488 | p.prefixlen = ip_masklen (asel->mask); |
| 3489 | apply_mask_ipv4 (&p); |
| 3490 | |
| 3491 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3492 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3493 | inet_ntoa (p.prefix), p.prefixlen, |
| 3494 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3495 | break; |
| 3496 | case OSPF_NETWORK_LSA: |
| 3497 | case OSPF_ASBR_SUMMARY_LSA: |
| 3498 | #ifdef HAVE_OPAQUE_LSA |
| 3499 | case OSPF_OPAQUE_LINK_LSA: |
| 3500 | case OSPF_OPAQUE_AREA_LSA: |
| 3501 | case OSPF_OPAQUE_AS_LSA: |
| 3502 | #endif /* HAVE_OPAQUE_LSA */ |
| 3503 | default: |
| 3504 | break; |
| 3505 | } |
| 3506 | vty_out (vty, VTY_NEWLINE); |
| 3507 | } |
| 3508 | |
| 3509 | return 0; |
| 3510 | } |
| 3511 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3512 | const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3513 | { |
| 3514 | "unknown", |
| 3515 | "Router Link States", |
| 3516 | "Net Link States", |
| 3517 | "Summary Link States", |
| 3518 | "ASBR-Summary Link States", |
| 3519 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3520 | "Group Membership LSA", |
| 3521 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3522 | #ifdef HAVE_OPAQUE_LSA |
| 3523 | "Type-8 LSA", |
| 3524 | "Link-Local Opaque-LSA", |
| 3525 | "Area-Local Opaque-LSA", |
| 3526 | "AS-external Opaque-LSA", |
| 3527 | #endif /* HAVE_OPAQUE_LSA */ |
| 3528 | }; |
| 3529 | |
| 3530 | #define SHOW_OSPF_COMMON_HEADER \ |
| 3531 | "Link ID ADV Router Age Seq# CkSum" |
| 3532 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3533 | const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3534 | { |
| 3535 | "", |
| 3536 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3537 | "Link ID ADV Router Age Seq# CkSum", |
| 3538 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3539 | "Link ID ADV Router Age Seq# CkSum", |
| 3540 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3541 | " --- header for Group Member ----", |
| 3542 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3543 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3544 | " --- type-8 ---", |
| 3545 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3546 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3547 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3548 | #endif /* HAVE_OPAQUE_LSA */ |
| 3549 | }; |
| 3550 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3551 | const char *show_lsa_flags[] = |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3552 | { |
| 3553 | "Self-originated", |
| 3554 | "Checked", |
| 3555 | "Received", |
| 3556 | "Approved", |
| 3557 | "Discard", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3558 | "Translated", |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3559 | }; |
| 3560 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3561 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3562 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3563 | { |
| 3564 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3565 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3566 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3567 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3568 | lsa->data->options, |
| 3569 | ospf_options_dump(lsa->data->options), |
| 3570 | VTY_NEWLINE); |
| 3571 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3572 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3573 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3574 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3575 | |
| 3576 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3577 | { |
| 3578 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3579 | |
| 3580 | if (rlsa->flags) |
| 3581 | vty_out (vty, " :%s%s%s%s", |
| 3582 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3583 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3584 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3585 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3586 | |
| 3587 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3588 | } |
| 3589 | vty_out (vty, " LS Type: %s%s", |
| 3590 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3591 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3592 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3593 | vty_out (vty, " Advertising Router: %s%s", |
| 3594 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3595 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3596 | VTY_NEWLINE); |
| 3597 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3598 | VTY_NEWLINE); |
| 3599 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3600 | } |
| 3601 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3602 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3603 | { |
| 3604 | "(null)", |
| 3605 | "another Router (point-to-point)", |
| 3606 | "a Transit Network", |
| 3607 | "Stub Network", |
| 3608 | "a Virtual Link", |
| 3609 | }; |
| 3610 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3611 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3612 | { |
| 3613 | "(null)", |
| 3614 | "Neighboring Router ID", |
| 3615 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3616 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3617 | "Neighboring Router ID", |
| 3618 | }; |
| 3619 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3620 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3621 | { |
| 3622 | "(null)", |
| 3623 | "Router Interface address", |
| 3624 | "Router Interface address", |
| 3625 | "Network Mask", |
| 3626 | "Router Interface address", |
| 3627 | }; |
| 3628 | |
| 3629 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3630 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3631 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3632 | struct router_lsa *rl) |
| 3633 | { |
| 3634 | int len, i, type; |
| 3635 | |
| 3636 | len = ntohs (rl->header.length) - 4; |
| 3637 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3638 | { |
| 3639 | type = rl->link[i].type; |
| 3640 | |
| 3641 | vty_out (vty, " Link connected to: %s%s", |
| 3642 | link_type_desc[type], VTY_NEWLINE); |
| 3643 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3644 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3645 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3646 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3647 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3648 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3649 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3650 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3651 | } |
| 3652 | } |
| 3653 | |
| 3654 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3655 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3656 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3657 | { |
| 3658 | if (lsa != NULL) |
| 3659 | { |
| 3660 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3661 | |
| 3662 | show_ip_ospf_database_header (vty, lsa); |
| 3663 | |
| 3664 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3665 | VTY_NEWLINE, VTY_NEWLINE); |
| 3666 | |
| 3667 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3668 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3669 | } |
| 3670 | |
| 3671 | return 0; |
| 3672 | } |
| 3673 | |
| 3674 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3675 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3676 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3677 | { |
| 3678 | int length, i; |
| 3679 | |
| 3680 | if (lsa != NULL) |
| 3681 | { |
| 3682 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3683 | |
| 3684 | show_ip_ospf_database_header (vty, lsa); |
| 3685 | |
| 3686 | vty_out (vty, " Network Mask: /%d%s", |
| 3687 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3688 | |
| 3689 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3690 | |
| 3691 | for (i = 0; length > 0; i++, length -= 4) |
| 3692 | vty_out (vty, " Attached Router: %s%s", |
| 3693 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3694 | |
| 3695 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3696 | } |
| 3697 | |
| 3698 | return 0; |
| 3699 | } |
| 3700 | |
| 3701 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3702 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3703 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3704 | { |
| 3705 | if (lsa != NULL) |
| 3706 | { |
| 3707 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3708 | |
| 3709 | show_ip_ospf_database_header (vty, lsa); |
| 3710 | |
| 3711 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3712 | VTY_NEWLINE); |
| 3713 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3714 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3715 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3716 | } |
| 3717 | |
| 3718 | return 0; |
| 3719 | } |
| 3720 | |
| 3721 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3722 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3723 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3724 | { |
| 3725 | if (lsa != NULL) |
| 3726 | { |
| 3727 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3728 | |
| 3729 | show_ip_ospf_database_header (vty, lsa); |
| 3730 | |
| 3731 | vty_out (vty, " Network Mask: /%d%s", |
| 3732 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3733 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3734 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3735 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3736 | } |
| 3737 | |
| 3738 | return 0; |
| 3739 | } |
| 3740 | |
| 3741 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3742 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3743 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3744 | { |
| 3745 | if (lsa != NULL) |
| 3746 | { |
| 3747 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3748 | |
| 3749 | show_ip_ospf_database_header (vty, lsa); |
| 3750 | |
| 3751 | vty_out (vty, " Network Mask: /%d%s", |
| 3752 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3753 | vty_out (vty, " Metric Type: %s%s", |
| 3754 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3755 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3756 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3757 | vty_out (vty, " Metric: %d%s", |
| 3758 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3759 | vty_out (vty, " Forward Address: %s%s", |
| 3760 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3761 | |
| 3762 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3763 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3764 | } |
| 3765 | |
| 3766 | return 0; |
| 3767 | } |
| 3768 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3769 | /* N.B. This function currently seems to be unused. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3770 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3771 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3772 | { |
| 3773 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3774 | |
| 3775 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3776 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3777 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3778 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3779 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3780 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3781 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3782 | zlog_debug( " TOS: 0%s", "\n"); |
| 3783 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3784 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3785 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3786 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3787 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3788 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3789 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3790 | |
| 3791 | return 0; |
| 3792 | } |
| 3793 | |
| 3794 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3795 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3796 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3797 | { |
| 3798 | if (lsa != NULL) |
| 3799 | { |
| 3800 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3801 | |
| 3802 | show_ip_ospf_database_header (vty, lsa); |
| 3803 | |
| 3804 | vty_out (vty, " Network Mask: /%d%s", |
| 3805 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3806 | vty_out (vty, " Metric Type: %s%s", |
| 3807 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3808 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3809 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3810 | vty_out (vty, " Metric: %d%s", |
| 3811 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3812 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3813 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3814 | |
| 3815 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3816 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3817 | } |
| 3818 | |
| 3819 | return 0; |
| 3820 | } |
| 3821 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3822 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3823 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3824 | { |
| 3825 | return 0; |
| 3826 | } |
| 3827 | |
| 3828 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3829 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3830 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3831 | { |
| 3832 | if (lsa != NULL) |
| 3833 | { |
| 3834 | show_ip_ospf_database_header (vty, lsa); |
| 3835 | show_opaque_info_detail (vty, lsa); |
| 3836 | |
| 3837 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3838 | } |
| 3839 | return 0; |
| 3840 | } |
| 3841 | #endif /* HAVE_OPAQUE_LSA */ |
| 3842 | |
| 3843 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3844 | { |
| 3845 | NULL, |
| 3846 | show_router_lsa_detail, |
| 3847 | show_network_lsa_detail, |
| 3848 | show_summary_lsa_detail, |
| 3849 | show_summary_asbr_lsa_detail, |
| 3850 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3851 | show_func_dummy, |
| 3852 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3853 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3854 | NULL, /* type-8 */ |
| 3855 | show_opaque_lsa_detail, |
| 3856 | show_opaque_lsa_detail, |
| 3857 | show_opaque_lsa_detail, |
| 3858 | #endif /* HAVE_OPAQUE_LSA */ |
| 3859 | }; |
| 3860 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3861 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3862 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3863 | struct in_addr *adv_router) |
| 3864 | { |
| 3865 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3866 | lp->family = 0; |
| 3867 | if (id == NULL) |
| 3868 | lp->prefixlen = 0; |
| 3869 | else if (adv_router == NULL) |
| 3870 | { |
| 3871 | lp->prefixlen = 32; |
| 3872 | lp->id = *id; |
| 3873 | } |
| 3874 | else |
| 3875 | { |
| 3876 | lp->prefixlen = 64; |
| 3877 | lp->id = *id; |
| 3878 | lp->adv_router = *adv_router; |
| 3879 | } |
| 3880 | } |
| 3881 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3882 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3883 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3884 | struct in_addr *id, struct in_addr *adv_router) |
| 3885 | { |
| 3886 | struct prefix_ls lp; |
| 3887 | struct route_node *rn, *start; |
| 3888 | struct ospf_lsa *lsa; |
| 3889 | |
| 3890 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3891 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3892 | if (start) |
| 3893 | { |
| 3894 | route_lock_node (start); |
| 3895 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3896 | if ((lsa = rn->info)) |
| 3897 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3898 | if (show_function[lsa->data->type] != NULL) |
| 3899 | show_function[lsa->data->type] (vty, lsa); |
| 3900 | } |
| 3901 | route_unlock_node (start); |
| 3902 | } |
| 3903 | } |
| 3904 | |
| 3905 | /* Show detail LSA information |
| 3906 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3907 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3908 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3909 | struct in_addr *id, struct in_addr *adv_router) |
| 3910 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3911 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3912 | struct ospf_area *area; |
| 3913 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3914 | switch (type) |
| 3915 | { |
| 3916 | case OSPF_AS_EXTERNAL_LSA: |
| 3917 | #ifdef HAVE_OPAQUE_LSA |
| 3918 | case OSPF_OPAQUE_AS_LSA: |
| 3919 | #endif /* HAVE_OPAQUE_LSA */ |
| 3920 | vty_out (vty, " %s %s%s", |
| 3921 | show_database_desc[type], |
| 3922 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3923 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3924 | break; |
| 3925 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3926 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3927 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3928 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3929 | VTY_NEWLINE, show_database_desc[type], |
| 3930 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3931 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3932 | } |
| 3933 | break; |
| 3934 | } |
| 3935 | } |
| 3936 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3937 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3938 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3939 | struct in_addr *adv_router) |
| 3940 | { |
| 3941 | struct route_node *rn; |
| 3942 | struct ospf_lsa *lsa; |
| 3943 | |
| 3944 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3945 | if ((lsa = rn->info)) |
| 3946 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3947 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3948 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3949 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3950 | if (show_function[lsa->data->type] != NULL) |
| 3951 | show_function[lsa->data->type] (vty, lsa); |
| 3952 | } |
| 3953 | } |
| 3954 | |
| 3955 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3956 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3957 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3958 | struct in_addr *adv_router) |
| 3959 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3960 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3961 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3962 | |
| 3963 | switch (type) |
| 3964 | { |
| 3965 | case OSPF_AS_EXTERNAL_LSA: |
| 3966 | #ifdef HAVE_OPAQUE_LSA |
| 3967 | case OSPF_OPAQUE_AS_LSA: |
| 3968 | #endif /* HAVE_OPAQUE_LSA */ |
| 3969 | vty_out (vty, " %s %s%s", |
| 3970 | show_database_desc[type], |
| 3971 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3972 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3973 | adv_router); |
| 3974 | break; |
| 3975 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3976 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3977 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3978 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3979 | VTY_NEWLINE, show_database_desc[type], |
| 3980 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3981 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3982 | adv_router); |
| 3983 | } |
| 3984 | break; |
| 3985 | } |
| 3986 | } |
| 3987 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3988 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3989 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3990 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3991 | struct ospf_lsa *lsa; |
| 3992 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3993 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3994 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3995 | int type; |
| 3996 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3997 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3998 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3999 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4000 | { |
| 4001 | switch (type) |
| 4002 | { |
| 4003 | case OSPF_AS_EXTERNAL_LSA: |
| 4004 | #ifdef HAVE_OPAQUE_LSA |
| 4005 | case OSPF_OPAQUE_AS_LSA: |
| 4006 | #endif /* HAVE_OPAQUE_LSA */ |
| 4007 | continue; |
| 4008 | default: |
| 4009 | break; |
| 4010 | } |
| 4011 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 4012 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 4013 | { |
| 4014 | vty_out (vty, " %s (Area %s)%s%s", |
| 4015 | show_database_desc[type], |
| 4016 | ospf_area_desc_string (area), |
| 4017 | VTY_NEWLINE, VTY_NEWLINE); |
| 4018 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 4019 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4020 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 4021 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4022 | |
| 4023 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4024 | } |
| 4025 | } |
| 4026 | } |
| 4027 | |
| 4028 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4029 | { |
| 4030 | switch (type) |
| 4031 | { |
| 4032 | case OSPF_AS_EXTERNAL_LSA: |
| 4033 | #ifdef HAVE_OPAQUE_LSA |
| 4034 | case OSPF_OPAQUE_AS_LSA: |
| 4035 | #endif /* HAVE_OPAQUE_LSA */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 4036 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4037 | default: |
| 4038 | continue; |
| 4039 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4040 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 4041 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4042 | { |
| 4043 | vty_out (vty, " %s%s%s", |
| 4044 | show_database_desc[type], |
| 4045 | VTY_NEWLINE, VTY_NEWLINE); |
| 4046 | vty_out (vty, "%s%s", show_database_header[type], |
| 4047 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4048 | |
| 4049 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 4050 | show_lsa_summary (vty, lsa, self); |
| 4051 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4052 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4053 | } |
| 4054 | } |
| 4055 | |
| 4056 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4057 | } |
| 4058 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4059 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4060 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4061 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 4062 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4063 | struct ospf_lsa *lsa; |
| 4064 | |
| 4065 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 4066 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 4067 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4068 | for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa)) |
| 4069 | { |
| 4070 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 4071 | vty_out (vty, "Link State ID: %s%s", |
| 4072 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 4073 | vty_out (vty, "Advertising Router: %s%s", |
| 4074 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 4075 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 4076 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4077 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4078 | } |
| 4079 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4080 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 4081 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4082 | |
| 4083 | #ifdef HAVE_OPAQUE_LSA |
| 4084 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 4085 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 4086 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 4087 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 4088 | #else /* HAVE_OPAQUE_LSA */ |
| 4089 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 4090 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 4091 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 4092 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 4093 | #endif /* HAVE_OPAQUE_LSA */ |
| 4094 | |
| 4095 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 4096 | "asbr-summary|external|network|router|summary" \ |
| 4097 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 4098 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 4099 | |
| 4100 | #define OSPF_LSA_TYPES_DESC \ |
| 4101 | "ASBR summary link states\n" \ |
| 4102 | "External link states\n" \ |
| 4103 | "Network link states\n" \ |
| 4104 | "Router link states\n" \ |
| 4105 | "Network summary link states\n" \ |
| 4106 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 4107 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 4108 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 4109 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 4110 | |
| 4111 | DEFUN (show_ip_ospf_database, |
| 4112 | show_ip_ospf_database_cmd, |
| 4113 | "show ip ospf database", |
| 4114 | SHOW_STR |
| 4115 | IP_STR |
| 4116 | "OSPF information\n" |
| 4117 | "Database summary\n") |
| 4118 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4119 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4120 | int type, ret; |
| 4121 | struct in_addr id, adv_router; |
| 4122 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4123 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4124 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4125 | { |
| 4126 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4127 | return CMD_SUCCESS; |
| 4128 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4129 | |
| 4130 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4131 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4132 | |
| 4133 | /* Show all LSA. */ |
| 4134 | if (argc == 0) |
| 4135 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4136 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4137 | return CMD_SUCCESS; |
| 4138 | } |
| 4139 | |
| 4140 | /* Set database type to show. */ |
| 4141 | if (strncmp (argv[0], "r", 1) == 0) |
| 4142 | type = OSPF_ROUTER_LSA; |
| 4143 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4144 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4145 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4146 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4147 | else if (strncmp (argv[0], "su", 2) == 0) |
| 4148 | type = OSPF_SUMMARY_LSA; |
| 4149 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4150 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4151 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4152 | type = OSPF_AS_EXTERNAL_LSA; |
| 4153 | else if (strncmp (argv[0], "se", 2) == 0) |
| 4154 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4155 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4156 | return CMD_SUCCESS; |
| 4157 | } |
| 4158 | else if (strncmp (argv[0], "m", 1) == 0) |
| 4159 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4160 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4161 | return CMD_SUCCESS; |
| 4162 | } |
| 4163 | #ifdef HAVE_OPAQUE_LSA |
| 4164 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4165 | type = OSPF_OPAQUE_LINK_LSA; |
| 4166 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4167 | type = OSPF_OPAQUE_AREA_LSA; |
| 4168 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4169 | type = OSPF_OPAQUE_AS_LSA; |
| 4170 | #endif /* HAVE_OPAQUE_LSA */ |
| 4171 | else |
| 4172 | return CMD_WARNING; |
| 4173 | |
| 4174 | /* `show ip ospf database LSA'. */ |
| 4175 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4176 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4177 | else if (argc >= 2) |
| 4178 | { |
| 4179 | ret = inet_aton (argv[1], &id); |
| 4180 | if (!ret) |
| 4181 | return CMD_WARNING; |
| 4182 | |
| 4183 | /* `show ip ospf database LSA ID'. */ |
| 4184 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4185 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4186 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4187 | else if (argc == 3) |
| 4188 | { |
| 4189 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4190 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4191 | else |
| 4192 | { |
| 4193 | ret = inet_aton (argv[2], &adv_router); |
| 4194 | if (!ret) |
| 4195 | return CMD_WARNING; |
| 4196 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4197 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4198 | } |
| 4199 | } |
| 4200 | |
| 4201 | return CMD_SUCCESS; |
| 4202 | } |
| 4203 | |
| 4204 | ALIAS (show_ip_ospf_database, |
| 4205 | show_ip_ospf_database_type_cmd, |
| 4206 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4207 | SHOW_STR |
| 4208 | IP_STR |
| 4209 | "OSPF information\n" |
| 4210 | "Database summary\n" |
| 4211 | OSPF_LSA_TYPES_DESC |
| 4212 | "LSAs in MaxAge list\n" |
| 4213 | "Self-originated link states\n") |
| 4214 | |
| 4215 | ALIAS (show_ip_ospf_database, |
| 4216 | show_ip_ospf_database_type_id_cmd, |
| 4217 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4218 | SHOW_STR |
| 4219 | IP_STR |
| 4220 | "OSPF information\n" |
| 4221 | "Database summary\n" |
| 4222 | OSPF_LSA_TYPES_DESC |
| 4223 | "Link State ID (as an IP address)\n") |
| 4224 | |
| 4225 | ALIAS (show_ip_ospf_database, |
| 4226 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4227 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4228 | SHOW_STR |
| 4229 | IP_STR |
| 4230 | "OSPF information\n" |
| 4231 | "Database summary\n" |
| 4232 | OSPF_LSA_TYPES_DESC |
| 4233 | "Link State ID (as an IP address)\n" |
| 4234 | "Advertising Router link states\n" |
| 4235 | "Advertising Router (as an IP address)\n") |
| 4236 | |
| 4237 | ALIAS (show_ip_ospf_database, |
| 4238 | show_ip_ospf_database_type_id_self_cmd, |
| 4239 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4240 | SHOW_STR |
| 4241 | IP_STR |
| 4242 | "OSPF information\n" |
| 4243 | "Database summary\n" |
| 4244 | OSPF_LSA_TYPES_DESC |
| 4245 | "Link State ID (as an IP address)\n" |
| 4246 | "Self-originated link states\n" |
| 4247 | "\n") |
| 4248 | |
| 4249 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4250 | show_ip_ospf_database_type_adv_router_cmd, |
| 4251 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4252 | SHOW_STR |
| 4253 | IP_STR |
| 4254 | "OSPF information\n" |
| 4255 | "Database summary\n" |
| 4256 | OSPF_LSA_TYPES_DESC |
| 4257 | "Advertising Router link states\n" |
| 4258 | "Advertising Router (as an IP address)\n") |
| 4259 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4260 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4261 | int type, ret; |
| 4262 | struct in_addr adv_router; |
| 4263 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4264 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4265 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4266 | { |
| 4267 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4268 | return CMD_SUCCESS; |
| 4269 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4270 | |
| 4271 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4272 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4273 | |
| 4274 | if (argc != 2) |
| 4275 | return CMD_WARNING; |
| 4276 | |
| 4277 | /* Set database type to show. */ |
| 4278 | if (strncmp (argv[0], "r", 1) == 0) |
| 4279 | type = OSPF_ROUTER_LSA; |
| 4280 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4281 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4282 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4283 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4284 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4285 | type = OSPF_SUMMARY_LSA; |
| 4286 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4287 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4288 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4289 | type = OSPF_AS_EXTERNAL_LSA; |
| 4290 | #ifdef HAVE_OPAQUE_LSA |
| 4291 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4292 | type = OSPF_OPAQUE_LINK_LSA; |
| 4293 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4294 | type = OSPF_OPAQUE_AREA_LSA; |
| 4295 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4296 | type = OSPF_OPAQUE_AS_LSA; |
| 4297 | #endif /* HAVE_OPAQUE_LSA */ |
| 4298 | else |
| 4299 | return CMD_WARNING; |
| 4300 | |
| 4301 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4302 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4303 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4304 | else |
| 4305 | { |
| 4306 | ret = inet_aton (argv[1], &adv_router); |
| 4307 | if (!ret) |
| 4308 | return CMD_WARNING; |
| 4309 | } |
| 4310 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4311 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4312 | |
| 4313 | return CMD_SUCCESS; |
| 4314 | } |
| 4315 | |
| 4316 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4317 | show_ip_ospf_database_type_self_cmd, |
| 4318 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4319 | SHOW_STR |
| 4320 | IP_STR |
| 4321 | "OSPF information\n" |
| 4322 | "Database summary\n" |
| 4323 | OSPF_LSA_TYPES_DESC |
| 4324 | "Self-originated link states\n") |
| 4325 | |
| 4326 | |
| 4327 | DEFUN (ip_ospf_authentication_args, |
| 4328 | ip_ospf_authentication_args_addr_cmd, |
| 4329 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4330 | "IP Information\n" |
| 4331 | "OSPF interface commands\n" |
| 4332 | "Enable authentication on this interface\n" |
| 4333 | "Use null authentication\n" |
| 4334 | "Use message-digest authentication\n" |
| 4335 | "Address of interface") |
| 4336 | { |
| 4337 | struct interface *ifp; |
| 4338 | struct in_addr addr; |
| 4339 | int ret; |
| 4340 | struct ospf_if_params *params; |
| 4341 | |
| 4342 | ifp = vty->index; |
| 4343 | params = IF_DEF_PARAMS (ifp); |
| 4344 | |
| 4345 | if (argc == 2) |
| 4346 | { |
| 4347 | ret = inet_aton(argv[1], &addr); |
| 4348 | if (!ret) |
| 4349 | { |
| 4350 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4351 | VTY_NEWLINE); |
| 4352 | return CMD_WARNING; |
| 4353 | } |
| 4354 | |
| 4355 | params = ospf_get_if_params (ifp, addr); |
| 4356 | ospf_if_update_params (ifp, addr); |
| 4357 | } |
| 4358 | |
| 4359 | /* Handle null authentication */ |
| 4360 | if ( argv[0][0] == 'n' ) |
| 4361 | { |
| 4362 | SET_IF_PARAM (params, auth_type); |
| 4363 | params->auth_type = OSPF_AUTH_NULL; |
| 4364 | return CMD_SUCCESS; |
| 4365 | } |
| 4366 | |
| 4367 | /* Handle message-digest authentication */ |
| 4368 | if ( argv[0][0] == 'm' ) |
| 4369 | { |
| 4370 | SET_IF_PARAM (params, auth_type); |
| 4371 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4372 | return CMD_SUCCESS; |
| 4373 | } |
| 4374 | |
| 4375 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4376 | return CMD_WARNING; |
| 4377 | } |
| 4378 | |
| 4379 | ALIAS (ip_ospf_authentication_args, |
| 4380 | ip_ospf_authentication_args_cmd, |
| 4381 | "ip ospf authentication (null|message-digest)", |
| 4382 | "IP Information\n" |
| 4383 | "OSPF interface commands\n" |
| 4384 | "Enable authentication on this interface\n" |
| 4385 | "Use null authentication\n" |
| 4386 | "Use message-digest authentication\n") |
| 4387 | |
| 4388 | DEFUN (ip_ospf_authentication, |
| 4389 | ip_ospf_authentication_addr_cmd, |
| 4390 | "ip ospf authentication A.B.C.D", |
| 4391 | "IP Information\n" |
| 4392 | "OSPF interface commands\n" |
| 4393 | "Enable authentication on this interface\n" |
| 4394 | "Address of interface") |
| 4395 | { |
| 4396 | struct interface *ifp; |
| 4397 | struct in_addr addr; |
| 4398 | int ret; |
| 4399 | struct ospf_if_params *params; |
| 4400 | |
| 4401 | ifp = vty->index; |
| 4402 | params = IF_DEF_PARAMS (ifp); |
| 4403 | |
| 4404 | if (argc == 1) |
| 4405 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4406 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4407 | if (!ret) |
| 4408 | { |
| 4409 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4410 | VTY_NEWLINE); |
| 4411 | return CMD_WARNING; |
| 4412 | } |
| 4413 | |
| 4414 | params = ospf_get_if_params (ifp, addr); |
| 4415 | ospf_if_update_params (ifp, addr); |
| 4416 | } |
| 4417 | |
| 4418 | SET_IF_PARAM (params, auth_type); |
| 4419 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4420 | |
| 4421 | return CMD_SUCCESS; |
| 4422 | } |
| 4423 | |
| 4424 | ALIAS (ip_ospf_authentication, |
| 4425 | ip_ospf_authentication_cmd, |
| 4426 | "ip ospf authentication", |
| 4427 | "IP Information\n" |
| 4428 | "OSPF interface commands\n" |
| 4429 | "Enable authentication on this interface\n") |
| 4430 | |
| 4431 | DEFUN (no_ip_ospf_authentication, |
| 4432 | no_ip_ospf_authentication_addr_cmd, |
| 4433 | "no ip ospf authentication A.B.C.D", |
| 4434 | NO_STR |
| 4435 | "IP Information\n" |
| 4436 | "OSPF interface commands\n" |
| 4437 | "Enable authentication on this interface\n" |
| 4438 | "Address of interface") |
| 4439 | { |
| 4440 | struct interface *ifp; |
| 4441 | struct in_addr addr; |
| 4442 | int ret; |
| 4443 | struct ospf_if_params *params; |
| 4444 | |
| 4445 | ifp = vty->index; |
| 4446 | params = IF_DEF_PARAMS (ifp); |
| 4447 | |
| 4448 | if (argc == 1) |
| 4449 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4450 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4451 | if (!ret) |
| 4452 | { |
| 4453 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4454 | VTY_NEWLINE); |
| 4455 | return CMD_WARNING; |
| 4456 | } |
| 4457 | |
| 4458 | params = ospf_lookup_if_params (ifp, addr); |
| 4459 | if (params == NULL) |
| 4460 | return CMD_SUCCESS; |
| 4461 | } |
| 4462 | |
| 4463 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4464 | UNSET_IF_PARAM (params, auth_type); |
| 4465 | |
| 4466 | if (params != IF_DEF_PARAMS (ifp)) |
| 4467 | { |
| 4468 | ospf_free_if_params (ifp, addr); |
| 4469 | ospf_if_update_params (ifp, addr); |
| 4470 | } |
| 4471 | |
| 4472 | return CMD_SUCCESS; |
| 4473 | } |
| 4474 | |
| 4475 | ALIAS (no_ip_ospf_authentication, |
| 4476 | no_ip_ospf_authentication_cmd, |
| 4477 | "no ip ospf authentication", |
| 4478 | NO_STR |
| 4479 | "IP Information\n" |
| 4480 | "OSPF interface commands\n" |
| 4481 | "Enable authentication on this interface\n") |
| 4482 | |
| 4483 | DEFUN (ip_ospf_authentication_key, |
| 4484 | ip_ospf_authentication_key_addr_cmd, |
| 4485 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4486 | "IP Information\n" |
| 4487 | "OSPF interface commands\n" |
| 4488 | "Authentication password (key)\n" |
| 4489 | "The OSPF password (key)\n" |
| 4490 | "Address of interface") |
| 4491 | { |
| 4492 | struct interface *ifp; |
| 4493 | struct in_addr addr; |
| 4494 | int ret; |
| 4495 | struct ospf_if_params *params; |
| 4496 | |
| 4497 | ifp = vty->index; |
| 4498 | params = IF_DEF_PARAMS (ifp); |
| 4499 | |
| 4500 | if (argc == 2) |
| 4501 | { |
| 4502 | ret = inet_aton(argv[1], &addr); |
| 4503 | if (!ret) |
| 4504 | { |
| 4505 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4506 | VTY_NEWLINE); |
| 4507 | return CMD_WARNING; |
| 4508 | } |
| 4509 | |
| 4510 | params = ospf_get_if_params (ifp, addr); |
| 4511 | ospf_if_update_params (ifp, addr); |
| 4512 | } |
| 4513 | |
| 4514 | |
| 4515 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4516 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4517 | SET_IF_PARAM (params, auth_simple); |
| 4518 | |
| 4519 | return CMD_SUCCESS; |
| 4520 | } |
| 4521 | |
| 4522 | ALIAS (ip_ospf_authentication_key, |
| 4523 | ip_ospf_authentication_key_cmd, |
| 4524 | "ip ospf authentication-key AUTH_KEY", |
| 4525 | "IP Information\n" |
| 4526 | "OSPF interface commands\n" |
| 4527 | "Authentication password (key)\n" |
| 4528 | "The OSPF password (key)") |
| 4529 | |
| 4530 | ALIAS (ip_ospf_authentication_key, |
| 4531 | ospf_authentication_key_cmd, |
| 4532 | "ospf authentication-key AUTH_KEY", |
| 4533 | "OSPF interface commands\n" |
| 4534 | "Authentication password (key)\n" |
| 4535 | "The OSPF password (key)") |
| 4536 | |
| 4537 | DEFUN (no_ip_ospf_authentication_key, |
| 4538 | no_ip_ospf_authentication_key_addr_cmd, |
| 4539 | "no ip ospf authentication-key A.B.C.D", |
| 4540 | NO_STR |
| 4541 | "IP Information\n" |
| 4542 | "OSPF interface commands\n" |
| 4543 | "Authentication password (key)\n" |
| 4544 | "Address of interface") |
| 4545 | { |
| 4546 | struct interface *ifp; |
| 4547 | struct in_addr addr; |
| 4548 | int ret; |
| 4549 | struct ospf_if_params *params; |
| 4550 | |
| 4551 | ifp = vty->index; |
| 4552 | params = IF_DEF_PARAMS (ifp); |
| 4553 | |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4554 | if (argc == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4555 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4556 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4557 | if (!ret) |
| 4558 | { |
| 4559 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4560 | VTY_NEWLINE); |
| 4561 | return CMD_WARNING; |
| 4562 | } |
| 4563 | |
| 4564 | params = ospf_lookup_if_params (ifp, addr); |
| 4565 | if (params == NULL) |
| 4566 | return CMD_SUCCESS; |
| 4567 | } |
| 4568 | |
| 4569 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4570 | UNSET_IF_PARAM (params, auth_simple); |
| 4571 | |
| 4572 | if (params != IF_DEF_PARAMS (ifp)) |
| 4573 | { |
| 4574 | ospf_free_if_params (ifp, addr); |
| 4575 | ospf_if_update_params (ifp, addr); |
| 4576 | } |
| 4577 | |
| 4578 | return CMD_SUCCESS; |
| 4579 | } |
| 4580 | |
| 4581 | ALIAS (no_ip_ospf_authentication_key, |
| 4582 | no_ip_ospf_authentication_key_cmd, |
| 4583 | "no ip ospf authentication-key", |
| 4584 | NO_STR |
| 4585 | "IP Information\n" |
| 4586 | "OSPF interface commands\n" |
| 4587 | "Authentication password (key)\n") |
| 4588 | |
| 4589 | ALIAS (no_ip_ospf_authentication_key, |
| 4590 | no_ospf_authentication_key_cmd, |
| 4591 | "no ospf authentication-key", |
| 4592 | NO_STR |
| 4593 | "OSPF interface commands\n" |
| 4594 | "Authentication password (key)\n") |
| 4595 | |
| 4596 | DEFUN (ip_ospf_message_digest_key, |
| 4597 | ip_ospf_message_digest_key_addr_cmd, |
| 4598 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4599 | "IP Information\n" |
| 4600 | "OSPF interface commands\n" |
| 4601 | "Message digest authentication password (key)\n" |
| 4602 | "Key ID\n" |
| 4603 | "Use MD5 algorithm\n" |
| 4604 | "The OSPF password (key)" |
| 4605 | "Address of interface") |
| 4606 | { |
| 4607 | struct interface *ifp; |
| 4608 | struct crypt_key *ck; |
| 4609 | u_char key_id; |
| 4610 | struct in_addr addr; |
| 4611 | int ret; |
| 4612 | struct ospf_if_params *params; |
| 4613 | |
| 4614 | ifp = vty->index; |
| 4615 | params = IF_DEF_PARAMS (ifp); |
| 4616 | |
| 4617 | if (argc == 3) |
| 4618 | { |
| 4619 | ret = inet_aton(argv[2], &addr); |
| 4620 | if (!ret) |
| 4621 | { |
| 4622 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4623 | VTY_NEWLINE); |
| 4624 | return CMD_WARNING; |
| 4625 | } |
| 4626 | |
| 4627 | params = ospf_get_if_params (ifp, addr); |
| 4628 | ospf_if_update_params (ifp, addr); |
| 4629 | } |
| 4630 | |
| 4631 | key_id = strtol (argv[0], NULL, 10); |
| 4632 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4633 | { |
| 4634 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4635 | return CMD_WARNING; |
| 4636 | } |
| 4637 | |
| 4638 | ck = ospf_crypt_key_new (); |
| 4639 | ck->key_id = (u_char) key_id; |
| 4640 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4641 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4642 | |
| 4643 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4644 | SET_IF_PARAM (params, auth_crypt); |
| 4645 | |
| 4646 | return CMD_SUCCESS; |
| 4647 | } |
| 4648 | |
| 4649 | ALIAS (ip_ospf_message_digest_key, |
| 4650 | ip_ospf_message_digest_key_cmd, |
| 4651 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4652 | "IP Information\n" |
| 4653 | "OSPF interface commands\n" |
| 4654 | "Message digest authentication password (key)\n" |
| 4655 | "Key ID\n" |
| 4656 | "Use MD5 algorithm\n" |
| 4657 | "The OSPF password (key)") |
| 4658 | |
| 4659 | ALIAS (ip_ospf_message_digest_key, |
| 4660 | ospf_message_digest_key_cmd, |
| 4661 | "ospf message-digest-key <1-255> md5 KEY", |
| 4662 | "OSPF interface commands\n" |
| 4663 | "Message digest authentication password (key)\n" |
| 4664 | "Key ID\n" |
| 4665 | "Use MD5 algorithm\n" |
| 4666 | "The OSPF password (key)") |
| 4667 | |
| 4668 | DEFUN (no_ip_ospf_message_digest_key, |
| 4669 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4670 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4671 | NO_STR |
| 4672 | "IP Information\n" |
| 4673 | "OSPF interface commands\n" |
| 4674 | "Message digest authentication password (key)\n" |
| 4675 | "Key ID\n" |
| 4676 | "Address of interface") |
| 4677 | { |
| 4678 | struct interface *ifp; |
| 4679 | struct crypt_key *ck; |
| 4680 | int key_id; |
| 4681 | struct in_addr addr; |
| 4682 | int ret; |
| 4683 | struct ospf_if_params *params; |
| 4684 | |
| 4685 | ifp = vty->index; |
| 4686 | params = IF_DEF_PARAMS (ifp); |
| 4687 | |
| 4688 | if (argc == 2) |
| 4689 | { |
| 4690 | ret = inet_aton(argv[1], &addr); |
| 4691 | if (!ret) |
| 4692 | { |
| 4693 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4694 | VTY_NEWLINE); |
| 4695 | return CMD_WARNING; |
| 4696 | } |
| 4697 | |
| 4698 | params = ospf_lookup_if_params (ifp, addr); |
| 4699 | if (params == NULL) |
| 4700 | return CMD_SUCCESS; |
| 4701 | } |
| 4702 | |
| 4703 | key_id = strtol (argv[0], NULL, 10); |
| 4704 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4705 | if (ck == NULL) |
| 4706 | { |
| 4707 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4708 | return CMD_WARNING; |
| 4709 | } |
| 4710 | |
| 4711 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4712 | |
| 4713 | if (params != IF_DEF_PARAMS (ifp)) |
| 4714 | { |
| 4715 | ospf_free_if_params (ifp, addr); |
| 4716 | ospf_if_update_params (ifp, addr); |
| 4717 | } |
| 4718 | |
| 4719 | return CMD_SUCCESS; |
| 4720 | } |
| 4721 | |
| 4722 | ALIAS (no_ip_ospf_message_digest_key, |
| 4723 | no_ip_ospf_message_digest_key_cmd, |
| 4724 | "no ip ospf message-digest-key <1-255>", |
| 4725 | NO_STR |
| 4726 | "IP Information\n" |
| 4727 | "OSPF interface commands\n" |
| 4728 | "Message digest authentication password (key)\n" |
| 4729 | "Key ID\n") |
| 4730 | |
| 4731 | ALIAS (no_ip_ospf_message_digest_key, |
| 4732 | no_ospf_message_digest_key_cmd, |
| 4733 | "no ospf message-digest-key <1-255>", |
| 4734 | NO_STR |
| 4735 | "OSPF interface commands\n" |
| 4736 | "Message digest authentication password (key)\n" |
| 4737 | "Key ID\n") |
| 4738 | |
| 4739 | DEFUN (ip_ospf_cost, |
| 4740 | ip_ospf_cost_addr_cmd, |
| 4741 | "ip ospf cost <1-65535> A.B.C.D", |
| 4742 | "IP Information\n" |
| 4743 | "OSPF interface commands\n" |
| 4744 | "Interface cost\n" |
| 4745 | "Cost\n" |
| 4746 | "Address of interface") |
| 4747 | { |
| 4748 | struct interface *ifp = vty->index; |
| 4749 | u_int32_t cost; |
| 4750 | struct in_addr addr; |
| 4751 | int ret; |
| 4752 | struct ospf_if_params *params; |
| 4753 | |
| 4754 | params = IF_DEF_PARAMS (ifp); |
| 4755 | |
| 4756 | cost = strtol (argv[0], NULL, 10); |
| 4757 | |
| 4758 | /* cost range is <1-65535>. */ |
| 4759 | if (cost < 1 || cost > 65535) |
| 4760 | { |
| 4761 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4762 | return CMD_WARNING; |
| 4763 | } |
| 4764 | |
| 4765 | if (argc == 2) |
| 4766 | { |
| 4767 | ret = inet_aton(argv[1], &addr); |
| 4768 | if (!ret) |
| 4769 | { |
| 4770 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4771 | VTY_NEWLINE); |
| 4772 | return CMD_WARNING; |
| 4773 | } |
| 4774 | |
| 4775 | params = ospf_get_if_params (ifp, addr); |
| 4776 | ospf_if_update_params (ifp, addr); |
| 4777 | } |
| 4778 | |
| 4779 | SET_IF_PARAM (params, output_cost_cmd); |
| 4780 | params->output_cost_cmd = cost; |
| 4781 | |
| 4782 | ospf_if_recalculate_output_cost (ifp); |
| 4783 | |
| 4784 | return CMD_SUCCESS; |
| 4785 | } |
| 4786 | |
| 4787 | ALIAS (ip_ospf_cost, |
| 4788 | ip_ospf_cost_cmd, |
| 4789 | "ip ospf cost <1-65535>", |
| 4790 | "IP Information\n" |
| 4791 | "OSPF interface commands\n" |
| 4792 | "Interface cost\n" |
| 4793 | "Cost") |
| 4794 | |
| 4795 | ALIAS (ip_ospf_cost, |
| 4796 | ospf_cost_cmd, |
| 4797 | "ospf cost <1-65535>", |
| 4798 | "OSPF interface commands\n" |
| 4799 | "Interface cost\n" |
| 4800 | "Cost") |
| 4801 | |
| 4802 | DEFUN (no_ip_ospf_cost, |
| 4803 | no_ip_ospf_cost_addr_cmd, |
| 4804 | "no ip ospf cost A.B.C.D", |
| 4805 | NO_STR |
| 4806 | "IP Information\n" |
| 4807 | "OSPF interface commands\n" |
| 4808 | "Interface cost\n" |
| 4809 | "Address of interface") |
| 4810 | { |
| 4811 | struct interface *ifp = vty->index; |
| 4812 | struct in_addr addr; |
| 4813 | int ret; |
| 4814 | struct ospf_if_params *params; |
| 4815 | |
| 4816 | ifp = vty->index; |
| 4817 | params = IF_DEF_PARAMS (ifp); |
| 4818 | |
| 4819 | if (argc == 1) |
| 4820 | { |
| 4821 | ret = inet_aton(argv[0], &addr); |
| 4822 | if (!ret) |
| 4823 | { |
| 4824 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4825 | VTY_NEWLINE); |
| 4826 | return CMD_WARNING; |
| 4827 | } |
| 4828 | |
| 4829 | params = ospf_lookup_if_params (ifp, addr); |
| 4830 | if (params == NULL) |
| 4831 | return CMD_SUCCESS; |
| 4832 | } |
| 4833 | |
| 4834 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4835 | |
| 4836 | if (params != IF_DEF_PARAMS (ifp)) |
| 4837 | { |
| 4838 | ospf_free_if_params (ifp, addr); |
| 4839 | ospf_if_update_params (ifp, addr); |
| 4840 | } |
| 4841 | |
| 4842 | ospf_if_recalculate_output_cost (ifp); |
| 4843 | |
| 4844 | return CMD_SUCCESS; |
| 4845 | } |
| 4846 | |
| 4847 | ALIAS (no_ip_ospf_cost, |
| 4848 | no_ip_ospf_cost_cmd, |
| 4849 | "no ip ospf cost", |
| 4850 | NO_STR |
| 4851 | "IP Information\n" |
| 4852 | "OSPF interface commands\n" |
| 4853 | "Interface cost\n") |
| 4854 | |
| 4855 | ALIAS (no_ip_ospf_cost, |
| 4856 | no_ospf_cost_cmd, |
| 4857 | "no ospf cost", |
| 4858 | NO_STR |
| 4859 | "OSPF interface commands\n" |
| 4860 | "Interface cost\n") |
| 4861 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4862 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4863 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4864 | { |
| 4865 | struct route_node *rn; |
| 4866 | struct ospf_neighbor *nbr; |
| 4867 | |
| 4868 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4869 | if ((nbr = rn->info)) |
| 4870 | { |
| 4871 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4872 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4873 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4874 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4875 | } |
| 4876 | } |
| 4877 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4878 | static int |
| 4879 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 4880 | const char *nbr_str, |
| 4881 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4882 | { |
| 4883 | struct interface *ifp = vty->index; |
| 4884 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4885 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4886 | struct in_addr addr; |
| 4887 | int ret; |
| 4888 | struct ospf_if_params *params; |
| 4889 | struct ospf_interface *oi; |
| 4890 | struct route_node *rn; |
| 4891 | |
| 4892 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4893 | |
| 4894 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4895 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4896 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4897 | if (!ret) |
| 4898 | { |
| 4899 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4900 | VTY_NEWLINE); |
| 4901 | return CMD_WARNING; |
| 4902 | } |
| 4903 | |
| 4904 | params = ospf_get_if_params (ifp, addr); |
| 4905 | ospf_if_update_params (ifp, addr); |
| 4906 | } |
| 4907 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4908 | if (interval_str) |
| 4909 | { |
| 4910 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 4911 | 1, 65535); |
| 4912 | |
| 4913 | /* reset fast_hello too, just to be sure */ |
| 4914 | UNSET_IF_PARAM (params, fast_hello); |
| 4915 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4916 | } |
| 4917 | else if (fast_hello_str) |
| 4918 | { |
| 4919 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 4920 | 1, 10); |
| 4921 | /* 1s dead-interval with sub-second hellos desired */ |
| 4922 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 4923 | SET_IF_PARAM (params, fast_hello); |
| 4924 | params->fast_hello = hellomult; |
| 4925 | } |
| 4926 | else |
| 4927 | { |
| 4928 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 4929 | VTY_NEWLINE); |
| 4930 | return CMD_WARNING; |
| 4931 | } |
| 4932 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4933 | SET_IF_PARAM (params, v_wait); |
| 4934 | params->v_wait = seconds; |
| 4935 | |
| 4936 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4937 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4938 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4939 | struct ospf *ospf; |
| 4940 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4941 | { |
| 4942 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 4943 | if (oi) |
| 4944 | ospf_nbr_timer_update (oi); |
| 4945 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4946 | } |
| 4947 | else |
| 4948 | { |
| 4949 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 4950 | if ((oi = rn->info)) |
| 4951 | ospf_nbr_timer_update (oi); |
| 4952 | } |
| 4953 | |
| 4954 | return CMD_SUCCESS; |
| 4955 | } |
| 4956 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4957 | |
| 4958 | DEFUN (ip_ospf_dead_interval, |
| 4959 | ip_ospf_dead_interval_addr_cmd, |
| 4960 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 4961 | "IP Information\n" |
| 4962 | "OSPF interface commands\n" |
| 4963 | "Interval after which a neighbor is declared dead\n" |
| 4964 | "Seconds\n" |
| 4965 | "Address of interface\n") |
| 4966 | { |
| 4967 | if (argc == 2) |
| 4968 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 4969 | else |
| 4970 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 4971 | } |
| 4972 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4973 | ALIAS (ip_ospf_dead_interval, |
| 4974 | ip_ospf_dead_interval_cmd, |
| 4975 | "ip ospf dead-interval <1-65535>", |
| 4976 | "IP Information\n" |
| 4977 | "OSPF interface commands\n" |
| 4978 | "Interval after which a neighbor is declared dead\n" |
| 4979 | "Seconds\n") |
| 4980 | |
| 4981 | ALIAS (ip_ospf_dead_interval, |
| 4982 | ospf_dead_interval_cmd, |
| 4983 | "ospf dead-interval <1-65535>", |
| 4984 | "OSPF interface commands\n" |
| 4985 | "Interval after which a neighbor is declared dead\n" |
| 4986 | "Seconds\n") |
| 4987 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4988 | DEFUN (ip_ospf_dead_interval_minimal, |
| 4989 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 4990 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 4991 | "IP Information\n" |
| 4992 | "OSPF interface commands\n" |
| 4993 | "Interval after which a neighbor is declared dead\n" |
| 4994 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 4995 | "Hello multiplier factor\n" |
| 4996 | "Number of Hellos to send each second\n" |
| 4997 | "Address of interface\n") |
| 4998 | { |
| 4999 | if (argc == 2) |
| 5000 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 5001 | else |
| 5002 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 5003 | } |
| 5004 | |
| 5005 | ALIAS (ip_ospf_dead_interval_minimal, |
| 5006 | ip_ospf_dead_interval_minimal_cmd, |
| 5007 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 5008 | "IP Information\n" |
| 5009 | "OSPF interface commands\n" |
| 5010 | "Interval after which a neighbor is declared dead\n" |
| 5011 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5012 | "Hello multiplier factor\n" |
| 5013 | "Number of Hellos to send each second\n") |
| 5014 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5015 | DEFUN (no_ip_ospf_dead_interval, |
| 5016 | no_ip_ospf_dead_interval_addr_cmd, |
| 5017 | "no ip ospf dead-interval A.B.C.D", |
| 5018 | NO_STR |
| 5019 | "IP Information\n" |
| 5020 | "OSPF interface commands\n" |
| 5021 | "Interval after which a neighbor is declared dead\n" |
| 5022 | "Address of interface") |
| 5023 | { |
| 5024 | struct interface *ifp = vty->index; |
| 5025 | struct in_addr addr; |
| 5026 | int ret; |
| 5027 | struct ospf_if_params *params; |
| 5028 | struct ospf_interface *oi; |
| 5029 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5030 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5031 | ifp = vty->index; |
| 5032 | params = IF_DEF_PARAMS (ifp); |
| 5033 | |
| 5034 | if (argc == 1) |
| 5035 | { |
| 5036 | ret = inet_aton(argv[0], &addr); |
| 5037 | if (!ret) |
| 5038 | { |
| 5039 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5040 | VTY_NEWLINE); |
| 5041 | return CMD_WARNING; |
| 5042 | } |
| 5043 | |
| 5044 | params = ospf_lookup_if_params (ifp, addr); |
| 5045 | if (params == NULL) |
| 5046 | return CMD_SUCCESS; |
| 5047 | } |
| 5048 | |
| 5049 | UNSET_IF_PARAM (params, v_wait); |
| 5050 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5051 | |
| 5052 | UNSET_IF_PARAM (params, fast_hello); |
| 5053 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 5054 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5055 | if (params != IF_DEF_PARAMS (ifp)) |
| 5056 | { |
| 5057 | ospf_free_if_params (ifp, addr); |
| 5058 | ospf_if_update_params (ifp, addr); |
| 5059 | } |
| 5060 | |
| 5061 | /* Update timer values in neighbor structure. */ |
| 5062 | if (argc == 1) |
| 5063 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5064 | struct ospf *ospf; |
| 5065 | |
| 5066 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5067 | { |
| 5068 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5069 | if (oi) |
| 5070 | ospf_nbr_timer_update (oi); |
| 5071 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5072 | } |
| 5073 | else |
| 5074 | { |
| 5075 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5076 | if ((oi = rn->info)) |
| 5077 | ospf_nbr_timer_update (oi); |
| 5078 | } |
| 5079 | |
| 5080 | return CMD_SUCCESS; |
| 5081 | } |
| 5082 | |
| 5083 | ALIAS (no_ip_ospf_dead_interval, |
| 5084 | no_ip_ospf_dead_interval_cmd, |
| 5085 | "no ip ospf dead-interval", |
| 5086 | NO_STR |
| 5087 | "IP Information\n" |
| 5088 | "OSPF interface commands\n" |
| 5089 | "Interval after which a neighbor is declared dead\n") |
| 5090 | |
| 5091 | ALIAS (no_ip_ospf_dead_interval, |
| 5092 | no_ospf_dead_interval_cmd, |
| 5093 | "no ospf dead-interval", |
| 5094 | NO_STR |
| 5095 | "OSPF interface commands\n" |
| 5096 | "Interval after which a neighbor is declared dead\n") |
| 5097 | |
| 5098 | DEFUN (ip_ospf_hello_interval, |
| 5099 | ip_ospf_hello_interval_addr_cmd, |
| 5100 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 5101 | "IP Information\n" |
| 5102 | "OSPF interface commands\n" |
| 5103 | "Time between HELLO packets\n" |
| 5104 | "Seconds\n" |
| 5105 | "Address of interface") |
| 5106 | { |
| 5107 | struct interface *ifp = vty->index; |
| 5108 | u_int32_t seconds; |
| 5109 | struct in_addr addr; |
| 5110 | int ret; |
| 5111 | struct ospf_if_params *params; |
| 5112 | |
| 5113 | params = IF_DEF_PARAMS (ifp); |
| 5114 | |
| 5115 | seconds = strtol (argv[0], NULL, 10); |
| 5116 | |
| 5117 | /* HelloInterval range is <1-65535>. */ |
| 5118 | if (seconds < 1 || seconds > 65535) |
| 5119 | { |
| 5120 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 5121 | return CMD_WARNING; |
| 5122 | } |
| 5123 | |
| 5124 | if (argc == 2) |
| 5125 | { |
| 5126 | ret = inet_aton(argv[1], &addr); |
| 5127 | if (!ret) |
| 5128 | { |
| 5129 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5130 | VTY_NEWLINE); |
| 5131 | return CMD_WARNING; |
| 5132 | } |
| 5133 | |
| 5134 | params = ospf_get_if_params (ifp, addr); |
| 5135 | ospf_if_update_params (ifp, addr); |
| 5136 | } |
| 5137 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5138 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5139 | params->v_hello = seconds; |
| 5140 | |
| 5141 | return CMD_SUCCESS; |
| 5142 | } |
| 5143 | |
| 5144 | ALIAS (ip_ospf_hello_interval, |
| 5145 | ip_ospf_hello_interval_cmd, |
| 5146 | "ip ospf hello-interval <1-65535>", |
| 5147 | "IP Information\n" |
| 5148 | "OSPF interface commands\n" |
| 5149 | "Time between HELLO packets\n" |
| 5150 | "Seconds\n") |
| 5151 | |
| 5152 | ALIAS (ip_ospf_hello_interval, |
| 5153 | ospf_hello_interval_cmd, |
| 5154 | "ospf hello-interval <1-65535>", |
| 5155 | "OSPF interface commands\n" |
| 5156 | "Time between HELLO packets\n" |
| 5157 | "Seconds\n") |
| 5158 | |
| 5159 | DEFUN (no_ip_ospf_hello_interval, |
| 5160 | no_ip_ospf_hello_interval_addr_cmd, |
| 5161 | "no ip ospf hello-interval A.B.C.D", |
| 5162 | NO_STR |
| 5163 | "IP Information\n" |
| 5164 | "OSPF interface commands\n" |
| 5165 | "Time between HELLO packets\n" |
| 5166 | "Address of interface") |
| 5167 | { |
| 5168 | struct interface *ifp = vty->index; |
| 5169 | struct in_addr addr; |
| 5170 | int ret; |
| 5171 | struct ospf_if_params *params; |
| 5172 | |
| 5173 | ifp = vty->index; |
| 5174 | params = IF_DEF_PARAMS (ifp); |
| 5175 | |
| 5176 | if (argc == 1) |
| 5177 | { |
| 5178 | ret = inet_aton(argv[0], &addr); |
| 5179 | if (!ret) |
| 5180 | { |
| 5181 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5182 | VTY_NEWLINE); |
| 5183 | return CMD_WARNING; |
| 5184 | } |
| 5185 | |
| 5186 | params = ospf_lookup_if_params (ifp, addr); |
| 5187 | if (params == NULL) |
| 5188 | return CMD_SUCCESS; |
| 5189 | } |
| 5190 | |
| 5191 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5192 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5193 | |
| 5194 | if (params != IF_DEF_PARAMS (ifp)) |
| 5195 | { |
| 5196 | ospf_free_if_params (ifp, addr); |
| 5197 | ospf_if_update_params (ifp, addr); |
| 5198 | } |
| 5199 | |
| 5200 | return CMD_SUCCESS; |
| 5201 | } |
| 5202 | |
| 5203 | ALIAS (no_ip_ospf_hello_interval, |
| 5204 | no_ip_ospf_hello_interval_cmd, |
| 5205 | "no ip ospf hello-interval", |
| 5206 | NO_STR |
| 5207 | "IP Information\n" |
| 5208 | "OSPF interface commands\n" |
| 5209 | "Time between HELLO packets\n") |
| 5210 | |
| 5211 | ALIAS (no_ip_ospf_hello_interval, |
| 5212 | no_ospf_hello_interval_cmd, |
| 5213 | "no ospf hello-interval", |
| 5214 | NO_STR |
| 5215 | "OSPF interface commands\n" |
| 5216 | "Time between HELLO packets\n") |
| 5217 | |
| 5218 | DEFUN (ip_ospf_network, |
| 5219 | ip_ospf_network_cmd, |
| 5220 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5221 | "IP Information\n" |
| 5222 | "OSPF interface commands\n" |
| 5223 | "Network type\n" |
| 5224 | "Specify OSPF broadcast multi-access network\n" |
| 5225 | "Specify OSPF NBMA network\n" |
| 5226 | "Specify OSPF point-to-multipoint network\n" |
| 5227 | "Specify OSPF point-to-point network\n") |
| 5228 | { |
| 5229 | struct interface *ifp = vty->index; |
| 5230 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5231 | struct route_node *rn; |
| 5232 | |
| 5233 | if (strncmp (argv[0], "b", 1) == 0) |
| 5234 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5235 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5236 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5237 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5238 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5239 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5240 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5241 | |
| 5242 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5243 | return CMD_SUCCESS; |
| 5244 | |
| 5245 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5246 | |
| 5247 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5248 | { |
| 5249 | struct ospf_interface *oi = rn->info; |
| 5250 | |
| 5251 | if (!oi) |
| 5252 | continue; |
| 5253 | |
| 5254 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5255 | |
| 5256 | if (oi->state > ISM_Down) |
| 5257 | { |
| 5258 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5259 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5260 | } |
| 5261 | } |
| 5262 | |
| 5263 | return CMD_SUCCESS; |
| 5264 | } |
| 5265 | |
| 5266 | ALIAS (ip_ospf_network, |
| 5267 | ospf_network_cmd, |
| 5268 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5269 | "OSPF interface commands\n" |
| 5270 | "Network type\n" |
| 5271 | "Specify OSPF broadcast multi-access network\n" |
| 5272 | "Specify OSPF NBMA network\n" |
| 5273 | "Specify OSPF point-to-multipoint network\n" |
| 5274 | "Specify OSPF point-to-point network\n") |
| 5275 | |
| 5276 | DEFUN (no_ip_ospf_network, |
| 5277 | no_ip_ospf_network_cmd, |
| 5278 | "no ip ospf network", |
| 5279 | NO_STR |
| 5280 | "IP Information\n" |
| 5281 | "OSPF interface commands\n" |
| 5282 | "Network type\n") |
| 5283 | { |
| 5284 | struct interface *ifp = vty->index; |
| 5285 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5286 | struct route_node *rn; |
| 5287 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5288 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5289 | |
| 5290 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5291 | return CMD_SUCCESS; |
| 5292 | |
| 5293 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5294 | { |
| 5295 | struct ospf_interface *oi = rn->info; |
| 5296 | |
| 5297 | if (!oi) |
| 5298 | continue; |
| 5299 | |
| 5300 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5301 | |
| 5302 | if (oi->state > ISM_Down) |
| 5303 | { |
| 5304 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5305 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5306 | } |
| 5307 | } |
| 5308 | |
| 5309 | return CMD_SUCCESS; |
| 5310 | } |
| 5311 | |
| 5312 | ALIAS (no_ip_ospf_network, |
| 5313 | no_ospf_network_cmd, |
| 5314 | "no ospf network", |
| 5315 | NO_STR |
| 5316 | "OSPF interface commands\n" |
| 5317 | "Network type\n") |
| 5318 | |
| 5319 | DEFUN (ip_ospf_priority, |
| 5320 | ip_ospf_priority_addr_cmd, |
| 5321 | "ip ospf priority <0-255> A.B.C.D", |
| 5322 | "IP Information\n" |
| 5323 | "OSPF interface commands\n" |
| 5324 | "Router priority\n" |
| 5325 | "Priority\n" |
| 5326 | "Address of interface") |
| 5327 | { |
| 5328 | struct interface *ifp = vty->index; |
| 5329 | u_int32_t priority; |
| 5330 | struct route_node *rn; |
| 5331 | struct in_addr addr; |
| 5332 | int ret; |
| 5333 | struct ospf_if_params *params; |
| 5334 | |
| 5335 | params = IF_DEF_PARAMS (ifp); |
| 5336 | |
| 5337 | priority = strtol (argv[0], NULL, 10); |
| 5338 | |
| 5339 | /* Router Priority range is <0-255>. */ |
| 5340 | if (priority < 0 || priority > 255) |
| 5341 | { |
| 5342 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5343 | return CMD_WARNING; |
| 5344 | } |
| 5345 | |
| 5346 | if (argc == 2) |
| 5347 | { |
| 5348 | ret = inet_aton(argv[1], &addr); |
| 5349 | if (!ret) |
| 5350 | { |
| 5351 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5352 | VTY_NEWLINE); |
| 5353 | return CMD_WARNING; |
| 5354 | } |
| 5355 | |
| 5356 | params = ospf_get_if_params (ifp, addr); |
| 5357 | ospf_if_update_params (ifp, addr); |
| 5358 | } |
| 5359 | |
| 5360 | SET_IF_PARAM (params, priority); |
| 5361 | params->priority = priority; |
| 5362 | |
| 5363 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5364 | { |
| 5365 | struct ospf_interface *oi = rn->info; |
| 5366 | |
| 5367 | if (!oi) |
| 5368 | continue; |
| 5369 | |
| 5370 | |
| 5371 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5372 | { |
| 5373 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5374 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5375 | } |
| 5376 | } |
| 5377 | |
| 5378 | return CMD_SUCCESS; |
| 5379 | } |
| 5380 | |
| 5381 | ALIAS (ip_ospf_priority, |
| 5382 | ip_ospf_priority_cmd, |
| 5383 | "ip ospf priority <0-255>", |
| 5384 | "IP Information\n" |
| 5385 | "OSPF interface commands\n" |
| 5386 | "Router priority\n" |
| 5387 | "Priority\n") |
| 5388 | |
| 5389 | ALIAS (ip_ospf_priority, |
| 5390 | ospf_priority_cmd, |
| 5391 | "ospf priority <0-255>", |
| 5392 | "OSPF interface commands\n" |
| 5393 | "Router priority\n" |
| 5394 | "Priority\n") |
| 5395 | |
| 5396 | DEFUN (no_ip_ospf_priority, |
| 5397 | no_ip_ospf_priority_addr_cmd, |
| 5398 | "no ip ospf priority A.B.C.D", |
| 5399 | NO_STR |
| 5400 | "IP Information\n" |
| 5401 | "OSPF interface commands\n" |
| 5402 | "Router priority\n" |
| 5403 | "Address of interface") |
| 5404 | { |
| 5405 | struct interface *ifp = vty->index; |
| 5406 | struct route_node *rn; |
| 5407 | struct in_addr addr; |
| 5408 | int ret; |
| 5409 | struct ospf_if_params *params; |
| 5410 | |
| 5411 | ifp = vty->index; |
| 5412 | params = IF_DEF_PARAMS (ifp); |
| 5413 | |
| 5414 | if (argc == 1) |
| 5415 | { |
| 5416 | ret = inet_aton(argv[0], &addr); |
| 5417 | if (!ret) |
| 5418 | { |
| 5419 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5420 | VTY_NEWLINE); |
| 5421 | return CMD_WARNING; |
| 5422 | } |
| 5423 | |
| 5424 | params = ospf_lookup_if_params (ifp, addr); |
| 5425 | if (params == NULL) |
| 5426 | return CMD_SUCCESS; |
| 5427 | } |
| 5428 | |
| 5429 | UNSET_IF_PARAM (params, priority); |
| 5430 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5431 | |
| 5432 | if (params != IF_DEF_PARAMS (ifp)) |
| 5433 | { |
| 5434 | ospf_free_if_params (ifp, addr); |
| 5435 | ospf_if_update_params (ifp, addr); |
| 5436 | } |
| 5437 | |
| 5438 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5439 | { |
| 5440 | struct ospf_interface *oi = rn->info; |
| 5441 | |
| 5442 | if (!oi) |
| 5443 | continue; |
| 5444 | |
| 5445 | |
| 5446 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5447 | { |
| 5448 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5449 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5450 | } |
| 5451 | } |
| 5452 | |
| 5453 | return CMD_SUCCESS; |
| 5454 | } |
| 5455 | |
| 5456 | ALIAS (no_ip_ospf_priority, |
| 5457 | no_ip_ospf_priority_cmd, |
| 5458 | "no ip ospf priority", |
| 5459 | NO_STR |
| 5460 | "IP Information\n" |
| 5461 | "OSPF interface commands\n" |
| 5462 | "Router priority\n") |
| 5463 | |
| 5464 | ALIAS (no_ip_ospf_priority, |
| 5465 | no_ospf_priority_cmd, |
| 5466 | "no ospf priority", |
| 5467 | NO_STR |
| 5468 | "OSPF interface commands\n" |
| 5469 | "Router priority\n") |
| 5470 | |
| 5471 | DEFUN (ip_ospf_retransmit_interval, |
| 5472 | ip_ospf_retransmit_interval_addr_cmd, |
| 5473 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5474 | "IP Information\n" |
| 5475 | "OSPF interface commands\n" |
| 5476 | "Time between retransmitting lost link state advertisements\n" |
| 5477 | "Seconds\n" |
| 5478 | "Address of interface") |
| 5479 | { |
| 5480 | struct interface *ifp = vty->index; |
| 5481 | u_int32_t seconds; |
| 5482 | struct in_addr addr; |
| 5483 | int ret; |
| 5484 | struct ospf_if_params *params; |
| 5485 | |
| 5486 | params = IF_DEF_PARAMS (ifp); |
| 5487 | seconds = strtol (argv[0], NULL, 10); |
| 5488 | |
| 5489 | /* Retransmit Interval range is <3-65535>. */ |
| 5490 | if (seconds < 3 || seconds > 65535) |
| 5491 | { |
| 5492 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5493 | return CMD_WARNING; |
| 5494 | } |
| 5495 | |
| 5496 | |
| 5497 | if (argc == 2) |
| 5498 | { |
| 5499 | ret = inet_aton(argv[1], &addr); |
| 5500 | if (!ret) |
| 5501 | { |
| 5502 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5503 | VTY_NEWLINE); |
| 5504 | return CMD_WARNING; |
| 5505 | } |
| 5506 | |
| 5507 | params = ospf_get_if_params (ifp, addr); |
| 5508 | ospf_if_update_params (ifp, addr); |
| 5509 | } |
| 5510 | |
| 5511 | SET_IF_PARAM (params, retransmit_interval); |
| 5512 | params->retransmit_interval = seconds; |
| 5513 | |
| 5514 | return CMD_SUCCESS; |
| 5515 | } |
| 5516 | |
| 5517 | ALIAS (ip_ospf_retransmit_interval, |
| 5518 | ip_ospf_retransmit_interval_cmd, |
| 5519 | "ip ospf retransmit-interval <3-65535>", |
| 5520 | "IP Information\n" |
| 5521 | "OSPF interface commands\n" |
| 5522 | "Time between retransmitting lost link state advertisements\n" |
| 5523 | "Seconds\n") |
| 5524 | |
| 5525 | ALIAS (ip_ospf_retransmit_interval, |
| 5526 | ospf_retransmit_interval_cmd, |
| 5527 | "ospf retransmit-interval <3-65535>", |
| 5528 | "OSPF interface commands\n" |
| 5529 | "Time between retransmitting lost link state advertisements\n" |
| 5530 | "Seconds\n") |
| 5531 | |
| 5532 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5533 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5534 | "no ip ospf retransmit-interval A.B.C.D", |
| 5535 | NO_STR |
| 5536 | "IP Information\n" |
| 5537 | "OSPF interface commands\n" |
| 5538 | "Time between retransmitting lost link state advertisements\n" |
| 5539 | "Address of interface") |
| 5540 | { |
| 5541 | struct interface *ifp = vty->index; |
| 5542 | struct in_addr addr; |
| 5543 | int ret; |
| 5544 | struct ospf_if_params *params; |
| 5545 | |
| 5546 | ifp = vty->index; |
| 5547 | params = IF_DEF_PARAMS (ifp); |
| 5548 | |
| 5549 | if (argc == 1) |
| 5550 | { |
| 5551 | ret = inet_aton(argv[0], &addr); |
| 5552 | if (!ret) |
| 5553 | { |
| 5554 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5555 | VTY_NEWLINE); |
| 5556 | return CMD_WARNING; |
| 5557 | } |
| 5558 | |
| 5559 | params = ospf_lookup_if_params (ifp, addr); |
| 5560 | if (params == NULL) |
| 5561 | return CMD_SUCCESS; |
| 5562 | } |
| 5563 | |
| 5564 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5565 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5566 | |
| 5567 | if (params != IF_DEF_PARAMS (ifp)) |
| 5568 | { |
| 5569 | ospf_free_if_params (ifp, addr); |
| 5570 | ospf_if_update_params (ifp, addr); |
| 5571 | } |
| 5572 | |
| 5573 | return CMD_SUCCESS; |
| 5574 | } |
| 5575 | |
| 5576 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5577 | no_ip_ospf_retransmit_interval_cmd, |
| 5578 | "no ip ospf retransmit-interval", |
| 5579 | NO_STR |
| 5580 | "IP Information\n" |
| 5581 | "OSPF interface commands\n" |
| 5582 | "Time between retransmitting lost link state advertisements\n") |
| 5583 | |
| 5584 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5585 | no_ospf_retransmit_interval_cmd, |
| 5586 | "no ospf retransmit-interval", |
| 5587 | NO_STR |
| 5588 | "OSPF interface commands\n" |
| 5589 | "Time between retransmitting lost link state advertisements\n") |
| 5590 | |
| 5591 | DEFUN (ip_ospf_transmit_delay, |
| 5592 | ip_ospf_transmit_delay_addr_cmd, |
| 5593 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5594 | "IP Information\n" |
| 5595 | "OSPF interface commands\n" |
| 5596 | "Link state transmit delay\n" |
| 5597 | "Seconds\n" |
| 5598 | "Address of interface") |
| 5599 | { |
| 5600 | struct interface *ifp = vty->index; |
| 5601 | u_int32_t seconds; |
| 5602 | struct in_addr addr; |
| 5603 | int ret; |
| 5604 | struct ospf_if_params *params; |
| 5605 | |
| 5606 | params = IF_DEF_PARAMS (ifp); |
| 5607 | seconds = strtol (argv[0], NULL, 10); |
| 5608 | |
| 5609 | /* Transmit Delay range is <1-65535>. */ |
| 5610 | if (seconds < 1 || seconds > 65535) |
| 5611 | { |
| 5612 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5613 | return CMD_WARNING; |
| 5614 | } |
| 5615 | |
| 5616 | if (argc == 2) |
| 5617 | { |
| 5618 | ret = inet_aton(argv[1], &addr); |
| 5619 | if (!ret) |
| 5620 | { |
| 5621 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5622 | VTY_NEWLINE); |
| 5623 | return CMD_WARNING; |
| 5624 | } |
| 5625 | |
| 5626 | params = ospf_get_if_params (ifp, addr); |
| 5627 | ospf_if_update_params (ifp, addr); |
| 5628 | } |
| 5629 | |
| 5630 | SET_IF_PARAM (params, transmit_delay); |
| 5631 | params->transmit_delay = seconds; |
| 5632 | |
| 5633 | return CMD_SUCCESS; |
| 5634 | } |
| 5635 | |
| 5636 | ALIAS (ip_ospf_transmit_delay, |
| 5637 | ip_ospf_transmit_delay_cmd, |
| 5638 | "ip ospf transmit-delay <1-65535>", |
| 5639 | "IP Information\n" |
| 5640 | "OSPF interface commands\n" |
| 5641 | "Link state transmit delay\n" |
| 5642 | "Seconds\n") |
| 5643 | |
| 5644 | ALIAS (ip_ospf_transmit_delay, |
| 5645 | ospf_transmit_delay_cmd, |
| 5646 | "ospf transmit-delay <1-65535>", |
| 5647 | "OSPF interface commands\n" |
| 5648 | "Link state transmit delay\n" |
| 5649 | "Seconds\n") |
| 5650 | |
| 5651 | DEFUN (no_ip_ospf_transmit_delay, |
| 5652 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5653 | "no ip ospf transmit-delay A.B.C.D", |
| 5654 | NO_STR |
| 5655 | "IP Information\n" |
| 5656 | "OSPF interface commands\n" |
| 5657 | "Link state transmit delay\n" |
| 5658 | "Address of interface") |
| 5659 | { |
| 5660 | struct interface *ifp = vty->index; |
| 5661 | struct in_addr addr; |
| 5662 | int ret; |
| 5663 | struct ospf_if_params *params; |
| 5664 | |
| 5665 | ifp = vty->index; |
| 5666 | params = IF_DEF_PARAMS (ifp); |
| 5667 | |
| 5668 | if (argc == 1) |
| 5669 | { |
| 5670 | ret = inet_aton(argv[0], &addr); |
| 5671 | if (!ret) |
| 5672 | { |
| 5673 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5674 | VTY_NEWLINE); |
| 5675 | return CMD_WARNING; |
| 5676 | } |
| 5677 | |
| 5678 | params = ospf_lookup_if_params (ifp, addr); |
| 5679 | if (params == NULL) |
| 5680 | return CMD_SUCCESS; |
| 5681 | } |
| 5682 | |
| 5683 | UNSET_IF_PARAM (params, transmit_delay); |
| 5684 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5685 | |
| 5686 | if (params != IF_DEF_PARAMS (ifp)) |
| 5687 | { |
| 5688 | ospf_free_if_params (ifp, addr); |
| 5689 | ospf_if_update_params (ifp, addr); |
| 5690 | } |
| 5691 | |
| 5692 | return CMD_SUCCESS; |
| 5693 | } |
| 5694 | |
| 5695 | ALIAS (no_ip_ospf_transmit_delay, |
| 5696 | no_ip_ospf_transmit_delay_cmd, |
| 5697 | "no ip ospf transmit-delay", |
| 5698 | NO_STR |
| 5699 | "IP Information\n" |
| 5700 | "OSPF interface commands\n" |
| 5701 | "Link state transmit delay\n") |
| 5702 | |
| 5703 | ALIAS (no_ip_ospf_transmit_delay, |
| 5704 | no_ospf_transmit_delay_cmd, |
| 5705 | "no ospf transmit-delay", |
| 5706 | NO_STR |
| 5707 | "OSPF interface commands\n" |
| 5708 | "Link state transmit delay\n") |
| 5709 | |
| 5710 | |
| 5711 | DEFUN (ospf_redistribute_source_metric_type, |
| 5712 | ospf_redistribute_source_metric_type_routemap_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5713 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5714 | " metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5715 | REDIST_STR |
| 5716 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5717 | "Metric for redistributed routes\n" |
| 5718 | "OSPF default metric\n" |
| 5719 | "OSPF exterior metric type for redistributed routes\n" |
| 5720 | "Set OSPF External Type 1 metrics\n" |
| 5721 | "Set OSPF External Type 2 metrics\n" |
| 5722 | "Route map reference\n" |
| 5723 | "Pointer to route-map entries\n") |
| 5724 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5725 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5726 | int source; |
| 5727 | int type = -1; |
| 5728 | int metric = -1; |
| 5729 | |
| 5730 | /* Get distribute source. */ |
| 5731 | if (!str2distribute_source (argv[0], &source)) |
| 5732 | return CMD_WARNING; |
| 5733 | |
| 5734 | /* Get metric value. */ |
| 5735 | if (argc >= 2) |
| 5736 | if (!str2metric (argv[1], &metric)) |
| 5737 | return CMD_WARNING; |
| 5738 | |
| 5739 | /* Get metric type. */ |
| 5740 | if (argc >= 3) |
| 5741 | if (!str2metric_type (argv[2], &type)) |
| 5742 | return CMD_WARNING; |
| 5743 | |
| 5744 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5745 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5746 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5747 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5748 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5749 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5750 | } |
| 5751 | |
| 5752 | ALIAS (ospf_redistribute_source_metric_type, |
| 5753 | ospf_redistribute_source_metric_type_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5754 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5755 | " metric <0-16777214> metric-type (1|2)", |
| 5756 | REDIST_STR |
| 5757 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5758 | "Metric for redistributed routes\n" |
| 5759 | "OSPF default metric\n" |
| 5760 | "OSPF exterior metric type for redistributed routes\n" |
| 5761 | "Set OSPF External Type 1 metrics\n" |
| 5762 | "Set OSPF External Type 2 metrics\n") |
| 5763 | |
| 5764 | ALIAS (ospf_redistribute_source_metric_type, |
| 5765 | ospf_redistribute_source_metric_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5766 | "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>", |
| 5767 | REDIST_STR |
| 5768 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5769 | "Metric for redistributed routes\n" |
| 5770 | "OSPF default metric\n") |
| 5771 | |
| 5772 | DEFUN (ospf_redistribute_source_type_metric, |
| 5773 | ospf_redistribute_source_type_metric_routemap_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5774 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5775 | " metric-type (1|2) metric <0-16777214> route-map WORD", |
| 5776 | REDIST_STR |
| 5777 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5778 | "OSPF exterior metric type for redistributed routes\n" |
| 5779 | "Set OSPF External Type 1 metrics\n" |
| 5780 | "Set OSPF External Type 2 metrics\n" |
| 5781 | "Metric for redistributed routes\n" |
| 5782 | "OSPF default metric\n" |
| 5783 | "Route map reference\n" |
| 5784 | "Pointer to route-map entries\n") |
| 5785 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5786 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5787 | int source; |
| 5788 | int type = -1; |
| 5789 | int metric = -1; |
| 5790 | |
| 5791 | /* Get distribute source. */ |
| 5792 | if (!str2distribute_source (argv[0], &source)) |
| 5793 | return CMD_WARNING; |
| 5794 | |
| 5795 | /* Get metric value. */ |
| 5796 | if (argc >= 2) |
| 5797 | if (!str2metric_type (argv[1], &type)) |
| 5798 | return CMD_WARNING; |
| 5799 | |
| 5800 | /* Get metric type. */ |
| 5801 | if (argc >= 3) |
| 5802 | if (!str2metric (argv[2], &metric)) |
| 5803 | return CMD_WARNING; |
| 5804 | |
| 5805 | if (argc == 4) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5806 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5807 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5808 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5809 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5810 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5811 | } |
| 5812 | |
| 5813 | ALIAS (ospf_redistribute_source_type_metric, |
| 5814 | ospf_redistribute_source_type_metric_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5815 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5816 | " metric-type (1|2) metric <0-16777214>", |
| 5817 | REDIST_STR |
| 5818 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5819 | "OSPF exterior metric type for redistributed routes\n" |
| 5820 | "Set OSPF External Type 1 metrics\n" |
| 5821 | "Set OSPF External Type 2 metrics\n" |
| 5822 | "Metric for redistributed routes\n" |
| 5823 | "OSPF default metric\n") |
| 5824 | |
| 5825 | ALIAS (ospf_redistribute_source_type_metric, |
| 5826 | ospf_redistribute_source_type_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5827 | "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)", |
| 5828 | REDIST_STR |
| 5829 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5830 | "OSPF exterior metric type for redistributed routes\n" |
| 5831 | "Set OSPF External Type 1 metrics\n" |
| 5832 | "Set OSPF External Type 2 metrics\n") |
| 5833 | |
| 5834 | ALIAS (ospf_redistribute_source_type_metric, |
| 5835 | ospf_redistribute_source_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5836 | "redistribute " QUAGGA_REDIST_STR_OSPFD, |
| 5837 | REDIST_STR |
| 5838 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5839 | |
| 5840 | DEFUN (ospf_redistribute_source_metric_routemap, |
| 5841 | ospf_redistribute_source_metric_routemap_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5842 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5843 | " metric <0-16777214> route-map WORD", |
| 5844 | REDIST_STR |
| 5845 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5846 | "Metric for redistributed routes\n" |
| 5847 | "OSPF default metric\n" |
| 5848 | "Route map reference\n" |
| 5849 | "Pointer to route-map entries\n") |
| 5850 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5851 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5852 | int source; |
| 5853 | int metric = -1; |
| 5854 | |
| 5855 | /* Get distribute source. */ |
| 5856 | if (!str2distribute_source (argv[0], &source)) |
| 5857 | return CMD_WARNING; |
| 5858 | |
| 5859 | /* Get metric value. */ |
| 5860 | if (argc >= 2) |
| 5861 | if (!str2metric (argv[1], &metric)) |
| 5862 | return CMD_WARNING; |
| 5863 | |
| 5864 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5865 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5866 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5867 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5868 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5869 | return ospf_redistribute_set (ospf, source, -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5870 | } |
| 5871 | |
| 5872 | DEFUN (ospf_redistribute_source_type_routemap, |
| 5873 | ospf_redistribute_source_type_routemap_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5874 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5875 | " metric-type (1|2) route-map WORD", |
| 5876 | REDIST_STR |
| 5877 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5878 | "OSPF exterior metric type for redistributed routes\n" |
| 5879 | "Set OSPF External Type 1 metrics\n" |
| 5880 | "Set OSPF External Type 2 metrics\n" |
| 5881 | "Route map reference\n" |
| 5882 | "Pointer to route-map entries\n") |
| 5883 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5884 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5885 | int source; |
| 5886 | int type = -1; |
| 5887 | |
| 5888 | /* Get distribute source. */ |
| 5889 | if (!str2distribute_source (argv[0], &source)) |
| 5890 | return CMD_WARNING; |
| 5891 | |
| 5892 | /* Get metric value. */ |
| 5893 | if (argc >= 2) |
| 5894 | if (!str2metric_type (argv[1], &type)) |
| 5895 | return CMD_WARNING; |
| 5896 | |
| 5897 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5898 | ospf_routemap_set (ospf, source, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5899 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5900 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5901 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5902 | return ospf_redistribute_set (ospf, source, type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5903 | } |
| 5904 | |
| 5905 | DEFUN (ospf_redistribute_source_routemap, |
| 5906 | ospf_redistribute_source_routemap_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5907 | "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD", |
| 5908 | REDIST_STR |
| 5909 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5910 | "Route map reference\n" |
| 5911 | "Pointer to route-map entries\n") |
| 5912 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5913 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5914 | int source; |
| 5915 | |
| 5916 | /* Get distribute source. */ |
| 5917 | if (!str2distribute_source (argv[0], &source)) |
| 5918 | return CMD_WARNING; |
| 5919 | |
| 5920 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5921 | ospf_routemap_set (ospf, source, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5922 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5923 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5924 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5925 | return ospf_redistribute_set (ospf, source, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | } |
| 5927 | |
| 5928 | DEFUN (no_ospf_redistribute_source, |
| 5929 | no_ospf_redistribute_source_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5930 | "no redistribute " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5931 | NO_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5932 | REDIST_STR |
| 5933 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 source; |
| 5937 | |
| 5938 | if (!str2distribute_source (argv[0], &source)) |
| 5939 | return CMD_WARNING; |
| 5940 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5941 | ospf_routemap_unset (ospf, source); |
| 5942 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5943 | } |
| 5944 | |
| 5945 | DEFUN (ospf_distribute_list_out, |
| 5946 | ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5947 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5948 | "Filter networks in routing updates\n" |
| 5949 | "Access-list name\n" |
| 5950 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5951 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5952 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5953 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5954 | int source; |
| 5955 | |
| 5956 | /* Get distribute source. */ |
| 5957 | if (!str2distribute_source (argv[1], &source)) |
| 5958 | return CMD_WARNING; |
| 5959 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5960 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5961 | } |
| 5962 | |
| 5963 | DEFUN (no_ospf_distribute_list_out, |
| 5964 | no_ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5965 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5966 | NO_STR |
| 5967 | "Filter networks in routing updates\n" |
| 5968 | "Access-list name\n" |
| 5969 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5970 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5971 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5972 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5973 | int source; |
| 5974 | |
| 5975 | if (!str2distribute_source (argv[1], &source)) |
| 5976 | return CMD_WARNING; |
| 5977 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5978 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5979 | } |
| 5980 | |
| 5981 | /* Default information originate. */ |
| 5982 | DEFUN (ospf_default_information_originate_metric_type_routemap, |
| 5983 | ospf_default_information_originate_metric_type_routemap_cmd, |
| 5984 | "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD", |
| 5985 | "Control distribution of default information\n" |
| 5986 | "Distribute a default route\n" |
| 5987 | "OSPF default metric\n" |
| 5988 | "OSPF metric\n" |
| 5989 | "OSPF metric type for default routes\n" |
| 5990 | "Set OSPF External Type 1 metrics\n" |
| 5991 | "Set OSPF External Type 2 metrics\n" |
| 5992 | "Route map reference\n" |
| 5993 | "Pointer to route-map entries\n") |
| 5994 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5995 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5996 | int type = -1; |
| 5997 | int metric = -1; |
| 5998 | |
| 5999 | /* Get metric value. */ |
| 6000 | if (argc >= 1) |
| 6001 | if (!str2metric (argv[0], &metric)) |
| 6002 | return CMD_WARNING; |
| 6003 | |
| 6004 | /* Get metric type. */ |
| 6005 | if (argc >= 2) |
| 6006 | if (!str2metric_type (argv[1], &type)) |
| 6007 | return CMD_WARNING; |
| 6008 | |
| 6009 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6010 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6011 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6012 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6013 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6014 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6015 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6016 | } |
| 6017 | |
| 6018 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 6019 | ospf_default_information_originate_metric_type_cmd, |
| 6020 | "default-information originate metric <0-16777214> metric-type (1|2)", |
| 6021 | "Control distribution of default information\n" |
| 6022 | "Distribute a default route\n" |
| 6023 | "OSPF default metric\n" |
| 6024 | "OSPF metric\n" |
| 6025 | "OSPF metric type for default routes\n" |
| 6026 | "Set OSPF External Type 1 metrics\n" |
| 6027 | "Set OSPF External Type 2 metrics\n") |
| 6028 | |
| 6029 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 6030 | ospf_default_information_originate_metric_cmd, |
| 6031 | "default-information originate metric <0-16777214>", |
| 6032 | "Control distribution of default information\n" |
| 6033 | "Distribute a default route\n" |
| 6034 | "OSPF default metric\n" |
| 6035 | "OSPF metric\n") |
| 6036 | |
| 6037 | ALIAS (ospf_default_information_originate_metric_type_routemap, |
| 6038 | ospf_default_information_originate_cmd, |
| 6039 | "default-information originate", |
| 6040 | "Control distribution of default information\n" |
| 6041 | "Distribute a default route\n") |
| 6042 | |
| 6043 | /* Default information originate. */ |
| 6044 | DEFUN (ospf_default_information_originate_metric_routemap, |
| 6045 | ospf_default_information_originate_metric_routemap_cmd, |
| 6046 | "default-information originate metric <0-16777214> route-map WORD", |
| 6047 | "Control distribution of default information\n" |
| 6048 | "Distribute a default route\n" |
| 6049 | "OSPF default metric\n" |
| 6050 | "OSPF metric\n" |
| 6051 | "Route map reference\n" |
| 6052 | "Pointer to route-map entries\n") |
| 6053 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6054 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6055 | int metric = -1; |
| 6056 | |
| 6057 | /* Get metric value. */ |
| 6058 | if (argc >= 1) |
| 6059 | if (!str2metric (argv[0], &metric)) |
| 6060 | return CMD_WARNING; |
| 6061 | |
| 6062 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6063 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6064 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6065 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6066 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6067 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6068 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6069 | } |
| 6070 | |
| 6071 | /* Default information originate. */ |
| 6072 | DEFUN (ospf_default_information_originate_routemap, |
| 6073 | ospf_default_information_originate_routemap_cmd, |
| 6074 | "default-information originate route-map WORD", |
| 6075 | "Control distribution of default information\n" |
| 6076 | "Distribute a default route\n" |
| 6077 | "Route map reference\n" |
| 6078 | "Pointer to route-map entries\n") |
| 6079 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6080 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6081 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6082 | if (argc == 1) |
| 6083 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 6084 | else |
| 6085 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6086 | |
| 6087 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6088 | } |
| 6089 | |
| 6090 | DEFUN (ospf_default_information_originate_type_metric_routemap, |
| 6091 | ospf_default_information_originate_type_metric_routemap_cmd, |
| 6092 | "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD", |
| 6093 | "Control distribution of default information\n" |
| 6094 | "Distribute a default route\n" |
| 6095 | "OSPF metric type for default routes\n" |
| 6096 | "Set OSPF External Type 1 metrics\n" |
| 6097 | "Set OSPF External Type 2 metrics\n" |
| 6098 | "OSPF default metric\n" |
| 6099 | "OSPF metric\n" |
| 6100 | "Route map reference\n" |
| 6101 | "Pointer to route-map entries\n") |
| 6102 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6103 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6104 | int type = -1; |
| 6105 | int metric = -1; |
| 6106 | |
| 6107 | /* Get metric type. */ |
| 6108 | if (argc >= 1) |
| 6109 | if (!str2metric_type (argv[0], &type)) |
| 6110 | return CMD_WARNING; |
| 6111 | |
| 6112 | /* Get metric value. */ |
| 6113 | if (argc >= 2) |
| 6114 | if (!str2metric (argv[1], &metric)) |
| 6115 | return CMD_WARNING; |
| 6116 | |
| 6117 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6118 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6119 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6120 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6121 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6122 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6123 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6124 | } |
| 6125 | |
| 6126 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6127 | ospf_default_information_originate_type_metric_cmd, |
| 6128 | "default-information originate metric-type (1|2) metric <0-16777214>", |
| 6129 | "Control distribution of default information\n" |
| 6130 | "Distribute a default route\n" |
| 6131 | "OSPF metric type for default routes\n" |
| 6132 | "Set OSPF External Type 1 metrics\n" |
| 6133 | "Set OSPF External Type 2 metrics\n" |
| 6134 | "OSPF default metric\n" |
| 6135 | "OSPF metric\n") |
| 6136 | |
| 6137 | ALIAS (ospf_default_information_originate_type_metric_routemap, |
| 6138 | ospf_default_information_originate_type_cmd, |
| 6139 | "default-information originate metric-type (1|2)", |
| 6140 | "Control distribution of default information\n" |
| 6141 | "Distribute a default route\n" |
| 6142 | "OSPF metric type for default routes\n" |
| 6143 | "Set OSPF External Type 1 metrics\n" |
| 6144 | "Set OSPF External Type 2 metrics\n") |
| 6145 | |
| 6146 | DEFUN (ospf_default_information_originate_type_routemap, |
| 6147 | ospf_default_information_originate_type_routemap_cmd, |
| 6148 | "default-information originate metric-type (1|2) route-map WORD", |
| 6149 | "Control distribution of default information\n" |
| 6150 | "Distribute a default route\n" |
| 6151 | "OSPF metric type for default routes\n" |
| 6152 | "Set OSPF External Type 1 metrics\n" |
| 6153 | "Set OSPF External Type 2 metrics\n" |
| 6154 | "Route map reference\n" |
| 6155 | "Pointer to route-map entries\n") |
| 6156 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6157 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6158 | int type = -1; |
| 6159 | |
| 6160 | /* Get metric type. */ |
| 6161 | if (argc >= 1) |
| 6162 | if (!str2metric_type (argv[0], &type)) |
| 6163 | return CMD_WARNING; |
| 6164 | |
| 6165 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6166 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6167 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6168 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6169 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6170 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, |
| 6171 | type, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6172 | } |
| 6173 | |
| 6174 | DEFUN (ospf_default_information_originate_always_metric_type_routemap, |
| 6175 | ospf_default_information_originate_always_metric_type_routemap_cmd, |
| 6176 | "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD", |
| 6177 | "Control distribution of default information\n" |
| 6178 | "Distribute a default route\n" |
| 6179 | "Always advertise default route\n" |
| 6180 | "OSPF default metric\n" |
| 6181 | "OSPF metric\n" |
| 6182 | "OSPF metric type for default routes\n" |
| 6183 | "Set OSPF External Type 1 metrics\n" |
| 6184 | "Set OSPF External Type 2 metrics\n" |
| 6185 | "Route map reference\n" |
| 6186 | "Pointer to route-map entries\n") |
| 6187 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6188 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6189 | int type = -1; |
| 6190 | int metric = -1; |
| 6191 | |
| 6192 | /* Get metric value. */ |
| 6193 | if (argc >= 1) |
| 6194 | if (!str2metric (argv[0], &metric)) |
| 6195 | return CMD_WARNING; |
| 6196 | |
| 6197 | /* Get metric type. */ |
| 6198 | if (argc >= 2) |
| 6199 | if (!str2metric_type (argv[1], &type)) |
| 6200 | return CMD_WARNING; |
| 6201 | |
| 6202 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6203 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6204 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6205 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6206 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6207 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6208 | type, metric); |
| 6209 | } |
| 6210 | |
| 6211 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6212 | ospf_default_information_originate_always_metric_type_cmd, |
| 6213 | "default-information originate always metric <0-16777214> metric-type (1|2)", |
| 6214 | "Control distribution of default information\n" |
| 6215 | "Distribute a default route\n" |
| 6216 | "Always advertise default route\n" |
| 6217 | "OSPF default metric\n" |
| 6218 | "OSPF metric\n" |
| 6219 | "OSPF metric type for default routes\n" |
| 6220 | "Set OSPF External Type 1 metrics\n" |
| 6221 | "Set OSPF External Type 2 metrics\n") |
| 6222 | |
| 6223 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6224 | ospf_default_information_originate_always_metric_cmd, |
| 6225 | "default-information originate always metric <0-16777214>", |
| 6226 | "Control distribution of default information\n" |
| 6227 | "Distribute a default route\n" |
| 6228 | "Always advertise default route\n" |
| 6229 | "OSPF default metric\n" |
| 6230 | "OSPF metric\n" |
| 6231 | "OSPF metric type for default routes\n") |
| 6232 | |
| 6233 | ALIAS (ospf_default_information_originate_always_metric_type_routemap, |
| 6234 | ospf_default_information_originate_always_cmd, |
| 6235 | "default-information originate always", |
| 6236 | "Control distribution of default information\n" |
| 6237 | "Distribute a default route\n" |
| 6238 | "Always advertise default route\n") |
| 6239 | |
| 6240 | DEFUN (ospf_default_information_originate_always_metric_routemap, |
| 6241 | ospf_default_information_originate_always_metric_routemap_cmd, |
| 6242 | "default-information originate always metric <0-16777214> route-map WORD", |
| 6243 | "Control distribution of default information\n" |
| 6244 | "Distribute a default route\n" |
| 6245 | "Always advertise default route\n" |
| 6246 | "OSPF default metric\n" |
| 6247 | "OSPF metric\n" |
| 6248 | "Route map reference\n" |
| 6249 | "Pointer to route-map entries\n") |
| 6250 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6251 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6252 | int metric = -1; |
| 6253 | |
| 6254 | /* Get metric value. */ |
| 6255 | if (argc >= 1) |
| 6256 | if (!str2metric (argv[0], &metric)) |
| 6257 | return CMD_WARNING; |
| 6258 | |
| 6259 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6260 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6261 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6262 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6263 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6264 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
| 6265 | -1, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6266 | } |
| 6267 | |
| 6268 | DEFUN (ospf_default_information_originate_always_routemap, |
| 6269 | ospf_default_information_originate_always_routemap_cmd, |
| 6270 | "default-information originate always route-map WORD", |
| 6271 | "Control distribution of default information\n" |
| 6272 | "Distribute a default route\n" |
| 6273 | "Always advertise default route\n" |
| 6274 | "Route map reference\n" |
| 6275 | "Pointer to route-map entries\n") |
| 6276 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6277 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6278 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6279 | if (argc == 1) |
| 6280 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]); |
| 6281 | else |
| 6282 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6283 | |
| 6284 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6285 | } |
| 6286 | |
| 6287 | DEFUN (ospf_default_information_originate_always_type_metric_routemap, |
| 6288 | ospf_default_information_originate_always_type_metric_routemap_cmd, |
| 6289 | "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD", |
| 6290 | "Control distribution of default information\n" |
| 6291 | "Distribute a default route\n" |
| 6292 | "Always advertise default route\n" |
| 6293 | "OSPF metric type for default routes\n" |
| 6294 | "Set OSPF External Type 1 metrics\n" |
| 6295 | "Set OSPF External Type 2 metrics\n" |
| 6296 | "OSPF default metric\n" |
| 6297 | "OSPF metric\n" |
| 6298 | "Route map reference\n" |
| 6299 | "Pointer to route-map entries\n") |
| 6300 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6301 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6302 | int type = -1; |
| 6303 | int metric = -1; |
| 6304 | |
| 6305 | /* Get metric type. */ |
| 6306 | if (argc >= 1) |
| 6307 | if (!str2metric_type (argv[0], &type)) |
| 6308 | return CMD_WARNING; |
| 6309 | |
| 6310 | /* Get metric value. */ |
| 6311 | if (argc >= 2) |
| 6312 | if (!str2metric (argv[1], &metric)) |
| 6313 | return CMD_WARNING; |
| 6314 | |
| 6315 | if (argc == 3) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6316 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6317 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6318 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6319 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6320 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6321 | type, metric); |
| 6322 | } |
| 6323 | |
| 6324 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6325 | ospf_default_information_originate_always_type_metric_cmd, |
| 6326 | "default-information originate always metric-type (1|2) metric <0-16777214>", |
| 6327 | "Control distribution of default information\n" |
| 6328 | "Distribute a default route\n" |
| 6329 | "Always advertise default route\n" |
| 6330 | "OSPF metric type for default routes\n" |
| 6331 | "Set OSPF External Type 1 metrics\n" |
| 6332 | "Set OSPF External Type 2 metrics\n" |
| 6333 | "OSPF default metric\n" |
| 6334 | "OSPF metric\n") |
| 6335 | |
| 6336 | ALIAS (ospf_default_information_originate_always_type_metric_routemap, |
| 6337 | ospf_default_information_originate_always_type_cmd, |
| 6338 | "default-information originate always metric-type (1|2)", |
| 6339 | "Control distribution of default information\n" |
| 6340 | "Distribute a default route\n" |
| 6341 | "Always advertise default route\n" |
| 6342 | "OSPF metric type for default routes\n" |
| 6343 | "Set OSPF External Type 1 metrics\n" |
| 6344 | "Set OSPF External Type 2 metrics\n") |
| 6345 | |
| 6346 | DEFUN (ospf_default_information_originate_always_type_routemap, |
| 6347 | ospf_default_information_originate_always_type_routemap_cmd, |
| 6348 | "default-information originate always metric-type (1|2) route-map WORD", |
| 6349 | "Control distribution of default information\n" |
| 6350 | "Distribute a default route\n" |
| 6351 | "Always advertise default route\n" |
| 6352 | "OSPF metric type for default routes\n" |
| 6353 | "Set OSPF External Type 1 metrics\n" |
| 6354 | "Set OSPF External Type 2 metrics\n" |
| 6355 | "Route map reference\n" |
| 6356 | "Pointer to route-map entries\n") |
| 6357 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6358 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6359 | int type = -1; |
| 6360 | |
| 6361 | /* Get metric type. */ |
| 6362 | if (argc >= 1) |
| 6363 | if (!str2metric_type (argv[0], &type)) |
| 6364 | return CMD_WARNING; |
| 6365 | |
| 6366 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6367 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6368 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6369 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6370 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6371 | return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6372 | type, -1); |
| 6373 | } |
| 6374 | |
| 6375 | DEFUN (no_ospf_default_information_originate, |
| 6376 | no_ospf_default_information_originate_cmd, |
| 6377 | "no default-information originate", |
| 6378 | NO_STR |
| 6379 | "Control distribution of default information\n" |
| 6380 | "Distribute a default route\n") |
| 6381 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6382 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6383 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6384 | |
| 6385 | p.family = AF_INET; |
| 6386 | p.prefix.s_addr = 0; |
| 6387 | p.prefixlen = 0; |
| 6388 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6389 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6390 | |
| 6391 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6392 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6393 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6394 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6395 | } |
| 6396 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6397 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6398 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6399 | } |
| 6400 | |
| 6401 | DEFUN (ospf_default_metric, |
| 6402 | ospf_default_metric_cmd, |
| 6403 | "default-metric <0-16777214>", |
| 6404 | "Set metric of redistributed routes\n" |
| 6405 | "Default metric\n") |
| 6406 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6407 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6408 | int metric = -1; |
| 6409 | |
| 6410 | if (!str2metric (argv[0], &metric)) |
| 6411 | return CMD_WARNING; |
| 6412 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6413 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6414 | |
| 6415 | return CMD_SUCCESS; |
| 6416 | } |
| 6417 | |
| 6418 | DEFUN (no_ospf_default_metric, |
| 6419 | no_ospf_default_metric_cmd, |
| 6420 | "no default-metric", |
| 6421 | NO_STR |
| 6422 | "Set metric of redistributed routes\n") |
| 6423 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6424 | struct ospf *ospf = vty->index; |
| 6425 | |
| 6426 | ospf->default_metric = -1; |
| 6427 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6428 | return CMD_SUCCESS; |
| 6429 | } |
| 6430 | |
| 6431 | ALIAS (no_ospf_default_metric, |
| 6432 | no_ospf_default_metric_val_cmd, |
| 6433 | "no default-metric <0-16777214>", |
| 6434 | NO_STR |
| 6435 | "Set metric of redistributed routes\n" |
| 6436 | "Default metric\n") |
| 6437 | |
| 6438 | DEFUN (ospf_distance, |
| 6439 | ospf_distance_cmd, |
| 6440 | "distance <1-255>", |
| 6441 | "Define an administrative distance\n" |
| 6442 | "OSPF Administrative distance\n") |
| 6443 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6444 | struct ospf *ospf = vty->index; |
| 6445 | |
| 6446 | ospf->distance_all = atoi (argv[0]); |
| 6447 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6448 | return CMD_SUCCESS; |
| 6449 | } |
| 6450 | |
| 6451 | DEFUN (no_ospf_distance, |
| 6452 | no_ospf_distance_cmd, |
| 6453 | "no distance <1-255>", |
| 6454 | NO_STR |
| 6455 | "Define an administrative distance\n" |
| 6456 | "OSPF Administrative distance\n") |
| 6457 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6458 | struct ospf *ospf = vty->index; |
| 6459 | |
| 6460 | ospf->distance_all = 0; |
| 6461 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6462 | return CMD_SUCCESS; |
| 6463 | } |
| 6464 | |
| 6465 | DEFUN (no_ospf_distance_ospf, |
| 6466 | no_ospf_distance_ospf_cmd, |
| 6467 | "no distance ospf", |
| 6468 | NO_STR |
| 6469 | "Define an administrative distance\n" |
| 6470 | "OSPF Administrative distance\n" |
| 6471 | "OSPF Distance\n") |
| 6472 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6473 | struct ospf *ospf = vty->index; |
| 6474 | |
| 6475 | ospf->distance_intra = 0; |
| 6476 | ospf->distance_inter = 0; |
| 6477 | ospf->distance_external = 0; |
| 6478 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6479 | return CMD_SUCCESS; |
| 6480 | } |
| 6481 | |
| 6482 | DEFUN (ospf_distance_ospf_intra, |
| 6483 | ospf_distance_ospf_intra_cmd, |
| 6484 | "distance ospf intra-area <1-255>", |
| 6485 | "Define an administrative distance\n" |
| 6486 | "OSPF Administrative distance\n" |
| 6487 | "Intra-area routes\n" |
| 6488 | "Distance for intra-area routes\n") |
| 6489 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6490 | struct ospf *ospf = vty->index; |
| 6491 | |
| 6492 | ospf->distance_intra = atoi (argv[0]); |
| 6493 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6494 | return CMD_SUCCESS; |
| 6495 | } |
| 6496 | |
| 6497 | DEFUN (ospf_distance_ospf_intra_inter, |
| 6498 | ospf_distance_ospf_intra_inter_cmd, |
| 6499 | "distance ospf intra-area <1-255> inter-area <1-255>", |
| 6500 | "Define an administrative distance\n" |
| 6501 | "OSPF Administrative distance\n" |
| 6502 | "Intra-area routes\n" |
| 6503 | "Distance for intra-area routes\n" |
| 6504 | "Inter-area routes\n" |
| 6505 | "Distance for inter-area routes\n") |
| 6506 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6507 | struct ospf *ospf = vty->index; |
| 6508 | |
| 6509 | ospf->distance_intra = atoi (argv[0]); |
| 6510 | ospf->distance_inter = atoi (argv[1]); |
| 6511 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6512 | return CMD_SUCCESS; |
| 6513 | } |
| 6514 | |
| 6515 | DEFUN (ospf_distance_ospf_intra_external, |
| 6516 | ospf_distance_ospf_intra_external_cmd, |
| 6517 | "distance ospf intra-area <1-255> external <1-255>", |
| 6518 | "Define an administrative distance\n" |
| 6519 | "OSPF Administrative distance\n" |
| 6520 | "Intra-area routes\n" |
| 6521 | "Distance for intra-area routes\n" |
| 6522 | "External routes\n" |
| 6523 | "Distance for external routes\n") |
| 6524 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6525 | struct ospf *ospf = vty->index; |
| 6526 | |
| 6527 | ospf->distance_intra = atoi (argv[0]); |
| 6528 | ospf->distance_external = atoi (argv[1]); |
| 6529 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6530 | return CMD_SUCCESS; |
| 6531 | } |
| 6532 | |
| 6533 | DEFUN (ospf_distance_ospf_intra_inter_external, |
| 6534 | ospf_distance_ospf_intra_inter_external_cmd, |
| 6535 | "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>", |
| 6536 | "Define an administrative distance\n" |
| 6537 | "OSPF Administrative distance\n" |
| 6538 | "Intra-area routes\n" |
| 6539 | "Distance for intra-area routes\n" |
| 6540 | "Inter-area routes\n" |
| 6541 | "Distance for inter-area routes\n" |
| 6542 | "External routes\n" |
| 6543 | "Distance for external routes\n") |
| 6544 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6545 | struct ospf *ospf = vty->index; |
| 6546 | |
| 6547 | ospf->distance_intra = atoi (argv[0]); |
| 6548 | ospf->distance_inter = atoi (argv[1]); |
| 6549 | ospf->distance_external = atoi (argv[2]); |
| 6550 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6551 | return CMD_SUCCESS; |
| 6552 | } |
| 6553 | |
| 6554 | DEFUN (ospf_distance_ospf_intra_external_inter, |
| 6555 | ospf_distance_ospf_intra_external_inter_cmd, |
| 6556 | "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>", |
| 6557 | "Define an administrative distance\n" |
| 6558 | "OSPF Administrative distance\n" |
| 6559 | "Intra-area routes\n" |
| 6560 | "Distance for intra-area routes\n" |
| 6561 | "External routes\n" |
| 6562 | "Distance for external routes\n" |
| 6563 | "Inter-area routes\n" |
| 6564 | "Distance for inter-area routes\n") |
| 6565 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6566 | struct ospf *ospf = vty->index; |
| 6567 | |
| 6568 | ospf->distance_intra = atoi (argv[0]); |
| 6569 | ospf->distance_external = atoi (argv[1]); |
| 6570 | ospf->distance_inter = atoi (argv[2]); |
| 6571 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6572 | return CMD_SUCCESS; |
| 6573 | } |
| 6574 | |
| 6575 | DEFUN (ospf_distance_ospf_inter, |
| 6576 | ospf_distance_ospf_inter_cmd, |
| 6577 | "distance ospf inter-area <1-255>", |
| 6578 | "Define an administrative distance\n" |
| 6579 | "OSPF Administrative distance\n" |
| 6580 | "Inter-area routes\n" |
| 6581 | "Distance for inter-area routes\n") |
| 6582 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6583 | struct ospf *ospf = vty->index; |
| 6584 | |
| 6585 | ospf->distance_inter = atoi (argv[0]); |
| 6586 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6587 | return CMD_SUCCESS; |
| 6588 | } |
| 6589 | |
| 6590 | DEFUN (ospf_distance_ospf_inter_intra, |
| 6591 | ospf_distance_ospf_inter_intra_cmd, |
| 6592 | "distance ospf inter-area <1-255> intra-area <1-255>", |
| 6593 | "Define an administrative distance\n" |
| 6594 | "OSPF Administrative distance\n" |
| 6595 | "Inter-area routes\n" |
| 6596 | "Distance for inter-area routes\n" |
| 6597 | "Intra-area routes\n" |
| 6598 | "Distance for intra-area routes\n") |
| 6599 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6600 | struct ospf *ospf = vty->index; |
| 6601 | |
| 6602 | ospf->distance_inter = atoi (argv[0]); |
| 6603 | ospf->distance_intra = atoi (argv[1]); |
| 6604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6605 | return CMD_SUCCESS; |
| 6606 | } |
| 6607 | |
| 6608 | DEFUN (ospf_distance_ospf_inter_external, |
| 6609 | ospf_distance_ospf_inter_external_cmd, |
| 6610 | "distance ospf inter-area <1-255> external <1-255>", |
| 6611 | "Define an administrative distance\n" |
| 6612 | "OSPF Administrative distance\n" |
| 6613 | "Inter-area routes\n" |
| 6614 | "Distance for inter-area routes\n" |
| 6615 | "External routes\n" |
| 6616 | "Distance for external routes\n") |
| 6617 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6618 | struct ospf *ospf = vty->index; |
| 6619 | |
| 6620 | ospf->distance_inter = atoi (argv[0]); |
| 6621 | ospf->distance_external = atoi (argv[1]); |
| 6622 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6623 | return CMD_SUCCESS; |
| 6624 | } |
| 6625 | |
| 6626 | DEFUN (ospf_distance_ospf_inter_intra_external, |
| 6627 | ospf_distance_ospf_inter_intra_external_cmd, |
| 6628 | "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>", |
| 6629 | "Define an administrative distance\n" |
| 6630 | "OSPF Administrative distance\n" |
| 6631 | "Inter-area routes\n" |
| 6632 | "Distance for inter-area routes\n" |
| 6633 | "Intra-area routes\n" |
| 6634 | "Distance for intra-area routes\n" |
| 6635 | "External routes\n" |
| 6636 | "Distance for external routes\n") |
| 6637 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6638 | struct ospf *ospf = vty->index; |
| 6639 | |
| 6640 | ospf->distance_inter = atoi (argv[0]); |
| 6641 | ospf->distance_intra = atoi (argv[1]); |
| 6642 | ospf->distance_external = atoi (argv[2]); |
| 6643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6644 | return CMD_SUCCESS; |
| 6645 | } |
| 6646 | |
| 6647 | DEFUN (ospf_distance_ospf_inter_external_intra, |
| 6648 | ospf_distance_ospf_inter_external_intra_cmd, |
| 6649 | "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>", |
| 6650 | "Define an administrative distance\n" |
| 6651 | "OSPF Administrative distance\n" |
| 6652 | "Inter-area routes\n" |
| 6653 | "Distance for inter-area routes\n" |
| 6654 | "External routes\n" |
| 6655 | "Distance for external routes\n" |
| 6656 | "Intra-area routes\n" |
| 6657 | "Distance for intra-area routes\n") |
| 6658 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6659 | struct ospf *ospf = vty->index; |
| 6660 | |
| 6661 | ospf->distance_inter = atoi (argv[0]); |
| 6662 | ospf->distance_external = atoi (argv[1]); |
| 6663 | ospf->distance_intra = atoi (argv[2]); |
| 6664 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6665 | return CMD_SUCCESS; |
| 6666 | } |
| 6667 | |
| 6668 | DEFUN (ospf_distance_ospf_external, |
| 6669 | ospf_distance_ospf_external_cmd, |
| 6670 | "distance ospf external <1-255>", |
| 6671 | "Define an administrative distance\n" |
| 6672 | "OSPF Administrative distance\n" |
| 6673 | "External routes\n" |
| 6674 | "Distance for external routes\n") |
| 6675 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6676 | struct ospf *ospf = vty->index; |
| 6677 | |
| 6678 | ospf->distance_external = atoi (argv[0]); |
| 6679 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6680 | return CMD_SUCCESS; |
| 6681 | } |
| 6682 | |
| 6683 | DEFUN (ospf_distance_ospf_external_intra, |
| 6684 | ospf_distance_ospf_external_intra_cmd, |
| 6685 | "distance ospf external <1-255> intra-area <1-255>", |
| 6686 | "Define an administrative distance\n" |
| 6687 | "OSPF Administrative distance\n" |
| 6688 | "External routes\n" |
| 6689 | "Distance for external routes\n" |
| 6690 | "Intra-area routes\n" |
| 6691 | "Distance for intra-area routes\n") |
| 6692 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6693 | struct ospf *ospf = vty->index; |
| 6694 | |
| 6695 | ospf->distance_external = atoi (argv[0]); |
| 6696 | ospf->distance_intra = atoi (argv[1]); |
| 6697 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6698 | return CMD_SUCCESS; |
| 6699 | } |
| 6700 | |
| 6701 | DEFUN (ospf_distance_ospf_external_inter, |
| 6702 | ospf_distance_ospf_external_inter_cmd, |
| 6703 | "distance ospf external <1-255> inter-area <1-255>", |
| 6704 | "Define an administrative distance\n" |
| 6705 | "OSPF Administrative distance\n" |
| 6706 | "External routes\n" |
| 6707 | "Distance for external routes\n" |
| 6708 | "Inter-area routes\n" |
| 6709 | "Distance for inter-area routes\n") |
| 6710 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6711 | struct ospf *ospf = vty->index; |
| 6712 | |
| 6713 | ospf->distance_external = atoi (argv[0]); |
| 6714 | ospf->distance_inter = atoi (argv[1]); |
| 6715 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6716 | return CMD_SUCCESS; |
| 6717 | } |
| 6718 | |
| 6719 | DEFUN (ospf_distance_ospf_external_intra_inter, |
| 6720 | ospf_distance_ospf_external_intra_inter_cmd, |
| 6721 | "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>", |
| 6722 | "Define an administrative distance\n" |
| 6723 | "OSPF Administrative distance\n" |
| 6724 | "External routes\n" |
| 6725 | "Distance for external routes\n" |
| 6726 | "Intra-area routes\n" |
| 6727 | "Distance for intra-area routes\n" |
| 6728 | "Inter-area routes\n" |
| 6729 | "Distance for inter-area routes\n") |
| 6730 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6731 | struct ospf *ospf = vty->index; |
| 6732 | |
| 6733 | ospf->distance_external = atoi (argv[0]); |
| 6734 | ospf->distance_intra = atoi (argv[1]); |
| 6735 | ospf->distance_inter = atoi (argv[2]); |
| 6736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6737 | return CMD_SUCCESS; |
| 6738 | } |
| 6739 | |
| 6740 | DEFUN (ospf_distance_ospf_external_inter_intra, |
| 6741 | ospf_distance_ospf_external_inter_intra_cmd, |
| 6742 | "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>", |
| 6743 | "Define an administrative distance\n" |
| 6744 | "OSPF Administrative distance\n" |
| 6745 | "External routes\n" |
| 6746 | "Distance for external routes\n" |
| 6747 | "Inter-area routes\n" |
| 6748 | "Distance for inter-area routes\n" |
| 6749 | "Intra-area routes\n" |
| 6750 | "Distance for intra-area routes\n") |
| 6751 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6752 | struct ospf *ospf = vty->index; |
| 6753 | |
| 6754 | ospf->distance_external = atoi (argv[0]); |
| 6755 | ospf->distance_inter = atoi (argv[1]); |
| 6756 | ospf->distance_intra = atoi (argv[2]); |
| 6757 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6758 | return CMD_SUCCESS; |
| 6759 | } |
| 6760 | |
| 6761 | DEFUN (ospf_distance_source, |
| 6762 | ospf_distance_source_cmd, |
| 6763 | "distance <1-255> A.B.C.D/M", |
| 6764 | "Administrative distance\n" |
| 6765 | "Distance value\n" |
| 6766 | "IP source prefix\n") |
| 6767 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6768 | struct ospf *ospf = vty->index; |
| 6769 | |
| 6770 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6771 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6772 | return CMD_SUCCESS; |
| 6773 | } |
| 6774 | |
| 6775 | DEFUN (no_ospf_distance_source, |
| 6776 | no_ospf_distance_source_cmd, |
| 6777 | "no distance <1-255> A.B.C.D/M", |
| 6778 | NO_STR |
| 6779 | "Administrative distance\n" |
| 6780 | "Distance value\n" |
| 6781 | "IP source prefix\n") |
| 6782 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6783 | struct ospf *ospf = vty->index; |
| 6784 | |
| 6785 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6786 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6787 | return CMD_SUCCESS; |
| 6788 | } |
| 6789 | |
| 6790 | DEFUN (ospf_distance_source_access_list, |
| 6791 | ospf_distance_source_access_list_cmd, |
| 6792 | "distance <1-255> A.B.C.D/M WORD", |
| 6793 | "Administrative distance\n" |
| 6794 | "Distance value\n" |
| 6795 | "IP source prefix\n" |
| 6796 | "Access list name\n") |
| 6797 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6798 | struct ospf *ospf = vty->index; |
| 6799 | |
| 6800 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6801 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6802 | return CMD_SUCCESS; |
| 6803 | } |
| 6804 | |
| 6805 | DEFUN (no_ospf_distance_source_access_list, |
| 6806 | no_ospf_distance_source_access_list_cmd, |
| 6807 | "no distance <1-255> A.B.C.D/M WORD", |
| 6808 | NO_STR |
| 6809 | "Administrative distance\n" |
| 6810 | "Distance value\n" |
| 6811 | "IP source prefix\n" |
| 6812 | "Access list name\n") |
| 6813 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6814 | struct ospf *ospf = vty->index; |
| 6815 | |
| 6816 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6817 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6818 | return CMD_SUCCESS; |
| 6819 | } |
| 6820 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6821 | DEFUN (ip_ospf_mtu_ignore, |
| 6822 | ip_ospf_mtu_ignore_addr_cmd, |
| 6823 | "ip ospf mtu-ignore A.B.C.D", |
| 6824 | "IP Information\n" |
| 6825 | "OSPF interface commands\n" |
| 6826 | "Disable mtu mismatch detection\n" |
| 6827 | "Address of interface") |
| 6828 | { |
| 6829 | struct interface *ifp = vty->index; |
| 6830 | struct in_addr addr; |
| 6831 | int ret; |
| 6832 | |
| 6833 | struct ospf_if_params *params; |
| 6834 | params = IF_DEF_PARAMS (ifp); |
| 6835 | |
| 6836 | if (argc == 1) |
| 6837 | { |
| 6838 | ret = inet_aton(argv[0], &addr); |
| 6839 | if (!ret) |
| 6840 | { |
| 6841 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6842 | VTY_NEWLINE); |
| 6843 | return CMD_WARNING; |
| 6844 | } |
| 6845 | params = ospf_get_if_params (ifp, addr); |
| 6846 | ospf_if_update_params (ifp, addr); |
| 6847 | } |
| 6848 | params->mtu_ignore = 1; |
| 6849 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6850 | SET_IF_PARAM (params, mtu_ignore); |
| 6851 | else |
| 6852 | { |
| 6853 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6854 | if (params != IF_DEF_PARAMS (ifp)) |
| 6855 | { |
| 6856 | ospf_free_if_params (ifp, addr); |
| 6857 | ospf_if_update_params (ifp, addr); |
| 6858 | } |
| 6859 | } |
| 6860 | return CMD_SUCCESS; |
| 6861 | } |
| 6862 | |
| 6863 | ALIAS (ip_ospf_mtu_ignore, |
| 6864 | ip_ospf_mtu_ignore_cmd, |
| 6865 | "ip ospf mtu-ignore", |
| 6866 | "IP Information\n" |
| 6867 | "OSPF interface commands\n" |
| 6868 | "Disable mtu mismatch detection\n") |
| 6869 | |
| 6870 | |
| 6871 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6872 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6873 | "no ip ospf mtu-ignore A.B.C.D", |
| 6874 | "IP Information\n" |
| 6875 | "OSPF interface commands\n" |
| 6876 | "Disable mtu mismatch detection\n" |
| 6877 | "Address of interface") |
| 6878 | { |
| 6879 | struct interface *ifp = vty->index; |
| 6880 | struct in_addr addr; |
| 6881 | int ret; |
| 6882 | |
| 6883 | struct ospf_if_params *params; |
| 6884 | params = IF_DEF_PARAMS (ifp); |
| 6885 | |
| 6886 | if (argc == 1) |
| 6887 | { |
| 6888 | ret = inet_aton(argv[0], &addr); |
| 6889 | if (!ret) |
| 6890 | { |
| 6891 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6892 | VTY_NEWLINE); |
| 6893 | return CMD_WARNING; |
| 6894 | } |
| 6895 | params = ospf_get_if_params (ifp, addr); |
| 6896 | ospf_if_update_params (ifp, addr); |
| 6897 | } |
| 6898 | params->mtu_ignore = 0; |
| 6899 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6900 | SET_IF_PARAM (params, mtu_ignore); |
| 6901 | else |
| 6902 | { |
| 6903 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6904 | if (params != IF_DEF_PARAMS (ifp)) |
| 6905 | { |
| 6906 | ospf_free_if_params (ifp, addr); |
| 6907 | ospf_if_update_params (ifp, addr); |
| 6908 | } |
| 6909 | } |
| 6910 | return CMD_SUCCESS; |
| 6911 | } |
| 6912 | |
| 6913 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6914 | no_ip_ospf_mtu_ignore_cmd, |
| 6915 | "no ip ospf mtu-ignore", |
| 6916 | "IP Information\n" |
| 6917 | "OSPF interface commands\n" |
| 6918 | "Disable mtu mismatch detection\n") |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6919 | |
| 6920 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6921 | ospf_max_metric_router_lsa_admin_cmd, |
| 6922 | "max-metric router-lsa administrative", |
| 6923 | "OSPF maximum / infinite-distance metric\n" |
| 6924 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6925 | "Administratively applied, for an indefinite period\n") |
| 6926 | { |
| 6927 | struct listnode *ln; |
| 6928 | struct ospf_area *area; |
| 6929 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6930 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6931 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6932 | { |
| 6933 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6934 | |
| 6935 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 6936 | ospf_router_lsa_timer_add (area); |
| 6937 | } |
| 6938 | return CMD_SUCCESS; |
| 6939 | } |
| 6940 | |
| 6941 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6942 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6943 | "no max-metric router-lsa administrative", |
| 6944 | NO_STR |
| 6945 | "OSPF maximum / infinite-distance metric\n" |
| 6946 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6947 | "Administratively applied, for an indefinite period\n") |
| 6948 | { |
| 6949 | struct listnode *ln; |
| 6950 | struct ospf_area *area; |
| 6951 | struct ospf *ospf = vty->index; |
| 6952 | |
| 6953 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6954 | { |
| 6955 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6956 | |
| 6957 | /* Don't trample on the start-up stub timer */ |
| 6958 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6959 | && !area->t_stub_router) |
| 6960 | { |
| 6961 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 6962 | ospf_router_lsa_timer_add (area); |
| 6963 | } |
| 6964 | } |
| 6965 | return CMD_SUCCESS; |
| 6966 | } |
| 6967 | |
| 6968 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6969 | ospf_max_metric_router_lsa_startup_cmd, |
| 6970 | "max-metric router-lsa on-startup <5-86400>", |
| 6971 | "OSPF maximum / infinite-distance metric\n" |
| 6972 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6973 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6974 | "Time (seconds) to advertise self as stub-router\n") |
| 6975 | { |
| 6976 | unsigned int seconds; |
| 6977 | struct ospf *ospf = vty->index; |
| 6978 | |
| 6979 | if (argc != 1) |
| 6980 | { |
| 6981 | vty_out (vty, "%% Must supply stub-router period"); |
| 6982 | return CMD_WARNING; |
| 6983 | } |
| 6984 | |
| 6985 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6986 | |
| 6987 | ospf->stub_router_startup_time = seconds; |
| 6988 | |
| 6989 | return CMD_SUCCESS; |
| 6990 | } |
| 6991 | |
| 6992 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6993 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6994 | "no max-metric router-lsa on-startup", |
| 6995 | NO_STR |
| 6996 | "OSPF maximum / infinite-distance metric\n" |
| 6997 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6998 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6999 | { |
| 7000 | struct listnode *ln; |
| 7001 | struct ospf_area *area; |
| 7002 | struct ospf *ospf = vty->index; |
| 7003 | |
| 7004 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 7005 | |
| 7006 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 7007 | { |
| 7008 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 7009 | OSPF_TIMER_OFF (area->t_stub_router); |
| 7010 | |
| 7011 | /* Don't trample on admin stub routed */ |
| 7012 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 7013 | { |
| 7014 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
| 7015 | ospf_router_lsa_timer_add (area); |
| 7016 | } |
| 7017 | } |
| 7018 | return CMD_SUCCESS; |
| 7019 | } |
| 7020 | |
| 7021 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 7022 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 7023 | "max-metric router-lsa on-shutdown <5-86400>", |
| 7024 | "OSPF maximum / infinite-distance metric\n" |
| 7025 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 7026 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 7027 | "Time (seconds) to wait till full shutdown\n") |
| 7028 | { |
| 7029 | unsigned int seconds; |
| 7030 | struct ospf *ospf = vty->index; |
| 7031 | |
| 7032 | if (argc != 1) |
| 7033 | { |
| 7034 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 7035 | return CMD_WARNING; |
| 7036 | } |
| 7037 | |
| 7038 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 7039 | |
| 7040 | ospf->stub_router_shutdown_time = seconds; |
| 7041 | |
| 7042 | return CMD_SUCCESS; |
| 7043 | } |
| 7044 | |
| 7045 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 7046 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 7047 | "no max-metric router-lsa on-shutdown", |
| 7048 | NO_STR |
| 7049 | "OSPF maximum / infinite-distance metric\n" |
| 7050 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 7051 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 7052 | { |
| 7053 | struct ospf *ospf = vty->index; |
| 7054 | |
| 7055 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 7056 | |
| 7057 | return CMD_SUCCESS; |
| 7058 | } |
| 7059 | |
| 7060 | static void |
| 7061 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 7062 | { |
| 7063 | struct listnode *ln; |
| 7064 | struct ospf_area *area; |
| 7065 | |
| 7066 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 7067 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 7068 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 7069 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 7070 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 7071 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 7072 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 7073 | { |
| 7074 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 7075 | { |
| 7076 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 7077 | VTY_NEWLINE); |
| 7078 | break; |
| 7079 | } |
| 7080 | } |
| 7081 | return; |
| 7082 | } |
| 7083 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7084 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7085 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 7086 | { |
| 7087 | struct route_node *rn; |
| 7088 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7089 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7090 | struct ospf_path *path; |
| 7091 | |
| 7092 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 7093 | VTY_NEWLINE); |
| 7094 | |
| 7095 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 7096 | if ((or = rn->info) != NULL) |
| 7097 | { |
| 7098 | char buf1[19]; |
| 7099 | snprintf (buf1, 19, "%s/%d", |
| 7100 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 7101 | |
| 7102 | switch (or->path_type) |
| 7103 | { |
| 7104 | case OSPF_PATH_INTER_AREA: |
| 7105 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 7106 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 7107 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 7108 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 7109 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 7110 | break; |
| 7111 | case OSPF_PATH_INTRA_AREA: |
| 7112 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 7113 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 7114 | break; |
| 7115 | default: |
| 7116 | break; |
| 7117 | } |
| 7118 | |
| 7119 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7120 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7121 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7122 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7123 | { |
| 7124 | if (path->nexthop.s_addr == 0) |
| 7125 | vty_out (vty, "%24s directly attached to %s%s", |
| 7126 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7127 | else |
| 7128 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7129 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7130 | VTY_NEWLINE); |
| 7131 | } |
| 7132 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7133 | } |
| 7134 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7135 | } |
| 7136 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7137 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7138 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 7139 | { |
| 7140 | struct route_node *rn; |
| 7141 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7142 | struct listnode *pnode; |
| 7143 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7144 | struct ospf_path *path; |
| 7145 | |
| 7146 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 7147 | VTY_NEWLINE); |
| 7148 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 7149 | if (rn->info) |
| 7150 | { |
| 7151 | int flag = 0; |
| 7152 | |
| 7153 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 7154 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7155 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 7156 | { |
| 7157 | if (flag++) |
| 7158 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7159 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7160 | /* Show path. */ |
| 7161 | vty_out (vty, "%s [%d] area: %s", |
| 7162 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 7163 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 7164 | /* Show flags. */ |
| 7165 | vty_out (vty, "%s%s%s", |
| 7166 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 7167 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 7168 | VTY_NEWLINE); |
| 7169 | |
| 7170 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 7171 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7172 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
| 7173 | { |
| 7174 | if (path->nexthop.s_addr == 0) |
| 7175 | vty_out (vty, "%24s directly attached to %s%s", |
| 7176 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7177 | else |
| 7178 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7179 | inet_ntoa (path->nexthop), |
| 7180 | path->oi->ifp->name, VTY_NEWLINE); |
| 7181 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7182 | } |
| 7183 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7184 | } |
| 7185 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7186 | } |
| 7187 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7188 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7189 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 7190 | { |
| 7191 | struct route_node *rn; |
| 7192 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7193 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7194 | struct ospf_path *path; |
| 7195 | |
| 7196 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 7197 | VTY_NEWLINE); |
| 7198 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 7199 | if ((er = rn->info) != NULL) |
| 7200 | { |
| 7201 | char buf1[19]; |
| 7202 | snprintf (buf1, 19, "%s/%d", |
| 7203 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 7204 | |
| 7205 | switch (er->path_type) |
| 7206 | { |
| 7207 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 7208 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 7209 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 7210 | break; |
| 7211 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 7212 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 7213 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 7214 | break; |
| 7215 | } |
| 7216 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7217 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7218 | { |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 7219 | if (path->oi != NULL && ospf_if_exists(path->oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7220 | { |
| 7221 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 7222 | vty_out (vty, "%24s directly attached to %s%s", |
| 7223 | "", path->oi->ifp->name, VTY_NEWLINE); |
| 7224 | else |
| 7225 | vty_out (vty, "%24s via %s, %s%s", "", |
| 7226 | inet_ntoa (path->nexthop), path->oi->ifp->name, |
| 7227 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7228 | } |
| 7229 | } |
| 7230 | } |
| 7231 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7232 | } |
| 7233 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7234 | DEFUN (show_ip_ospf_border_routers, |
| 7235 | show_ip_ospf_border_routers_cmd, |
| 7236 | "show ip ospf border-routers", |
| 7237 | SHOW_STR |
| 7238 | IP_STR |
| 7239 | "show all the ABR's and ASBR's\n" |
| 7240 | "for this area\n") |
| 7241 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7242 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7243 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7244 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7246 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7247 | return CMD_SUCCESS; |
| 7248 | } |
| 7249 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7250 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7251 | { |
| 7252 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7253 | return CMD_SUCCESS; |
| 7254 | } |
| 7255 | |
| 7256 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7257 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7258 | |
| 7259 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7260 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7261 | |
| 7262 | return CMD_SUCCESS; |
| 7263 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7264 | |
| 7265 | DEFUN (show_ip_ospf_route, |
| 7266 | show_ip_ospf_route_cmd, |
| 7267 | "show ip ospf route", |
| 7268 | SHOW_STR |
| 7269 | IP_STR |
| 7270 | "OSPF information\n" |
| 7271 | "OSPF routing table\n") |
| 7272 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7273 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7274 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7275 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7276 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 7277 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7278 | return CMD_SUCCESS; |
| 7279 | } |
| 7280 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7281 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7282 | { |
| 7283 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 7284 | return CMD_SUCCESS; |
| 7285 | } |
| 7286 | |
| 7287 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7288 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7289 | |
| 7290 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7291 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7292 | |
| 7293 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7294 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7295 | |
| 7296 | return CMD_SUCCESS; |
| 7297 | } |
| 7298 | |
| 7299 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7300 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7301 | { |
| 7302 | "unknown", |
| 7303 | "standard", |
| 7304 | "ibm", |
| 7305 | "cisco", |
| 7306 | "shortcut" |
| 7307 | }; |
| 7308 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7309 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7310 | { |
| 7311 | "default", |
| 7312 | "enable", |
| 7313 | "disable" |
| 7314 | }; |
| 7315 | |
| 7316 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7317 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7318 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 7319 | { |
| 7320 | memset (buf, 0, length); |
| 7321 | |
| 7322 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 7323 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 7324 | else |
| 7325 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 7326 | } |
| 7327 | |
| 7328 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7329 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7330 | { |
| 7331 | "unknown", /* should never be used. */ |
| 7332 | "point-to-point", |
| 7333 | "broadcast", |
| 7334 | "non-broadcast", |
| 7335 | "point-to-multipoint", |
| 7336 | "virtual-link", /* should never be used. */ |
| 7337 | "loopback" |
| 7338 | }; |
| 7339 | |
| 7340 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7341 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7342 | config_write_interface (struct vty *vty) |
| 7343 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7344 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7345 | struct interface *ifp; |
| 7346 | struct crypt_key *ck; |
| 7347 | int write = 0; |
| 7348 | struct route_node *rn = NULL; |
| 7349 | struct ospf_if_params *params; |
| 7350 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7351 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7352 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7353 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 7354 | continue; |
| 7355 | |
| 7356 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 7357 | vty_out (vty, "interface %s%s", ifp->name, |
| 7358 | VTY_NEWLINE); |
| 7359 | if (ifp->desc) |
| 7360 | vty_out (vty, " description %s%s", ifp->desc, |
| 7361 | VTY_NEWLINE); |
| 7362 | |
| 7363 | write++; |
| 7364 | |
| 7365 | params = IF_DEF_PARAMS (ifp); |
| 7366 | |
| 7367 | do { |
| 7368 | /* Interface Network print. */ |
| 7369 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7370 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 7371 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 7372 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 7373 | { |
| 7374 | vty_out (vty, " ip ospf network %s", |
| 7375 | ospf_int_type_str[params->type]); |
| 7376 | if (params != IF_DEF_PARAMS (ifp)) |
| 7377 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7378 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7379 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7380 | } |
| 7381 | |
| 7382 | /* OSPF interface authentication print */ |
| 7383 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 7384 | params->auth_type != OSPF_AUTH_NOTSET) |
| 7385 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 7386 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7387 | |
| 7388 | /* Translation tables are not that much help here due to syntax |
| 7389 | of the simple option */ |
| 7390 | switch (params->auth_type) |
| 7391 | { |
| 7392 | |
| 7393 | case OSPF_AUTH_NULL: |
| 7394 | auth_str = " null"; |
| 7395 | break; |
| 7396 | |
| 7397 | case OSPF_AUTH_SIMPLE: |
| 7398 | auth_str = ""; |
| 7399 | break; |
| 7400 | |
| 7401 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 7402 | auth_str = " message-digest"; |
| 7403 | break; |
| 7404 | |
| 7405 | default: |
| 7406 | auth_str = ""; |
| 7407 | break; |
| 7408 | } |
| 7409 | |
| 7410 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 7411 | if (params != IF_DEF_PARAMS (ifp)) |
| 7412 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7413 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7414 | } |
| 7415 | |
| 7416 | /* Simple Authentication Password print. */ |
| 7417 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 7418 | params->auth_simple[0] != '\0') |
| 7419 | { |
| 7420 | vty_out (vty, " ip ospf authentication-key %s", |
| 7421 | params->auth_simple); |
| 7422 | if (params != IF_DEF_PARAMS (ifp)) |
| 7423 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7424 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7425 | } |
| 7426 | |
| 7427 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7428 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7429 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7430 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 7431 | ck->key_id, ck->auth_key); |
| 7432 | if (params != IF_DEF_PARAMS (ifp)) |
| 7433 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7434 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7435 | } |
| 7436 | |
| 7437 | /* Interface Output Cost print. */ |
| 7438 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 7439 | { |
| 7440 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 7441 | if (params != IF_DEF_PARAMS (ifp)) |
| 7442 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7443 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7444 | } |
| 7445 | |
| 7446 | /* Hello Interval print. */ |
| 7447 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 7448 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 7449 | { |
| 7450 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 7451 | if (params != IF_DEF_PARAMS (ifp)) |
| 7452 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7453 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7454 | } |
| 7455 | |
| 7456 | |
| 7457 | /* Router Dead Interval print. */ |
| 7458 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 7459 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 7460 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7461 | vty_out (vty, " ip ospf dead-interval "); |
| 7462 | |
| 7463 | /* fast hello ? */ |
| 7464 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 7465 | vty_out (vty, "minimal hello-multiplier %d", |
| 7466 | params->fast_hello); |
| 7467 | else |
| 7468 | vty_out (vty, "%u", params->v_wait); |
| 7469 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7470 | if (params != IF_DEF_PARAMS (ifp)) |
| 7471 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7472 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7473 | } |
| 7474 | |
| 7475 | /* Router Priority print. */ |
| 7476 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 7477 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 7478 | { |
| 7479 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 7480 | if (params != IF_DEF_PARAMS (ifp)) |
| 7481 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7482 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7483 | } |
| 7484 | |
| 7485 | /* Retransmit Interval print. */ |
| 7486 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 7487 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 7488 | { |
| 7489 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 7490 | params->retransmit_interval); |
| 7491 | if (params != IF_DEF_PARAMS (ifp)) |
| 7492 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7493 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7494 | } |
| 7495 | |
| 7496 | /* Transmit Delay print. */ |
| 7497 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 7498 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7499 | { |
| 7500 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 7501 | if (params != IF_DEF_PARAMS (ifp)) |
| 7502 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7503 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7504 | } |
| 7505 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7506 | /* MTU ignore print. */ |
| 7507 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 7508 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 7509 | { |
| 7510 | if (params->mtu_ignore == 0) |
| 7511 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 7512 | else |
| 7513 | vty_out (vty, " ip ospf mtu-ignore"); |
| 7514 | if (params != IF_DEF_PARAMS (ifp)) |
| 7515 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7516 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7517 | } |
| 7518 | |
| 7519 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7520 | while (1) |
| 7521 | { |
| 7522 | if (rn == NULL) |
| 7523 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 7524 | else |
| 7525 | rn = route_next (rn); |
| 7526 | |
| 7527 | if (rn == NULL) |
| 7528 | break; |
| 7529 | params = rn->info; |
| 7530 | if (params != NULL) |
| 7531 | break; |
| 7532 | } |
| 7533 | } while (rn); |
| 7534 | |
| 7535 | #ifdef HAVE_OPAQUE_LSA |
| 7536 | ospf_opaque_config_write_if (vty, ifp); |
| 7537 | #endif /* HAVE_OPAQUE_LSA */ |
| 7538 | } |
| 7539 | |
| 7540 | return write; |
| 7541 | } |
| 7542 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7543 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7544 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7545 | { |
| 7546 | struct route_node *rn; |
| 7547 | u_char buf[INET_ADDRSTRLEN]; |
| 7548 | |
| 7549 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7550 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7551 | if (rn->info) |
| 7552 | { |
| 7553 | struct ospf_network *n = rn->info; |
| 7554 | |
| 7555 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7556 | |
| 7557 | /* Create Area ID string by specified Area ID format. */ |
| 7558 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7559 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7560 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7561 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7562 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7563 | |
| 7564 | /* Network print. */ |
| 7565 | vty_out (vty, " network %s/%d area %s%s", |
| 7566 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7567 | buf, VTY_NEWLINE); |
| 7568 | } |
| 7569 | |
| 7570 | return 0; |
| 7571 | } |
| 7572 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7573 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7574 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7575 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7576 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7577 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7578 | u_char buf[INET_ADDRSTRLEN]; |
| 7579 | |
| 7580 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7581 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7582 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7583 | struct route_node *rn1; |
| 7584 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7585 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7586 | |
| 7587 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7588 | { |
| 7589 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7590 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7591 | else |
| 7592 | vty_out (vty, " area %s authentication message-digest%s", |
| 7593 | buf, VTY_NEWLINE); |
| 7594 | } |
| 7595 | |
| 7596 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7597 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7598 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7599 | VTY_NEWLINE); |
| 7600 | |
| 7601 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7602 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7603 | ) |
| 7604 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7605 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7606 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7607 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7608 | { |
| 7609 | vty_out (vty, " area %s nssa", buf); |
| 7610 | switch (area->NSSATranslatorRole) |
| 7611 | { |
| 7612 | case OSPF_NSSA_ROLE_NEVER: |
| 7613 | vty_out (vty, " translate-never"); |
| 7614 | break; |
| 7615 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7616 | vty_out (vty, " translate-always"); |
| 7617 | break; |
| 7618 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7619 | default: |
| 7620 | vty_out (vty, " translate-candidate"); |
| 7621 | } |
| 7622 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7623 | |
| 7624 | if (area->no_summary) |
| 7625 | vty_out (vty, " no-summary"); |
| 7626 | |
| 7627 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7628 | |
| 7629 | if (area->default_cost != 1) |
| 7630 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7631 | area->default_cost, VTY_NEWLINE); |
| 7632 | } |
| 7633 | |
| 7634 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7635 | if (rn1->info) |
| 7636 | { |
| 7637 | struct ospf_area_range *range = rn1->info; |
| 7638 | |
| 7639 | vty_out (vty, " area %s range %s/%d", buf, |
| 7640 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7641 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7642 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7643 | vty_out (vty, " cost %d", range->cost_config); |
| 7644 | |
| 7645 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7646 | vty_out (vty, " not-advertise"); |
| 7647 | |
| 7648 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7649 | vty_out (vty, " substitute %s/%d", |
| 7650 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7651 | |
| 7652 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7653 | } |
| 7654 | |
| 7655 | if (EXPORT_NAME (area)) |
| 7656 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7657 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7658 | |
| 7659 | if (IMPORT_NAME (area)) |
| 7660 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7661 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7662 | |
| 7663 | if (PREFIX_NAME_IN (area)) |
| 7664 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7665 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7666 | |
| 7667 | if (PREFIX_NAME_OUT (area)) |
| 7668 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7669 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7670 | } |
| 7671 | |
| 7672 | return 0; |
| 7673 | } |
| 7674 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7675 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7676 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7677 | { |
| 7678 | struct ospf_nbr_nbma *nbr_nbma; |
| 7679 | struct route_node *rn; |
| 7680 | |
| 7681 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7682 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7683 | if ((nbr_nbma = rn->info)) |
| 7684 | { |
| 7685 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7686 | |
| 7687 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7688 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7689 | |
| 7690 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7691 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7692 | |
| 7693 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7694 | } |
| 7695 | |
| 7696 | return 0; |
| 7697 | } |
| 7698 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7699 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7700 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7701 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7702 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7703 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7704 | u_char buf[INET_ADDRSTRLEN]; |
| 7705 | |
| 7706 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7707 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7708 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7709 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7710 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7711 | struct ospf_interface *oi; |
| 7712 | |
| 7713 | if (vl_data != NULL) |
| 7714 | { |
| 7715 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7716 | |
| 7717 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7718 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7719 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7720 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7721 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7722 | oi = vl_data->vl_oi; |
| 7723 | |
| 7724 | /* timers */ |
| 7725 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7726 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7727 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7728 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7729 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7730 | buf, |
| 7731 | inet_ntoa (vl_data->vl_peer), |
| 7732 | OSPF_IF_PARAM (oi, v_hello), |
| 7733 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7734 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7735 | OSPF_IF_PARAM (oi, v_wait), |
| 7736 | VTY_NEWLINE); |
| 7737 | else |
| 7738 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7739 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7740 | /* Auth key */ |
| 7741 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7742 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7743 | buf, |
| 7744 | inet_ntoa (vl_data->vl_peer), |
| 7745 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7746 | VTY_NEWLINE); |
| 7747 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7748 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7749 | n2, ck)) |
| 7750 | vty_out (vty, " area %s virtual-link %s" |
| 7751 | " message-digest-key %d md5 %s%s", |
| 7752 | buf, |
| 7753 | inet_ntoa (vl_data->vl_peer), |
| 7754 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7755 | |
| 7756 | } |
| 7757 | } |
| 7758 | |
| 7759 | return 0; |
| 7760 | } |
| 7761 | |
| 7762 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7763 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7764 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7765 | { |
| 7766 | int type; |
| 7767 | |
| 7768 | /* redistribute print. */ |
| 7769 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7770 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7771 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7772 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7773 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7774 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7775 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7776 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7777 | vty_out (vty, " metric-type 1"); |
| 7778 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7779 | if (ROUTEMAP_NAME (ospf, type)) |
| 7780 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7781 | |
| 7782 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7783 | } |
| 7784 | |
| 7785 | return 0; |
| 7786 | } |
| 7787 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7788 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7789 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7790 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7791 | if (ospf->default_metric != -1) |
| 7792 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7793 | VTY_NEWLINE); |
| 7794 | return 0; |
| 7795 | } |
| 7796 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7797 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7798 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7799 | { |
| 7800 | int type; |
| 7801 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7802 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7803 | { |
| 7804 | /* distribute-list print. */ |
| 7805 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7806 | if (ospf->dlist[type].name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7807 | vty_out (vty, " distribute-list %s out %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7808 | ospf->dlist[type].name, |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7809 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7810 | |
| 7811 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7812 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7813 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7814 | vty_out (vty, " default-information originate"); |
| 7815 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7816 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7817 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7818 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7819 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7820 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7821 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7822 | vty_out (vty, " metric-type 1"); |
| 7823 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7824 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7825 | vty_out (vty, " route-map %s", |
| 7826 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7827 | |
| 7828 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7829 | } |
| 7830 | |
| 7831 | } |
| 7832 | |
| 7833 | return 0; |
| 7834 | } |
| 7835 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7836 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7837 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7838 | { |
| 7839 | struct route_node *rn; |
| 7840 | struct ospf_distance *odistance; |
| 7841 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7842 | if (ospf->distance_all) |
| 7843 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7844 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7845 | if (ospf->distance_intra |
| 7846 | || ospf->distance_inter |
| 7847 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7848 | { |
| 7849 | vty_out (vty, " distance ospf"); |
| 7850 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7851 | if (ospf->distance_intra) |
| 7852 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7853 | if (ospf->distance_inter) |
| 7854 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7855 | if (ospf->distance_external) |
| 7856 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7857 | |
| 7858 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7859 | } |
| 7860 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7861 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7862 | if ((odistance = rn->info) != NULL) |
| 7863 | { |
| 7864 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7865 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7866 | odistance->access_list ? odistance->access_list : "", |
| 7867 | VTY_NEWLINE); |
| 7868 | } |
| 7869 | return 0; |
| 7870 | } |
| 7871 | |
| 7872 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7873 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7874 | ospf_config_write (struct vty *vty) |
| 7875 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7876 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7877 | struct interface *ifp; |
| 7878 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7879 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7880 | int write = 0; |
| 7881 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7882 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7883 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7884 | { |
| 7885 | /* `router ospf' print. */ |
| 7886 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7887 | |
| 7888 | write++; |
| 7889 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7890 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7891 | return write; |
| 7892 | |
| 7893 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7894 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7895 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7896 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7897 | |
| 7898 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7899 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7900 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7901 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7902 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7903 | /* log-adjacency-changes flag print. */ |
| 7904 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 7905 | { |
| 7906 | vty_out(vty, " log-adjacency-changes"); |
| 7907 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 7908 | vty_out(vty, " detail"); |
| 7909 | vty_out(vty, "%s", VTY_NEWLINE); |
| 7910 | } |
| 7911 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7912 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7913 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7914 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7915 | |
| 7916 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7917 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7918 | { |
| 7919 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7920 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7921 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7922 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7923 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7924 | |
| 7925 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7926 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7927 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7928 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7929 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7930 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7931 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7932 | |
| 7933 | /* Max-metric router-lsa print */ |
| 7934 | config_write_stub_router (vty, ospf); |
| 7935 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7936 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7937 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7938 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7939 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7940 | |
| 7941 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7942 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7943 | |
| 7944 | /* passive-interface print. */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7945 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
| 7946 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); |
| 7947 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7948 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7949 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
| 7950 | && IF_DEF_PARAMS (ifp)->passive_interface != |
| 7951 | ospf->passive_interface_default) |
| 7952 | { |
| 7953 | vty_out (vty, " %spassive-interface %s%s", |
| 7954 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", |
| 7955 | ifp->name, VTY_NEWLINE); |
| 7956 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7957 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7958 | { |
| 7959 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) |
| 7960 | continue; |
| 7961 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), |
| 7962 | passive_interface)) |
| 7963 | { |
| 7964 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) |
| 7965 | continue; |
| 7966 | } |
| 7967 | else if (oi->params->passive_interface == ospf->passive_interface_default) |
| 7968 | continue; |
| 7969 | |
| 7970 | vty_out (vty, " %spassive-interface %s %s%s", |
| 7971 | oi->params->passive_interface ? "" : "no ", |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7972 | oi->ifp->name, |
| 7973 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7974 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7975 | |
| 7976 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7977 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7978 | |
| 7979 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7980 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7981 | |
| 7982 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7983 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7984 | |
| 7985 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7986 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7987 | |
| 7988 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7989 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7990 | |
| 7991 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7992 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7993 | |
| 7994 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7995 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7996 | |
| 7997 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7998 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7999 | #endif /* HAVE_OPAQUE_LSA */ |
| 8000 | } |
| 8001 | |
| 8002 | return write; |
| 8003 | } |
| 8004 | |
| 8005 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8006 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8007 | { |
| 8008 | /* "show ip ospf" commands. */ |
| 8009 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 8010 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 8011 | |
| 8012 | /* "show ip ospf database" commands. */ |
| 8013 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 8014 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 8015 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 8016 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 8017 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 8018 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 8019 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 8020 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 8021 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 8022 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 8023 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 8024 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 8025 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 8026 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 8027 | |
| 8028 | /* "show ip ospf interface" commands. */ |
| 8029 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 8030 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 8031 | |
| 8032 | /* "show ip ospf neighbor" commands. */ |
| 8033 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 8034 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 8035 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 8036 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 8037 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 8038 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 8039 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 8040 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 8041 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 8042 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 8043 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 8044 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 8045 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 8046 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 8047 | |
| 8048 | /* "show ip ospf route" commands. */ |
| 8049 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 8050 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8051 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 8052 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8053 | } |
| 8054 | |
| 8055 | |
| 8056 | /* ospfd's interface node. */ |
| 8057 | struct cmd_node interface_node = |
| 8058 | { |
| 8059 | INTERFACE_NODE, |
| 8060 | "%s(config-if)# ", |
| 8061 | 1 |
| 8062 | }; |
| 8063 | |
| 8064 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8065 | static void |
| 8066 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8067 | { |
| 8068 | /* Install interface node. */ |
| 8069 | install_node (&interface_node, config_write_interface); |
| 8070 | |
| 8071 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 8072 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8073 | install_default (INTERFACE_NODE); |
| 8074 | |
| 8075 | /* "description" commands. */ |
| 8076 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 8077 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 8078 | |
| 8079 | /* "ip ospf authentication" commands. */ |
| 8080 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 8081 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 8082 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 8083 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 8084 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 8085 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 8086 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 8087 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 8088 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 8089 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 8090 | |
| 8091 | /* "ip ospf message-digest-key" commands. */ |
| 8092 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 8093 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 8094 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 8095 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 8096 | |
| 8097 | /* "ip ospf cost" commands. */ |
| 8098 | install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd); |
| 8099 | install_element (INTERFACE_NODE, &ip_ospf_cost_cmd); |
| 8100 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd); |
| 8101 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 8102 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 8103 | /* "ip ospf mtu-ignore" commands. */ |
| 8104 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 8105 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 8106 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 8107 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 8108 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8109 | /* "ip ospf dead-interval" commands. */ |
| 8110 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 8111 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 8112 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 8113 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8114 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 8115 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 8116 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8117 | /* "ip ospf hello-interval" commands. */ |
| 8118 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 8119 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 8120 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 8121 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 8122 | |
| 8123 | /* "ip ospf network" commands. */ |
| 8124 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 8125 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 8126 | |
| 8127 | /* "ip ospf priority" commands. */ |
| 8128 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 8129 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 8130 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 8131 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 8132 | |
| 8133 | /* "ip ospf retransmit-interval" commands. */ |
| 8134 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 8135 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 8136 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 8137 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 8138 | |
| 8139 | /* "ip ospf transmit-delay" commands. */ |
| 8140 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 8141 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 8142 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 8143 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 8144 | |
| 8145 | /* These commands are compatibitliy for previous version. */ |
| 8146 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 8147 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 8148 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 8149 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
| 8150 | install_element (INTERFACE_NODE, &ospf_cost_cmd); |
| 8151 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
| 8152 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 8153 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 8154 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 8155 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 8156 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 8157 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 8158 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 8159 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 8160 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 8161 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 8162 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 8163 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 8164 | } |
| 8165 | |
| 8166 | /* Zebra node structure. */ |
| 8167 | struct cmd_node zebra_node = |
| 8168 | { |
| 8169 | ZEBRA_NODE, |
| 8170 | "%s(config-router)#", |
| 8171 | }; |
| 8172 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8173 | static void |
| 8174 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8175 | { |
| 8176 | install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd); |
| 8177 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd); |
| 8178 | install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd); |
| 8179 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd); |
| 8180 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
| 8181 | install_element (OSPF_NODE, |
| 8182 | &ospf_redistribute_source_metric_type_routemap_cmd); |
| 8183 | install_element (OSPF_NODE, |
| 8184 | &ospf_redistribute_source_type_metric_routemap_cmd); |
| 8185 | install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd); |
| 8186 | install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd); |
| 8187 | install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd); |
| 8188 | |
| 8189 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 8190 | |
| 8191 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 8192 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 8193 | |
| 8194 | install_element (OSPF_NODE, |
| 8195 | &ospf_default_information_originate_metric_type_cmd); |
| 8196 | install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd); |
| 8197 | install_element (OSPF_NODE, |
| 8198 | &ospf_default_information_originate_type_metric_cmd); |
| 8199 | install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd); |
| 8200 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
| 8201 | install_element (OSPF_NODE, |
| 8202 | &ospf_default_information_originate_always_metric_type_cmd); |
| 8203 | install_element (OSPF_NODE, |
| 8204 | &ospf_default_information_originate_always_metric_cmd); |
| 8205 | install_element (OSPF_NODE, |
| 8206 | &ospf_default_information_originate_always_cmd); |
| 8207 | install_element (OSPF_NODE, |
| 8208 | &ospf_default_information_originate_always_type_metric_cmd); |
| 8209 | install_element (OSPF_NODE, |
| 8210 | &ospf_default_information_originate_always_type_cmd); |
| 8211 | |
| 8212 | install_element (OSPF_NODE, |
| 8213 | &ospf_default_information_originate_metric_type_routemap_cmd); |
| 8214 | install_element (OSPF_NODE, |
| 8215 | &ospf_default_information_originate_metric_routemap_cmd); |
| 8216 | install_element (OSPF_NODE, |
| 8217 | &ospf_default_information_originate_routemap_cmd); |
| 8218 | install_element (OSPF_NODE, |
| 8219 | &ospf_default_information_originate_type_metric_routemap_cmd); |
| 8220 | install_element (OSPF_NODE, |
| 8221 | &ospf_default_information_originate_type_routemap_cmd); |
| 8222 | install_element (OSPF_NODE, |
| 8223 | &ospf_default_information_originate_always_metric_type_routemap_cmd); |
| 8224 | install_element (OSPF_NODE, |
| 8225 | &ospf_default_information_originate_always_metric_routemap_cmd); |
| 8226 | install_element (OSPF_NODE, |
| 8227 | &ospf_default_information_originate_always_routemap_cmd); |
| 8228 | install_element (OSPF_NODE, |
| 8229 | &ospf_default_information_originate_always_type_metric_routemap_cmd); |
| 8230 | install_element (OSPF_NODE, |
| 8231 | &ospf_default_information_originate_always_type_routemap_cmd); |
| 8232 | |
| 8233 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 8234 | |
| 8235 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 8236 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 8237 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 8238 | |
| 8239 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 8240 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 8241 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
| 8242 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd); |
| 8243 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd); |
| 8244 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd); |
| 8245 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd); |
| 8246 | install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd); |
| 8247 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd); |
| 8248 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd); |
| 8249 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd); |
| 8250 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd); |
| 8251 | install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd); |
| 8252 | install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd); |
| 8253 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd); |
| 8254 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd); |
| 8255 | install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd); |
| 8256 | install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd); |
| 8257 | #if 0 |
| 8258 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 8259 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 8260 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 8261 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 8262 | #endif /* 0 */ |
| 8263 | } |
| 8264 | |
| 8265 | struct cmd_node ospf_node = |
| 8266 | { |
| 8267 | OSPF_NODE, |
| 8268 | "%s(config-router)# ", |
| 8269 | 1 |
| 8270 | }; |
| 8271 | |
| 8272 | |
| 8273 | /* Install OSPF related vty commands. */ |
| 8274 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 8275 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8276 | { |
| 8277 | /* Install ospf top node. */ |
| 8278 | install_node (&ospf_node, ospf_config_write); |
| 8279 | |
| 8280 | /* "router ospf" commands. */ |
| 8281 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 8282 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 8283 | |
| 8284 | install_default (OSPF_NODE); |
| 8285 | |
| 8286 | /* "ospf router-id" commands. */ |
| 8287 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 8288 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8289 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 8290 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8291 | |
| 8292 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8293 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 8294 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 8295 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8296 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 8297 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 8298 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8299 | |
| 8300 | /* "ospf abr-type" commands. */ |
| 8301 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 8302 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 8303 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 8304 | /* "ospf log-adjacency-changes" commands. */ |
| 8305 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); |
| 8306 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); |
| 8307 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); |
| 8308 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); |
| 8309 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8310 | /* "ospf rfc1583-compatible" commands. */ |
| 8311 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 8312 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 8313 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 8314 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 8315 | |
| 8316 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8317 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 8318 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8319 | |
| 8320 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8321 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 8322 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 8323 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8324 | |
| 8325 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8326 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 8327 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 8328 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 8329 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 8330 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 8331 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 8332 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 8333 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 8334 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 8335 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 8336 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8337 | |
| 8338 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8339 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 8340 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8341 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8342 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 8343 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8344 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8345 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 8346 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8347 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8348 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 8349 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8350 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8351 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 8352 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8353 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8354 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 8355 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 8356 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8357 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8358 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 8359 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8360 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8361 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 8362 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8363 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8364 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 8365 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 8366 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8367 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8368 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 8369 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 8370 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8371 | |
| 8372 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8373 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 8374 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 8375 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 8376 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8377 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8378 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8379 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 8380 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 8381 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 8382 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 8383 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 8384 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8386 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 8387 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8388 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8389 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 8390 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8391 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8392 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 8393 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8394 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8395 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 8396 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8397 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8398 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 8399 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8400 | |
| 8401 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8402 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 8403 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 8404 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 8405 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 8406 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8407 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8408 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 8409 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 8410 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8411 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 8412 | /* max-metric commands */ |
| 8413 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 8414 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 8415 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 8416 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 8417 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 8418 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 8419 | |
| 8420 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8421 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 8422 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8423 | |
| 8424 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 8425 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 8426 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 8427 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 8428 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 8429 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 8430 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 8431 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 8432 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 8433 | |
| 8434 | /* Init interface related vty commands. */ |
| 8435 | ospf_vty_if_init (); |
| 8436 | |
| 8437 | /* Init zebra related vty commands. */ |
| 8438 | ospf_vty_zebra_init (); |
| 8439 | } |