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 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 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 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 64 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | { |
Ulrich Weber | 664711c | 2011-12-21 02:24:11 +0400 | [diff] [blame] | 83 | if (*str == '-') |
| 84 | return -1; |
| 85 | errno = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 86 | ret = strtoul (str, &endptr, 10); |
Ulrich Weber | 664711c | 2011-12-21 02:24:11 +0400 | [diff] [blame] | 87 | if (*endptr != '\0' || errno || ret > UINT32_MAX) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 88 | return -1; |
| 89 | |
| 90 | area_id->s_addr = htonl (ret); |
| 91 | *format = OSPF_AREA_ID_FORMAT_DECIMAL; |
| 92 | } |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 97 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 98 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 99 | str2metric (const char *str, int *metric) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | { |
| 101 | /* Sanity check. */ |
| 102 | if (str == NULL) |
| 103 | return 0; |
| 104 | |
| 105 | *metric = strtol (str, NULL, 10); |
| 106 | if (*metric < 0 && *metric > 16777214) |
| 107 | { |
| 108 | /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */ |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | return 1; |
| 113 | } |
| 114 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 115 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 116 | str2metric_type (const char *str, int *metric_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | { |
| 118 | /* Sanity check. */ |
| 119 | if (str == NULL) |
| 120 | return 0; |
| 121 | |
| 122 | if (strncmp (str, "1", 1) == 0) |
| 123 | *metric_type = EXTERNAL_METRIC_TYPE_1; |
| 124 | else if (strncmp (str, "2", 1) == 0) |
| 125 | *metric_type = EXTERNAL_METRIC_TYPE_2; |
| 126 | else |
| 127 | return 0; |
| 128 | |
| 129 | return 1; |
| 130 | } |
| 131 | |
| 132 | int |
| 133 | ospf_oi_count (struct interface *ifp) |
| 134 | { |
| 135 | struct route_node *rn; |
| 136 | int i = 0; |
| 137 | |
| 138 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 139 | if (rn->info) |
| 140 | i++; |
| 141 | |
| 142 | return i; |
| 143 | } |
| 144 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 145 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | DEFUN (router_ospf, |
| 147 | router_ospf_cmd, |
| 148 | "router ospf", |
| 149 | "Enable a routing process\n" |
| 150 | "Start OSPF configuration\n") |
| 151 | { |
| 152 | vty->node = OSPF_NODE; |
| 153 | vty->index = ospf_get (); |
| 154 | |
| 155 | return CMD_SUCCESS; |
| 156 | } |
| 157 | |
| 158 | DEFUN (no_router_ospf, |
| 159 | no_router_ospf_cmd, |
| 160 | "no router ospf", |
| 161 | NO_STR |
| 162 | "Enable a routing process\n" |
| 163 | "Start OSPF configuration\n") |
| 164 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 165 | struct ospf *ospf; |
| 166 | |
| 167 | ospf = ospf_lookup (); |
| 168 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 170 | vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 171 | return CMD_WARNING; |
| 172 | } |
| 173 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 174 | ospf_finish (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 175 | |
| 176 | return CMD_SUCCESS; |
| 177 | } |
| 178 | |
| 179 | DEFUN (ospf_router_id, |
| 180 | ospf_router_id_cmd, |
| 181 | "ospf router-id A.B.C.D", |
| 182 | "OSPF specific commands\n" |
| 183 | "router-id for the OSPF process\n" |
| 184 | "OSPF router-id in IP address format\n") |
| 185 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 186 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 187 | struct in_addr router_id; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 188 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | |
| 190 | ret = inet_aton (argv[0], &router_id); |
| 191 | if (!ret) |
| 192 | { |
| 193 | vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE); |
| 194 | return CMD_WARNING; |
| 195 | } |
| 196 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 197 | ospf->router_id_static = router_id; |
paul | b29800a | 2005-11-20 14:50:45 +0000 | [diff] [blame] | 198 | |
| 199 | ospf_router_id_update (ospf); |
| 200 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | return CMD_SUCCESS; |
| 202 | } |
| 203 | |
| 204 | ALIAS (ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 205 | router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 206 | "router-id A.B.C.D", |
| 207 | "router-id for the OSPF process\n" |
| 208 | "OSPF router-id in IP address format\n") |
| 209 | |
| 210 | DEFUN (no_ospf_router_id, |
| 211 | no_ospf_router_id_cmd, |
| 212 | "no ospf router-id", |
| 213 | NO_STR |
| 214 | "OSPF specific commands\n" |
| 215 | "router-id for the OSPF process\n") |
| 216 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 217 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 219 | ospf->router_id_static.s_addr = 0; |
| 220 | |
| 221 | ospf_router_id_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 222 | |
| 223 | return CMD_SUCCESS; |
| 224 | } |
| 225 | |
| 226 | ALIAS (no_ospf_router_id, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 227 | no_router_ospf_id_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 228 | "no router-id", |
| 229 | NO_STR |
| 230 | "router-id for the OSPF process\n") |
| 231 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 232 | static void |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 233 | ospf_passive_interface_default (struct ospf *ospf, u_char newval) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 234 | { |
| 235 | struct listnode *ln; |
| 236 | struct interface *ifp; |
| 237 | struct ospf_interface *oi; |
| 238 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 239 | ospf->passive_interface_default = newval; |
| 240 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 241 | for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp)) |
| 242 | { |
| 243 | if (ifp && |
| 244 | OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) |
| 245 | UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface); |
| 246 | } |
| 247 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi)) |
| 248 | { |
| 249 | if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) |
| 250 | UNSET_IF_PARAM (oi->params, passive_interface); |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 251 | /* update multicast memberships */ |
| 252 | ospf_if_set_multicast(oi); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | static void |
| 257 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, |
| 258 | struct in_addr addr, |
| 259 | struct ospf_if_params *params, u_char value) |
| 260 | { |
| 261 | u_char dflt; |
| 262 | |
| 263 | params->passive_interface = value; |
| 264 | if (params != IF_DEF_PARAMS (ifp)) |
| 265 | { |
| 266 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)) |
| 267 | dflt = IF_DEF_PARAMS (ifp)->passive_interface; |
| 268 | else |
| 269 | dflt = ospf->passive_interface_default; |
| 270 | |
| 271 | if (value != dflt) |
| 272 | SET_IF_PARAM (params, passive_interface); |
| 273 | else |
| 274 | UNSET_IF_PARAM (params, passive_interface); |
| 275 | |
| 276 | ospf_free_if_params (ifp, addr); |
| 277 | ospf_if_update_params (ifp, addr); |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | if (value != ospf->passive_interface_default) |
| 282 | SET_IF_PARAM (params, passive_interface); |
| 283 | else |
| 284 | UNSET_IF_PARAM (params, passive_interface); |
| 285 | } |
| 286 | } |
| 287 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 288 | DEFUN (ospf_passive_interface, |
| 289 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 290 | "passive-interface IFNAME A.B.C.D", |
| 291 | "Suppress routing updates on an interface\n" |
| 292 | "Interface's name\n") |
| 293 | { |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 294 | struct interface *ifp; |
| 295 | struct in_addr addr; |
| 296 | int ret; |
| 297 | struct ospf_if_params *params; |
| 298 | struct route_node *rn; |
| 299 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 301 | if (argc == 0) |
| 302 | { |
| 303 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); |
| 304 | return CMD_SUCCESS; |
| 305 | } |
| 306 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 307 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 308 | |
| 309 | params = IF_DEF_PARAMS (ifp); |
| 310 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 311 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 312 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 313 | ret = inet_aton(argv[1], &addr); |
| 314 | if (!ret) |
| 315 | { |
| 316 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 317 | VTY_NEWLINE); |
| 318 | return CMD_WARNING; |
| 319 | } |
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 | params = ospf_get_if_params (ifp, addr); |
| 322 | ospf_if_update_params (ifp, addr); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 323 | } |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 324 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE); |
| 325 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 326 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 327 | * interfaces for which the passive property changed. It is too much |
| 328 | * work to determine this set, so we do this for every interface. |
| 329 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 330 | * record of joined groups to avoid systems calls if the desired |
| 331 | * memberships match the current memership. |
| 332 | */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 333 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 334 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 335 | { |
| 336 | struct ospf_interface *oi = rn->info; |
| 337 | |
| 338 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 339 | ospf_if_set_multicast(oi); |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 340 | } |
| 341 | /* |
| 342 | * XXX It is not clear what state transitions the interface needs to |
| 343 | * undergo when going from active to passive. Fixing this will |
| 344 | * require precise identification of interfaces having such a |
| 345 | * transition. |
| 346 | */ |
| 347 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 348 | return CMD_SUCCESS; |
| 349 | } |
| 350 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 351 | ALIAS (ospf_passive_interface, |
| 352 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 353 | "passive-interface IFNAME", |
| 354 | "Suppress routing updates on an interface\n" |
| 355 | "Interface's name\n") |
| 356 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 357 | ALIAS (ospf_passive_interface, |
| 358 | ospf_passive_interface_default_cmd, |
| 359 | "passive-interface default", |
| 360 | "Suppress routing updates on an interface\n" |
| 361 | "Suppress routing updates on interfaces by default\n") |
| 362 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 363 | DEFUN (no_ospf_passive_interface, |
| 364 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 365 | "no passive-interface IFNAME A.B.C.D", |
| 366 | NO_STR |
| 367 | "Allow routing updates on an interface\n" |
| 368 | "Interface's name\n") |
| 369 | { |
| 370 | struct interface *ifp; |
| 371 | struct in_addr addr; |
| 372 | struct ospf_if_params *params; |
| 373 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 374 | struct route_node *rn; |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 375 | struct ospf *ospf = vty->index; |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 376 | |
| 377 | if (argc == 0) |
| 378 | { |
| 379 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); |
| 380 | return CMD_SUCCESS; |
| 381 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 382 | |
Andrew J. Schorr | 6e72cb6 | 2006-06-18 00:45:48 +0000 | [diff] [blame] | 383 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | |
| 385 | params = IF_DEF_PARAMS (ifp); |
| 386 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 387 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 388 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 389 | ret = inet_aton(argv[1], &addr); |
| 390 | if (!ret) |
| 391 | { |
| 392 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 393 | VTY_NEWLINE); |
| 394 | return CMD_WARNING; |
| 395 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 396 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 397 | params = ospf_lookup_if_params (ifp, addr); |
| 398 | if (params == NULL) |
| 399 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 400 | } |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 401 | ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE); |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 402 | |
| 403 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 404 | * interfaces for which the passive property changed. It is too much |
| 405 | * work to determine this set, so we do this for every interface. |
| 406 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 407 | * record of joined groups to avoid systems calls if the desired |
| 408 | * memberships match the current memership. |
| 409 | */ |
| 410 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 411 | { |
| 412 | struct ospf_interface *oi = rn->info; |
| 413 | |
| 414 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 415 | ospf_if_set_multicast(oi); |
| 416 | } |
| 417 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 418 | return CMD_SUCCESS; |
| 419 | } |
| 420 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 421 | ALIAS (no_ospf_passive_interface, |
| 422 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 423 | "no passive-interface IFNAME", |
| 424 | NO_STR |
| 425 | "Allow routing updates on an interface\n" |
| 426 | "Interface's name\n") |
| 427 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 428 | ALIAS (no_ospf_passive_interface, |
| 429 | no_ospf_passive_interface_default_cmd, |
| 430 | "no passive-interface default", |
| 431 | NO_STR |
| 432 | "Allow routing updates on an interface\n" |
| 433 | "Allow routing updates on interfaces by default\n") |
| 434 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 435 | DEFUN (ospf_network_area, |
| 436 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 437 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 438 | "Enable routing on an IP network\n" |
| 439 | "OSPF network prefix\n" |
| 440 | "Set the OSPF area ID\n" |
| 441 | "OSPF area ID in IP address format\n" |
| 442 | "OSPF area ID as a decimal value\n") |
| 443 | { |
| 444 | struct ospf *ospf= vty->index; |
| 445 | struct prefix_ipv4 p; |
| 446 | struct in_addr area_id; |
| 447 | int ret, format; |
| 448 | |
| 449 | /* Get network prefix and Area ID. */ |
| 450 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 451 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 452 | |
| 453 | ret = ospf_network_set (ospf, &p, area_id); |
| 454 | if (ret == 0) |
| 455 | { |
| 456 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 457 | return CMD_WARNING; |
| 458 | } |
| 459 | |
| 460 | return CMD_SUCCESS; |
| 461 | } |
| 462 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 463 | DEFUN (no_ospf_network_area, |
| 464 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 465 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 466 | NO_STR |
| 467 | "Enable routing on an IP network\n" |
| 468 | "OSPF network prefix\n" |
| 469 | "Set the OSPF area ID\n" |
| 470 | "OSPF area ID in IP address format\n" |
| 471 | "OSPF area ID as a decimal value\n") |
| 472 | { |
| 473 | struct ospf *ospf = (struct ospf *) vty->index; |
| 474 | struct prefix_ipv4 p; |
| 475 | struct in_addr area_id; |
| 476 | int ret, format; |
| 477 | |
| 478 | /* Get network prefix and Area ID. */ |
| 479 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 480 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 481 | |
| 482 | ret = ospf_network_unset (ospf, &p, area_id); |
| 483 | if (ret == 0) |
| 484 | { |
| 485 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 486 | VTY_NEWLINE); |
| 487 | return CMD_WARNING; |
| 488 | } |
| 489 | |
| 490 | return CMD_SUCCESS; |
| 491 | } |
| 492 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 493 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 494 | DEFUN (ospf_area_range, |
| 495 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 496 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 497 | "OSPF area parameters\n" |
| 498 | "OSPF area ID in IP address format\n" |
| 499 | "OSPF area ID as a decimal value\n" |
| 500 | "Summarize routes matching address/mask (border routers only)\n" |
| 501 | "Area range prefix\n") |
| 502 | { |
| 503 | struct ospf *ospf = vty->index; |
| 504 | struct prefix_ipv4 p; |
| 505 | struct in_addr area_id; |
| 506 | int format; |
| 507 | u_int32_t cost; |
| 508 | |
| 509 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 510 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 511 | |
| 512 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 513 | if (argc > 2) |
| 514 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 515 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 516 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 517 | } |
| 518 | |
| 519 | return CMD_SUCCESS; |
| 520 | } |
| 521 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 522 | ALIAS (ospf_area_range, |
| 523 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 525 | "OSPF area parameters\n" |
| 526 | "OSPF area ID in IP address format\n" |
| 527 | "OSPF area ID as a decimal value\n" |
| 528 | "OSPF area range for route advertise (default)\n" |
| 529 | "Area range prefix\n" |
| 530 | "Advertise this range (default)\n") |
| 531 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 532 | ALIAS (ospf_area_range, |
| 533 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 534 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 535 | "OSPF area parameters\n" |
| 536 | "OSPF area ID in IP address format\n" |
| 537 | "OSPF area ID as a decimal value\n" |
| 538 | "Summarize routes matching address/mask (border routers only)\n" |
| 539 | "Area range prefix\n" |
| 540 | "User specified metric for this range\n" |
| 541 | "Advertised metric for this range\n") |
| 542 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 543 | ALIAS (ospf_area_range, |
| 544 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 545 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 546 | "OSPF area parameters\n" |
| 547 | "OSPF area ID in IP address format\n" |
| 548 | "OSPF area ID as a decimal value\n" |
| 549 | "Summarize routes matching address/mask (border routers only)\n" |
| 550 | "Area range prefix\n" |
| 551 | "Advertise this range (default)\n" |
| 552 | "User specified metric for this range\n" |
| 553 | "Advertised metric for this range\n") |
| 554 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 555 | DEFUN (ospf_area_range_not_advertise, |
| 556 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 557 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 558 | "OSPF area parameters\n" |
| 559 | "OSPF area ID in IP address format\n" |
| 560 | "OSPF area ID as a decimal value\n" |
| 561 | "Summarize routes matching address/mask (border routers only)\n" |
| 562 | "Area range prefix\n" |
| 563 | "DoNotAdvertise this range\n") |
| 564 | { |
| 565 | struct ospf *ospf = vty->index; |
| 566 | struct prefix_ipv4 p; |
| 567 | struct in_addr area_id; |
| 568 | int format; |
| 569 | |
| 570 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 571 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 572 | |
| 573 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 574 | |
| 575 | return CMD_SUCCESS; |
| 576 | } |
| 577 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 578 | DEFUN (no_ospf_area_range, |
| 579 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 580 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 581 | NO_STR |
| 582 | "OSPF area parameters\n" |
| 583 | "OSPF area ID in IP address format\n" |
| 584 | "OSPF area ID as a decimal value\n" |
| 585 | "Summarize routes matching address/mask (border routers only)\n" |
| 586 | "Area range prefix\n") |
| 587 | { |
| 588 | struct ospf *ospf = vty->index; |
| 589 | struct prefix_ipv4 p; |
| 590 | struct in_addr area_id; |
| 591 | int format; |
| 592 | |
| 593 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 594 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 595 | |
| 596 | ospf_area_range_unset (ospf, area_id, &p); |
| 597 | |
| 598 | return CMD_SUCCESS; |
| 599 | } |
| 600 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 601 | ALIAS (no_ospf_area_range, |
| 602 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 603 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 604 | NO_STR |
| 605 | "OSPF area parameters\n" |
| 606 | "OSPF area ID in IP address format\n" |
| 607 | "OSPF area ID as a decimal value\n" |
| 608 | "Summarize routes matching address/mask (border routers only)\n" |
| 609 | "Area range prefix\n" |
| 610 | "Advertise this range (default)\n" |
| 611 | "DoNotAdvertise this range\n") |
| 612 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 613 | ALIAS (no_ospf_area_range, |
| 614 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 615 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 616 | NO_STR |
| 617 | "OSPF area parameters\n" |
| 618 | "OSPF area ID in IP address format\n" |
| 619 | "OSPF area ID as a decimal value\n" |
| 620 | "Summarize routes matching address/mask (border routers only)\n" |
| 621 | "Area range prefix\n" |
| 622 | "User specified metric for this range\n" |
| 623 | "Advertised metric for this range\n") |
| 624 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 625 | ALIAS (no_ospf_area_range, |
| 626 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 627 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 628 | NO_STR |
| 629 | "OSPF area parameters\n" |
| 630 | "OSPF area ID in IP address format\n" |
| 631 | "OSPF area ID as a decimal value\n" |
| 632 | "Summarize routes matching address/mask (border routers only)\n" |
| 633 | "Area range prefix\n" |
| 634 | "Advertise this range (default)\n" |
| 635 | "User specified metric for this range\n" |
| 636 | "Advertised metric for this range\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 637 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 638 | DEFUN (ospf_area_range_substitute, |
| 639 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 641 | "OSPF area parameters\n" |
| 642 | "OSPF area ID in IP address format\n" |
| 643 | "OSPF area ID as a decimal value\n" |
| 644 | "Summarize routes matching address/mask (border routers only)\n" |
| 645 | "Area range prefix\n" |
| 646 | "Announce area range as another prefix\n" |
| 647 | "Network prefix to be announced instead of range\n") |
| 648 | { |
| 649 | struct ospf *ospf = vty->index; |
| 650 | struct prefix_ipv4 p, s; |
| 651 | struct in_addr area_id; |
| 652 | int format; |
| 653 | |
| 654 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 655 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 656 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 657 | |
| 658 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 659 | |
| 660 | return CMD_SUCCESS; |
| 661 | } |
| 662 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 663 | DEFUN (no_ospf_area_range_substitute, |
| 664 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 665 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 666 | NO_STR |
| 667 | "OSPF area parameters\n" |
| 668 | "OSPF area ID in IP address format\n" |
| 669 | "OSPF area ID as a decimal value\n" |
| 670 | "Summarize routes matching address/mask (border routers only)\n" |
| 671 | "Area range prefix\n" |
| 672 | "Announce area range as another prefix\n" |
| 673 | "Network prefix to be announced instead of range\n") |
| 674 | { |
| 675 | struct ospf *ospf = vty->index; |
| 676 | struct prefix_ipv4 p, s; |
| 677 | struct in_addr area_id; |
| 678 | int format; |
| 679 | |
| 680 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 681 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 682 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 683 | |
| 684 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 685 | |
| 686 | return CMD_SUCCESS; |
| 687 | } |
| 688 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 689 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | /* Command Handler Logic in VLink stuff is delicate!! |
| 691 | |
| 692 | ALTER AT YOUR OWN RISK!!!! |
| 693 | |
| 694 | Various dummy values are used to represent 'NoChange' state for |
| 695 | VLink configuration NOT being changed by a VLink command, and |
| 696 | special syntax is used within the command strings so that the |
| 697 | typed in command verbs can be seen in the configuration command |
| 698 | bacckend handler. This is to drastically reduce the verbeage |
| 699 | required to coe up with a reasonably compatible Cisco VLink command |
| 700 | |
| 701 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 702 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 703 | */ |
| 704 | |
| 705 | |
| 706 | /* Configuration data for virtual links |
| 707 | */ |
| 708 | struct ospf_vl_config_data { |
| 709 | struct vty *vty; /* vty stuff */ |
| 710 | struct in_addr area_id; /* area ID from command line */ |
| 711 | int format; /* command line area ID format */ |
| 712 | struct in_addr vl_peer; /* command line vl_peer */ |
| 713 | int auth_type; /* Authehntication type, if given */ |
| 714 | char *auth_key; /* simple password if present */ |
| 715 | int crypto_key_id; /* Cryptographic key ID */ |
| 716 | char *md5_key; /* MD5 authentication key */ |
| 717 | int hello_interval; /* Obvious what these are... */ |
| 718 | int retransmit_interval; |
| 719 | int transmit_delay; |
| 720 | int dead_interval; |
| 721 | }; |
| 722 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 723 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 724 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 725 | struct vty *vty) |
| 726 | { |
| 727 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 728 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 729 | vl_config->vty = vty; |
| 730 | } |
| 731 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 732 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 733 | 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] | 734 | { |
| 735 | struct ospf_area *area; |
| 736 | struct ospf_vl_data *vl_data; |
| 737 | struct vty *vty; |
| 738 | struct in_addr area_id; |
| 739 | |
| 740 | vty = vl_config->vty; |
| 741 | area_id = vl_config->area_id; |
| 742 | |
| 743 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 744 | { |
| 745 | vty_out (vty, |
| 746 | "Configuring VLs over the backbone is not allowed%s", |
| 747 | VTY_NEWLINE); |
| 748 | return NULL; |
| 749 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 750 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 751 | |
| 752 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 753 | { |
| 754 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 755 | vty_out (vty, "Area %s is %s%s", |
| 756 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 757 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 758 | VTY_NEWLINE); |
| 759 | else |
| 760 | vty_out (vty, "Area %ld is %s%s", |
| 761 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 762 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 763 | VTY_NEWLINE); |
| 764 | return NULL; |
| 765 | } |
| 766 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 767 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 768 | { |
| 769 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 770 | if (vl_data->vl_oi == NULL) |
| 771 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 772 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 773 | ospf_vl_add (ospf, vl_data); |
| 774 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | } |
| 776 | } |
| 777 | return vl_data; |
| 778 | } |
| 779 | |
| 780 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 781 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 782 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 783 | struct ospf_vl_config_data *vl_config) |
| 784 | { |
| 785 | struct crypt_key *ck; |
| 786 | struct vty *vty; |
| 787 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 788 | |
| 789 | vty = vl_config->vty; |
| 790 | |
| 791 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 792 | { |
| 793 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 794 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 795 | } |
| 796 | |
| 797 | if (vl_config->auth_key) |
| 798 | { |
| 799 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 800 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 801 | OSPF_AUTH_SIMPLE_SIZE); |
| 802 | } |
| 803 | else if (vl_config->md5_key) |
| 804 | { |
| 805 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 806 | != NULL) |
| 807 | { |
| 808 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 809 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 810 | return CMD_WARNING; |
| 811 | } |
| 812 | ck = ospf_crypt_key_new (); |
| 813 | ck->key_id = vl_config->crypto_key_id; |
| 814 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 815 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 816 | |
| 817 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 818 | } |
| 819 | else if (vl_config->crypto_key_id != 0) |
| 820 | { |
| 821 | /* Delete a key */ |
| 822 | |
| 823 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 824 | vl_config->crypto_key_id) == NULL) |
| 825 | { |
| 826 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 827 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 828 | return CMD_WARNING; |
| 829 | } |
| 830 | |
| 831 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 832 | |
| 833 | } |
| 834 | |
| 835 | return CMD_SUCCESS; |
| 836 | } |
| 837 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 838 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 839 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 840 | struct ospf_vl_config_data *vl_config) |
| 841 | { |
| 842 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 843 | /* Virtual Link data initialised to defaults, so only set |
| 844 | if a value given */ |
| 845 | if (vl_config->hello_interval) |
| 846 | { |
| 847 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 848 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 849 | } |
| 850 | |
| 851 | if (vl_config->dead_interval) |
| 852 | { |
| 853 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 854 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 855 | } |
| 856 | |
| 857 | if (vl_config->retransmit_interval) |
| 858 | { |
| 859 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 860 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 861 | } |
| 862 | |
| 863 | if (vl_config->transmit_delay) |
| 864 | { |
| 865 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 866 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 867 | } |
| 868 | |
| 869 | return CMD_SUCCESS; |
| 870 | } |
| 871 | |
| 872 | |
| 873 | |
| 874 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 875 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 876 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | { |
| 878 | struct ospf_vl_data *vl_data; |
| 879 | int ret; |
| 880 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 881 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 882 | if (!vl_data) |
| 883 | return CMD_WARNING; |
| 884 | |
| 885 | /* Process this one first as it can have a fatal result, which can |
| 886 | only logically occur if the virtual link exists already |
| 887 | Thus a command error does not result in a change to the |
| 888 | running configuration such as unexpectedly altered timer |
| 889 | values etc.*/ |
| 890 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 891 | if (ret != CMD_SUCCESS) |
| 892 | return ret; |
| 893 | |
| 894 | /* Set any time based parameters, these area already range checked */ |
| 895 | |
| 896 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 897 | if (ret != CMD_SUCCESS) |
| 898 | return ret; |
| 899 | |
| 900 | return CMD_SUCCESS; |
| 901 | |
| 902 | } |
| 903 | |
| 904 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 905 | */ |
| 906 | #define VLINK_HELPSTR_IPADDR \ |
| 907 | "OSPF area parameters\n" \ |
| 908 | "OSPF area ID in IP address format\n" \ |
| 909 | "OSPF area ID as a decimal value\n" \ |
| 910 | "Configure a virtual link\n" \ |
| 911 | "Router ID of the remote ABR\n" |
| 912 | |
| 913 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 914 | "Enable authentication on this virtual link\n" \ |
| 915 | "dummy string \n" |
| 916 | |
| 917 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 918 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 919 | "Use null authentication\n" \ |
| 920 | "Use message-digest authentication\n" |
| 921 | |
| 922 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 923 | "Time between HELLO packets\n" \ |
| 924 | "Time between retransmitting lost link state advertisements\n" \ |
| 925 | "Link state transmit delay\n" \ |
| 926 | "Interval after which a neighbor is declared dead\n" |
| 927 | |
| 928 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 929 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 930 | "Seconds\n" |
| 931 | |
| 932 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 933 | "Authentication password (key)\n" \ |
| 934 | "The OSPF password (key)" |
| 935 | |
| 936 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 937 | "Message digest authentication password (key)\n" \ |
| 938 | "dummy string \n" \ |
| 939 | "Key ID\n" \ |
| 940 | "Use MD5 algorithm\n" \ |
| 941 | "The OSPF password (key)" |
| 942 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 943 | DEFUN (ospf_area_vlink, |
| 944 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 945 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 946 | VLINK_HELPSTR_IPADDR) |
| 947 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 948 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 949 | struct ospf_vl_config_data vl_config; |
| 950 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 951 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 952 | int i; |
| 953 | int ret; |
| 954 | |
| 955 | ospf_vl_config_data_init(&vl_config, vty); |
| 956 | |
| 957 | /* Read off first 2 parameters and check them */ |
| 958 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 959 | if (ret < 0) |
| 960 | { |
| 961 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 962 | return CMD_WARNING; |
| 963 | } |
| 964 | |
| 965 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 966 | if (! ret) |
| 967 | { |
| 968 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 969 | VTY_NEWLINE); |
| 970 | return CMD_WARNING; |
| 971 | } |
| 972 | |
| 973 | if (argc <=2) |
| 974 | { |
| 975 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 976 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 977 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | /* Deal with other parameters */ |
| 981 | for (i=2; i < argc; i++) |
| 982 | { |
| 983 | |
| 984 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 985 | |
| 986 | switch (argv[i][0]) |
| 987 | { |
| 988 | |
| 989 | case 'a': |
| 990 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 991 | { |
| 992 | /* authentication-key - this option can occur anywhere on |
| 993 | command line. At start of command line |
| 994 | must check for authentication option. */ |
| 995 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 996 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 997 | vl_config.auth_key = auth_key; |
| 998 | i++; |
| 999 | } |
| 1000 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1001 | { |
| 1002 | /* authentication - this option can only occur at start |
| 1003 | of command line */ |
| 1004 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 1005 | if ((i+1) < argc) |
| 1006 | { |
| 1007 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 1008 | { |
| 1009 | /* "authentication null" */ |
| 1010 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 1011 | i++; |
| 1012 | } |
| 1013 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 1014 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 1015 | { |
| 1016 | /* "authentication message-digest" */ |
| 1017 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1018 | i++; |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | break; |
| 1023 | |
| 1024 | case 'm': |
| 1025 | /* message-digest-key */ |
| 1026 | i++; |
| 1027 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1028 | if (vl_config.crypto_key_id < 0) |
| 1029 | return CMD_WARNING; |
| 1030 | i++; |
| 1031 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 1032 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 1033 | vl_config.md5_key = md5_key; |
| 1034 | break; |
| 1035 | |
| 1036 | case 'h': |
| 1037 | /* Hello interval */ |
| 1038 | i++; |
| 1039 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 1040 | if (vl_config.hello_interval < 0) |
| 1041 | return CMD_WARNING; |
| 1042 | break; |
| 1043 | |
| 1044 | case 'r': |
| 1045 | /* Retransmit Interval */ |
| 1046 | i++; |
| 1047 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1048 | if (vl_config.retransmit_interval < 0) |
| 1049 | return CMD_WARNING; |
| 1050 | break; |
| 1051 | |
| 1052 | case 't': |
| 1053 | /* Transmit Delay */ |
| 1054 | i++; |
| 1055 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1056 | if (vl_config.transmit_delay < 0) |
| 1057 | return CMD_WARNING; |
| 1058 | break; |
| 1059 | |
| 1060 | case 'd': |
| 1061 | /* Dead Interval */ |
| 1062 | i++; |
| 1063 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1064 | if (vl_config.dead_interval < 0) |
| 1065 | return CMD_WARNING; |
| 1066 | break; |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | |
| 1071 | /* Action configuration */ |
| 1072 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1073 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1074 | |
| 1075 | } |
| 1076 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1077 | DEFUN (no_ospf_area_vlink, |
| 1078 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1079 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1080 | NO_STR |
| 1081 | VLINK_HELPSTR_IPADDR) |
| 1082 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1083 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1084 | struct ospf_area *area; |
| 1085 | struct ospf_vl_config_data vl_config; |
| 1086 | struct ospf_vl_data *vl_data = NULL; |
| 1087 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1088 | int i; |
| 1089 | int ret, format; |
| 1090 | |
| 1091 | ospf_vl_config_data_init(&vl_config, vty); |
| 1092 | |
| 1093 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1094 | if (ret < 0) |
| 1095 | { |
| 1096 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1097 | return CMD_WARNING; |
| 1098 | } |
| 1099 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1100 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1101 | if (!area) |
| 1102 | { |
| 1103 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1104 | return CMD_WARNING; |
| 1105 | } |
| 1106 | |
| 1107 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1108 | if (! ret) |
| 1109 | { |
| 1110 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1111 | VTY_NEWLINE); |
| 1112 | return CMD_WARNING; |
| 1113 | } |
| 1114 | |
| 1115 | if (argc <=2) |
| 1116 | { |
| 1117 | /* Basic VLink no command */ |
| 1118 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 1119 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1120 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1121 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1122 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1123 | |
| 1124 | return CMD_SUCCESS; |
| 1125 | } |
| 1126 | |
| 1127 | /* If we are down here, we are reseting parameters */ |
| 1128 | |
| 1129 | /* Deal with other parameters */ |
| 1130 | for (i=2; i < argc; i++) |
| 1131 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1132 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1133 | |
| 1134 | switch (argv[i][0]) |
| 1135 | { |
| 1136 | |
| 1137 | case 'a': |
| 1138 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1139 | { |
| 1140 | /* authentication-key - this option can occur anywhere on |
| 1141 | command line. At start of command line |
| 1142 | must check for authentication option. */ |
| 1143 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1144 | vl_config.auth_key = auth_key; |
| 1145 | } |
| 1146 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1147 | { |
| 1148 | /* authentication - this option can only occur at start |
| 1149 | of command line */ |
| 1150 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1151 | } |
| 1152 | break; |
| 1153 | |
| 1154 | case 'm': |
| 1155 | /* message-digest-key */ |
| 1156 | /* Delete one key */ |
| 1157 | i++; |
| 1158 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1159 | if (vl_config.crypto_key_id < 0) |
| 1160 | return CMD_WARNING; |
| 1161 | vl_config.md5_key = NULL; |
| 1162 | break; |
| 1163 | |
| 1164 | case 'h': |
| 1165 | /* Hello interval */ |
| 1166 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1167 | break; |
| 1168 | |
| 1169 | case 'r': |
| 1170 | /* Retransmit Interval */ |
| 1171 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1172 | break; |
| 1173 | |
| 1174 | case 't': |
| 1175 | /* Transmit Delay */ |
| 1176 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1177 | break; |
| 1178 | |
| 1179 | case 'd': |
| 1180 | /* Dead Interval */ |
| 1181 | i++; |
| 1182 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1183 | break; |
| 1184 | } |
| 1185 | } |
| 1186 | |
| 1187 | |
| 1188 | /* Action configuration */ |
| 1189 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1190 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1191 | } |
| 1192 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1193 | ALIAS (ospf_area_vlink, |
| 1194 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1195 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1196 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1197 | VLINK_HELPSTR_IPADDR |
| 1198 | VLINK_HELPSTR_TIME_PARAM) |
| 1199 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1200 | ALIAS (no_ospf_area_vlink, |
| 1201 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1202 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1203 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1204 | NO_STR |
| 1205 | VLINK_HELPSTR_IPADDR |
| 1206 | VLINK_HELPSTR_TIME_PARAM) |
| 1207 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1208 | ALIAS (ospf_area_vlink, |
| 1209 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1210 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1211 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1212 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1213 | VLINK_HELPSTR_IPADDR |
| 1214 | VLINK_HELPSTR_TIME_PARAM |
| 1215 | VLINK_HELPSTR_TIME_PARAM) |
| 1216 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1217 | ALIAS (no_ospf_area_vlink, |
| 1218 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1219 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1220 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1221 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1222 | NO_STR |
| 1223 | VLINK_HELPSTR_IPADDR |
| 1224 | VLINK_HELPSTR_TIME_PARAM |
| 1225 | VLINK_HELPSTR_TIME_PARAM) |
| 1226 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1227 | ALIAS (ospf_area_vlink, |
| 1228 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1229 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1230 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 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 | VLINK_HELPSTR_TIME_PARAM) |
| 1237 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1238 | ALIAS (no_ospf_area_vlink, |
| 1239 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1240 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1241 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1242 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1243 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1244 | NO_STR |
| 1245 | VLINK_HELPSTR_IPADDR |
| 1246 | VLINK_HELPSTR_TIME_PARAM |
| 1247 | VLINK_HELPSTR_TIME_PARAM |
| 1248 | VLINK_HELPSTR_TIME_PARAM) |
| 1249 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1250 | ALIAS (ospf_area_vlink, |
| 1251 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1252 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1253 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1254 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1255 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1256 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1257 | VLINK_HELPSTR_IPADDR |
| 1258 | VLINK_HELPSTR_TIME_PARAM |
| 1259 | VLINK_HELPSTR_TIME_PARAM |
| 1260 | VLINK_HELPSTR_TIME_PARAM |
| 1261 | VLINK_HELPSTR_TIME_PARAM) |
| 1262 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1263 | ALIAS (no_ospf_area_vlink, |
| 1264 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1265 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1266 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1267 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1268 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1269 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1270 | NO_STR |
| 1271 | VLINK_HELPSTR_IPADDR |
| 1272 | VLINK_HELPSTR_TIME_PARAM |
| 1273 | VLINK_HELPSTR_TIME_PARAM |
| 1274 | VLINK_HELPSTR_TIME_PARAM |
| 1275 | VLINK_HELPSTR_TIME_PARAM) |
| 1276 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1277 | ALIAS (ospf_area_vlink, |
| 1278 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1279 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1280 | "(authentication|) (message-digest|null)", |
| 1281 | VLINK_HELPSTR_IPADDR |
| 1282 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1283 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1284 | ALIAS (ospf_area_vlink, |
| 1285 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1286 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1287 | "(authentication|)", |
| 1288 | VLINK_HELPSTR_IPADDR |
| 1289 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1290 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1291 | ALIAS (no_ospf_area_vlink, |
| 1292 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1293 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1294 | "(authentication|)", |
| 1295 | NO_STR |
| 1296 | VLINK_HELPSTR_IPADDR |
| 1297 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1298 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1299 | ALIAS (ospf_area_vlink, |
| 1300 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1301 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1302 | "(message-digest-key|) <1-255> md5 KEY", |
| 1303 | VLINK_HELPSTR_IPADDR |
| 1304 | VLINK_HELPSTR_AUTH_MD5) |
| 1305 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1306 | ALIAS (no_ospf_area_vlink, |
| 1307 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1308 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1309 | "(message-digest-key|) <1-255>", |
| 1310 | NO_STR |
| 1311 | VLINK_HELPSTR_IPADDR |
| 1312 | VLINK_HELPSTR_AUTH_MD5) |
| 1313 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1314 | ALIAS (ospf_area_vlink, |
| 1315 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1316 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1317 | "(authentication-key|) AUTH_KEY", |
| 1318 | VLINK_HELPSTR_IPADDR |
| 1319 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1320 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1321 | ALIAS (no_ospf_area_vlink, |
| 1322 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1323 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1324 | "(authentication-key|)", |
| 1325 | NO_STR |
| 1326 | VLINK_HELPSTR_IPADDR |
| 1327 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1328 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1329 | ALIAS (ospf_area_vlink, |
| 1330 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1331 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1332 | "(authentication|) (message-digest|null) " |
| 1333 | "(authentication-key|) AUTH_KEY", |
| 1334 | VLINK_HELPSTR_IPADDR |
| 1335 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1336 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1337 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1338 | ALIAS (ospf_area_vlink, |
| 1339 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1340 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1341 | "(authentication|) " |
| 1342 | "(authentication-key|) AUTH_KEY", |
| 1343 | VLINK_HELPSTR_IPADDR |
| 1344 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1345 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1346 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1347 | ALIAS (no_ospf_area_vlink, |
| 1348 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1349 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1350 | "(authentication|) " |
| 1351 | "(authentication-key|)", |
| 1352 | NO_STR |
| 1353 | VLINK_HELPSTR_IPADDR |
| 1354 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1355 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1356 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1357 | ALIAS (ospf_area_vlink, |
| 1358 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1359 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1360 | "(authentication|) (message-digest|null) " |
| 1361 | "(message-digest-key|) <1-255> md5 KEY", |
| 1362 | VLINK_HELPSTR_IPADDR |
| 1363 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1364 | VLINK_HELPSTR_AUTH_MD5) |
| 1365 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1366 | ALIAS (ospf_area_vlink, |
| 1367 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1368 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1369 | "(authentication|) " |
| 1370 | "(message-digest-key|) <1-255> md5 KEY", |
| 1371 | VLINK_HELPSTR_IPADDR |
| 1372 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1373 | VLINK_HELPSTR_AUTH_MD5) |
| 1374 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1375 | ALIAS (no_ospf_area_vlink, |
| 1376 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1377 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1378 | "(authentication|) " |
| 1379 | "(message-digest-key|)", |
| 1380 | NO_STR |
| 1381 | VLINK_HELPSTR_IPADDR |
| 1382 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1383 | VLINK_HELPSTR_AUTH_MD5) |
| 1384 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1385 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1386 | DEFUN (ospf_area_shortcut, |
| 1387 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1388 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1389 | "OSPF area parameters\n" |
| 1390 | "OSPF area ID in IP address format\n" |
| 1391 | "OSPF area ID as a decimal value\n" |
| 1392 | "Configure the area's shortcutting mode\n" |
| 1393 | "Set default shortcutting behavior\n" |
| 1394 | "Enable shortcutting through the area\n" |
| 1395 | "Disable shortcutting through the area\n") |
| 1396 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1397 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1398 | struct ospf_area *area; |
| 1399 | struct in_addr area_id; |
| 1400 | int mode; |
| 1401 | int format; |
| 1402 | |
| 1403 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1404 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1405 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1406 | |
| 1407 | if (strncmp (argv[1], "de", 2) == 0) |
| 1408 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1409 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1410 | mode = OSPF_SHORTCUT_DISABLE; |
| 1411 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1412 | mode = OSPF_SHORTCUT_ENABLE; |
| 1413 | else |
| 1414 | return CMD_WARNING; |
| 1415 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1416 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1417 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1418 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1419 | vty_out (vty, "Shortcut area setting will take effect " |
| 1420 | "only when the router is configured as Shortcut ABR%s", |
| 1421 | VTY_NEWLINE); |
| 1422 | |
| 1423 | return CMD_SUCCESS; |
| 1424 | } |
| 1425 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1426 | DEFUN (no_ospf_area_shortcut, |
| 1427 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1428 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1429 | NO_STR |
| 1430 | "OSPF area parameters\n" |
| 1431 | "OSPF area ID in IP address format\n" |
| 1432 | "OSPF area ID as a decimal value\n" |
| 1433 | "Deconfigure the area's shortcutting mode\n" |
| 1434 | "Deconfigure enabled shortcutting through the area\n" |
| 1435 | "Deconfigure disabled shortcutting through the area\n") |
| 1436 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1437 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1438 | struct ospf_area *area; |
| 1439 | struct in_addr area_id; |
| 1440 | int format; |
| 1441 | |
| 1442 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1443 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1444 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1445 | if (!area) |
| 1446 | return CMD_SUCCESS; |
| 1447 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1448 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1449 | |
| 1450 | return CMD_SUCCESS; |
| 1451 | } |
| 1452 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1453 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1454 | DEFUN (ospf_area_stub, |
| 1455 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1456 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1457 | "OSPF area parameters\n" |
| 1458 | "OSPF area ID in IP address format\n" |
| 1459 | "OSPF area ID as a decimal value\n" |
| 1460 | "Configure OSPF area as stub\n") |
| 1461 | { |
| 1462 | struct ospf *ospf = vty->index; |
| 1463 | struct in_addr area_id; |
| 1464 | int ret, format; |
| 1465 | |
| 1466 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1467 | |
| 1468 | ret = ospf_area_stub_set (ospf, area_id); |
| 1469 | if (ret == 0) |
| 1470 | { |
| 1471 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1472 | VTY_NEWLINE); |
| 1473 | return CMD_WARNING; |
| 1474 | } |
| 1475 | |
| 1476 | ospf_area_no_summary_unset (ospf, area_id); |
| 1477 | |
| 1478 | return CMD_SUCCESS; |
| 1479 | } |
| 1480 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1481 | DEFUN (ospf_area_stub_no_summary, |
| 1482 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1483 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1484 | "OSPF stub parameters\n" |
| 1485 | "OSPF area ID in IP address format\n" |
| 1486 | "OSPF area ID as a decimal value\n" |
| 1487 | "Configure OSPF area as stub\n" |
| 1488 | "Do not inject inter-area routes into stub\n") |
| 1489 | { |
| 1490 | struct ospf *ospf = vty->index; |
| 1491 | struct in_addr area_id; |
| 1492 | int ret, format; |
| 1493 | |
| 1494 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1495 | |
| 1496 | ret = ospf_area_stub_set (ospf, area_id); |
| 1497 | if (ret == 0) |
| 1498 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1499 | 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] | 1500 | VTY_NEWLINE); |
| 1501 | return CMD_WARNING; |
| 1502 | } |
| 1503 | |
| 1504 | ospf_area_no_summary_set (ospf, area_id); |
| 1505 | |
| 1506 | return CMD_SUCCESS; |
| 1507 | } |
| 1508 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1509 | DEFUN (no_ospf_area_stub, |
| 1510 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1511 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1512 | NO_STR |
| 1513 | "OSPF area parameters\n" |
| 1514 | "OSPF area ID in IP address format\n" |
| 1515 | "OSPF area ID as a decimal value\n" |
| 1516 | "Configure OSPF area as stub\n") |
| 1517 | { |
| 1518 | struct ospf *ospf = vty->index; |
| 1519 | struct in_addr area_id; |
| 1520 | int format; |
| 1521 | |
| 1522 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1523 | |
| 1524 | ospf_area_stub_unset (ospf, area_id); |
| 1525 | ospf_area_no_summary_unset (ospf, area_id); |
| 1526 | |
| 1527 | return CMD_SUCCESS; |
| 1528 | } |
| 1529 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1530 | DEFUN (no_ospf_area_stub_no_summary, |
| 1531 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1532 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1533 | NO_STR |
| 1534 | "OSPF area parameters\n" |
| 1535 | "OSPF area ID in IP address format\n" |
| 1536 | "OSPF area ID as a decimal value\n" |
| 1537 | "Configure OSPF area as stub\n" |
| 1538 | "Do not inject inter-area routes into area\n") |
| 1539 | { |
| 1540 | struct ospf *ospf = vty->index; |
| 1541 | struct in_addr area_id; |
| 1542 | int format; |
| 1543 | |
| 1544 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1545 | ospf_area_no_summary_unset (ospf, area_id); |
| 1546 | |
| 1547 | return CMD_SUCCESS; |
| 1548 | } |
| 1549 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1550 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1551 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1552 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1553 | { |
| 1554 | struct ospf *ospf = vty->index; |
| 1555 | struct in_addr area_id; |
| 1556 | int ret, format; |
| 1557 | |
| 1558 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1559 | |
| 1560 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1561 | if (ret == 0) |
| 1562 | { |
| 1563 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1564 | VTY_NEWLINE); |
| 1565 | return CMD_WARNING; |
| 1566 | } |
| 1567 | |
| 1568 | if (argc > 1) |
| 1569 | { |
| 1570 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1571 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1572 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1573 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1574 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1575 | OSPF_NSSA_ROLE_NEVER); |
| 1576 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1577 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1578 | OSPF_NSSA_ROLE_ALWAYS); |
| 1579 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1580 | else |
| 1581 | { |
| 1582 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1583 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1584 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1585 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1586 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1587 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1588 | else |
| 1589 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1590 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1591 | ospf_schedule_abr_task (ospf); |
| 1592 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1593 | return CMD_SUCCESS; |
| 1594 | } |
| 1595 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1596 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1597 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1598 | "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] | 1599 | "OSPF area parameters\n" |
| 1600 | "OSPF area ID in IP address format\n" |
| 1601 | "OSPF area ID as a decimal value\n" |
| 1602 | "Configure OSPF area as nssa\n" |
| 1603 | "Configure NSSA-ABR for translate election (default)\n" |
| 1604 | "Configure NSSA-ABR to never translate\n" |
| 1605 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1606 | "Do not inject inter-area routes into nssa\n") |
| 1607 | { |
| 1608 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1609 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1610 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1611 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1612 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1613 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1614 | "OSPF area parameters\n" |
| 1615 | "OSPF area ID in IP address format\n" |
| 1616 | "OSPF area ID as a decimal value\n" |
| 1617 | "Configure OSPF area as nssa\n" |
| 1618 | "Configure NSSA-ABR for translate election (default)\n" |
| 1619 | "Configure NSSA-ABR to never translate\n" |
| 1620 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1621 | { |
| 1622 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1623 | } |
| 1624 | |
| 1625 | DEFUN (ospf_area_nssa, |
| 1626 | ospf_area_nssa_cmd, |
| 1627 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1628 | "OSPF area parameters\n" |
| 1629 | "OSPF area ID in IP address format\n" |
| 1630 | "OSPF area ID as a decimal value\n" |
| 1631 | "Configure OSPF area as nssa\n") |
| 1632 | { |
| 1633 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1634 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1635 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1636 | DEFUN (ospf_area_nssa_no_summary, |
| 1637 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1638 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1639 | "OSPF area parameters\n" |
| 1640 | "OSPF area ID in IP address format\n" |
| 1641 | "OSPF area ID as a decimal value\n" |
| 1642 | "Configure OSPF area as nssa\n" |
| 1643 | "Do not inject inter-area routes into nssa\n") |
| 1644 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1645 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1646 | } |
| 1647 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1648 | DEFUN (no_ospf_area_nssa, |
| 1649 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1650 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1651 | NO_STR |
| 1652 | "OSPF area parameters\n" |
| 1653 | "OSPF area ID in IP address format\n" |
| 1654 | "OSPF area ID as a decimal value\n" |
| 1655 | "Configure OSPF area as nssa\n") |
| 1656 | { |
| 1657 | struct ospf *ospf = vty->index; |
| 1658 | struct in_addr area_id; |
| 1659 | int format; |
| 1660 | |
| 1661 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1662 | |
| 1663 | ospf_area_nssa_unset (ospf, area_id); |
| 1664 | ospf_area_no_summary_unset (ospf, area_id); |
| 1665 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1666 | ospf_schedule_abr_task (ospf); |
| 1667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1668 | return CMD_SUCCESS; |
| 1669 | } |
| 1670 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1671 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1672 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1673 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1674 | NO_STR |
| 1675 | "OSPF area parameters\n" |
| 1676 | "OSPF area ID in IP address format\n" |
| 1677 | "OSPF area ID as a decimal value\n" |
| 1678 | "Configure OSPF area as nssa\n" |
| 1679 | "Do not inject inter-area routes into nssa\n") |
| 1680 | { |
| 1681 | struct ospf *ospf = vty->index; |
| 1682 | struct in_addr area_id; |
| 1683 | int format; |
| 1684 | |
| 1685 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1686 | ospf_area_no_summary_unset (ospf, area_id); |
| 1687 | |
| 1688 | return CMD_SUCCESS; |
| 1689 | } |
| 1690 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1691 | DEFUN (ospf_area_default_cost, |
| 1692 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1693 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1694 | "OSPF area parameters\n" |
| 1695 | "OSPF area ID in IP address format\n" |
| 1696 | "OSPF area ID as a decimal value\n" |
| 1697 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1698 | "Stub's advertised default summary cost\n") |
| 1699 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1700 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1701 | struct ospf_area *area; |
| 1702 | struct in_addr area_id; |
| 1703 | u_int32_t cost; |
| 1704 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1705 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1706 | |
| 1707 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1708 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1709 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1710 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1711 | |
| 1712 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1713 | { |
| 1714 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1715 | return CMD_WARNING; |
| 1716 | } |
| 1717 | |
| 1718 | area->default_cost = cost; |
| 1719 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1720 | p.family = AF_INET; |
| 1721 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1722 | p.prefixlen = 0; |
| 1723 | if (IS_DEBUG_OSPF_EVENT) |
| 1724 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1725 | "announcing 0.0.0.0/0 to area %s", |
| 1726 | inet_ntoa (area->area_id)); |
| 1727 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1728 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1729 | return CMD_SUCCESS; |
| 1730 | } |
| 1731 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1732 | DEFUN (no_ospf_area_default_cost, |
| 1733 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1734 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1735 | NO_STR |
| 1736 | "OSPF area parameters\n" |
| 1737 | "OSPF area ID in IP address format\n" |
| 1738 | "OSPF area ID as a decimal value\n" |
| 1739 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1740 | "Stub's advertised default summary cost\n") |
| 1741 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1742 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1743 | struct ospf_area *area; |
| 1744 | struct in_addr area_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1745 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1746 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1747 | |
| 1748 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 1749 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1750 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1751 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1752 | if (area == NULL) |
| 1753 | return CMD_SUCCESS; |
| 1754 | |
| 1755 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1756 | { |
| 1757 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1758 | return CMD_WARNING; |
| 1759 | } |
| 1760 | |
| 1761 | area->default_cost = 1; |
| 1762 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1763 | p.family = AF_INET; |
| 1764 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1765 | p.prefixlen = 0; |
| 1766 | if (IS_DEBUG_OSPF_EVENT) |
| 1767 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1768 | "announcing 0.0.0.0/0 to area %s", |
| 1769 | inet_ntoa (area->area_id)); |
| 1770 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1771 | |
| 1772 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1773 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1774 | |
| 1775 | return CMD_SUCCESS; |
| 1776 | } |
| 1777 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1778 | DEFUN (ospf_area_export_list, |
| 1779 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1780 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1781 | "OSPF area parameters\n" |
| 1782 | "OSPF area ID in IP address format\n" |
| 1783 | "OSPF area ID as a decimal value\n" |
| 1784 | "Set the filter for networks announced to other areas\n" |
| 1785 | "Name of the access-list\n") |
| 1786 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1787 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1788 | struct ospf_area *area; |
| 1789 | struct in_addr area_id; |
| 1790 | int format; |
| 1791 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1792 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1793 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1794 | area = ospf_area_get (ospf, area_id, format); |
| 1795 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1796 | |
| 1797 | return CMD_SUCCESS; |
| 1798 | } |
| 1799 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1800 | DEFUN (no_ospf_area_export_list, |
| 1801 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1802 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1803 | NO_STR |
| 1804 | "OSPF area parameters\n" |
| 1805 | "OSPF area ID in IP address format\n" |
| 1806 | "OSPF area ID as a decimal value\n" |
| 1807 | "Unset the filter for networks announced to other areas\n" |
| 1808 | "Name of the access-list\n") |
| 1809 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1810 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1811 | struct ospf_area *area; |
| 1812 | struct in_addr area_id; |
| 1813 | int format; |
| 1814 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1815 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1816 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1817 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | if (area == NULL) |
| 1819 | return CMD_SUCCESS; |
| 1820 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1821 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1822 | |
| 1823 | return CMD_SUCCESS; |
| 1824 | } |
| 1825 | |
| 1826 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1827 | DEFUN (ospf_area_import_list, |
| 1828 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1829 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1830 | "OSPF area parameters\n" |
| 1831 | "OSPF area ID in IP address format\n" |
| 1832 | "OSPF area ID as a decimal value\n" |
| 1833 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1834 | "Name of the access-list\n") |
| 1835 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1836 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1837 | struct ospf_area *area; |
| 1838 | struct in_addr area_id; |
| 1839 | int format; |
| 1840 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1841 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1842 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1843 | area = ospf_area_get (ospf, area_id, format); |
| 1844 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1845 | |
| 1846 | return CMD_SUCCESS; |
| 1847 | } |
| 1848 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1849 | DEFUN (no_ospf_area_import_list, |
| 1850 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1851 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1852 | NO_STR |
| 1853 | "OSPF area parameters\n" |
| 1854 | "OSPF area ID in IP address format\n" |
| 1855 | "OSPF area ID as a decimal value\n" |
| 1856 | "Unset the filter for networks announced to other areas\n" |
| 1857 | "Name of the access-list\n") |
| 1858 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1859 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1860 | struct ospf_area *area; |
| 1861 | struct in_addr area_id; |
| 1862 | int format; |
| 1863 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1864 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1865 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1866 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1867 | if (area == NULL) |
| 1868 | return CMD_SUCCESS; |
| 1869 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1870 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1871 | |
| 1872 | return CMD_SUCCESS; |
| 1873 | } |
| 1874 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1875 | DEFUN (ospf_area_filter_list, |
| 1876 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1877 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1878 | "OSPF area parameters\n" |
| 1879 | "OSPF area ID in IP address format\n" |
| 1880 | "OSPF area ID as a decimal value\n" |
| 1881 | "Filter networks between OSPF areas\n" |
| 1882 | "Filter prefixes between OSPF areas\n" |
| 1883 | "Name of an IP prefix-list\n" |
| 1884 | "Filter networks sent to this area\n" |
| 1885 | "Filter networks sent from this area\n") |
| 1886 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1887 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1888 | struct ospf_area *area; |
| 1889 | struct in_addr area_id; |
| 1890 | struct prefix_list *plist; |
| 1891 | int format; |
| 1892 | |
| 1893 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1894 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1895 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1896 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1897 | if (strncmp (argv[2], "in", 2) == 0) |
| 1898 | { |
| 1899 | PREFIX_LIST_IN (area) = plist; |
| 1900 | if (PREFIX_NAME_IN (area)) |
| 1901 | free (PREFIX_NAME_IN (area)); |
| 1902 | |
| 1903 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1904 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1905 | } |
| 1906 | else |
| 1907 | { |
| 1908 | PREFIX_LIST_OUT (area) = plist; |
| 1909 | if (PREFIX_NAME_OUT (area)) |
| 1910 | free (PREFIX_NAME_OUT (area)); |
| 1911 | |
| 1912 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1913 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1914 | } |
| 1915 | |
| 1916 | return CMD_SUCCESS; |
| 1917 | } |
| 1918 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1919 | DEFUN (no_ospf_area_filter_list, |
| 1920 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1921 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1922 | NO_STR |
| 1923 | "OSPF area parameters\n" |
| 1924 | "OSPF area ID in IP address format\n" |
| 1925 | "OSPF area ID as a decimal value\n" |
| 1926 | "Filter networks between OSPF areas\n" |
| 1927 | "Filter prefixes between OSPF areas\n" |
| 1928 | "Name of an IP prefix-list\n" |
| 1929 | "Filter networks sent to this area\n" |
| 1930 | "Filter networks sent from this area\n") |
| 1931 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1932 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1933 | struct ospf_area *area; |
| 1934 | struct in_addr area_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1935 | int format; |
| 1936 | |
| 1937 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1938 | |
Paul Jakma | 1a8ec2b | 2006-05-11 13:34:08 +0000 | [diff] [blame] | 1939 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
| 1940 | return CMD_SUCCESS; |
| 1941 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1942 | if (strncmp (argv[2], "in", 2) == 0) |
| 1943 | { |
| 1944 | if (PREFIX_NAME_IN (area)) |
| 1945 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1946 | return CMD_SUCCESS; |
| 1947 | |
| 1948 | PREFIX_LIST_IN (area) = NULL; |
| 1949 | if (PREFIX_NAME_IN (area)) |
| 1950 | free (PREFIX_NAME_IN (area)); |
| 1951 | |
| 1952 | PREFIX_NAME_IN (area) = NULL; |
| 1953 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1954 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1955 | } |
| 1956 | else |
| 1957 | { |
| 1958 | if (PREFIX_NAME_OUT (area)) |
| 1959 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1960 | return CMD_SUCCESS; |
| 1961 | |
| 1962 | PREFIX_LIST_OUT (area) = NULL; |
| 1963 | if (PREFIX_NAME_OUT (area)) |
| 1964 | free (PREFIX_NAME_OUT (area)); |
| 1965 | |
| 1966 | PREFIX_NAME_OUT (area) = NULL; |
| 1967 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1968 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1969 | } |
| 1970 | |
| 1971 | return CMD_SUCCESS; |
| 1972 | } |
| 1973 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1974 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1975 | DEFUN (ospf_area_authentication_message_digest, |
| 1976 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1977 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1978 | "OSPF area parameters\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 1979 | "OSPF area ID in IP address format\n" |
| 1980 | "OSPF area ID as a decimal value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1981 | "Enable authentication\n" |
| 1982 | "Use message-digest authentication\n") |
| 1983 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1984 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1985 | struct ospf_area *area; |
| 1986 | struct in_addr area_id; |
| 1987 | int format; |
| 1988 | |
| 1989 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1990 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1991 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1992 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1993 | |
| 1994 | return CMD_SUCCESS; |
| 1995 | } |
| 1996 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1997 | DEFUN (ospf_area_authentication, |
| 1998 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1999 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 2000 | "OSPF area parameters\n" |
| 2001 | "OSPF area ID in IP address format\n" |
| 2002 | "OSPF area ID as a decimal value\n" |
| 2003 | "Enable 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_SIMPLE; |
| 2014 | |
| 2015 | return CMD_SUCCESS; |
| 2016 | } |
| 2017 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2018 | DEFUN (no_ospf_area_authentication, |
| 2019 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2020 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 2021 | NO_STR |
| 2022 | "OSPF area parameters\n" |
| 2023 | "OSPF area ID in IP address format\n" |
| 2024 | "OSPF area ID as a decimal value\n" |
| 2025 | "Enable authentication\n") |
| 2026 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2027 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2028 | struct ospf_area *area; |
| 2029 | struct in_addr area_id; |
| 2030 | int format; |
| 2031 | |
| 2032 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2033 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2034 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2035 | if (area == NULL) |
| 2036 | return CMD_SUCCESS; |
| 2037 | |
| 2038 | area->auth_type = OSPF_AUTH_NULL; |
| 2039 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2040 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2041 | |
| 2042 | return CMD_SUCCESS; |
| 2043 | } |
| 2044 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2045 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2046 | DEFUN (ospf_abr_type, |
| 2047 | ospf_abr_type_cmd, |
| 2048 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 2049 | "OSPF specific commands\n" |
| 2050 | "Set OSPF ABR type\n" |
| 2051 | "Alternative ABR, cisco implementation\n" |
| 2052 | "Alternative ABR, IBM implementation\n" |
| 2053 | "Shortcut ABR\n" |
| 2054 | "Standard behavior (RFC2328)\n") |
| 2055 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2056 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2057 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2058 | |
| 2059 | if (strncmp (argv[0], "c", 1) == 0) |
| 2060 | abr_type = OSPF_ABR_CISCO; |
| 2061 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2062 | abr_type = OSPF_ABR_IBM; |
| 2063 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2064 | abr_type = OSPF_ABR_SHORTCUT; |
| 2065 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2066 | abr_type = OSPF_ABR_STAND; |
| 2067 | else |
| 2068 | return CMD_WARNING; |
| 2069 | |
| 2070 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2071 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2072 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2073 | ospf->abr_type = abr_type; |
| 2074 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2075 | } |
| 2076 | |
| 2077 | return CMD_SUCCESS; |
| 2078 | } |
| 2079 | |
| 2080 | DEFUN (no_ospf_abr_type, |
| 2081 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2082 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2083 | NO_STR |
| 2084 | "OSPF specific commands\n" |
| 2085 | "Set OSPF ABR type\n" |
| 2086 | "Alternative ABR, cisco implementation\n" |
| 2087 | "Alternative ABR, IBM implementation\n" |
| 2088 | "Shortcut ABR\n") |
| 2089 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2090 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2091 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2092 | |
| 2093 | if (strncmp (argv[0], "c", 1) == 0) |
| 2094 | abr_type = OSPF_ABR_CISCO; |
| 2095 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2096 | abr_type = OSPF_ABR_IBM; |
Francesco Dolcini | 04d2331 | 2009-06-02 18:20:09 +0100 | [diff] [blame] | 2097 | else if (strncmp (argv[0], "sh", 2) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2098 | abr_type = OSPF_ABR_SHORTCUT; |
Francesco Dolcini | 04d2331 | 2009-06-02 18:20:09 +0100 | [diff] [blame] | 2099 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2100 | abr_type = OSPF_ABR_STAND; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2101 | else |
| 2102 | return CMD_WARNING; |
| 2103 | |
| 2104 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2105 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2106 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2107 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2108 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2109 | } |
| 2110 | |
| 2111 | return CMD_SUCCESS; |
| 2112 | } |
| 2113 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2114 | DEFUN (ospf_log_adjacency_changes, |
| 2115 | ospf_log_adjacency_changes_cmd, |
| 2116 | "log-adjacency-changes", |
| 2117 | "Log changes in adjacency state\n") |
| 2118 | { |
| 2119 | struct ospf *ospf = vty->index; |
| 2120 | |
| 2121 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2122 | return CMD_SUCCESS; |
| 2123 | } |
| 2124 | |
| 2125 | DEFUN (ospf_log_adjacency_changes_detail, |
| 2126 | ospf_log_adjacency_changes_detail_cmd, |
| 2127 | "log-adjacency-changes detail", |
| 2128 | "Log changes in adjacency state\n" |
| 2129 | "Log all state changes\n") |
| 2130 | { |
| 2131 | struct ospf *ospf = vty->index; |
| 2132 | |
| 2133 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2134 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2135 | return CMD_SUCCESS; |
| 2136 | } |
| 2137 | |
| 2138 | DEFUN (no_ospf_log_adjacency_changes, |
| 2139 | no_ospf_log_adjacency_changes_cmd, |
| 2140 | "no log-adjacency-changes", |
| 2141 | NO_STR |
| 2142 | "Log changes in adjacency state\n") |
| 2143 | { |
| 2144 | struct ospf *ospf = vty->index; |
| 2145 | |
| 2146 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2147 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2148 | return CMD_SUCCESS; |
| 2149 | } |
| 2150 | |
| 2151 | DEFUN (no_ospf_log_adjacency_changes_detail, |
| 2152 | no_ospf_log_adjacency_changes_detail_cmd, |
| 2153 | "no log-adjacency-changes detail", |
| 2154 | NO_STR |
| 2155 | "Log changes in adjacency state\n" |
| 2156 | "Log all state changes\n") |
| 2157 | { |
| 2158 | struct ospf *ospf = vty->index; |
| 2159 | |
| 2160 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2161 | return CMD_SUCCESS; |
| 2162 | } |
| 2163 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2164 | DEFUN (ospf_compatible_rfc1583, |
| 2165 | ospf_compatible_rfc1583_cmd, |
| 2166 | "compatible rfc1583", |
| 2167 | "OSPF compatibility list\n" |
| 2168 | "compatible with RFC 1583\n") |
| 2169 | { |
| 2170 | struct ospf *ospf = vty->index; |
| 2171 | |
| 2172 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2173 | { |
| 2174 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2175 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2176 | } |
| 2177 | return CMD_SUCCESS; |
| 2178 | } |
| 2179 | |
| 2180 | DEFUN (no_ospf_compatible_rfc1583, |
| 2181 | no_ospf_compatible_rfc1583_cmd, |
| 2182 | "no compatible rfc1583", |
| 2183 | NO_STR |
| 2184 | "OSPF compatibility list\n" |
| 2185 | "compatible with RFC 1583\n") |
| 2186 | { |
| 2187 | struct ospf *ospf = vty->index; |
| 2188 | |
| 2189 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2190 | { |
| 2191 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2192 | ospf_spf_calculate_schedule (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2193 | } |
| 2194 | return CMD_SUCCESS; |
| 2195 | } |
| 2196 | |
| 2197 | ALIAS (ospf_compatible_rfc1583, |
| 2198 | ospf_rfc1583_flag_cmd, |
| 2199 | "ospf rfc1583compatibility", |
| 2200 | "OSPF specific commands\n" |
| 2201 | "Enable the RFC1583Compatibility flag\n") |
| 2202 | |
| 2203 | ALIAS (no_ospf_compatible_rfc1583, |
| 2204 | no_ospf_rfc1583_flag_cmd, |
| 2205 | "no ospf rfc1583compatibility", |
| 2206 | NO_STR |
| 2207 | "OSPF specific commands\n" |
| 2208 | "Disable the RFC1583Compatibility flag\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2209 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2210 | static int |
| 2211 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2212 | unsigned int hold, |
| 2213 | unsigned int max) |
| 2214 | { |
| 2215 | struct ospf *ospf = vty->index; |
| 2216 | |
| 2217 | ospf->spf_delay = delay; |
| 2218 | ospf->spf_holdtime = hold; |
| 2219 | ospf->spf_max_holdtime = max; |
| 2220 | |
| 2221 | return CMD_SUCCESS; |
| 2222 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2224 | DEFUN (ospf_timers_throttle_spf, |
| 2225 | ospf_timers_throttle_spf_cmd, |
| 2226 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2227 | "Adjust routing timers\n" |
| 2228 | "Throttling adaptive timer\n" |
| 2229 | "OSPF SPF timers\n" |
| 2230 | "Delay (msec) from first change received till SPF calculation\n" |
| 2231 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2232 | "Maximum hold time (msec)\n") |
| 2233 | { |
| 2234 | unsigned int delay, hold, max; |
| 2235 | |
| 2236 | if (argc != 3) |
| 2237 | { |
| 2238 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2239 | return CMD_WARNING; |
| 2240 | } |
| 2241 | |
| 2242 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2243 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2244 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2245 | |
| 2246 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2247 | } |
| 2248 | |
| 2249 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2250 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2251 | "timers spf <0-4294967295> <0-4294967295>", |
| 2252 | "Adjust routing timers\n" |
| 2253 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2254 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2255 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2256 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2257 | unsigned int delay, hold; |
| 2258 | |
| 2259 | if (argc != 2) |
| 2260 | { |
| 2261 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2262 | return CMD_WARNING; |
| 2263 | } |
| 2264 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2265 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2266 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2267 | |
| 2268 | /* truncate down the second values if they're greater than 600000ms */ |
| 2269 | if (delay > (600000 / 1000)) |
| 2270 | delay = 600000; |
| 2271 | else if (delay == 0) |
| 2272 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2273 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2274 | if (hold > (600000 / 1000)) |
| 2275 | hold = 600000; |
| 2276 | |
| 2277 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2278 | } |
| 2279 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2280 | DEFUN (no_ospf_timers_throttle_spf, |
| 2281 | no_ospf_timers_throttle_spf_cmd, |
| 2282 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2283 | NO_STR |
| 2284 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2285 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2286 | "OSPF SPF timers\n") |
| 2287 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2288 | return ospf_timers_spf_set (vty, |
| 2289 | OSPF_SPF_DELAY_DEFAULT, |
| 2290 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2291 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2292 | } |
| 2293 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2294 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2295 | no_ospf_timers_spf_cmd, |
| 2296 | "no timers spf", |
| 2297 | NO_STR |
| 2298 | "Adjust routing timers\n" |
| 2299 | "OSPF SPF timers\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2300 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2301 | DEFUN (ospf_neighbor, |
| 2302 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2303 | "neighbor A.B.C.D", |
| 2304 | NEIGHBOR_STR |
| 2305 | "Neighbor IP address\n") |
| 2306 | { |
| 2307 | struct ospf *ospf = vty->index; |
| 2308 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2309 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2310 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2311 | |
| 2312 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2313 | |
| 2314 | if (argc > 1) |
| 2315 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2316 | |
| 2317 | if (argc > 2) |
| 2318 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2319 | |
| 2320 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2321 | if (argc > 1) |
| 2322 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2323 | if (argc > 2) |
Andrew Certain | 1a61ad1 | 2012-12-04 12:50:23 -0800 | [diff] [blame] | 2324 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2325 | |
| 2326 | return CMD_SUCCESS; |
| 2327 | } |
| 2328 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2329 | ALIAS (ospf_neighbor, |
| 2330 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2331 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2332 | NEIGHBOR_STR |
| 2333 | "Neighbor IP address\n" |
| 2334 | "Neighbor Priority\n" |
| 2335 | "Priority\n" |
| 2336 | "Dead Neighbor Polling interval\n" |
| 2337 | "Seconds\n") |
| 2338 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2339 | ALIAS (ospf_neighbor, |
| 2340 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2341 | "neighbor A.B.C.D priority <0-255>", |
| 2342 | NEIGHBOR_STR |
| 2343 | "Neighbor IP address\n" |
| 2344 | "Neighbor Priority\n" |
| 2345 | "Seconds\n") |
| 2346 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2347 | DEFUN (ospf_neighbor_poll_interval, |
| 2348 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2349 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2350 | NEIGHBOR_STR |
| 2351 | "Neighbor IP address\n" |
| 2352 | "Dead Neighbor Polling interval\n" |
| 2353 | "Seconds\n") |
| 2354 | { |
| 2355 | struct ospf *ospf = vty->index; |
| 2356 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2357 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2358 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2359 | |
| 2360 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2361 | |
| 2362 | if (argc > 1) |
| 2363 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2364 | |
| 2365 | if (argc > 2) |
| 2366 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2367 | |
| 2368 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2369 | if (argc > 1) |
| 2370 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2371 | if (argc > 2) |
| 2372 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2373 | |
| 2374 | return CMD_SUCCESS; |
| 2375 | } |
| 2376 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2377 | ALIAS (ospf_neighbor_poll_interval, |
| 2378 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2379 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2380 | NEIGHBOR_STR |
| 2381 | "Neighbor address\n" |
| 2382 | "OSPF dead-router polling interval\n" |
| 2383 | "Seconds\n" |
| 2384 | "OSPF priority of non-broadcast neighbor\n" |
| 2385 | "Priority\n") |
| 2386 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2387 | DEFUN (no_ospf_neighbor, |
| 2388 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2389 | "no neighbor A.B.C.D", |
| 2390 | NO_STR |
| 2391 | NEIGHBOR_STR |
| 2392 | "Neighbor IP address\n") |
| 2393 | { |
| 2394 | struct ospf *ospf = vty->index; |
| 2395 | struct in_addr nbr_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2396 | |
| 2397 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2398 | |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 2399 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2400 | |
| 2401 | return CMD_SUCCESS; |
| 2402 | } |
| 2403 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2404 | ALIAS (no_ospf_neighbor, |
| 2405 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2406 | "no neighbor A.B.C.D priority <0-255>", |
| 2407 | NO_STR |
| 2408 | NEIGHBOR_STR |
| 2409 | "Neighbor IP address\n" |
| 2410 | "Neighbor Priority\n" |
| 2411 | "Priority\n") |
| 2412 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2413 | ALIAS (no_ospf_neighbor, |
| 2414 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2415 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2416 | NO_STR |
| 2417 | NEIGHBOR_STR |
| 2418 | "Neighbor IP address\n" |
| 2419 | "Dead Neighbor Polling interval\n" |
| 2420 | "Seconds\n") |
| 2421 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2422 | ALIAS (no_ospf_neighbor, |
| 2423 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2424 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2425 | NO_STR |
| 2426 | NEIGHBOR_STR |
| 2427 | "Neighbor IP address\n" |
| 2428 | "Neighbor Priority\n" |
| 2429 | "Priority\n" |
| 2430 | "Dead Neighbor Polling interval\n" |
| 2431 | "Seconds\n") |
| 2432 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2433 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2434 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2435 | "refresh timer <10-1800>", |
| 2436 | "Adjust refresh parameters\n" |
| 2437 | "Set refresh timer\n" |
| 2438 | "Timer value in seconds\n") |
| 2439 | { |
| 2440 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2441 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2442 | |
| 2443 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2444 | interval = (interval / 10) * 10; |
| 2445 | |
| 2446 | ospf_timers_refresh_set (ospf, interval); |
| 2447 | |
| 2448 | return CMD_SUCCESS; |
| 2449 | } |
| 2450 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2451 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2452 | "no refresh timer <10-1800>", |
| 2453 | "Adjust refresh parameters\n" |
| 2454 | "Unset refresh timer\n" |
| 2455 | "Timer value in seconds\n") |
| 2456 | { |
| 2457 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2458 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2459 | |
| 2460 | if (argc == 1) |
| 2461 | { |
| 2462 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2463 | |
| 2464 | if (ospf->lsa_refresh_interval != interval || |
| 2465 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2466 | return CMD_SUCCESS; |
| 2467 | } |
| 2468 | |
| 2469 | ospf_timers_refresh_unset (ospf); |
| 2470 | |
| 2471 | return CMD_SUCCESS; |
| 2472 | } |
| 2473 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2474 | ALIAS (no_ospf_refresh_timer, |
| 2475 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2476 | "no refresh timer", |
| 2477 | "Adjust refresh parameters\n" |
| 2478 | "Unset refresh timer\n") |
| 2479 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2480 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2481 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2482 | "auto-cost reference-bandwidth <1-4294967>", |
| 2483 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2484 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2485 | "The reference bandwidth in terms of Mbits per second\n") |
| 2486 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2487 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2488 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2489 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2490 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2491 | |
| 2492 | refbw = strtol (argv[0], NULL, 10); |
| 2493 | if (refbw < 1 || refbw > 4294967) |
| 2494 | { |
| 2495 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2496 | return CMD_WARNING; |
| 2497 | } |
| 2498 | |
| 2499 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2500 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2501 | return CMD_SUCCESS; |
| 2502 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2503 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2504 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2505 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2506 | |
| 2507 | return CMD_SUCCESS; |
| 2508 | } |
| 2509 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2510 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2511 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2512 | "no auto-cost reference-bandwidth", |
| 2513 | NO_STR |
| 2514 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2515 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2516 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2517 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2518 | struct listnode *node, *nnode; |
| 2519 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2521 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2522 | return CMD_SUCCESS; |
| 2523 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2524 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2525 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2526 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2527 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2528 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2529 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | |
| 2531 | return CMD_SUCCESS; |
| 2532 | } |
| 2533 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2534 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2535 | { |
| 2536 | "Unknown", |
| 2537 | "Standard (RFC2328)", |
| 2538 | "Alternative IBM", |
| 2539 | "Alternative Cisco", |
| 2540 | "Alternative Shortcut" |
| 2541 | }; |
| 2542 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2543 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2544 | { |
| 2545 | "Default", |
| 2546 | "Enabled", |
| 2547 | "Disabled" |
| 2548 | }; |
| 2549 | |
| 2550 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2551 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2552 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2553 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2554 | { |
| 2555 | /* Show Area ID. */ |
| 2556 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2557 | |
| 2558 | /* Show Area type/mode. */ |
| 2559 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2560 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2561 | else |
| 2562 | { |
| 2563 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2564 | vty_out (vty, " (Stub%s%s)", |
| 2565 | area->no_summary ? ", no summary" : "", |
| 2566 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2567 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2568 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2569 | vty_out (vty, " (NSSA%s%s)", |
| 2570 | area->no_summary ? ", no summary" : "", |
| 2571 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2572 | |
| 2573 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2574 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2575 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2577 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2578 | } |
| 2579 | |
| 2580 | /* Show number of interfaces. */ |
| 2581 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2582 | "Active: %d%s", listcount (area->oiflist), |
| 2583 | area->act_ints, VTY_NEWLINE); |
| 2584 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2585 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2586 | { |
| 2587 | 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] | 2588 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2589 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2590 | VTY_NEWLINE); |
| 2591 | else if (area->NSSATranslatorState) |
| 2592 | { |
| 2593 | vty_out (vty, " We are an ABR and "); |
| 2594 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2595 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2596 | VTY_NEWLINE); |
| 2597 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2598 | vty_out (vty, "always an NSSA Translator. %s", |
| 2599 | VTY_NEWLINE); |
| 2600 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2601 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2602 | { |
| 2603 | vty_out (vty, " We are an ABR, but "); |
| 2604 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2605 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2606 | VTY_NEWLINE); |
| 2607 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2608 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2609 | VTY_NEWLINE); |
| 2610 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2611 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2612 | /* Stub-router state for this area */ |
| 2613 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2614 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2615 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2616 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2617 | VTY_NEWLINE); |
| 2618 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2619 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2620 | VTY_NEWLINE); |
| 2621 | if (area->t_stub_router) |
| 2622 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2623 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2624 | sizeof(timebuf)), VTY_NEWLINE); |
| 2625 | } |
| 2626 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2627 | /* Show number of fully adjacent neighbors. */ |
| 2628 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2629 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2630 | |
| 2631 | /* Show authentication type. */ |
| 2632 | vty_out (vty, " Area has "); |
| 2633 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2634 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2635 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2636 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2637 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2638 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2639 | |
| 2640 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2641 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2642 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2643 | |
| 2644 | /* Show SPF calculation times. */ |
| 2645 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2646 | area->spf_calculation, VTY_NEWLINE); |
| 2647 | |
| 2648 | /* Show number of LSA. */ |
| 2649 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2650 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2651 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2652 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2653 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2654 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2655 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2656 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2657 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2658 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2659 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2660 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2661 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2662 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2663 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2664 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2665 | #ifdef HAVE_OPAQUE_LSA |
| 2666 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2667 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2668 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2669 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2670 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2671 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2672 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2673 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2674 | } |
| 2675 | |
| 2676 | DEFUN (show_ip_ospf, |
| 2677 | show_ip_ospf_cmd, |
| 2678 | "show ip ospf", |
| 2679 | SHOW_STR |
| 2680 | IP_STR |
| 2681 | "OSPF information\n") |
| 2682 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2683 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2684 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2685 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2686 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2687 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2688 | |
| 2689 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2690 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2691 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2692 | { |
| 2693 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2694 | return CMD_SUCCESS; |
| 2695 | } |
| 2696 | |
| 2697 | /* Show Router ID. */ |
| 2698 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2699 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2700 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2701 | |
| 2702 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2703 | if (ospf->t_deferred_shutdown) |
| 2704 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2705 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2706 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2707 | /* Show capability. */ |
| 2708 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2709 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2710 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2711 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2712 | "enabled" : "disabled", VTY_NEWLINE); |
| 2713 | #ifdef HAVE_OPAQUE_LSA |
| 2714 | vty_out (vty, " OpaqueCapability flag is %s%s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2715 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | "enabled" : "disabled", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2717 | IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2718 | " (origination blocked)" : "", |
| 2719 | VTY_NEWLINE); |
| 2720 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2721 | |
| 2722 | /* Show stub-router configuration */ |
| 2723 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2724 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2725 | { |
| 2726 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2727 | VTY_NEWLINE); |
| 2728 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2729 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2730 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2731 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2732 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2733 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2734 | } |
| 2735 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2736 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2737 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2738 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2739 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2740 | " Hold time multiplier is currently %d%s", |
| 2741 | ospf->spf_delay, VTY_NEWLINE, |
| 2742 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2743 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2744 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2745 | vty_out (vty, " SPF algorithm "); |
| 2746 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2747 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 2748 | result = tv_sub (recent_relative_time (), ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2749 | vty_out (vty, "last executed %s ago%s", |
| 2750 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2751 | VTY_NEWLINE); |
| 2752 | } |
| 2753 | else |
| 2754 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2755 | vty_out (vty, " SPF timer %s%s%s", |
| 2756 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2757 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2758 | VTY_NEWLINE); |
| 2759 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2760 | /* Show refresh parameters. */ |
| 2761 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2762 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2763 | |
| 2764 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2765 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2766 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2767 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2768 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2769 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2770 | vty_out (vty, " This router is an ASBR " |
| 2771 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2772 | |
| 2773 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2774 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2775 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2776 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2777 | #ifdef HAVE_OPAQUE_LSA |
| 2778 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2779 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2780 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2781 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2782 | /* Show number of areas attached. */ |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2783 | vty_out (vty, " Number of areas attached to this router: %d%s", |
| 2784 | listcount (ospf->areas), VTY_NEWLINE); |
| 2785 | |
| 2786 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 2787 | { |
| 2788 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 2789 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); |
| 2790 | else |
| 2791 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); |
| 2792 | } |
| 2793 | |
| 2794 | vty_out (vty, "%s",VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2795 | |
| 2796 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2797 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2798 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2799 | |
| 2800 | return CMD_SUCCESS; |
| 2801 | } |
| 2802 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2803 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2804 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2805 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2806 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2807 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2808 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2809 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2810 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2811 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2812 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2813 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2814 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2815 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2816 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2817 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2818 | |
| 2819 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2820 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2821 | { |
| 2822 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2823 | return; |
| 2824 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2825 | else if (!is_up) |
| 2826 | { |
| 2827 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2828 | VTY_NEWLINE); |
| 2829 | return; |
| 2830 | } |
| 2831 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2832 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2833 | { |
| 2834 | struct ospf_interface *oi = rn->info; |
| 2835 | |
| 2836 | if (oi == NULL) |
| 2837 | continue; |
| 2838 | |
| 2839 | /* Show OSPF interface information. */ |
| 2840 | vty_out (vty, " Internet Address %s/%d,", |
| 2841 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2842 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2843 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2844 | { |
| 2845 | struct in_addr *dest; |
| 2846 | const char *dstr; |
| 2847 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 2848 | if (CONNECTED_PEER(oi->connected) |
| 2849 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2850 | dstr = "Peer"; |
| 2851 | else |
| 2852 | dstr = "Broadcast"; |
| 2853 | |
| 2854 | /* For Vlinks, showing the peer address is probably more |
| 2855 | * informative than the local interface that is being used |
| 2856 | */ |
| 2857 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2858 | dest = &oi->vl_data->peer_addr; |
| 2859 | else |
| 2860 | dest = &oi->connected->destination->u.prefix4; |
| 2861 | |
| 2862 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); |
| 2863 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2864 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2865 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2866 | VTY_NEWLINE); |
| 2867 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2868 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2869 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2870 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2871 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2872 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2873 | oi->output_cost, VTY_NEWLINE); |
| 2874 | |
| 2875 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2876 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2877 | PRIORITY (oi), VTY_NEWLINE); |
| 2878 | |
| 2879 | /* Show DR information. */ |
| 2880 | if (DR (oi).s_addr == 0) |
| 2881 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2882 | else |
| 2883 | { |
| 2884 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2885 | if (nbr == NULL) |
| 2886 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2887 | else |
| 2888 | { |
| 2889 | vty_out (vty, " Designated Router (ID) %s,", |
| 2890 | inet_ntoa (nbr->router_id)); |
| 2891 | vty_out (vty, " Interface Address %s%s", |
| 2892 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2893 | } |
| 2894 | } |
| 2895 | |
| 2896 | /* Show BDR information. */ |
| 2897 | if (BDR (oi).s_addr == 0) |
| 2898 | vty_out (vty, " No backup designated router on this network%s", |
| 2899 | VTY_NEWLINE); |
| 2900 | else |
| 2901 | { |
| 2902 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2903 | if (nbr == NULL) |
| 2904 | vty_out (vty, " No backup designated router on this network%s", |
| 2905 | VTY_NEWLINE); |
| 2906 | else |
| 2907 | { |
| 2908 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2909 | inet_ntoa (nbr->router_id)); |
| 2910 | vty_out (vty, " Interface Address %s%s", |
| 2911 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2912 | } |
| 2913 | } |
Paul Jakma | 7eb5b47 | 2009-10-13 16:13:13 +0100 | [diff] [blame] | 2914 | |
| 2915 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
| 2916 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) |
| 2917 | != OSPF_INITIAL_SEQUENCE_NUMBER) |
| 2918 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", |
| 2919 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); |
| 2920 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2921 | vty_out (vty, " Multicast group memberships:"); |
Paul Jakma | 429ac78 | 2006-06-15 18:40:49 +0000 | [diff] [blame] | 2922 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
| 2923 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2924 | { |
| 2925 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) |
| 2926 | vty_out (vty, " OSPFAllRouters"); |
| 2927 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 2928 | vty_out (vty, " OSPFDesignatedRouters"); |
| 2929 | } |
| 2930 | else |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 2931 | vty_out (vty, " <None>"); |
| 2932 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2933 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2934 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2935 | vty_out (vty, " Hello "); |
| 2936 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 2937 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 2938 | else |
| 2939 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 2940 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 2941 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2942 | OSPF_IF_PARAM (oi, v_wait), |
| 2943 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 2944 | VTY_NEWLINE); |
| 2945 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 2946 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2947 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2948 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2949 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2950 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 2951 | VTY_NEWLINE); |
| 2952 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 2953 | else /* passive-interface is set */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2954 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 2955 | |
| 2956 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2957 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2958 | VTY_NEWLINE); |
| 2959 | } |
| 2960 | } |
| 2961 | |
| 2962 | DEFUN (show_ip_ospf_interface, |
| 2963 | show_ip_ospf_interface_cmd, |
| 2964 | "show ip ospf interface [INTERFACE]", |
| 2965 | SHOW_STR |
| 2966 | IP_STR |
| 2967 | "OSPF information\n" |
| 2968 | "Interface information\n" |
| 2969 | "Interface name\n") |
| 2970 | { |
| 2971 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2972 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2973 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2974 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2975 | ospf = ospf_lookup (); |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 2976 | if (ospf == NULL) |
| 2977 | { |
| 2978 | vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2979 | return CMD_SUCCESS; |
| 2980 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2981 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2982 | /* Show All Interfaces. */ |
| 2983 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2984 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 2985 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2986 | /* Interface name is specified. */ |
| 2987 | else |
| 2988 | { |
| 2989 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 2990 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 2991 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2992 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2993 | } |
| 2994 | |
| 2995 | return CMD_SUCCESS; |
| 2996 | } |
| 2997 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2998 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2999 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 3000 | { |
| 3001 | vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
| 3002 | VTY_NEWLINE, |
| 3003 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 3004 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 3005 | VTY_NEWLINE); |
| 3006 | } |
| 3007 | |
| 3008 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3009 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 3010 | { |
| 3011 | struct route_node *rn; |
| 3012 | struct ospf_neighbor *nbr; |
| 3013 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3014 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3015 | |
| 3016 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3017 | if ((nbr = rn->info)) |
| 3018 | /* Do not show myself. */ |
| 3019 | if (nbr != oi->nbr_self) |
| 3020 | /* Down state is not shown. */ |
| 3021 | if (nbr->state != NSM_Down) |
| 3022 | { |
| 3023 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 3024 | |
| 3025 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3026 | vty_out (vty, "%-15s %3d %-15s ", |
| 3027 | "-", nbr->priority, |
| 3028 | msgbuf); |
| 3029 | else |
| 3030 | vty_out (vty, "%-15s %3d %-15s ", |
| 3031 | inet_ntoa (nbr->router_id), nbr->priority, |
| 3032 | msgbuf); |
| 3033 | |
| 3034 | vty_out (vty, "%9s ", |
| 3035 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 3036 | sizeof(timebuf))); |
| 3037 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3038 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3039 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3040 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 3041 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 3042 | VTY_NEWLINE); |
| 3043 | } |
| 3044 | } |
| 3045 | |
| 3046 | DEFUN (show_ip_ospf_neighbor, |
| 3047 | show_ip_ospf_neighbor_cmd, |
| 3048 | "show ip ospf neighbor", |
| 3049 | SHOW_STR |
| 3050 | IP_STR |
| 3051 | "OSPF information\n" |
| 3052 | "Neighbor list\n") |
| 3053 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3054 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3055 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3056 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3057 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3058 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3059 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3060 | { |
| 3061 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3062 | return CMD_SUCCESS; |
| 3063 | } |
| 3064 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3065 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3066 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3067 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3068 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3069 | |
| 3070 | return CMD_SUCCESS; |
| 3071 | } |
| 3072 | |
| 3073 | DEFUN (show_ip_ospf_neighbor_all, |
| 3074 | show_ip_ospf_neighbor_all_cmd, |
| 3075 | "show ip ospf neighbor all", |
| 3076 | SHOW_STR |
| 3077 | IP_STR |
| 3078 | "OSPF information\n" |
| 3079 | "Neighbor list\n" |
| 3080 | "include down status neighbor\n") |
| 3081 | { |
Joakim Tjernlund | 35f8914 | 2008-07-01 16:54:07 +0200 | [diff] [blame] | 3082 | struct ospf *ospf = ospf_lookup (); |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3083 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3084 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3085 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3086 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3087 | { |
| 3088 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3089 | return CMD_SUCCESS; |
| 3090 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3091 | |
| 3092 | show_ip_ospf_neighbour_header (vty); |
| 3093 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3094 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3095 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3096 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3097 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3098 | |
| 3099 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3100 | |
| 3101 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3102 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3103 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3104 | if (nbr_nbma->nbr == NULL |
| 3105 | || nbr_nbma->nbr->state == NSM_Down) |
| 3106 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3107 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3108 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3109 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3110 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 3111 | 0, 0, 0, VTY_NEWLINE); |
| 3112 | } |
| 3113 | } |
| 3114 | } |
| 3115 | |
| 3116 | return CMD_SUCCESS; |
| 3117 | } |
| 3118 | |
| 3119 | DEFUN (show_ip_ospf_neighbor_int, |
| 3120 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3121 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3122 | SHOW_STR |
| 3123 | IP_STR |
| 3124 | "OSPF information\n" |
| 3125 | "Neighbor list\n" |
| 3126 | "Interface name\n") |
| 3127 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3128 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3129 | struct interface *ifp; |
| 3130 | struct route_node *rn; |
| 3131 | |
| 3132 | ifp = if_lookup_by_name (argv[0]); |
| 3133 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3134 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3135 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3136 | return CMD_WARNING; |
| 3137 | } |
| 3138 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3139 | ospf = ospf_lookup (); |
| 3140 | if (ospf == NULL) |
| 3141 | { |
| 3142 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3143 | return CMD_SUCCESS; |
| 3144 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3145 | |
| 3146 | show_ip_ospf_neighbour_header (vty); |
| 3147 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3148 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3149 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3150 | struct ospf_interface *oi = rn->info; |
| 3151 | |
| 3152 | if (oi == NULL) |
| 3153 | continue; |
| 3154 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3155 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3156 | } |
| 3157 | |
| 3158 | return CMD_SUCCESS; |
| 3159 | } |
| 3160 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3161 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3162 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3163 | struct ospf_nbr_nbma *nbr_nbma) |
| 3164 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3165 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3166 | |
| 3167 | /* Show neighbor ID. */ |
| 3168 | vty_out (vty, " Neighbor %s,", "-"); |
| 3169 | |
| 3170 | /* Show interface address. */ |
| 3171 | vty_out (vty, " interface address %s%s", |
| 3172 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3173 | /* Show Area ID. */ |
| 3174 | vty_out (vty, " In the area %s via interface %s%s", |
| 3175 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3176 | /* Show neighbor priority and state. */ |
| 3177 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3178 | nbr_nbma->priority, "Down"); |
| 3179 | /* Show state changes. */ |
| 3180 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3181 | |
| 3182 | /* Show PollInterval */ |
| 3183 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3184 | |
| 3185 | /* Show poll-interval timer. */ |
| 3186 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3187 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3188 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3189 | |
| 3190 | /* Show poll-interval timer thread. */ |
| 3191 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3192 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3193 | } |
| 3194 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3195 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3196 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3197 | struct ospf_neighbor *nbr) |
| 3198 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3199 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3200 | |
| 3201 | /* Show neighbor ID. */ |
| 3202 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3203 | vty_out (vty, " Neighbor %s,", "-"); |
| 3204 | else |
| 3205 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3206 | |
| 3207 | /* Show interface address. */ |
| 3208 | vty_out (vty, " interface address %s%s", |
| 3209 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3210 | /* Show Area ID. */ |
| 3211 | vty_out (vty, " In the area %s via interface %s%s", |
| 3212 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3213 | /* Show neighbor priority and state. */ |
| 3214 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3215 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3216 | /* Show state changes. */ |
| 3217 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3218 | 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] | 3219 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3220 | struct timeval res |
| 3221 | = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3222 | vty_out (vty, " Most recent state change statistics:%s", |
| 3223 | VTY_NEWLINE); |
| 3224 | vty_out (vty, " Progressive change %s ago%s", |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3225 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3226 | VTY_NEWLINE); |
| 3227 | } |
| 3228 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
| 3229 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3230 | struct timeval res |
| 3231 | = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3232 | vty_out (vty, " Regressive change %s ago, due to %s%s", |
| 3233 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
| 3234 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3235 | VTY_NEWLINE); |
| 3236 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3237 | /* Show Designated Rotuer ID. */ |
| 3238 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3239 | /* Show Backup Designated Rotuer ID. */ |
| 3240 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3241 | /* Show options. */ |
| 3242 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3243 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3244 | /* Show Router Dead interval timer. */ |
| 3245 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3246 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3247 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3248 | /* Show Database Summary list. */ |
| 3249 | vty_out (vty, " Database Summary List %d%s", |
| 3250 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3251 | /* Show Link State Request list. */ |
| 3252 | vty_out (vty, " Link State Request List %ld%s", |
| 3253 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3254 | /* Show Link State Retransmission list. */ |
| 3255 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3256 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3257 | /* Show inactivity timer thread. */ |
| 3258 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3259 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3260 | /* Show Database Description retransmission thread. */ |
| 3261 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3262 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3263 | /* Show Link State Request Retransmission thread. */ |
| 3264 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3265 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3266 | /* Show Link State Update Retransmission thread. */ |
| 3267 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3268 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3269 | } |
| 3270 | |
| 3271 | DEFUN (show_ip_ospf_neighbor_id, |
| 3272 | show_ip_ospf_neighbor_id_cmd, |
| 3273 | "show ip ospf neighbor A.B.C.D", |
| 3274 | SHOW_STR |
| 3275 | IP_STR |
| 3276 | "OSPF information\n" |
| 3277 | "Neighbor list\n" |
| 3278 | "Neighbor ID\n") |
| 3279 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3280 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3281 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3282 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3283 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3284 | struct in_addr router_id; |
| 3285 | int ret; |
| 3286 | |
| 3287 | ret = inet_aton (argv[0], &router_id); |
| 3288 | if (!ret) |
| 3289 | { |
| 3290 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3291 | return CMD_WARNING; |
| 3292 | } |
| 3293 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3294 | ospf = ospf_lookup (); |
| 3295 | if (ospf == NULL) |
| 3296 | { |
| 3297 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3298 | return CMD_SUCCESS; |
| 3299 | } |
| 3300 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3301 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3302 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
Andrew J. Schorr | 1c066bf | 2006-06-30 16:53:47 +0000 | [diff] [blame] | 3303 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3304 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3305 | return CMD_SUCCESS; |
| 3306 | } |
| 3307 | |
| 3308 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3309 | show_ip_ospf_neighbor_detail_cmd, |
| 3310 | "show ip ospf neighbor detail", |
| 3311 | SHOW_STR |
| 3312 | IP_STR |
| 3313 | "OSPF information\n" |
| 3314 | "Neighbor list\n" |
| 3315 | "detail of all neighbors\n") |
| 3316 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3317 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3318 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3319 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3320 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3321 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3322 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3323 | { |
| 3324 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3325 | return CMD_SUCCESS; |
| 3326 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3327 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3328 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3329 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3330 | struct route_node *rn; |
| 3331 | struct ospf_neighbor *nbr; |
| 3332 | |
| 3333 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3334 | if ((nbr = rn->info)) |
| 3335 | if (nbr != oi->nbr_self) |
| 3336 | if (nbr->state != NSM_Down) |
| 3337 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3338 | } |
| 3339 | |
| 3340 | return CMD_SUCCESS; |
| 3341 | } |
| 3342 | |
| 3343 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3344 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3345 | "show ip ospf neighbor detail all", |
| 3346 | SHOW_STR |
| 3347 | IP_STR |
| 3348 | "OSPF information\n" |
| 3349 | "Neighbor list\n" |
| 3350 | "detail of all neighbors\n" |
| 3351 | "include down status neighbor\n") |
| 3352 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3353 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3354 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3355 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3356 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3357 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3358 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3359 | { |
| 3360 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3361 | return CMD_SUCCESS; |
| 3362 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3363 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3364 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3365 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3366 | struct route_node *rn; |
| 3367 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3368 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3369 | |
| 3370 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3371 | if ((nbr = rn->info)) |
| 3372 | if (nbr != oi->nbr_self) |
| 3373 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3374 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3375 | |
| 3376 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3377 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3378 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3379 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3380 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3381 | if (nbr_nbma->nbr == NULL |
| 3382 | || nbr_nbma->nbr->state == NSM_Down) |
| 3383 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3384 | } |
| 3385 | } |
| 3386 | |
| 3387 | return CMD_SUCCESS; |
| 3388 | } |
| 3389 | |
| 3390 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3391 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3392 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3393 | SHOW_STR |
| 3394 | IP_STR |
| 3395 | "OSPF information\n" |
| 3396 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3397 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3398 | "detail of all neighbors") |
| 3399 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3400 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3401 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3402 | struct interface *ifp; |
| 3403 | struct route_node *rn, *nrn; |
| 3404 | struct ospf_neighbor *nbr; |
| 3405 | |
| 3406 | ifp = if_lookup_by_name (argv[0]); |
| 3407 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3408 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3409 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3410 | return CMD_WARNING; |
| 3411 | } |
| 3412 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3413 | ospf = ospf_lookup (); |
| 3414 | if (ospf == NULL) |
| 3415 | { |
| 3416 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3417 | return CMD_SUCCESS; |
| 3418 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3419 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3420 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3421 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3422 | if ((oi = rn->info)) |
| 3423 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3424 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3425 | if (nbr != oi->nbr_self) |
| 3426 | if (nbr->state != NSM_Down) |
| 3427 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3428 | |
| 3429 | return CMD_SUCCESS; |
| 3430 | } |
| 3431 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3432 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3433 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3434 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3435 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3436 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3437 | struct router_lsa *rl; |
| 3438 | struct summary_lsa *sl; |
| 3439 | struct as_external_lsa *asel; |
| 3440 | struct prefix_ipv4 p; |
| 3441 | |
| 3442 | if (lsa != NULL) |
| 3443 | /* If self option is set, check LSA self flag. */ |
| 3444 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3445 | { |
| 3446 | /* LSA common part show. */ |
| 3447 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3448 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3449 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3450 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3451 | /* LSA specific part show. */ |
| 3452 | switch (lsa->data->type) |
| 3453 | { |
| 3454 | case OSPF_ROUTER_LSA: |
| 3455 | rl = (struct router_lsa *) lsa->data; |
| 3456 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3457 | break; |
| 3458 | case OSPF_SUMMARY_LSA: |
| 3459 | sl = (struct summary_lsa *) lsa->data; |
| 3460 | |
| 3461 | p.family = AF_INET; |
| 3462 | p.prefix = sl->header.id; |
| 3463 | p.prefixlen = ip_masklen (sl->mask); |
| 3464 | apply_mask_ipv4 (&p); |
| 3465 | |
| 3466 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3467 | break; |
| 3468 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3469 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3470 | asel = (struct as_external_lsa *) lsa->data; |
| 3471 | |
| 3472 | p.family = AF_INET; |
| 3473 | p.prefix = asel->header.id; |
| 3474 | p.prefixlen = ip_masklen (asel->mask); |
| 3475 | apply_mask_ipv4 (&p); |
| 3476 | |
| 3477 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3478 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3479 | inet_ntoa (p.prefix), p.prefixlen, |
| 3480 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3481 | break; |
| 3482 | case OSPF_NETWORK_LSA: |
| 3483 | case OSPF_ASBR_SUMMARY_LSA: |
| 3484 | #ifdef HAVE_OPAQUE_LSA |
| 3485 | case OSPF_OPAQUE_LINK_LSA: |
| 3486 | case OSPF_OPAQUE_AREA_LSA: |
| 3487 | case OSPF_OPAQUE_AS_LSA: |
| 3488 | #endif /* HAVE_OPAQUE_LSA */ |
| 3489 | default: |
| 3490 | break; |
| 3491 | } |
| 3492 | vty_out (vty, VTY_NEWLINE); |
| 3493 | } |
| 3494 | |
| 3495 | return 0; |
| 3496 | } |
| 3497 | |
Stephen Hemminger | 8b6a15b | 2009-12-03 19:25:04 +0300 | [diff] [blame] | 3498 | static const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3499 | { |
| 3500 | "unknown", |
| 3501 | "Router Link States", |
| 3502 | "Net Link States", |
| 3503 | "Summary Link States", |
| 3504 | "ASBR-Summary Link States", |
| 3505 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3506 | "Group Membership LSA", |
| 3507 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3508 | #ifdef HAVE_OPAQUE_LSA |
| 3509 | "Type-8 LSA", |
| 3510 | "Link-Local Opaque-LSA", |
| 3511 | "Area-Local Opaque-LSA", |
| 3512 | "AS-external Opaque-LSA", |
| 3513 | #endif /* HAVE_OPAQUE_LSA */ |
| 3514 | }; |
| 3515 | |
Stephen Hemminger | 8b6a15b | 2009-12-03 19:25:04 +0300 | [diff] [blame] | 3516 | static const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3517 | { |
| 3518 | "", |
| 3519 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3520 | "Link ID ADV Router Age Seq# CkSum", |
| 3521 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3522 | "Link ID ADV Router Age Seq# CkSum", |
| 3523 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3524 | " --- header for Group Member ----", |
| 3525 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3526 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3527 | " --- type-8 ---", |
| 3528 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3529 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3530 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3531 | #endif /* HAVE_OPAQUE_LSA */ |
| 3532 | }; |
| 3533 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3534 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3535 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3536 | { |
| 3537 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3538 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3539 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3540 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3541 | lsa->data->options, |
| 3542 | ospf_options_dump(lsa->data->options), |
| 3543 | VTY_NEWLINE); |
| 3544 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3545 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3546 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3547 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3548 | |
| 3549 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3550 | { |
| 3551 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3552 | |
| 3553 | if (rlsa->flags) |
| 3554 | vty_out (vty, " :%s%s%s%s", |
| 3555 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3556 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3557 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3558 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3559 | |
| 3560 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3561 | } |
| 3562 | vty_out (vty, " LS Type: %s%s", |
| 3563 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3564 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3565 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3566 | vty_out (vty, " Advertising Router: %s%s", |
| 3567 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3568 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3569 | VTY_NEWLINE); |
| 3570 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3571 | VTY_NEWLINE); |
| 3572 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3573 | } |
| 3574 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3575 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3576 | { |
| 3577 | "(null)", |
| 3578 | "another Router (point-to-point)", |
| 3579 | "a Transit Network", |
| 3580 | "Stub Network", |
| 3581 | "a Virtual Link", |
| 3582 | }; |
| 3583 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3584 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3585 | { |
| 3586 | "(null)", |
| 3587 | "Neighboring Router ID", |
| 3588 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3589 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3590 | "Neighboring Router ID", |
| 3591 | }; |
| 3592 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3593 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3594 | { |
| 3595 | "(null)", |
| 3596 | "Router Interface address", |
| 3597 | "Router Interface address", |
| 3598 | "Network Mask", |
| 3599 | "Router Interface address", |
| 3600 | }; |
| 3601 | |
| 3602 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3603 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3604 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3605 | struct router_lsa *rl) |
| 3606 | { |
| 3607 | int len, i, type; |
| 3608 | |
| 3609 | len = ntohs (rl->header.length) - 4; |
| 3610 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3611 | { |
| 3612 | type = rl->link[i].type; |
| 3613 | |
| 3614 | vty_out (vty, " Link connected to: %s%s", |
| 3615 | link_type_desc[type], VTY_NEWLINE); |
| 3616 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3617 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3618 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3619 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3620 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3621 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3622 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3623 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3624 | } |
| 3625 | } |
| 3626 | |
| 3627 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3628 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3629 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3630 | { |
| 3631 | if (lsa != NULL) |
| 3632 | { |
| 3633 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3634 | |
| 3635 | show_ip_ospf_database_header (vty, lsa); |
| 3636 | |
| 3637 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3638 | VTY_NEWLINE, VTY_NEWLINE); |
| 3639 | |
| 3640 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3641 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3642 | } |
| 3643 | |
| 3644 | return 0; |
| 3645 | } |
| 3646 | |
| 3647 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3648 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3649 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3650 | { |
| 3651 | int length, i; |
| 3652 | |
| 3653 | if (lsa != NULL) |
| 3654 | { |
| 3655 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3656 | |
| 3657 | show_ip_ospf_database_header (vty, lsa); |
| 3658 | |
| 3659 | vty_out (vty, " Network Mask: /%d%s", |
| 3660 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3661 | |
| 3662 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3663 | |
| 3664 | for (i = 0; length > 0; i++, length -= 4) |
| 3665 | vty_out (vty, " Attached Router: %s%s", |
| 3666 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3667 | |
| 3668 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3669 | } |
| 3670 | |
| 3671 | return 0; |
| 3672 | } |
| 3673 | |
| 3674 | /* Show summary-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_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3677 | { |
| 3678 | if (lsa != NULL) |
| 3679 | { |
| 3680 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3681 | |
| 3682 | show_ip_ospf_database_header (vty, lsa); |
| 3683 | |
| 3684 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3685 | VTY_NEWLINE); |
| 3686 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3687 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3688 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3689 | } |
| 3690 | |
| 3691 | return 0; |
| 3692 | } |
| 3693 | |
| 3694 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3695 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3696 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3697 | { |
| 3698 | if (lsa != NULL) |
| 3699 | { |
| 3700 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3701 | |
| 3702 | show_ip_ospf_database_header (vty, lsa); |
| 3703 | |
| 3704 | vty_out (vty, " Network Mask: /%d%s", |
| 3705 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3706 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3707 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3708 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3709 | } |
| 3710 | |
| 3711 | return 0; |
| 3712 | } |
| 3713 | |
| 3714 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3715 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3716 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3717 | { |
| 3718 | if (lsa != NULL) |
| 3719 | { |
| 3720 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3721 | |
| 3722 | show_ip_ospf_database_header (vty, lsa); |
| 3723 | |
| 3724 | vty_out (vty, " Network Mask: /%d%s", |
| 3725 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3726 | vty_out (vty, " Metric Type: %s%s", |
| 3727 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3728 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3729 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3730 | vty_out (vty, " Metric: %d%s", |
| 3731 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3732 | vty_out (vty, " Forward Address: %s%s", |
| 3733 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3734 | |
| 3735 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3736 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3737 | } |
| 3738 | |
| 3739 | return 0; |
| 3740 | } |
| 3741 | |
Stephen Hemminger | 075e12f | 2011-12-06 23:54:17 +0400 | [diff] [blame] | 3742 | #if 0 |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3743 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3744 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3745 | { |
| 3746 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3747 | |
| 3748 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3749 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3750 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3751 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3752 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3753 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3754 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3755 | zlog_debug( " TOS: 0%s", "\n"); |
| 3756 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3757 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3758 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3759 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3760 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3761 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3762 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3763 | |
| 3764 | return 0; |
| 3765 | } |
Stephen Hemminger | 075e12f | 2011-12-06 23:54:17 +0400 | [diff] [blame] | 3766 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3767 | |
| 3768 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3769 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3770 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3771 | { |
| 3772 | if (lsa != NULL) |
| 3773 | { |
| 3774 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3775 | |
| 3776 | show_ip_ospf_database_header (vty, lsa); |
| 3777 | |
| 3778 | vty_out (vty, " Network Mask: /%d%s", |
| 3779 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3780 | vty_out (vty, " Metric Type: %s%s", |
| 3781 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3782 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3783 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3784 | vty_out (vty, " Metric: %d%s", |
| 3785 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3786 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3787 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3788 | |
| 3789 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3790 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3791 | } |
| 3792 | |
| 3793 | return 0; |
| 3794 | } |
| 3795 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3796 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3797 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3798 | { |
| 3799 | return 0; |
| 3800 | } |
| 3801 | |
| 3802 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3803 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3804 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3805 | { |
| 3806 | if (lsa != NULL) |
| 3807 | { |
| 3808 | show_ip_ospf_database_header (vty, lsa); |
| 3809 | show_opaque_info_detail (vty, lsa); |
| 3810 | |
| 3811 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3812 | } |
| 3813 | return 0; |
| 3814 | } |
| 3815 | #endif /* HAVE_OPAQUE_LSA */ |
| 3816 | |
| 3817 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3818 | { |
| 3819 | NULL, |
| 3820 | show_router_lsa_detail, |
| 3821 | show_network_lsa_detail, |
| 3822 | show_summary_lsa_detail, |
| 3823 | show_summary_asbr_lsa_detail, |
| 3824 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3825 | show_func_dummy, |
| 3826 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3827 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3828 | NULL, /* type-8 */ |
| 3829 | show_opaque_lsa_detail, |
| 3830 | show_opaque_lsa_detail, |
| 3831 | show_opaque_lsa_detail, |
| 3832 | #endif /* HAVE_OPAQUE_LSA */ |
| 3833 | }; |
| 3834 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3835 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3836 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3837 | struct in_addr *adv_router) |
| 3838 | { |
| 3839 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3840 | lp->family = 0; |
| 3841 | if (id == NULL) |
| 3842 | lp->prefixlen = 0; |
| 3843 | else if (adv_router == NULL) |
| 3844 | { |
| 3845 | lp->prefixlen = 32; |
| 3846 | lp->id = *id; |
| 3847 | } |
| 3848 | else |
| 3849 | { |
| 3850 | lp->prefixlen = 64; |
| 3851 | lp->id = *id; |
| 3852 | lp->adv_router = *adv_router; |
| 3853 | } |
| 3854 | } |
| 3855 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3856 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3857 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3858 | struct in_addr *id, struct in_addr *adv_router) |
| 3859 | { |
| 3860 | struct prefix_ls lp; |
| 3861 | struct route_node *rn, *start; |
| 3862 | struct ospf_lsa *lsa; |
| 3863 | |
| 3864 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3865 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3866 | if (start) |
| 3867 | { |
| 3868 | route_lock_node (start); |
| 3869 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3870 | if ((lsa = rn->info)) |
| 3871 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3872 | if (show_function[lsa->data->type] != NULL) |
| 3873 | show_function[lsa->data->type] (vty, lsa); |
| 3874 | } |
| 3875 | route_unlock_node (start); |
| 3876 | } |
| 3877 | } |
| 3878 | |
| 3879 | /* Show detail LSA information |
| 3880 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3881 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3882 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3883 | struct in_addr *id, struct in_addr *adv_router) |
| 3884 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3885 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3886 | struct ospf_area *area; |
| 3887 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3888 | switch (type) |
| 3889 | { |
| 3890 | case OSPF_AS_EXTERNAL_LSA: |
| 3891 | #ifdef HAVE_OPAQUE_LSA |
| 3892 | case OSPF_OPAQUE_AS_LSA: |
| 3893 | #endif /* HAVE_OPAQUE_LSA */ |
| 3894 | vty_out (vty, " %s %s%s", |
| 3895 | show_database_desc[type], |
| 3896 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3897 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3898 | break; |
| 3899 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3900 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3901 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3902 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3903 | VTY_NEWLINE, show_database_desc[type], |
| 3904 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3905 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3906 | } |
| 3907 | break; |
| 3908 | } |
| 3909 | } |
| 3910 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3911 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3912 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 3913 | struct in_addr *adv_router) |
| 3914 | { |
| 3915 | struct route_node *rn; |
| 3916 | struct ospf_lsa *lsa; |
| 3917 | |
| 3918 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 3919 | if ((lsa = rn->info)) |
| 3920 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 3921 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3922 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 3923 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3924 | if (show_function[lsa->data->type] != NULL) |
| 3925 | show_function[lsa->data->type] (vty, lsa); |
| 3926 | } |
| 3927 | } |
| 3928 | |
| 3929 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3930 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3931 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3932 | struct in_addr *adv_router) |
| 3933 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3934 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3935 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3936 | |
| 3937 | switch (type) |
| 3938 | { |
| 3939 | case OSPF_AS_EXTERNAL_LSA: |
| 3940 | #ifdef HAVE_OPAQUE_LSA |
| 3941 | case OSPF_OPAQUE_AS_LSA: |
| 3942 | #endif /* HAVE_OPAQUE_LSA */ |
| 3943 | vty_out (vty, " %s %s%s", |
| 3944 | show_database_desc[type], |
| 3945 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3946 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3947 | adv_router); |
| 3948 | break; |
| 3949 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3950 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3951 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3952 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3953 | VTY_NEWLINE, show_database_desc[type], |
| 3954 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3955 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 3956 | adv_router); |
| 3957 | } |
| 3958 | break; |
| 3959 | } |
| 3960 | } |
| 3961 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3962 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3963 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3964 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3965 | struct ospf_lsa *lsa; |
| 3966 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3967 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3968 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3969 | int type; |
| 3970 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3971 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3972 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3973 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 3974 | { |
| 3975 | switch (type) |
| 3976 | { |
| 3977 | case OSPF_AS_EXTERNAL_LSA: |
| 3978 | #ifdef HAVE_OPAQUE_LSA |
| 3979 | case OSPF_OPAQUE_AS_LSA: |
| 3980 | #endif /* HAVE_OPAQUE_LSA */ |
| 3981 | continue; |
| 3982 | default: |
| 3983 | break; |
| 3984 | } |
| 3985 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 3986 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 3987 | { |
| 3988 | vty_out (vty, " %s (Area %s)%s%s", |
| 3989 | show_database_desc[type], |
| 3990 | ospf_area_desc_string (area), |
| 3991 | VTY_NEWLINE, VTY_NEWLINE); |
| 3992 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 3993 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3994 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 3995 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3996 | |
| 3997 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3998 | } |
| 3999 | } |
| 4000 | } |
| 4001 | |
| 4002 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4003 | { |
| 4004 | switch (type) |
| 4005 | { |
| 4006 | case OSPF_AS_EXTERNAL_LSA: |
| 4007 | #ifdef HAVE_OPAQUE_LSA |
| 4008 | case OSPF_OPAQUE_AS_LSA: |
| 4009 | #endif /* HAVE_OPAQUE_LSA */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 4010 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4011 | default: |
| 4012 | continue; |
| 4013 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4014 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 4015 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4016 | { |
| 4017 | vty_out (vty, " %s%s%s", |
| 4018 | show_database_desc[type], |
| 4019 | VTY_NEWLINE, VTY_NEWLINE); |
| 4020 | vty_out (vty, "%s%s", show_database_header[type], |
| 4021 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4022 | |
| 4023 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 4024 | show_lsa_summary (vty, lsa, self); |
| 4025 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4026 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4027 | } |
| 4028 | } |
| 4029 | |
| 4030 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4031 | } |
| 4032 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4033 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4034 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4035 | { |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4036 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4037 | struct ospf_lsa *lsa; |
| 4038 | |
| 4039 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 4040 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 4041 | |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4042 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4043 | { |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4044 | struct ospf_lsa *lsa; |
| 4045 | |
| 4046 | if ((lsa = rn->info) != NULL) |
| 4047 | { |
| 4048 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 4049 | vty_out (vty, "Link State ID: %s%s", |
| 4050 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 4051 | vty_out (vty, "Advertising Router: %s%s", |
| 4052 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 4053 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 4054 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4055 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4056 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4057 | } |
| 4058 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4059 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 4060 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4061 | |
| 4062 | #ifdef HAVE_OPAQUE_LSA |
| 4063 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 4064 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 4065 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 4066 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 4067 | #else /* HAVE_OPAQUE_LSA */ |
| 4068 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 4069 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 4070 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 4071 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 4072 | #endif /* HAVE_OPAQUE_LSA */ |
| 4073 | |
| 4074 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 4075 | "asbr-summary|external|network|router|summary" \ |
| 4076 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 4077 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 4078 | |
| 4079 | #define OSPF_LSA_TYPES_DESC \ |
| 4080 | "ASBR summary link states\n" \ |
| 4081 | "External link states\n" \ |
| 4082 | "Network link states\n" \ |
| 4083 | "Router link states\n" \ |
| 4084 | "Network summary link states\n" \ |
| 4085 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 4086 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 4087 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 4088 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 4089 | |
| 4090 | DEFUN (show_ip_ospf_database, |
| 4091 | show_ip_ospf_database_cmd, |
| 4092 | "show ip ospf database", |
| 4093 | SHOW_STR |
| 4094 | IP_STR |
| 4095 | "OSPF information\n" |
| 4096 | "Database summary\n") |
| 4097 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4098 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4099 | int type, ret; |
| 4100 | struct in_addr id, adv_router; |
| 4101 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4102 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4103 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4104 | { |
| 4105 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4106 | return CMD_SUCCESS; |
| 4107 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4108 | |
| 4109 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4110 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4111 | |
| 4112 | /* Show all LSA. */ |
| 4113 | if (argc == 0) |
| 4114 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4115 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4116 | return CMD_SUCCESS; |
| 4117 | } |
| 4118 | |
| 4119 | /* Set database type to show. */ |
| 4120 | if (strncmp (argv[0], "r", 1) == 0) |
| 4121 | type = OSPF_ROUTER_LSA; |
| 4122 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4123 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4124 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4125 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4126 | else if (strncmp (argv[0], "su", 2) == 0) |
| 4127 | type = OSPF_SUMMARY_LSA; |
| 4128 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4129 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4130 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4131 | type = OSPF_AS_EXTERNAL_LSA; |
| 4132 | else if (strncmp (argv[0], "se", 2) == 0) |
| 4133 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4134 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4135 | return CMD_SUCCESS; |
| 4136 | } |
| 4137 | else if (strncmp (argv[0], "m", 1) == 0) |
| 4138 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4139 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4140 | return CMD_SUCCESS; |
| 4141 | } |
| 4142 | #ifdef HAVE_OPAQUE_LSA |
| 4143 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4144 | type = OSPF_OPAQUE_LINK_LSA; |
| 4145 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4146 | type = OSPF_OPAQUE_AREA_LSA; |
| 4147 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4148 | type = OSPF_OPAQUE_AS_LSA; |
| 4149 | #endif /* HAVE_OPAQUE_LSA */ |
| 4150 | else |
| 4151 | return CMD_WARNING; |
| 4152 | |
| 4153 | /* `show ip ospf database LSA'. */ |
| 4154 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4155 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4156 | else if (argc >= 2) |
| 4157 | { |
| 4158 | ret = inet_aton (argv[1], &id); |
| 4159 | if (!ret) |
| 4160 | return CMD_WARNING; |
| 4161 | |
| 4162 | /* `show ip ospf database LSA ID'. */ |
| 4163 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4164 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4165 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4166 | else if (argc == 3) |
| 4167 | { |
| 4168 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4169 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4170 | else |
| 4171 | { |
| 4172 | ret = inet_aton (argv[2], &adv_router); |
| 4173 | if (!ret) |
| 4174 | return CMD_WARNING; |
| 4175 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4176 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4177 | } |
| 4178 | } |
| 4179 | |
| 4180 | return CMD_SUCCESS; |
| 4181 | } |
| 4182 | |
| 4183 | ALIAS (show_ip_ospf_database, |
| 4184 | show_ip_ospf_database_type_cmd, |
| 4185 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4186 | SHOW_STR |
| 4187 | IP_STR |
| 4188 | "OSPF information\n" |
| 4189 | "Database summary\n" |
| 4190 | OSPF_LSA_TYPES_DESC |
| 4191 | "LSAs in MaxAge list\n" |
| 4192 | "Self-originated link states\n") |
| 4193 | |
| 4194 | ALIAS (show_ip_ospf_database, |
| 4195 | show_ip_ospf_database_type_id_cmd, |
| 4196 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4197 | SHOW_STR |
| 4198 | IP_STR |
| 4199 | "OSPF information\n" |
| 4200 | "Database summary\n" |
| 4201 | OSPF_LSA_TYPES_DESC |
| 4202 | "Link State ID (as an IP address)\n") |
| 4203 | |
| 4204 | ALIAS (show_ip_ospf_database, |
| 4205 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4206 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4207 | SHOW_STR |
| 4208 | IP_STR |
| 4209 | "OSPF information\n" |
| 4210 | "Database summary\n" |
| 4211 | OSPF_LSA_TYPES_DESC |
| 4212 | "Link State ID (as an IP address)\n" |
| 4213 | "Advertising Router link states\n" |
| 4214 | "Advertising Router (as an IP address)\n") |
| 4215 | |
| 4216 | ALIAS (show_ip_ospf_database, |
| 4217 | show_ip_ospf_database_type_id_self_cmd, |
| 4218 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4219 | SHOW_STR |
| 4220 | IP_STR |
| 4221 | "OSPF information\n" |
| 4222 | "Database summary\n" |
| 4223 | OSPF_LSA_TYPES_DESC |
| 4224 | "Link State ID (as an IP address)\n" |
| 4225 | "Self-originated link states\n" |
| 4226 | "\n") |
| 4227 | |
| 4228 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4229 | show_ip_ospf_database_type_adv_router_cmd, |
| 4230 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4231 | SHOW_STR |
| 4232 | IP_STR |
| 4233 | "OSPF information\n" |
| 4234 | "Database summary\n" |
| 4235 | OSPF_LSA_TYPES_DESC |
| 4236 | "Advertising Router link states\n" |
| 4237 | "Advertising Router (as an IP address)\n") |
| 4238 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4239 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4240 | int type, ret; |
| 4241 | struct in_addr adv_router; |
| 4242 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4243 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4244 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4245 | { |
| 4246 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4247 | return CMD_SUCCESS; |
| 4248 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4249 | |
| 4250 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4251 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4252 | |
| 4253 | if (argc != 2) |
| 4254 | return CMD_WARNING; |
| 4255 | |
| 4256 | /* Set database type to show. */ |
| 4257 | if (strncmp (argv[0], "r", 1) == 0) |
| 4258 | type = OSPF_ROUTER_LSA; |
| 4259 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4260 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4261 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4262 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4263 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4264 | type = OSPF_SUMMARY_LSA; |
| 4265 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4266 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4267 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4268 | type = OSPF_AS_EXTERNAL_LSA; |
| 4269 | #ifdef HAVE_OPAQUE_LSA |
| 4270 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4271 | type = OSPF_OPAQUE_LINK_LSA; |
| 4272 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4273 | type = OSPF_OPAQUE_AREA_LSA; |
| 4274 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4275 | type = OSPF_OPAQUE_AS_LSA; |
| 4276 | #endif /* HAVE_OPAQUE_LSA */ |
| 4277 | else |
| 4278 | return CMD_WARNING; |
| 4279 | |
| 4280 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4281 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4282 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4283 | else |
| 4284 | { |
| 4285 | ret = inet_aton (argv[1], &adv_router); |
| 4286 | if (!ret) |
| 4287 | return CMD_WARNING; |
| 4288 | } |
| 4289 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4290 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4291 | |
| 4292 | return CMD_SUCCESS; |
| 4293 | } |
| 4294 | |
| 4295 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4296 | show_ip_ospf_database_type_self_cmd, |
| 4297 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4298 | SHOW_STR |
| 4299 | IP_STR |
| 4300 | "OSPF information\n" |
| 4301 | "Database summary\n" |
| 4302 | OSPF_LSA_TYPES_DESC |
| 4303 | "Self-originated link states\n") |
| 4304 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4305 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4306 | DEFUN (ip_ospf_authentication_args, |
| 4307 | ip_ospf_authentication_args_addr_cmd, |
| 4308 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4309 | "IP Information\n" |
| 4310 | "OSPF interface commands\n" |
| 4311 | "Enable authentication on this interface\n" |
| 4312 | "Use null authentication\n" |
| 4313 | "Use message-digest authentication\n" |
| 4314 | "Address of interface") |
| 4315 | { |
| 4316 | struct interface *ifp; |
| 4317 | struct in_addr addr; |
| 4318 | int ret; |
| 4319 | struct ospf_if_params *params; |
| 4320 | |
| 4321 | ifp = vty->index; |
| 4322 | params = IF_DEF_PARAMS (ifp); |
| 4323 | |
| 4324 | if (argc == 2) |
| 4325 | { |
| 4326 | ret = inet_aton(argv[1], &addr); |
| 4327 | if (!ret) |
| 4328 | { |
| 4329 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4330 | VTY_NEWLINE); |
| 4331 | return CMD_WARNING; |
| 4332 | } |
| 4333 | |
| 4334 | params = ospf_get_if_params (ifp, addr); |
| 4335 | ospf_if_update_params (ifp, addr); |
| 4336 | } |
| 4337 | |
| 4338 | /* Handle null authentication */ |
| 4339 | if ( argv[0][0] == 'n' ) |
| 4340 | { |
| 4341 | SET_IF_PARAM (params, auth_type); |
| 4342 | params->auth_type = OSPF_AUTH_NULL; |
| 4343 | return CMD_SUCCESS; |
| 4344 | } |
| 4345 | |
| 4346 | /* Handle message-digest authentication */ |
| 4347 | if ( argv[0][0] == 'm' ) |
| 4348 | { |
| 4349 | SET_IF_PARAM (params, auth_type); |
| 4350 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4351 | return CMD_SUCCESS; |
| 4352 | } |
| 4353 | |
| 4354 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4355 | return CMD_WARNING; |
| 4356 | } |
| 4357 | |
| 4358 | ALIAS (ip_ospf_authentication_args, |
| 4359 | ip_ospf_authentication_args_cmd, |
| 4360 | "ip ospf authentication (null|message-digest)", |
| 4361 | "IP Information\n" |
| 4362 | "OSPF interface commands\n" |
| 4363 | "Enable authentication on this interface\n" |
| 4364 | "Use null authentication\n" |
| 4365 | "Use message-digest authentication\n") |
| 4366 | |
| 4367 | DEFUN (ip_ospf_authentication, |
| 4368 | ip_ospf_authentication_addr_cmd, |
| 4369 | "ip ospf authentication A.B.C.D", |
| 4370 | "IP Information\n" |
| 4371 | "OSPF interface commands\n" |
| 4372 | "Enable authentication on this interface\n" |
| 4373 | "Address of interface") |
| 4374 | { |
| 4375 | struct interface *ifp; |
| 4376 | struct in_addr addr; |
| 4377 | int ret; |
| 4378 | struct ospf_if_params *params; |
| 4379 | |
| 4380 | ifp = vty->index; |
| 4381 | params = IF_DEF_PARAMS (ifp); |
| 4382 | |
| 4383 | if (argc == 1) |
| 4384 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4385 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4386 | if (!ret) |
| 4387 | { |
| 4388 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4389 | VTY_NEWLINE); |
| 4390 | return CMD_WARNING; |
| 4391 | } |
| 4392 | |
| 4393 | params = ospf_get_if_params (ifp, addr); |
| 4394 | ospf_if_update_params (ifp, addr); |
| 4395 | } |
| 4396 | |
| 4397 | SET_IF_PARAM (params, auth_type); |
| 4398 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4399 | |
| 4400 | return CMD_SUCCESS; |
| 4401 | } |
| 4402 | |
| 4403 | ALIAS (ip_ospf_authentication, |
| 4404 | ip_ospf_authentication_cmd, |
| 4405 | "ip ospf authentication", |
| 4406 | "IP Information\n" |
| 4407 | "OSPF interface commands\n" |
| 4408 | "Enable authentication on this interface\n") |
| 4409 | |
| 4410 | DEFUN (no_ip_ospf_authentication, |
| 4411 | no_ip_ospf_authentication_addr_cmd, |
| 4412 | "no ip ospf authentication A.B.C.D", |
| 4413 | NO_STR |
| 4414 | "IP Information\n" |
| 4415 | "OSPF interface commands\n" |
| 4416 | "Enable authentication on this interface\n" |
| 4417 | "Address of interface") |
| 4418 | { |
| 4419 | struct interface *ifp; |
| 4420 | struct in_addr addr; |
| 4421 | int ret; |
| 4422 | struct ospf_if_params *params; |
| 4423 | |
| 4424 | ifp = vty->index; |
| 4425 | params = IF_DEF_PARAMS (ifp); |
| 4426 | |
| 4427 | if (argc == 1) |
| 4428 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4429 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4430 | if (!ret) |
| 4431 | { |
| 4432 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4433 | VTY_NEWLINE); |
| 4434 | return CMD_WARNING; |
| 4435 | } |
| 4436 | |
| 4437 | params = ospf_lookup_if_params (ifp, addr); |
| 4438 | if (params == NULL) |
| 4439 | return CMD_SUCCESS; |
| 4440 | } |
| 4441 | |
| 4442 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4443 | UNSET_IF_PARAM (params, auth_type); |
| 4444 | |
| 4445 | if (params != IF_DEF_PARAMS (ifp)) |
| 4446 | { |
| 4447 | ospf_free_if_params (ifp, addr); |
| 4448 | ospf_if_update_params (ifp, addr); |
| 4449 | } |
| 4450 | |
| 4451 | return CMD_SUCCESS; |
| 4452 | } |
| 4453 | |
| 4454 | ALIAS (no_ip_ospf_authentication, |
| 4455 | no_ip_ospf_authentication_cmd, |
| 4456 | "no ip ospf authentication", |
| 4457 | NO_STR |
| 4458 | "IP Information\n" |
| 4459 | "OSPF interface commands\n" |
| 4460 | "Enable authentication on this interface\n") |
| 4461 | |
| 4462 | DEFUN (ip_ospf_authentication_key, |
| 4463 | ip_ospf_authentication_key_addr_cmd, |
| 4464 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4465 | "IP Information\n" |
| 4466 | "OSPF interface commands\n" |
| 4467 | "Authentication password (key)\n" |
| 4468 | "The OSPF password (key)\n" |
| 4469 | "Address of interface") |
| 4470 | { |
| 4471 | struct interface *ifp; |
| 4472 | struct in_addr addr; |
| 4473 | int ret; |
| 4474 | struct ospf_if_params *params; |
| 4475 | |
| 4476 | ifp = vty->index; |
| 4477 | params = IF_DEF_PARAMS (ifp); |
| 4478 | |
| 4479 | if (argc == 2) |
| 4480 | { |
| 4481 | ret = inet_aton(argv[1], &addr); |
| 4482 | if (!ret) |
| 4483 | { |
| 4484 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4485 | VTY_NEWLINE); |
| 4486 | return CMD_WARNING; |
| 4487 | } |
| 4488 | |
| 4489 | params = ospf_get_if_params (ifp, addr); |
| 4490 | ospf_if_update_params (ifp, addr); |
| 4491 | } |
| 4492 | |
| 4493 | |
| 4494 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4495 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4496 | SET_IF_PARAM (params, auth_simple); |
| 4497 | |
| 4498 | return CMD_SUCCESS; |
| 4499 | } |
| 4500 | |
| 4501 | ALIAS (ip_ospf_authentication_key, |
| 4502 | ip_ospf_authentication_key_cmd, |
| 4503 | "ip ospf authentication-key AUTH_KEY", |
| 4504 | "IP Information\n" |
| 4505 | "OSPF interface commands\n" |
| 4506 | "Authentication password (key)\n" |
| 4507 | "The OSPF password (key)") |
| 4508 | |
| 4509 | ALIAS (ip_ospf_authentication_key, |
| 4510 | ospf_authentication_key_cmd, |
| 4511 | "ospf authentication-key AUTH_KEY", |
| 4512 | "OSPF interface commands\n" |
| 4513 | "Authentication password (key)\n" |
| 4514 | "The OSPF password (key)") |
| 4515 | |
| 4516 | DEFUN (no_ip_ospf_authentication_key, |
| 4517 | no_ip_ospf_authentication_key_addr_cmd, |
| 4518 | "no ip ospf authentication-key A.B.C.D", |
| 4519 | NO_STR |
| 4520 | "IP Information\n" |
| 4521 | "OSPF interface commands\n" |
| 4522 | "Authentication password (key)\n" |
| 4523 | "Address of interface") |
| 4524 | { |
| 4525 | struct interface *ifp; |
| 4526 | struct in_addr addr; |
| 4527 | int ret; |
| 4528 | struct ospf_if_params *params; |
| 4529 | |
| 4530 | ifp = vty->index; |
| 4531 | params = IF_DEF_PARAMS (ifp); |
| 4532 | |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4533 | if (argc == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4534 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4535 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4536 | if (!ret) |
| 4537 | { |
| 4538 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4539 | VTY_NEWLINE); |
| 4540 | return CMD_WARNING; |
| 4541 | } |
| 4542 | |
| 4543 | params = ospf_lookup_if_params (ifp, addr); |
| 4544 | if (params == NULL) |
| 4545 | return CMD_SUCCESS; |
| 4546 | } |
| 4547 | |
| 4548 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4549 | UNSET_IF_PARAM (params, auth_simple); |
| 4550 | |
| 4551 | if (params != IF_DEF_PARAMS (ifp)) |
| 4552 | { |
| 4553 | ospf_free_if_params (ifp, addr); |
| 4554 | ospf_if_update_params (ifp, addr); |
| 4555 | } |
| 4556 | |
| 4557 | return CMD_SUCCESS; |
| 4558 | } |
| 4559 | |
| 4560 | ALIAS (no_ip_ospf_authentication_key, |
| 4561 | no_ip_ospf_authentication_key_cmd, |
| 4562 | "no ip ospf authentication-key", |
| 4563 | NO_STR |
| 4564 | "IP Information\n" |
| 4565 | "OSPF interface commands\n" |
| 4566 | "Authentication password (key)\n") |
| 4567 | |
| 4568 | ALIAS (no_ip_ospf_authentication_key, |
| 4569 | no_ospf_authentication_key_cmd, |
| 4570 | "no ospf authentication-key", |
| 4571 | NO_STR |
| 4572 | "OSPF interface commands\n" |
| 4573 | "Authentication password (key)\n") |
| 4574 | |
| 4575 | DEFUN (ip_ospf_message_digest_key, |
| 4576 | ip_ospf_message_digest_key_addr_cmd, |
| 4577 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4578 | "IP Information\n" |
| 4579 | "OSPF interface commands\n" |
| 4580 | "Message digest authentication password (key)\n" |
| 4581 | "Key ID\n" |
| 4582 | "Use MD5 algorithm\n" |
| 4583 | "The OSPF password (key)" |
| 4584 | "Address of interface") |
| 4585 | { |
| 4586 | struct interface *ifp; |
| 4587 | struct crypt_key *ck; |
| 4588 | u_char key_id; |
| 4589 | struct in_addr addr; |
| 4590 | int ret; |
| 4591 | struct ospf_if_params *params; |
| 4592 | |
| 4593 | ifp = vty->index; |
| 4594 | params = IF_DEF_PARAMS (ifp); |
| 4595 | |
| 4596 | if (argc == 3) |
| 4597 | { |
| 4598 | ret = inet_aton(argv[2], &addr); |
| 4599 | if (!ret) |
| 4600 | { |
| 4601 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4602 | VTY_NEWLINE); |
| 4603 | return CMD_WARNING; |
| 4604 | } |
| 4605 | |
| 4606 | params = ospf_get_if_params (ifp, addr); |
| 4607 | ospf_if_update_params (ifp, addr); |
| 4608 | } |
| 4609 | |
| 4610 | key_id = strtol (argv[0], NULL, 10); |
| 4611 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4612 | { |
| 4613 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4614 | return CMD_WARNING; |
| 4615 | } |
| 4616 | |
| 4617 | ck = ospf_crypt_key_new (); |
| 4618 | ck->key_id = (u_char) key_id; |
| 4619 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4620 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4621 | |
| 4622 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4623 | SET_IF_PARAM (params, auth_crypt); |
| 4624 | |
| 4625 | return CMD_SUCCESS; |
| 4626 | } |
| 4627 | |
| 4628 | ALIAS (ip_ospf_message_digest_key, |
| 4629 | ip_ospf_message_digest_key_cmd, |
| 4630 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4631 | "IP Information\n" |
| 4632 | "OSPF interface commands\n" |
| 4633 | "Message digest authentication password (key)\n" |
| 4634 | "Key ID\n" |
| 4635 | "Use MD5 algorithm\n" |
| 4636 | "The OSPF password (key)") |
| 4637 | |
| 4638 | ALIAS (ip_ospf_message_digest_key, |
| 4639 | ospf_message_digest_key_cmd, |
| 4640 | "ospf message-digest-key <1-255> md5 KEY", |
| 4641 | "OSPF interface commands\n" |
| 4642 | "Message digest authentication password (key)\n" |
| 4643 | "Key ID\n" |
| 4644 | "Use MD5 algorithm\n" |
| 4645 | "The OSPF password (key)") |
| 4646 | |
| 4647 | DEFUN (no_ip_ospf_message_digest_key, |
| 4648 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4649 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4650 | NO_STR |
| 4651 | "IP Information\n" |
| 4652 | "OSPF interface commands\n" |
| 4653 | "Message digest authentication password (key)\n" |
| 4654 | "Key ID\n" |
| 4655 | "Address of interface") |
| 4656 | { |
| 4657 | struct interface *ifp; |
| 4658 | struct crypt_key *ck; |
| 4659 | int key_id; |
| 4660 | struct in_addr addr; |
| 4661 | int ret; |
| 4662 | struct ospf_if_params *params; |
| 4663 | |
| 4664 | ifp = vty->index; |
| 4665 | params = IF_DEF_PARAMS (ifp); |
| 4666 | |
| 4667 | if (argc == 2) |
| 4668 | { |
| 4669 | ret = inet_aton(argv[1], &addr); |
| 4670 | if (!ret) |
| 4671 | { |
| 4672 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4673 | VTY_NEWLINE); |
| 4674 | return CMD_WARNING; |
| 4675 | } |
| 4676 | |
| 4677 | params = ospf_lookup_if_params (ifp, addr); |
| 4678 | if (params == NULL) |
| 4679 | return CMD_SUCCESS; |
| 4680 | } |
| 4681 | |
| 4682 | key_id = strtol (argv[0], NULL, 10); |
| 4683 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4684 | if (ck == NULL) |
| 4685 | { |
| 4686 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4687 | return CMD_WARNING; |
| 4688 | } |
| 4689 | |
| 4690 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4691 | |
| 4692 | if (params != IF_DEF_PARAMS (ifp)) |
| 4693 | { |
| 4694 | ospf_free_if_params (ifp, addr); |
| 4695 | ospf_if_update_params (ifp, addr); |
| 4696 | } |
| 4697 | |
| 4698 | return CMD_SUCCESS; |
| 4699 | } |
| 4700 | |
| 4701 | ALIAS (no_ip_ospf_message_digest_key, |
| 4702 | no_ip_ospf_message_digest_key_cmd, |
| 4703 | "no ip ospf message-digest-key <1-255>", |
| 4704 | NO_STR |
| 4705 | "IP Information\n" |
| 4706 | "OSPF interface commands\n" |
| 4707 | "Message digest authentication password (key)\n" |
| 4708 | "Key ID\n") |
| 4709 | |
| 4710 | ALIAS (no_ip_ospf_message_digest_key, |
| 4711 | no_ospf_message_digest_key_cmd, |
| 4712 | "no ospf message-digest-key <1-255>", |
| 4713 | NO_STR |
| 4714 | "OSPF interface commands\n" |
| 4715 | "Message digest authentication password (key)\n" |
| 4716 | "Key ID\n") |
| 4717 | |
| 4718 | DEFUN (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4719 | ip_ospf_cost_u32_inet4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4720 | "ip ospf cost <1-65535> A.B.C.D", |
| 4721 | "IP Information\n" |
| 4722 | "OSPF interface commands\n" |
| 4723 | "Interface cost\n" |
| 4724 | "Cost\n" |
| 4725 | "Address of interface") |
| 4726 | { |
| 4727 | struct interface *ifp = vty->index; |
| 4728 | u_int32_t cost; |
| 4729 | struct in_addr addr; |
| 4730 | int ret; |
| 4731 | struct ospf_if_params *params; |
| 4732 | |
| 4733 | params = IF_DEF_PARAMS (ifp); |
| 4734 | |
| 4735 | cost = strtol (argv[0], NULL, 10); |
| 4736 | |
| 4737 | /* cost range is <1-65535>. */ |
| 4738 | if (cost < 1 || cost > 65535) |
| 4739 | { |
| 4740 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4741 | return CMD_WARNING; |
| 4742 | } |
| 4743 | |
| 4744 | if (argc == 2) |
| 4745 | { |
| 4746 | ret = inet_aton(argv[1], &addr); |
| 4747 | if (!ret) |
| 4748 | { |
| 4749 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4750 | VTY_NEWLINE); |
| 4751 | return CMD_WARNING; |
| 4752 | } |
| 4753 | |
| 4754 | params = ospf_get_if_params (ifp, addr); |
| 4755 | ospf_if_update_params (ifp, addr); |
| 4756 | } |
| 4757 | |
| 4758 | SET_IF_PARAM (params, output_cost_cmd); |
| 4759 | params->output_cost_cmd = cost; |
| 4760 | |
| 4761 | ospf_if_recalculate_output_cost (ifp); |
| 4762 | |
| 4763 | return CMD_SUCCESS; |
| 4764 | } |
| 4765 | |
| 4766 | ALIAS (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4767 | ip_ospf_cost_u32_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4768 | "ip ospf cost <1-65535>", |
| 4769 | "IP Information\n" |
| 4770 | "OSPF interface commands\n" |
| 4771 | "Interface cost\n" |
| 4772 | "Cost") |
| 4773 | |
| 4774 | ALIAS (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4775 | ospf_cost_u32_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4776 | "ospf cost <1-65535>", |
| 4777 | "OSPF interface commands\n" |
| 4778 | "Interface cost\n" |
| 4779 | "Cost") |
| 4780 | |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4781 | ALIAS (ip_ospf_cost, |
| 4782 | ospf_cost_u32_inet4_cmd, |
| 4783 | "ospf cost <1-65535> A.B.C.D", |
| 4784 | "OSPF interface commands\n" |
| 4785 | "Interface cost\n" |
| 4786 | "Cost\n" |
| 4787 | "Address of interface") |
| 4788 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4789 | DEFUN (no_ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4790 | no_ip_ospf_cost_inet4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4791 | "no ip ospf cost A.B.C.D", |
| 4792 | NO_STR |
| 4793 | "IP Information\n" |
| 4794 | "OSPF interface commands\n" |
| 4795 | "Interface cost\n" |
| 4796 | "Address of interface") |
| 4797 | { |
| 4798 | struct interface *ifp = vty->index; |
| 4799 | struct in_addr addr; |
| 4800 | int ret; |
| 4801 | struct ospf_if_params *params; |
| 4802 | |
| 4803 | ifp = vty->index; |
| 4804 | params = IF_DEF_PARAMS (ifp); |
| 4805 | |
| 4806 | if (argc == 1) |
| 4807 | { |
| 4808 | ret = inet_aton(argv[0], &addr); |
| 4809 | if (!ret) |
| 4810 | { |
| 4811 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4812 | VTY_NEWLINE); |
| 4813 | return CMD_WARNING; |
| 4814 | } |
| 4815 | |
| 4816 | params = ospf_lookup_if_params (ifp, addr); |
| 4817 | if (params == NULL) |
| 4818 | return CMD_SUCCESS; |
| 4819 | } |
| 4820 | |
| 4821 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4822 | |
| 4823 | if (params != IF_DEF_PARAMS (ifp)) |
| 4824 | { |
| 4825 | ospf_free_if_params (ifp, addr); |
| 4826 | ospf_if_update_params (ifp, addr); |
| 4827 | } |
| 4828 | |
| 4829 | ospf_if_recalculate_output_cost (ifp); |
| 4830 | |
| 4831 | return CMD_SUCCESS; |
| 4832 | } |
| 4833 | |
| 4834 | ALIAS (no_ip_ospf_cost, |
| 4835 | no_ip_ospf_cost_cmd, |
| 4836 | "no ip ospf cost", |
| 4837 | NO_STR |
| 4838 | "IP Information\n" |
| 4839 | "OSPF interface commands\n" |
| 4840 | "Interface cost\n") |
| 4841 | |
| 4842 | ALIAS (no_ip_ospf_cost, |
| 4843 | no_ospf_cost_cmd, |
| 4844 | "no ospf cost", |
| 4845 | NO_STR |
| 4846 | "OSPF interface commands\n" |
| 4847 | "Interface cost\n") |
| 4848 | |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4849 | ALIAS (no_ip_ospf_cost, |
| 4850 | no_ospf_cost_inet4_cmd, |
| 4851 | "no ospf cost A.B.C.D", |
| 4852 | NO_STR |
| 4853 | "OSPF interface commands\n" |
| 4854 | "Interface cost\n" |
| 4855 | "Address of interface") |
| 4856 | |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 4857 | DEFUN (no_ip_ospf_cost2, |
| 4858 | no_ip_ospf_cost_u32_cmd, |
| 4859 | "no ip ospf cost <1-65535>", |
| 4860 | NO_STR |
| 4861 | "IP Information\n" |
| 4862 | "OSPF interface commands\n" |
| 4863 | "Interface cost\n" |
| 4864 | "Cost") |
| 4865 | { |
| 4866 | struct interface *ifp = vty->index; |
| 4867 | struct in_addr addr; |
| 4868 | u_int32_t cost; |
| 4869 | int ret; |
| 4870 | struct ospf_if_params *params; |
| 4871 | |
| 4872 | ifp = vty->index; |
| 4873 | params = IF_DEF_PARAMS (ifp); |
| 4874 | |
| 4875 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
| 4876 | * always treated as "no ip ospf cost" regardless of the actual value |
| 4877 | * of N already configured for the interface. Thus the first argument |
| 4878 | * is always checked to be a number, but is ignored after that. |
| 4879 | */ |
| 4880 | cost = strtol (argv[0], NULL, 10); |
| 4881 | if (cost < 1 || cost > 65535) |
| 4882 | { |
| 4883 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4884 | return CMD_WARNING; |
| 4885 | } |
| 4886 | |
| 4887 | if (argc == 2) |
| 4888 | { |
| 4889 | ret = inet_aton(argv[1], &addr); |
| 4890 | if (!ret) |
| 4891 | { |
| 4892 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4893 | VTY_NEWLINE); |
| 4894 | return CMD_WARNING; |
| 4895 | } |
| 4896 | |
| 4897 | params = ospf_lookup_if_params (ifp, addr); |
| 4898 | if (params == NULL) |
| 4899 | return CMD_SUCCESS; |
| 4900 | } |
| 4901 | |
| 4902 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4903 | |
| 4904 | if (params != IF_DEF_PARAMS (ifp)) |
| 4905 | { |
| 4906 | ospf_free_if_params (ifp, addr); |
| 4907 | ospf_if_update_params (ifp, addr); |
| 4908 | } |
| 4909 | |
| 4910 | ospf_if_recalculate_output_cost (ifp); |
| 4911 | |
| 4912 | return CMD_SUCCESS; |
| 4913 | } |
| 4914 | |
| 4915 | ALIAS (no_ip_ospf_cost2, |
| 4916 | no_ospf_cost_u32_cmd, |
| 4917 | "no ospf cost <1-65535>", |
| 4918 | NO_STR |
| 4919 | "OSPF interface commands\n" |
| 4920 | "Interface cost\n" |
| 4921 | "Cost") |
| 4922 | |
| 4923 | ALIAS (no_ip_ospf_cost2, |
| 4924 | no_ip_ospf_cost_u32_inet4_cmd, |
| 4925 | "no ip ospf cost <1-65535> A.B.C.D", |
| 4926 | NO_STR |
| 4927 | "IP Information\n" |
| 4928 | "OSPF interface commands\n" |
| 4929 | "Interface cost\n" |
| 4930 | "Cost\n" |
| 4931 | "Address of interface") |
| 4932 | |
| 4933 | ALIAS (no_ip_ospf_cost2, |
| 4934 | no_ospf_cost_u32_inet4_cmd, |
| 4935 | "no ospf cost <1-65535> A.B.C.D", |
| 4936 | NO_STR |
| 4937 | "OSPF interface commands\n" |
| 4938 | "Interface cost\n" |
| 4939 | "Cost\n" |
| 4940 | "Address of interface") |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4941 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4942 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4943 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 4944 | { |
| 4945 | struct route_node *rn; |
| 4946 | struct ospf_neighbor *nbr; |
| 4947 | |
| 4948 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 4949 | if ((nbr = rn->info)) |
| 4950 | { |
| 4951 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 4952 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4953 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4954 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 4955 | } |
| 4956 | } |
| 4957 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4958 | static int |
| 4959 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 4960 | const char *nbr_str, |
| 4961 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4962 | { |
| 4963 | struct interface *ifp = vty->index; |
| 4964 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4965 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4966 | struct in_addr addr; |
| 4967 | int ret; |
| 4968 | struct ospf_if_params *params; |
| 4969 | struct ospf_interface *oi; |
| 4970 | struct route_node *rn; |
| 4971 | |
| 4972 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4973 | |
| 4974 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4975 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4976 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4977 | if (!ret) |
| 4978 | { |
| 4979 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4980 | VTY_NEWLINE); |
| 4981 | return CMD_WARNING; |
| 4982 | } |
| 4983 | |
| 4984 | params = ospf_get_if_params (ifp, addr); |
| 4985 | ospf_if_update_params (ifp, addr); |
| 4986 | } |
| 4987 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 4988 | if (interval_str) |
| 4989 | { |
| 4990 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 4991 | 1, 65535); |
| 4992 | |
| 4993 | /* reset fast_hello too, just to be sure */ |
| 4994 | UNSET_IF_PARAM (params, fast_hello); |
| 4995 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 4996 | } |
| 4997 | else if (fast_hello_str) |
| 4998 | { |
| 4999 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 5000 | 1, 10); |
| 5001 | /* 1s dead-interval with sub-second hellos desired */ |
| 5002 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 5003 | SET_IF_PARAM (params, fast_hello); |
| 5004 | params->fast_hello = hellomult; |
| 5005 | } |
| 5006 | else |
| 5007 | { |
| 5008 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 5009 | VTY_NEWLINE); |
| 5010 | return CMD_WARNING; |
| 5011 | } |
| 5012 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5013 | SET_IF_PARAM (params, v_wait); |
| 5014 | params->v_wait = seconds; |
| 5015 | |
| 5016 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5017 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5018 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5019 | struct ospf *ospf; |
| 5020 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5021 | { |
| 5022 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5023 | if (oi) |
| 5024 | ospf_nbr_timer_update (oi); |
| 5025 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5026 | } |
| 5027 | else |
| 5028 | { |
| 5029 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5030 | if ((oi = rn->info)) |
| 5031 | ospf_nbr_timer_update (oi); |
| 5032 | } |
| 5033 | |
| 5034 | return CMD_SUCCESS; |
| 5035 | } |
| 5036 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5037 | |
| 5038 | DEFUN (ip_ospf_dead_interval, |
| 5039 | ip_ospf_dead_interval_addr_cmd, |
| 5040 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 5041 | "IP Information\n" |
| 5042 | "OSPF interface commands\n" |
| 5043 | "Interval after which a neighbor is declared dead\n" |
| 5044 | "Seconds\n" |
| 5045 | "Address of interface\n") |
| 5046 | { |
| 5047 | if (argc == 2) |
| 5048 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 5049 | else |
| 5050 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 5051 | } |
| 5052 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5053 | ALIAS (ip_ospf_dead_interval, |
| 5054 | ip_ospf_dead_interval_cmd, |
| 5055 | "ip ospf dead-interval <1-65535>", |
| 5056 | "IP Information\n" |
| 5057 | "OSPF interface commands\n" |
| 5058 | "Interval after which a neighbor is declared dead\n" |
| 5059 | "Seconds\n") |
| 5060 | |
| 5061 | ALIAS (ip_ospf_dead_interval, |
| 5062 | ospf_dead_interval_cmd, |
| 5063 | "ospf dead-interval <1-65535>", |
| 5064 | "OSPF interface commands\n" |
| 5065 | "Interval after which a neighbor is declared dead\n" |
| 5066 | "Seconds\n") |
| 5067 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5068 | DEFUN (ip_ospf_dead_interval_minimal, |
| 5069 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 5070 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 5071 | "IP Information\n" |
| 5072 | "OSPF interface commands\n" |
| 5073 | "Interval after which a neighbor is declared dead\n" |
| 5074 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5075 | "Hello multiplier factor\n" |
| 5076 | "Number of Hellos to send each second\n" |
| 5077 | "Address of interface\n") |
| 5078 | { |
| 5079 | if (argc == 2) |
| 5080 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 5081 | else |
| 5082 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 5083 | } |
| 5084 | |
| 5085 | ALIAS (ip_ospf_dead_interval_minimal, |
| 5086 | ip_ospf_dead_interval_minimal_cmd, |
| 5087 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 5088 | "IP Information\n" |
| 5089 | "OSPF interface commands\n" |
| 5090 | "Interval after which a neighbor is declared dead\n" |
| 5091 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5092 | "Hello multiplier factor\n" |
| 5093 | "Number of Hellos to send each second\n") |
| 5094 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5095 | DEFUN (no_ip_ospf_dead_interval, |
| 5096 | no_ip_ospf_dead_interval_addr_cmd, |
| 5097 | "no ip ospf dead-interval A.B.C.D", |
| 5098 | NO_STR |
| 5099 | "IP Information\n" |
| 5100 | "OSPF interface commands\n" |
| 5101 | "Interval after which a neighbor is declared dead\n" |
| 5102 | "Address of interface") |
| 5103 | { |
| 5104 | struct interface *ifp = vty->index; |
| 5105 | struct in_addr addr; |
| 5106 | int ret; |
| 5107 | struct ospf_if_params *params; |
| 5108 | struct ospf_interface *oi; |
| 5109 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5110 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5111 | ifp = vty->index; |
| 5112 | params = IF_DEF_PARAMS (ifp); |
| 5113 | |
| 5114 | if (argc == 1) |
| 5115 | { |
| 5116 | ret = inet_aton(argv[0], &addr); |
| 5117 | if (!ret) |
| 5118 | { |
| 5119 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5120 | VTY_NEWLINE); |
| 5121 | return CMD_WARNING; |
| 5122 | } |
| 5123 | |
| 5124 | params = ospf_lookup_if_params (ifp, addr); |
| 5125 | if (params == NULL) |
| 5126 | return CMD_SUCCESS; |
| 5127 | } |
| 5128 | |
| 5129 | UNSET_IF_PARAM (params, v_wait); |
| 5130 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5131 | |
| 5132 | UNSET_IF_PARAM (params, fast_hello); |
| 5133 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 5134 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5135 | if (params != IF_DEF_PARAMS (ifp)) |
| 5136 | { |
| 5137 | ospf_free_if_params (ifp, addr); |
| 5138 | ospf_if_update_params (ifp, addr); |
| 5139 | } |
| 5140 | |
| 5141 | /* Update timer values in neighbor structure. */ |
| 5142 | if (argc == 1) |
| 5143 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5144 | struct ospf *ospf; |
| 5145 | |
| 5146 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5147 | { |
| 5148 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5149 | if (oi) |
| 5150 | ospf_nbr_timer_update (oi); |
| 5151 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5152 | } |
| 5153 | else |
| 5154 | { |
| 5155 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5156 | if ((oi = rn->info)) |
| 5157 | ospf_nbr_timer_update (oi); |
| 5158 | } |
| 5159 | |
| 5160 | return CMD_SUCCESS; |
| 5161 | } |
| 5162 | |
| 5163 | ALIAS (no_ip_ospf_dead_interval, |
| 5164 | no_ip_ospf_dead_interval_cmd, |
| 5165 | "no ip ospf dead-interval", |
| 5166 | NO_STR |
| 5167 | "IP Information\n" |
| 5168 | "OSPF interface commands\n" |
| 5169 | "Interval after which a neighbor is declared dead\n") |
| 5170 | |
| 5171 | ALIAS (no_ip_ospf_dead_interval, |
| 5172 | no_ospf_dead_interval_cmd, |
| 5173 | "no ospf dead-interval", |
| 5174 | NO_STR |
| 5175 | "OSPF interface commands\n" |
| 5176 | "Interval after which a neighbor is declared dead\n") |
| 5177 | |
| 5178 | DEFUN (ip_ospf_hello_interval, |
| 5179 | ip_ospf_hello_interval_addr_cmd, |
| 5180 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 5181 | "IP Information\n" |
| 5182 | "OSPF interface commands\n" |
| 5183 | "Time between HELLO packets\n" |
| 5184 | "Seconds\n" |
| 5185 | "Address of interface") |
| 5186 | { |
| 5187 | struct interface *ifp = vty->index; |
| 5188 | u_int32_t seconds; |
| 5189 | struct in_addr addr; |
| 5190 | int ret; |
| 5191 | struct ospf_if_params *params; |
| 5192 | |
| 5193 | params = IF_DEF_PARAMS (ifp); |
| 5194 | |
| 5195 | seconds = strtol (argv[0], NULL, 10); |
| 5196 | |
| 5197 | /* HelloInterval range is <1-65535>. */ |
| 5198 | if (seconds < 1 || seconds > 65535) |
| 5199 | { |
| 5200 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 5201 | return CMD_WARNING; |
| 5202 | } |
| 5203 | |
| 5204 | if (argc == 2) |
| 5205 | { |
| 5206 | ret = inet_aton(argv[1], &addr); |
| 5207 | if (!ret) |
| 5208 | { |
| 5209 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5210 | VTY_NEWLINE); |
| 5211 | return CMD_WARNING; |
| 5212 | } |
| 5213 | |
| 5214 | params = ospf_get_if_params (ifp, addr); |
| 5215 | ospf_if_update_params (ifp, addr); |
| 5216 | } |
| 5217 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5218 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5219 | params->v_hello = seconds; |
| 5220 | |
| 5221 | return CMD_SUCCESS; |
| 5222 | } |
| 5223 | |
| 5224 | ALIAS (ip_ospf_hello_interval, |
| 5225 | ip_ospf_hello_interval_cmd, |
| 5226 | "ip ospf hello-interval <1-65535>", |
| 5227 | "IP Information\n" |
| 5228 | "OSPF interface commands\n" |
| 5229 | "Time between HELLO packets\n" |
| 5230 | "Seconds\n") |
| 5231 | |
| 5232 | ALIAS (ip_ospf_hello_interval, |
| 5233 | ospf_hello_interval_cmd, |
| 5234 | "ospf hello-interval <1-65535>", |
| 5235 | "OSPF interface commands\n" |
| 5236 | "Time between HELLO packets\n" |
| 5237 | "Seconds\n") |
| 5238 | |
| 5239 | DEFUN (no_ip_ospf_hello_interval, |
| 5240 | no_ip_ospf_hello_interval_addr_cmd, |
| 5241 | "no ip ospf hello-interval A.B.C.D", |
| 5242 | NO_STR |
| 5243 | "IP Information\n" |
| 5244 | "OSPF interface commands\n" |
| 5245 | "Time between HELLO packets\n" |
| 5246 | "Address of interface") |
| 5247 | { |
| 5248 | struct interface *ifp = vty->index; |
| 5249 | struct in_addr addr; |
| 5250 | int ret; |
| 5251 | struct ospf_if_params *params; |
| 5252 | |
| 5253 | ifp = vty->index; |
| 5254 | params = IF_DEF_PARAMS (ifp); |
| 5255 | |
| 5256 | if (argc == 1) |
| 5257 | { |
| 5258 | ret = inet_aton(argv[0], &addr); |
| 5259 | if (!ret) |
| 5260 | { |
| 5261 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5262 | VTY_NEWLINE); |
| 5263 | return CMD_WARNING; |
| 5264 | } |
| 5265 | |
| 5266 | params = ospf_lookup_if_params (ifp, addr); |
| 5267 | if (params == NULL) |
| 5268 | return CMD_SUCCESS; |
| 5269 | } |
| 5270 | |
| 5271 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5272 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5273 | |
| 5274 | if (params != IF_DEF_PARAMS (ifp)) |
| 5275 | { |
| 5276 | ospf_free_if_params (ifp, addr); |
| 5277 | ospf_if_update_params (ifp, addr); |
| 5278 | } |
| 5279 | |
| 5280 | return CMD_SUCCESS; |
| 5281 | } |
| 5282 | |
| 5283 | ALIAS (no_ip_ospf_hello_interval, |
| 5284 | no_ip_ospf_hello_interval_cmd, |
| 5285 | "no ip ospf hello-interval", |
| 5286 | NO_STR |
| 5287 | "IP Information\n" |
| 5288 | "OSPF interface commands\n" |
| 5289 | "Time between HELLO packets\n") |
| 5290 | |
| 5291 | ALIAS (no_ip_ospf_hello_interval, |
| 5292 | no_ospf_hello_interval_cmd, |
| 5293 | "no ospf hello-interval", |
| 5294 | NO_STR |
| 5295 | "OSPF interface commands\n" |
| 5296 | "Time between HELLO packets\n") |
| 5297 | |
| 5298 | DEFUN (ip_ospf_network, |
| 5299 | ip_ospf_network_cmd, |
| 5300 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5301 | "IP Information\n" |
| 5302 | "OSPF interface commands\n" |
| 5303 | "Network type\n" |
| 5304 | "Specify OSPF broadcast multi-access network\n" |
| 5305 | "Specify OSPF NBMA network\n" |
| 5306 | "Specify OSPF point-to-multipoint network\n" |
| 5307 | "Specify OSPF point-to-point network\n") |
| 5308 | { |
| 5309 | struct interface *ifp = vty->index; |
| 5310 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5311 | struct route_node *rn; |
Christian Franke | 4b4bda9 | 2013-07-11 07:56:29 +0000 | [diff] [blame] | 5312 | |
| 5313 | if (old_type == OSPF_IFTYPE_LOOPBACK) |
| 5314 | { |
| 5315 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); |
| 5316 | return CMD_WARNING; |
| 5317 | } |
| 5318 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5319 | if (strncmp (argv[0], "b", 1) == 0) |
| 5320 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5321 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5322 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5323 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5324 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5325 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5326 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5327 | |
| 5328 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5329 | return CMD_SUCCESS; |
| 5330 | |
| 5331 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5332 | |
| 5333 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5334 | { |
| 5335 | struct ospf_interface *oi = rn->info; |
| 5336 | |
| 5337 | if (!oi) |
| 5338 | continue; |
| 5339 | |
| 5340 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5341 | |
| 5342 | if (oi->state > ISM_Down) |
| 5343 | { |
| 5344 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5345 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5346 | } |
| 5347 | } |
| 5348 | |
| 5349 | return CMD_SUCCESS; |
| 5350 | } |
| 5351 | |
| 5352 | ALIAS (ip_ospf_network, |
| 5353 | ospf_network_cmd, |
| 5354 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5355 | "OSPF interface commands\n" |
| 5356 | "Network type\n" |
| 5357 | "Specify OSPF broadcast multi-access network\n" |
| 5358 | "Specify OSPF NBMA network\n" |
| 5359 | "Specify OSPF point-to-multipoint network\n" |
| 5360 | "Specify OSPF point-to-point network\n") |
| 5361 | |
| 5362 | DEFUN (no_ip_ospf_network, |
| 5363 | no_ip_ospf_network_cmd, |
| 5364 | "no ip ospf network", |
| 5365 | NO_STR |
| 5366 | "IP Information\n" |
| 5367 | "OSPF interface commands\n" |
| 5368 | "Network type\n") |
| 5369 | { |
| 5370 | struct interface *ifp = vty->index; |
| 5371 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5372 | struct route_node *rn; |
| 5373 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5374 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5375 | |
| 5376 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5377 | return CMD_SUCCESS; |
| 5378 | |
| 5379 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5380 | { |
| 5381 | struct ospf_interface *oi = rn->info; |
| 5382 | |
| 5383 | if (!oi) |
| 5384 | continue; |
| 5385 | |
| 5386 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5387 | |
| 5388 | if (oi->state > ISM_Down) |
| 5389 | { |
| 5390 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5391 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5392 | } |
| 5393 | } |
| 5394 | |
| 5395 | return CMD_SUCCESS; |
| 5396 | } |
| 5397 | |
| 5398 | ALIAS (no_ip_ospf_network, |
| 5399 | no_ospf_network_cmd, |
| 5400 | "no ospf network", |
| 5401 | NO_STR |
| 5402 | "OSPF interface commands\n" |
| 5403 | "Network type\n") |
| 5404 | |
| 5405 | DEFUN (ip_ospf_priority, |
| 5406 | ip_ospf_priority_addr_cmd, |
| 5407 | "ip ospf priority <0-255> A.B.C.D", |
| 5408 | "IP Information\n" |
| 5409 | "OSPF interface commands\n" |
| 5410 | "Router priority\n" |
| 5411 | "Priority\n" |
| 5412 | "Address of interface") |
| 5413 | { |
| 5414 | struct interface *ifp = vty->index; |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 5415 | long priority; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5416 | struct route_node *rn; |
| 5417 | struct in_addr addr; |
| 5418 | int ret; |
| 5419 | struct ospf_if_params *params; |
| 5420 | |
| 5421 | params = IF_DEF_PARAMS (ifp); |
| 5422 | |
| 5423 | priority = strtol (argv[0], NULL, 10); |
| 5424 | |
| 5425 | /* Router Priority range is <0-255>. */ |
| 5426 | if (priority < 0 || priority > 255) |
| 5427 | { |
| 5428 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5429 | return CMD_WARNING; |
| 5430 | } |
| 5431 | |
| 5432 | if (argc == 2) |
| 5433 | { |
| 5434 | ret = inet_aton(argv[1], &addr); |
| 5435 | if (!ret) |
| 5436 | { |
| 5437 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5438 | VTY_NEWLINE); |
| 5439 | return CMD_WARNING; |
| 5440 | } |
| 5441 | |
| 5442 | params = ospf_get_if_params (ifp, addr); |
| 5443 | ospf_if_update_params (ifp, addr); |
| 5444 | } |
| 5445 | |
| 5446 | SET_IF_PARAM (params, priority); |
| 5447 | params->priority = priority; |
| 5448 | |
| 5449 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5450 | { |
| 5451 | struct ospf_interface *oi = rn->info; |
| 5452 | |
| 5453 | if (!oi) |
| 5454 | continue; |
| 5455 | |
| 5456 | |
| 5457 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5458 | { |
| 5459 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5460 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5461 | } |
| 5462 | } |
| 5463 | |
| 5464 | return CMD_SUCCESS; |
| 5465 | } |
| 5466 | |
| 5467 | ALIAS (ip_ospf_priority, |
| 5468 | ip_ospf_priority_cmd, |
| 5469 | "ip ospf priority <0-255>", |
| 5470 | "IP Information\n" |
| 5471 | "OSPF interface commands\n" |
| 5472 | "Router priority\n" |
| 5473 | "Priority\n") |
| 5474 | |
| 5475 | ALIAS (ip_ospf_priority, |
| 5476 | ospf_priority_cmd, |
| 5477 | "ospf priority <0-255>", |
| 5478 | "OSPF interface commands\n" |
| 5479 | "Router priority\n" |
| 5480 | "Priority\n") |
| 5481 | |
| 5482 | DEFUN (no_ip_ospf_priority, |
| 5483 | no_ip_ospf_priority_addr_cmd, |
| 5484 | "no ip ospf priority A.B.C.D", |
| 5485 | NO_STR |
| 5486 | "IP Information\n" |
| 5487 | "OSPF interface commands\n" |
| 5488 | "Router priority\n" |
| 5489 | "Address of interface") |
| 5490 | { |
| 5491 | struct interface *ifp = vty->index; |
| 5492 | struct route_node *rn; |
| 5493 | struct in_addr addr; |
| 5494 | int ret; |
| 5495 | struct ospf_if_params *params; |
| 5496 | |
| 5497 | ifp = vty->index; |
| 5498 | params = IF_DEF_PARAMS (ifp); |
| 5499 | |
| 5500 | if (argc == 1) |
| 5501 | { |
| 5502 | ret = inet_aton(argv[0], &addr); |
| 5503 | if (!ret) |
| 5504 | { |
| 5505 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5506 | VTY_NEWLINE); |
| 5507 | return CMD_WARNING; |
| 5508 | } |
| 5509 | |
| 5510 | params = ospf_lookup_if_params (ifp, addr); |
| 5511 | if (params == NULL) |
| 5512 | return CMD_SUCCESS; |
| 5513 | } |
| 5514 | |
| 5515 | UNSET_IF_PARAM (params, priority); |
| 5516 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5517 | |
| 5518 | if (params != IF_DEF_PARAMS (ifp)) |
| 5519 | { |
| 5520 | ospf_free_if_params (ifp, addr); |
| 5521 | ospf_if_update_params (ifp, addr); |
| 5522 | } |
| 5523 | |
| 5524 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5525 | { |
| 5526 | struct ospf_interface *oi = rn->info; |
| 5527 | |
| 5528 | if (!oi) |
| 5529 | continue; |
| 5530 | |
| 5531 | |
| 5532 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5533 | { |
| 5534 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5535 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5536 | } |
| 5537 | } |
| 5538 | |
| 5539 | return CMD_SUCCESS; |
| 5540 | } |
| 5541 | |
| 5542 | ALIAS (no_ip_ospf_priority, |
| 5543 | no_ip_ospf_priority_cmd, |
| 5544 | "no ip ospf priority", |
| 5545 | NO_STR |
| 5546 | "IP Information\n" |
| 5547 | "OSPF interface commands\n" |
| 5548 | "Router priority\n") |
| 5549 | |
| 5550 | ALIAS (no_ip_ospf_priority, |
| 5551 | no_ospf_priority_cmd, |
| 5552 | "no ospf priority", |
| 5553 | NO_STR |
| 5554 | "OSPF interface commands\n" |
| 5555 | "Router priority\n") |
| 5556 | |
| 5557 | DEFUN (ip_ospf_retransmit_interval, |
| 5558 | ip_ospf_retransmit_interval_addr_cmd, |
| 5559 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5560 | "IP Information\n" |
| 5561 | "OSPF interface commands\n" |
| 5562 | "Time between retransmitting lost link state advertisements\n" |
| 5563 | "Seconds\n" |
| 5564 | "Address of interface") |
| 5565 | { |
| 5566 | struct interface *ifp = vty->index; |
| 5567 | u_int32_t seconds; |
| 5568 | struct in_addr addr; |
| 5569 | int ret; |
| 5570 | struct ospf_if_params *params; |
| 5571 | |
| 5572 | params = IF_DEF_PARAMS (ifp); |
| 5573 | seconds = strtol (argv[0], NULL, 10); |
| 5574 | |
| 5575 | /* Retransmit Interval range is <3-65535>. */ |
| 5576 | if (seconds < 3 || seconds > 65535) |
| 5577 | { |
| 5578 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5579 | return CMD_WARNING; |
| 5580 | } |
| 5581 | |
| 5582 | |
| 5583 | if (argc == 2) |
| 5584 | { |
| 5585 | ret = inet_aton(argv[1], &addr); |
| 5586 | if (!ret) |
| 5587 | { |
| 5588 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5589 | VTY_NEWLINE); |
| 5590 | return CMD_WARNING; |
| 5591 | } |
| 5592 | |
| 5593 | params = ospf_get_if_params (ifp, addr); |
| 5594 | ospf_if_update_params (ifp, addr); |
| 5595 | } |
| 5596 | |
| 5597 | SET_IF_PARAM (params, retransmit_interval); |
| 5598 | params->retransmit_interval = seconds; |
| 5599 | |
| 5600 | return CMD_SUCCESS; |
| 5601 | } |
| 5602 | |
| 5603 | ALIAS (ip_ospf_retransmit_interval, |
| 5604 | ip_ospf_retransmit_interval_cmd, |
| 5605 | "ip ospf retransmit-interval <3-65535>", |
| 5606 | "IP Information\n" |
| 5607 | "OSPF interface commands\n" |
| 5608 | "Time between retransmitting lost link state advertisements\n" |
| 5609 | "Seconds\n") |
| 5610 | |
| 5611 | ALIAS (ip_ospf_retransmit_interval, |
| 5612 | ospf_retransmit_interval_cmd, |
| 5613 | "ospf retransmit-interval <3-65535>", |
| 5614 | "OSPF interface commands\n" |
| 5615 | "Time between retransmitting lost link state advertisements\n" |
| 5616 | "Seconds\n") |
| 5617 | |
| 5618 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5619 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5620 | "no ip ospf retransmit-interval A.B.C.D", |
| 5621 | NO_STR |
| 5622 | "IP Information\n" |
| 5623 | "OSPF interface commands\n" |
| 5624 | "Time between retransmitting lost link state advertisements\n" |
| 5625 | "Address of interface") |
| 5626 | { |
| 5627 | struct interface *ifp = vty->index; |
| 5628 | struct in_addr addr; |
| 5629 | int ret; |
| 5630 | struct ospf_if_params *params; |
| 5631 | |
| 5632 | ifp = vty->index; |
| 5633 | params = IF_DEF_PARAMS (ifp); |
| 5634 | |
| 5635 | if (argc == 1) |
| 5636 | { |
| 5637 | ret = inet_aton(argv[0], &addr); |
| 5638 | if (!ret) |
| 5639 | { |
| 5640 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5641 | VTY_NEWLINE); |
| 5642 | return CMD_WARNING; |
| 5643 | } |
| 5644 | |
| 5645 | params = ospf_lookup_if_params (ifp, addr); |
| 5646 | if (params == NULL) |
| 5647 | return CMD_SUCCESS; |
| 5648 | } |
| 5649 | |
| 5650 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5651 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5652 | |
| 5653 | if (params != IF_DEF_PARAMS (ifp)) |
| 5654 | { |
| 5655 | ospf_free_if_params (ifp, addr); |
| 5656 | ospf_if_update_params (ifp, addr); |
| 5657 | } |
| 5658 | |
| 5659 | return CMD_SUCCESS; |
| 5660 | } |
| 5661 | |
| 5662 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5663 | no_ip_ospf_retransmit_interval_cmd, |
| 5664 | "no ip ospf retransmit-interval", |
| 5665 | NO_STR |
| 5666 | "IP Information\n" |
| 5667 | "OSPF interface commands\n" |
| 5668 | "Time between retransmitting lost link state advertisements\n") |
| 5669 | |
| 5670 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5671 | no_ospf_retransmit_interval_cmd, |
| 5672 | "no ospf retransmit-interval", |
| 5673 | NO_STR |
| 5674 | "OSPF interface commands\n" |
| 5675 | "Time between retransmitting lost link state advertisements\n") |
| 5676 | |
| 5677 | DEFUN (ip_ospf_transmit_delay, |
| 5678 | ip_ospf_transmit_delay_addr_cmd, |
| 5679 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5680 | "IP Information\n" |
| 5681 | "OSPF interface commands\n" |
| 5682 | "Link state transmit delay\n" |
| 5683 | "Seconds\n" |
| 5684 | "Address of interface") |
| 5685 | { |
| 5686 | struct interface *ifp = vty->index; |
| 5687 | u_int32_t seconds; |
| 5688 | struct in_addr addr; |
| 5689 | int ret; |
| 5690 | struct ospf_if_params *params; |
| 5691 | |
| 5692 | params = IF_DEF_PARAMS (ifp); |
| 5693 | seconds = strtol (argv[0], NULL, 10); |
| 5694 | |
| 5695 | /* Transmit Delay range is <1-65535>. */ |
| 5696 | if (seconds < 1 || seconds > 65535) |
| 5697 | { |
| 5698 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5699 | return CMD_WARNING; |
| 5700 | } |
| 5701 | |
| 5702 | if (argc == 2) |
| 5703 | { |
| 5704 | ret = inet_aton(argv[1], &addr); |
| 5705 | if (!ret) |
| 5706 | { |
| 5707 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5708 | VTY_NEWLINE); |
| 5709 | return CMD_WARNING; |
| 5710 | } |
| 5711 | |
| 5712 | params = ospf_get_if_params (ifp, addr); |
| 5713 | ospf_if_update_params (ifp, addr); |
| 5714 | } |
| 5715 | |
| 5716 | SET_IF_PARAM (params, transmit_delay); |
| 5717 | params->transmit_delay = seconds; |
| 5718 | |
| 5719 | return CMD_SUCCESS; |
| 5720 | } |
| 5721 | |
| 5722 | ALIAS (ip_ospf_transmit_delay, |
| 5723 | ip_ospf_transmit_delay_cmd, |
| 5724 | "ip ospf transmit-delay <1-65535>", |
| 5725 | "IP Information\n" |
| 5726 | "OSPF interface commands\n" |
| 5727 | "Link state transmit delay\n" |
| 5728 | "Seconds\n") |
| 5729 | |
| 5730 | ALIAS (ip_ospf_transmit_delay, |
| 5731 | ospf_transmit_delay_cmd, |
| 5732 | "ospf transmit-delay <1-65535>", |
| 5733 | "OSPF interface commands\n" |
| 5734 | "Link state transmit delay\n" |
| 5735 | "Seconds\n") |
| 5736 | |
| 5737 | DEFUN (no_ip_ospf_transmit_delay, |
| 5738 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5739 | "no ip ospf transmit-delay A.B.C.D", |
| 5740 | NO_STR |
| 5741 | "IP Information\n" |
| 5742 | "OSPF interface commands\n" |
| 5743 | "Link state transmit delay\n" |
| 5744 | "Address of interface") |
| 5745 | { |
| 5746 | struct interface *ifp = vty->index; |
| 5747 | struct in_addr addr; |
| 5748 | int ret; |
| 5749 | struct ospf_if_params *params; |
| 5750 | |
| 5751 | ifp = vty->index; |
| 5752 | params = IF_DEF_PARAMS (ifp); |
| 5753 | |
| 5754 | if (argc == 1) |
| 5755 | { |
| 5756 | ret = inet_aton(argv[0], &addr); |
| 5757 | if (!ret) |
| 5758 | { |
| 5759 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5760 | VTY_NEWLINE); |
| 5761 | return CMD_WARNING; |
| 5762 | } |
| 5763 | |
| 5764 | params = ospf_lookup_if_params (ifp, addr); |
| 5765 | if (params == NULL) |
| 5766 | return CMD_SUCCESS; |
| 5767 | } |
| 5768 | |
| 5769 | UNSET_IF_PARAM (params, transmit_delay); |
| 5770 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5771 | |
| 5772 | if (params != IF_DEF_PARAMS (ifp)) |
| 5773 | { |
| 5774 | ospf_free_if_params (ifp, addr); |
| 5775 | ospf_if_update_params (ifp, addr); |
| 5776 | } |
| 5777 | |
| 5778 | return CMD_SUCCESS; |
| 5779 | } |
| 5780 | |
| 5781 | ALIAS (no_ip_ospf_transmit_delay, |
| 5782 | no_ip_ospf_transmit_delay_cmd, |
| 5783 | "no ip ospf transmit-delay", |
| 5784 | NO_STR |
| 5785 | "IP Information\n" |
| 5786 | "OSPF interface commands\n" |
| 5787 | "Link state transmit delay\n") |
| 5788 | |
| 5789 | ALIAS (no_ip_ospf_transmit_delay, |
| 5790 | no_ospf_transmit_delay_cmd, |
| 5791 | "no ospf transmit-delay", |
| 5792 | NO_STR |
| 5793 | "OSPF interface commands\n" |
| 5794 | "Link state transmit delay\n") |
| 5795 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5796 | DEFUN (ospf_redistribute_source, |
| 5797 | ospf_redistribute_source_cmd, |
| 5798 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5799 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5800 | REDIST_STR |
| 5801 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5802 | "Metric for redistributed routes\n" |
| 5803 | "OSPF default metric\n" |
| 5804 | "OSPF exterior metric type for redistributed routes\n" |
| 5805 | "Set OSPF External Type 1 metrics\n" |
| 5806 | "Set OSPF External Type 2 metrics\n" |
| 5807 | "Route map reference\n" |
| 5808 | "Pointer to route-map entries\n") |
| 5809 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5810 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5811 | int source; |
| 5812 | int type = -1; |
| 5813 | int metric = -1; |
| 5814 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5815 | if (argc < 4) |
| 5816 | return CMD_WARNING; /* should not happen */ |
| 5817 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5818 | /* Get distribute source. */ |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5819 | source = proto_redistnum(AFI_IP, argv[0]); |
| 5820 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5821 | return CMD_WARNING; |
| 5822 | |
| 5823 | /* Get metric value. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5824 | if (argv[1] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5825 | if (!str2metric (argv[1], &metric)) |
| 5826 | return CMD_WARNING; |
| 5827 | |
| 5828 | /* Get metric type. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5829 | if (argv[2] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5830 | if (!str2metric_type (argv[2], &type)) |
| 5831 | return CMD_WARNING; |
| 5832 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5833 | if (argv[3] != NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5834 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5835 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5836 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5837 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5838 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5839 | } |
| 5840 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5841 | DEFUN (no_ospf_redistribute_source, |
| 5842 | no_ospf_redistribute_source_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5843 | "no redistribute " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5844 | NO_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5845 | REDIST_STR |
| 5846 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5847 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5848 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5849 | int source; |
| 5850 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5851 | source = proto_redistnum(AFI_IP, argv[0]); |
| 5852 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5853 | return CMD_WARNING; |
| 5854 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5855 | ospf_routemap_unset (ospf, source); |
| 5856 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5857 | } |
| 5858 | |
| 5859 | DEFUN (ospf_distribute_list_out, |
| 5860 | ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5861 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5862 | "Filter networks in routing updates\n" |
| 5863 | "Access-list name\n" |
| 5864 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5865 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5866 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5867 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5868 | int source; |
| 5869 | |
| 5870 | /* Get distribute source. */ |
Christian Franke | bda3c32 | 2012-12-04 11:31:16 -0800 | [diff] [blame] | 5871 | source = proto_redistnum(AFI_IP, argv[1]); |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5872 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5873 | return CMD_WARNING; |
| 5874 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5875 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5876 | } |
| 5877 | |
| 5878 | DEFUN (no_ospf_distribute_list_out, |
| 5879 | no_ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5880 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5881 | NO_STR |
| 5882 | "Filter networks in routing updates\n" |
| 5883 | "Access-list name\n" |
| 5884 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5885 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5886 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5887 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5888 | int source; |
| 5889 | |
Christian Franke | bda3c32 | 2012-12-04 11:31:16 -0800 | [diff] [blame] | 5890 | source = proto_redistnum(AFI_IP, argv[1]); |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5891 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5892 | return CMD_WARNING; |
| 5893 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5894 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5895 | } |
| 5896 | |
| 5897 | /* Default information originate. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5898 | DEFUN (ospf_default_information_originate, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5899 | ospf_default_information_originate_cmd, |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5900 | "default-information originate " |
| 5901 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5902 | "Control distribution of default information\n" |
| 5903 | "Distribute a default route\n" |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5904 | "Always advertise default route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5905 | "OSPF default metric\n" |
| 5906 | "OSPF metric\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5907 | "OSPF metric type for default routes\n" |
| 5908 | "Set OSPF External Type 1 metrics\n" |
| 5909 | "Set OSPF External Type 2 metrics\n" |
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; |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5914 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5915 | int type = -1; |
| 5916 | int metric = -1; |
| 5917 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5918 | if (argc < 4) |
| 5919 | return CMD_WARNING; /* this should not happen */ |
| 5920 | |
| 5921 | /* Check whether "always" was specified */ |
| 5922 | if (argv[0] != NULL) |
| 5923 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5924 | |
| 5925 | /* Get metric value. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5926 | if (argv[1] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5927 | if (!str2metric (argv[1], &metric)) |
| 5928 | return CMD_WARNING; |
| 5929 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5930 | /* Get metric type. */ |
| 5931 | if (argv[2] != NULL) |
| 5932 | if (!str2metric_type (argv[2], &type)) |
| 5933 | return CMD_WARNING; |
| 5934 | |
| 5935 | if (argv[3] != NULL) |
| 5936 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5937 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5938 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5939 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5940 | return ospf_redistribute_default_set (ospf, default_originate, |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5941 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5942 | } |
| 5943 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5944 | DEFUN (no_ospf_default_information_originate, |
| 5945 | no_ospf_default_information_originate_cmd, |
| 5946 | "no default-information originate", |
| 5947 | NO_STR |
| 5948 | "Control distribution of default information\n" |
| 5949 | "Distribute a default route\n") |
| 5950 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5951 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5952 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5953 | |
| 5954 | p.family = AF_INET; |
| 5955 | p.prefix.s_addr = 0; |
| 5956 | p.prefixlen = 0; |
| 5957 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 5958 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5959 | |
| 5960 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 5961 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 5962 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 5963 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 5964 | } |
| 5965 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5966 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 5967 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5968 | } |
| 5969 | |
| 5970 | DEFUN (ospf_default_metric, |
| 5971 | ospf_default_metric_cmd, |
| 5972 | "default-metric <0-16777214>", |
| 5973 | "Set metric of redistributed routes\n" |
| 5974 | "Default metric\n") |
| 5975 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5976 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5977 | int metric = -1; |
| 5978 | |
| 5979 | if (!str2metric (argv[0], &metric)) |
| 5980 | return CMD_WARNING; |
| 5981 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5982 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5983 | |
| 5984 | return CMD_SUCCESS; |
| 5985 | } |
| 5986 | |
| 5987 | DEFUN (no_ospf_default_metric, |
| 5988 | no_ospf_default_metric_cmd, |
| 5989 | "no default-metric", |
| 5990 | NO_STR |
| 5991 | "Set metric of redistributed routes\n") |
| 5992 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5993 | struct ospf *ospf = vty->index; |
| 5994 | |
| 5995 | ospf->default_metric = -1; |
| 5996 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5997 | return CMD_SUCCESS; |
| 5998 | } |
| 5999 | |
| 6000 | ALIAS (no_ospf_default_metric, |
| 6001 | no_ospf_default_metric_val_cmd, |
| 6002 | "no default-metric <0-16777214>", |
| 6003 | NO_STR |
| 6004 | "Set metric of redistributed routes\n" |
| 6005 | "Default metric\n") |
| 6006 | |
| 6007 | DEFUN (ospf_distance, |
| 6008 | ospf_distance_cmd, |
| 6009 | "distance <1-255>", |
| 6010 | "Define an administrative distance\n" |
| 6011 | "OSPF Administrative distance\n") |
| 6012 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6013 | struct ospf *ospf = vty->index; |
| 6014 | |
| 6015 | ospf->distance_all = atoi (argv[0]); |
| 6016 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6017 | return CMD_SUCCESS; |
| 6018 | } |
| 6019 | |
| 6020 | DEFUN (no_ospf_distance, |
| 6021 | no_ospf_distance_cmd, |
| 6022 | "no distance <1-255>", |
| 6023 | NO_STR |
| 6024 | "Define an administrative distance\n" |
| 6025 | "OSPF Administrative distance\n") |
| 6026 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6027 | struct ospf *ospf = vty->index; |
| 6028 | |
| 6029 | ospf->distance_all = 0; |
| 6030 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6031 | return CMD_SUCCESS; |
| 6032 | } |
| 6033 | |
| 6034 | DEFUN (no_ospf_distance_ospf, |
| 6035 | no_ospf_distance_ospf_cmd, |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6036 | "no distance ospf {intra-area|inter-area|external}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6037 | NO_STR |
| 6038 | "Define an administrative distance\n" |
| 6039 | "OSPF Administrative distance\n" |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6040 | "OSPF Distance\n" |
| 6041 | "Intra-area routes\n" |
| 6042 | "Inter-area routes\n" |
| 6043 | "External routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6044 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6045 | struct ospf *ospf = vty->index; |
| 6046 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6047 | if (argc < 3) |
| 6048 | return CMD_WARNING; |
| 6049 | |
| 6050 | if (argv[0] != NULL) |
| 6051 | ospf->distance_intra = 0; |
| 6052 | |
| 6053 | if (argv[1] != NULL) |
| 6054 | ospf->distance_inter = 0; |
| 6055 | |
| 6056 | if (argv[2] != NULL) |
| 6057 | ospf->distance_external = 0; |
| 6058 | |
| 6059 | if (argv[0] || argv[1] || argv[2]) |
| 6060 | return CMD_SUCCESS; |
| 6061 | |
| 6062 | /* If no arguments are given, clear all distance information */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6063 | ospf->distance_intra = 0; |
| 6064 | ospf->distance_inter = 0; |
| 6065 | ospf->distance_external = 0; |
| 6066 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6067 | return CMD_SUCCESS; |
| 6068 | } |
| 6069 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6070 | DEFUN (ospf_distance_ospf, |
| 6071 | ospf_distance_ospf_cmd, |
| 6072 | "distance ospf " |
| 6073 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6074 | "Define an administrative distance\n" |
| 6075 | "OSPF Administrative distance\n" |
| 6076 | "Intra-area routes\n" |
| 6077 | "Distance for intra-area routes\n" |
| 6078 | "Inter-area routes\n" |
| 6079 | "Distance for inter-area routes\n" |
| 6080 | "External routes\n" |
| 6081 | "Distance for external routes\n") |
| 6082 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6083 | struct ospf *ospf = vty->index; |
| 6084 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6085 | if (argc < 3) /* should not happen */ |
| 6086 | return CMD_WARNING; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6087 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6088 | if (!argv[0] && !argv[1] && !argv[2]) |
| 6089 | { |
| 6090 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", |
| 6091 | VTY_NEWLINE); |
| 6092 | return CMD_WARNING; |
| 6093 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6094 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6095 | if (argv[0] != NULL) |
| 6096 | ospf->distance_intra = atoi(argv[0]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6097 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6098 | if (argv[1] != NULL) |
| 6099 | ospf->distance_inter = atoi(argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6100 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6101 | if (argv[2] != NULL) |
| 6102 | ospf->distance_external = atoi(argv[2]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6103 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6104 | return CMD_SUCCESS; |
| 6105 | } |
| 6106 | |
| 6107 | DEFUN (ospf_distance_source, |
| 6108 | ospf_distance_source_cmd, |
| 6109 | "distance <1-255> A.B.C.D/M", |
| 6110 | "Administrative distance\n" |
| 6111 | "Distance value\n" |
| 6112 | "IP source prefix\n") |
| 6113 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6114 | struct ospf *ospf = vty->index; |
| 6115 | |
| 6116 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6117 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6118 | return CMD_SUCCESS; |
| 6119 | } |
| 6120 | |
| 6121 | DEFUN (no_ospf_distance_source, |
| 6122 | no_ospf_distance_source_cmd, |
| 6123 | "no distance <1-255> A.B.C.D/M", |
| 6124 | NO_STR |
| 6125 | "Administrative distance\n" |
| 6126 | "Distance value\n" |
| 6127 | "IP source prefix\n") |
| 6128 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6129 | struct ospf *ospf = vty->index; |
| 6130 | |
| 6131 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6132 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6133 | return CMD_SUCCESS; |
| 6134 | } |
| 6135 | |
| 6136 | DEFUN (ospf_distance_source_access_list, |
| 6137 | ospf_distance_source_access_list_cmd, |
| 6138 | "distance <1-255> A.B.C.D/M WORD", |
| 6139 | "Administrative distance\n" |
| 6140 | "Distance value\n" |
| 6141 | "IP source prefix\n" |
| 6142 | "Access list name\n") |
| 6143 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6144 | struct ospf *ospf = vty->index; |
| 6145 | |
| 6146 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6148 | return CMD_SUCCESS; |
| 6149 | } |
| 6150 | |
| 6151 | DEFUN (no_ospf_distance_source_access_list, |
| 6152 | no_ospf_distance_source_access_list_cmd, |
| 6153 | "no distance <1-255> A.B.C.D/M WORD", |
| 6154 | NO_STR |
| 6155 | "Administrative distance\n" |
| 6156 | "Distance value\n" |
| 6157 | "IP source prefix\n" |
| 6158 | "Access list name\n") |
| 6159 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6160 | struct ospf *ospf = vty->index; |
| 6161 | |
| 6162 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6163 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6164 | return CMD_SUCCESS; |
| 6165 | } |
| 6166 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6167 | DEFUN (ip_ospf_mtu_ignore, |
| 6168 | ip_ospf_mtu_ignore_addr_cmd, |
| 6169 | "ip ospf mtu-ignore A.B.C.D", |
| 6170 | "IP Information\n" |
| 6171 | "OSPF interface commands\n" |
| 6172 | "Disable mtu mismatch detection\n" |
| 6173 | "Address of interface") |
| 6174 | { |
| 6175 | struct interface *ifp = vty->index; |
| 6176 | struct in_addr addr; |
| 6177 | int ret; |
| 6178 | |
| 6179 | struct ospf_if_params *params; |
| 6180 | params = IF_DEF_PARAMS (ifp); |
| 6181 | |
| 6182 | if (argc == 1) |
| 6183 | { |
| 6184 | ret = inet_aton(argv[0], &addr); |
| 6185 | if (!ret) |
| 6186 | { |
| 6187 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6188 | VTY_NEWLINE); |
| 6189 | return CMD_WARNING; |
| 6190 | } |
| 6191 | params = ospf_get_if_params (ifp, addr); |
| 6192 | ospf_if_update_params (ifp, addr); |
| 6193 | } |
| 6194 | params->mtu_ignore = 1; |
| 6195 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6196 | SET_IF_PARAM (params, mtu_ignore); |
| 6197 | else |
| 6198 | { |
| 6199 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6200 | if (params != IF_DEF_PARAMS (ifp)) |
| 6201 | { |
| 6202 | ospf_free_if_params (ifp, addr); |
| 6203 | ospf_if_update_params (ifp, addr); |
| 6204 | } |
| 6205 | } |
| 6206 | return CMD_SUCCESS; |
| 6207 | } |
| 6208 | |
| 6209 | ALIAS (ip_ospf_mtu_ignore, |
| 6210 | ip_ospf_mtu_ignore_cmd, |
| 6211 | "ip ospf mtu-ignore", |
| 6212 | "IP Information\n" |
| 6213 | "OSPF interface commands\n" |
| 6214 | "Disable mtu mismatch detection\n") |
| 6215 | |
| 6216 | |
| 6217 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6218 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6219 | "no ip ospf mtu-ignore A.B.C.D", |
| 6220 | "IP Information\n" |
| 6221 | "OSPF interface commands\n" |
| 6222 | "Disable mtu mismatch detection\n" |
| 6223 | "Address of interface") |
| 6224 | { |
| 6225 | struct interface *ifp = vty->index; |
| 6226 | struct in_addr addr; |
| 6227 | int ret; |
| 6228 | |
| 6229 | struct ospf_if_params *params; |
| 6230 | params = IF_DEF_PARAMS (ifp); |
| 6231 | |
| 6232 | if (argc == 1) |
| 6233 | { |
| 6234 | ret = inet_aton(argv[0], &addr); |
| 6235 | if (!ret) |
| 6236 | { |
| 6237 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6238 | VTY_NEWLINE); |
| 6239 | return CMD_WARNING; |
| 6240 | } |
| 6241 | params = ospf_get_if_params (ifp, addr); |
| 6242 | ospf_if_update_params (ifp, addr); |
| 6243 | } |
| 6244 | params->mtu_ignore = 0; |
| 6245 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6246 | SET_IF_PARAM (params, mtu_ignore); |
| 6247 | else |
| 6248 | { |
| 6249 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6250 | if (params != IF_DEF_PARAMS (ifp)) |
| 6251 | { |
| 6252 | ospf_free_if_params (ifp, addr); |
| 6253 | ospf_if_update_params (ifp, addr); |
| 6254 | } |
| 6255 | } |
| 6256 | return CMD_SUCCESS; |
| 6257 | } |
| 6258 | |
| 6259 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6260 | no_ip_ospf_mtu_ignore_cmd, |
| 6261 | "no ip ospf mtu-ignore", |
| 6262 | "IP Information\n" |
| 6263 | "OSPF interface commands\n" |
| 6264 | "Disable mtu mismatch detection\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6265 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6266 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6267 | ospf_max_metric_router_lsa_admin_cmd, |
| 6268 | "max-metric router-lsa administrative", |
| 6269 | "OSPF maximum / infinite-distance metric\n" |
| 6270 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6271 | "Administratively applied, for an indefinite period\n") |
| 6272 | { |
| 6273 | struct listnode *ln; |
| 6274 | struct ospf_area *area; |
| 6275 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6276 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6277 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6278 | { |
| 6279 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6280 | |
| 6281 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6282 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6283 | } |
Ayan Banerjee | 4ba4fc8 | 2012-12-03 11:17:24 -0800 | [diff] [blame] | 6284 | |
| 6285 | /* Allows for areas configured later to get the property */ |
| 6286 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; |
| 6287 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6288 | return CMD_SUCCESS; |
| 6289 | } |
| 6290 | |
| 6291 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6292 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6293 | "no max-metric router-lsa administrative", |
| 6294 | NO_STR |
| 6295 | "OSPF maximum / infinite-distance metric\n" |
| 6296 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6297 | "Administratively applied, for an indefinite period\n") |
| 6298 | { |
| 6299 | struct listnode *ln; |
| 6300 | struct ospf_area *area; |
| 6301 | struct ospf *ospf = vty->index; |
| 6302 | |
| 6303 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6304 | { |
| 6305 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6306 | |
| 6307 | /* Don't trample on the start-up stub timer */ |
| 6308 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6309 | && !area->t_stub_router) |
| 6310 | { |
| 6311 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6312 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6313 | } |
| 6314 | } |
Ayan Banerjee | 4ba4fc8 | 2012-12-03 11:17:24 -0800 | [diff] [blame] | 6315 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6316 | return CMD_SUCCESS; |
| 6317 | } |
| 6318 | |
| 6319 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6320 | ospf_max_metric_router_lsa_startup_cmd, |
| 6321 | "max-metric router-lsa on-startup <5-86400>", |
| 6322 | "OSPF maximum / infinite-distance metric\n" |
| 6323 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6324 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6325 | "Time (seconds) to advertise self as stub-router\n") |
| 6326 | { |
| 6327 | unsigned int seconds; |
| 6328 | struct ospf *ospf = vty->index; |
| 6329 | |
| 6330 | if (argc != 1) |
| 6331 | { |
| 6332 | vty_out (vty, "%% Must supply stub-router period"); |
| 6333 | return CMD_WARNING; |
| 6334 | } |
| 6335 | |
| 6336 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6337 | |
| 6338 | ospf->stub_router_startup_time = seconds; |
| 6339 | |
| 6340 | return CMD_SUCCESS; |
| 6341 | } |
| 6342 | |
| 6343 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6344 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6345 | "no max-metric router-lsa on-startup", |
| 6346 | NO_STR |
| 6347 | "OSPF maximum / infinite-distance metric\n" |
| 6348 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6349 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6350 | { |
| 6351 | struct listnode *ln; |
| 6352 | struct ospf_area *area; |
| 6353 | struct ospf *ospf = vty->index; |
| 6354 | |
| 6355 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6356 | |
| 6357 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6358 | { |
| 6359 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 6360 | OSPF_TIMER_OFF (area->t_stub_router); |
| 6361 | |
| 6362 | /* Don't trample on admin stub routed */ |
| 6363 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6364 | { |
| 6365 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6366 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6367 | } |
| 6368 | } |
| 6369 | return CMD_SUCCESS; |
| 6370 | } |
| 6371 | |
| 6372 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 6373 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 6374 | "max-metric router-lsa on-shutdown <5-86400>", |
| 6375 | "OSPF maximum / infinite-distance metric\n" |
| 6376 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6377 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 6378 | "Time (seconds) to wait till full shutdown\n") |
| 6379 | { |
| 6380 | unsigned int seconds; |
| 6381 | struct ospf *ospf = vty->index; |
| 6382 | |
| 6383 | if (argc != 1) |
| 6384 | { |
| 6385 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 6386 | return CMD_WARNING; |
| 6387 | } |
| 6388 | |
| 6389 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 6390 | |
| 6391 | ospf->stub_router_shutdown_time = seconds; |
| 6392 | |
| 6393 | return CMD_SUCCESS; |
| 6394 | } |
| 6395 | |
| 6396 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 6397 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 6398 | "no max-metric router-lsa on-shutdown", |
| 6399 | NO_STR |
| 6400 | "OSPF maximum / infinite-distance metric\n" |
| 6401 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6402 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 6403 | { |
| 6404 | struct ospf *ospf = vty->index; |
| 6405 | |
| 6406 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6407 | |
| 6408 | return CMD_SUCCESS; |
| 6409 | } |
| 6410 | |
| 6411 | static void |
| 6412 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 6413 | { |
| 6414 | struct listnode *ln; |
| 6415 | struct ospf_area *area; |
| 6416 | |
| 6417 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6418 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 6419 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 6420 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6421 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 6422 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 6423 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6424 | { |
| 6425 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6426 | { |
| 6427 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 6428 | VTY_NEWLINE); |
| 6429 | break; |
| 6430 | } |
| 6431 | } |
| 6432 | return; |
| 6433 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6434 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6435 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6436 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6437 | { |
| 6438 | struct route_node *rn; |
| 6439 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6440 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6441 | struct ospf_path *path; |
| 6442 | |
| 6443 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6444 | VTY_NEWLINE); |
| 6445 | |
| 6446 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6447 | if ((or = rn->info) != NULL) |
| 6448 | { |
| 6449 | char buf1[19]; |
| 6450 | snprintf (buf1, 19, "%s/%d", |
| 6451 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6452 | |
| 6453 | switch (or->path_type) |
| 6454 | { |
| 6455 | case OSPF_PATH_INTER_AREA: |
| 6456 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6457 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6458 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6459 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6460 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6461 | break; |
| 6462 | case OSPF_PATH_INTRA_AREA: |
| 6463 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6464 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6465 | break; |
| 6466 | default: |
| 6467 | break; |
| 6468 | } |
| 6469 | |
| 6470 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6471 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6472 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6473 | if (if_lookup_by_index(path->ifindex)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6474 | { |
| 6475 | if (path->nexthop.s_addr == 0) |
| 6476 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6477 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6478 | else |
| 6479 | vty_out (vty, "%24s via %s, %s%s", "", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6480 | inet_ntoa (path->nexthop), |
| 6481 | ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6482 | } |
| 6483 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6484 | } |
| 6485 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6486 | } |
| 6487 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6488 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6489 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6490 | { |
| 6491 | struct route_node *rn; |
| 6492 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6493 | struct listnode *pnode; |
| 6494 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6495 | struct ospf_path *path; |
| 6496 | |
| 6497 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6498 | VTY_NEWLINE); |
| 6499 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6500 | if (rn->info) |
| 6501 | { |
| 6502 | int flag = 0; |
| 6503 | |
| 6504 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6505 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6506 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 6507 | { |
| 6508 | if (flag++) |
| 6509 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6510 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6511 | /* Show path. */ |
| 6512 | vty_out (vty, "%s [%d] area: %s", |
| 6513 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6514 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6515 | /* Show flags. */ |
| 6516 | vty_out (vty, "%s%s%s", |
| 6517 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6518 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6519 | VTY_NEWLINE); |
| 6520 | |
| 6521 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 6522 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6523 | if (if_lookup_by_index(path->ifindex)) |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6524 | { |
| 6525 | if (path->nexthop.s_addr == 0) |
| 6526 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6527 | "", ifindex2ifname (path->ifindex), |
| 6528 | VTY_NEWLINE); |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6529 | else |
| 6530 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6531 | inet_ntoa (path->nexthop), |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6532 | ifindex2ifname (path->ifindex), |
| 6533 | VTY_NEWLINE); |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6534 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6535 | } |
| 6536 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6537 | } |
| 6538 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6539 | } |
| 6540 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6541 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6542 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6543 | { |
| 6544 | struct route_node *rn; |
| 6545 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6546 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6547 | struct ospf_path *path; |
| 6548 | |
| 6549 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6550 | VTY_NEWLINE); |
| 6551 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6552 | if ((er = rn->info) != NULL) |
| 6553 | { |
| 6554 | char buf1[19]; |
| 6555 | snprintf (buf1, 19, "%s/%d", |
| 6556 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6557 | |
| 6558 | switch (er->path_type) |
| 6559 | { |
| 6560 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6561 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6562 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6563 | break; |
| 6564 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6565 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6566 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6567 | break; |
| 6568 | } |
| 6569 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6570 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6571 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6572 | if (if_lookup_by_index(path->ifindex)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6573 | { |
| 6574 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6575 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6576 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6577 | else |
| 6578 | vty_out (vty, "%24s via %s, %s%s", "", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6579 | inet_ntoa (path->nexthop), |
| 6580 | ifindex2ifname (path->ifindex), |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6581 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6582 | } |
| 6583 | } |
| 6584 | } |
| 6585 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6586 | } |
| 6587 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6588 | DEFUN (show_ip_ospf_border_routers, |
| 6589 | show_ip_ospf_border_routers_cmd, |
| 6590 | "show ip ospf border-routers", |
| 6591 | SHOW_STR |
| 6592 | IP_STR |
| 6593 | "show all the ABR's and ASBR's\n" |
| 6594 | "for this area\n") |
| 6595 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6596 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6597 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6598 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6599 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6600 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6601 | return CMD_SUCCESS; |
| 6602 | } |
| 6603 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6604 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6605 | { |
| 6606 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6607 | return CMD_SUCCESS; |
| 6608 | } |
| 6609 | |
| 6610 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6611 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6612 | |
| 6613 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6614 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6615 | |
| 6616 | return CMD_SUCCESS; |
| 6617 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6618 | |
| 6619 | DEFUN (show_ip_ospf_route, |
| 6620 | show_ip_ospf_route_cmd, |
| 6621 | "show ip ospf route", |
| 6622 | SHOW_STR |
| 6623 | IP_STR |
| 6624 | "OSPF information\n" |
| 6625 | "OSPF routing table\n") |
| 6626 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6627 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6628 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6629 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6630 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6631 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6632 | return CMD_SUCCESS; |
| 6633 | } |
| 6634 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6635 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6636 | { |
| 6637 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6638 | return CMD_SUCCESS; |
| 6639 | } |
| 6640 | |
| 6641 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6642 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6643 | |
| 6644 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6645 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6646 | |
| 6647 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6648 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6649 | |
| 6650 | return CMD_SUCCESS; |
| 6651 | } |
| 6652 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6653 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6654 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6655 | { |
| 6656 | "unknown", |
| 6657 | "standard", |
| 6658 | "ibm", |
| 6659 | "cisco", |
| 6660 | "shortcut" |
| 6661 | }; |
| 6662 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6663 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6664 | { |
| 6665 | "default", |
| 6666 | "enable", |
| 6667 | "disable" |
| 6668 | }; |
| 6669 | |
| 6670 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6671 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6672 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6673 | { |
| 6674 | memset (buf, 0, length); |
| 6675 | |
| 6676 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6677 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6678 | else |
| 6679 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6680 | } |
| 6681 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6682 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6683 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6684 | { |
| 6685 | "unknown", /* should never be used. */ |
| 6686 | "point-to-point", |
| 6687 | "broadcast", |
| 6688 | "non-broadcast", |
| 6689 | "point-to-multipoint", |
| 6690 | "virtual-link", /* should never be used. */ |
| 6691 | "loopback" |
| 6692 | }; |
| 6693 | |
| 6694 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6695 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6696 | config_write_interface (struct vty *vty) |
| 6697 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6698 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6699 | struct interface *ifp; |
| 6700 | struct crypt_key *ck; |
| 6701 | int write = 0; |
| 6702 | struct route_node *rn = NULL; |
| 6703 | struct ospf_if_params *params; |
| 6704 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6705 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6706 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6707 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6708 | continue; |
| 6709 | |
| 6710 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6711 | vty_out (vty, "interface %s%s", ifp->name, |
| 6712 | VTY_NEWLINE); |
| 6713 | if (ifp->desc) |
| 6714 | vty_out (vty, " description %s%s", ifp->desc, |
| 6715 | VTY_NEWLINE); |
| 6716 | |
| 6717 | write++; |
| 6718 | |
| 6719 | params = IF_DEF_PARAMS (ifp); |
| 6720 | |
| 6721 | do { |
| 6722 | /* Interface Network print. */ |
| 6723 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6724 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6725 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 6726 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 6727 | { |
| 6728 | vty_out (vty, " ip ospf network %s", |
| 6729 | ospf_int_type_str[params->type]); |
| 6730 | if (params != IF_DEF_PARAMS (ifp)) |
| 6731 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6732 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6733 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6734 | } |
| 6735 | |
| 6736 | /* OSPF interface authentication print */ |
| 6737 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6738 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6739 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6740 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6741 | |
| 6742 | /* Translation tables are not that much help here due to syntax |
| 6743 | of the simple option */ |
| 6744 | switch (params->auth_type) |
| 6745 | { |
| 6746 | |
| 6747 | case OSPF_AUTH_NULL: |
| 6748 | auth_str = " null"; |
| 6749 | break; |
| 6750 | |
| 6751 | case OSPF_AUTH_SIMPLE: |
| 6752 | auth_str = ""; |
| 6753 | break; |
| 6754 | |
| 6755 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6756 | auth_str = " message-digest"; |
| 6757 | break; |
| 6758 | |
| 6759 | default: |
| 6760 | auth_str = ""; |
| 6761 | break; |
| 6762 | } |
| 6763 | |
| 6764 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6765 | if (params != IF_DEF_PARAMS (ifp)) |
| 6766 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6767 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6768 | } |
| 6769 | |
| 6770 | /* Simple Authentication Password print. */ |
| 6771 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6772 | params->auth_simple[0] != '\0') |
| 6773 | { |
| 6774 | vty_out (vty, " ip ospf authentication-key %s", |
| 6775 | params->auth_simple); |
| 6776 | if (params != IF_DEF_PARAMS (ifp)) |
| 6777 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6778 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6779 | } |
| 6780 | |
| 6781 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6782 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6783 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6784 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6785 | ck->key_id, ck->auth_key); |
| 6786 | if (params != IF_DEF_PARAMS (ifp)) |
| 6787 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6788 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6789 | } |
| 6790 | |
| 6791 | /* Interface Output Cost print. */ |
| 6792 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6793 | { |
| 6794 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6795 | if (params != IF_DEF_PARAMS (ifp)) |
| 6796 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6797 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6798 | } |
| 6799 | |
| 6800 | /* Hello Interval print. */ |
| 6801 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6802 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6803 | { |
| 6804 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6805 | if (params != IF_DEF_PARAMS (ifp)) |
| 6806 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6807 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6808 | } |
| 6809 | |
| 6810 | |
| 6811 | /* Router Dead Interval print. */ |
| 6812 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6813 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6814 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 6815 | vty_out (vty, " ip ospf dead-interval "); |
| 6816 | |
| 6817 | /* fast hello ? */ |
| 6818 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 6819 | vty_out (vty, "minimal hello-multiplier %d", |
| 6820 | params->fast_hello); |
| 6821 | else |
| 6822 | vty_out (vty, "%u", params->v_wait); |
| 6823 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6824 | if (params != IF_DEF_PARAMS (ifp)) |
| 6825 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6826 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6827 | } |
| 6828 | |
| 6829 | /* Router Priority print. */ |
| 6830 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 6831 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 6832 | { |
| 6833 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 6834 | if (params != IF_DEF_PARAMS (ifp)) |
| 6835 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6836 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6837 | } |
| 6838 | |
| 6839 | /* Retransmit Interval print. */ |
| 6840 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 6841 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 6842 | { |
| 6843 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 6844 | params->retransmit_interval); |
| 6845 | if (params != IF_DEF_PARAMS (ifp)) |
| 6846 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6847 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6848 | } |
| 6849 | |
| 6850 | /* Transmit Delay print. */ |
| 6851 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 6852 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 6853 | { |
| 6854 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 6855 | if (params != IF_DEF_PARAMS (ifp)) |
| 6856 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6857 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6858 | } |
| 6859 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6860 | /* MTU ignore print. */ |
| 6861 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 6862 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6863 | { |
| 6864 | if (params->mtu_ignore == 0) |
| 6865 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 6866 | else |
| 6867 | vty_out (vty, " ip ospf mtu-ignore"); |
| 6868 | if (params != IF_DEF_PARAMS (ifp)) |
| 6869 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6870 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6871 | } |
| 6872 | |
| 6873 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6874 | while (1) |
| 6875 | { |
| 6876 | if (rn == NULL) |
| 6877 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 6878 | else |
| 6879 | rn = route_next (rn); |
| 6880 | |
| 6881 | if (rn == NULL) |
| 6882 | break; |
| 6883 | params = rn->info; |
| 6884 | if (params != NULL) |
| 6885 | break; |
| 6886 | } |
| 6887 | } while (rn); |
| 6888 | |
| 6889 | #ifdef HAVE_OPAQUE_LSA |
| 6890 | ospf_opaque_config_write_if (vty, ifp); |
| 6891 | #endif /* HAVE_OPAQUE_LSA */ |
| 6892 | } |
| 6893 | |
| 6894 | return write; |
| 6895 | } |
| 6896 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6897 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6898 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6899 | { |
| 6900 | struct route_node *rn; |
| 6901 | u_char buf[INET_ADDRSTRLEN]; |
| 6902 | |
| 6903 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6904 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6905 | if (rn->info) |
| 6906 | { |
| 6907 | struct ospf_network *n = rn->info; |
| 6908 | |
| 6909 | memset (buf, 0, INET_ADDRSTRLEN); |
| 6910 | |
| 6911 | /* Create Area ID string by specified Area ID format. */ |
| 6912 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 6913 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6914 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 6915 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6916 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 6917 | |
| 6918 | /* Network print. */ |
| 6919 | vty_out (vty, " network %s/%d area %s%s", |
| 6920 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 6921 | buf, VTY_NEWLINE); |
| 6922 | } |
| 6923 | |
| 6924 | return 0; |
| 6925 | } |
| 6926 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6927 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6928 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6929 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6930 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6931 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6932 | u_char buf[INET_ADDRSTRLEN]; |
| 6933 | |
| 6934 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6935 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6936 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6937 | struct route_node *rn1; |
| 6938 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 6939 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6940 | |
| 6941 | if (area->auth_type != OSPF_AUTH_NULL) |
| 6942 | { |
| 6943 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 6944 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 6945 | else |
| 6946 | vty_out (vty, " area %s authentication message-digest%s", |
| 6947 | buf, VTY_NEWLINE); |
| 6948 | } |
| 6949 | |
| 6950 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 6951 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 6952 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 6953 | VTY_NEWLINE); |
| 6954 | |
| 6955 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6956 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6957 | ) |
| 6958 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 6959 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6960 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 6961 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 6962 | { |
| 6963 | vty_out (vty, " area %s nssa", buf); |
| 6964 | switch (area->NSSATranslatorRole) |
| 6965 | { |
| 6966 | case OSPF_NSSA_ROLE_NEVER: |
| 6967 | vty_out (vty, " translate-never"); |
| 6968 | break; |
| 6969 | case OSPF_NSSA_ROLE_ALWAYS: |
| 6970 | vty_out (vty, " translate-always"); |
| 6971 | break; |
| 6972 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 6973 | default: |
| 6974 | vty_out (vty, " translate-candidate"); |
| 6975 | } |
| 6976 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6977 | |
| 6978 | if (area->no_summary) |
| 6979 | vty_out (vty, " no-summary"); |
| 6980 | |
| 6981 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6982 | |
| 6983 | if (area->default_cost != 1) |
| 6984 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 6985 | area->default_cost, VTY_NEWLINE); |
| 6986 | } |
| 6987 | |
| 6988 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 6989 | if (rn1->info) |
| 6990 | { |
| 6991 | struct ospf_area_range *range = rn1->info; |
| 6992 | |
| 6993 | vty_out (vty, " area %s range %s/%d", buf, |
| 6994 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 6995 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 6996 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6997 | vty_out (vty, " cost %d", range->cost_config); |
| 6998 | |
| 6999 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7000 | vty_out (vty, " not-advertise"); |
| 7001 | |
| 7002 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7003 | vty_out (vty, " substitute %s/%d", |
| 7004 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7005 | |
| 7006 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7007 | } |
| 7008 | |
| 7009 | if (EXPORT_NAME (area)) |
| 7010 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7011 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7012 | |
| 7013 | if (IMPORT_NAME (area)) |
| 7014 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7015 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7016 | |
| 7017 | if (PREFIX_NAME_IN (area)) |
| 7018 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7019 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7020 | |
| 7021 | if (PREFIX_NAME_OUT (area)) |
| 7022 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7023 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7024 | } |
| 7025 | |
| 7026 | return 0; |
| 7027 | } |
| 7028 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7029 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7030 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7031 | { |
| 7032 | struct ospf_nbr_nbma *nbr_nbma; |
| 7033 | struct route_node *rn; |
| 7034 | |
| 7035 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7036 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7037 | if ((nbr_nbma = rn->info)) |
| 7038 | { |
| 7039 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7040 | |
| 7041 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7042 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7043 | |
| 7044 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7045 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7046 | |
| 7047 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7048 | } |
| 7049 | |
| 7050 | return 0; |
| 7051 | } |
| 7052 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7053 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7054 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7055 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7056 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7057 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7058 | u_char buf[INET_ADDRSTRLEN]; |
| 7059 | |
| 7060 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7061 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7062 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7063 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7064 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7065 | struct ospf_interface *oi; |
| 7066 | |
| 7067 | if (vl_data != NULL) |
| 7068 | { |
| 7069 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7070 | |
| 7071 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7072 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7073 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7074 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7075 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7076 | oi = vl_data->vl_oi; |
| 7077 | |
| 7078 | /* timers */ |
| 7079 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7080 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7081 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7082 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7083 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7084 | buf, |
| 7085 | inet_ntoa (vl_data->vl_peer), |
| 7086 | OSPF_IF_PARAM (oi, v_hello), |
| 7087 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7088 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7089 | OSPF_IF_PARAM (oi, v_wait), |
| 7090 | VTY_NEWLINE); |
| 7091 | else |
| 7092 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7093 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7094 | /* Auth key */ |
| 7095 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7096 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7097 | buf, |
| 7098 | inet_ntoa (vl_data->vl_peer), |
| 7099 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7100 | VTY_NEWLINE); |
| 7101 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7102 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7103 | n2, ck)) |
| 7104 | vty_out (vty, " area %s virtual-link %s" |
| 7105 | " message-digest-key %d md5 %s%s", |
| 7106 | buf, |
| 7107 | inet_ntoa (vl_data->vl_peer), |
| 7108 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7109 | |
| 7110 | } |
| 7111 | } |
| 7112 | |
| 7113 | return 0; |
| 7114 | } |
| 7115 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7116 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7117 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7118 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7119 | { |
| 7120 | int type; |
| 7121 | |
| 7122 | /* redistribute print. */ |
| 7123 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
| 7124 | if (type != zclient->redist_default && zclient->redist[type]) |
| 7125 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7126 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7127 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7128 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7129 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7130 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7131 | vty_out (vty, " metric-type 1"); |
| 7132 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7133 | if (ROUTEMAP_NAME (ospf, type)) |
| 7134 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7135 | |
| 7136 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7137 | } |
| 7138 | |
| 7139 | return 0; |
| 7140 | } |
| 7141 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7142 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7143 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7144 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7145 | if (ospf->default_metric != -1) |
| 7146 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7147 | VTY_NEWLINE); |
| 7148 | return 0; |
| 7149 | } |
| 7150 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7151 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7152 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7153 | { |
| 7154 | int type; |
| 7155 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7156 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7157 | { |
| 7158 | /* distribute-list print. */ |
| 7159 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
Denis Ovsienko | 171c9a9 | 2011-09-10 16:40:23 +0400 | [diff] [blame] | 7160 | if (DISTRIBUTE_NAME (ospf, type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7161 | vty_out (vty, " distribute-list %s out %s%s", |
Denis Ovsienko | 171c9a9 | 2011-09-10 16:40:23 +0400 | [diff] [blame] | 7162 | DISTRIBUTE_NAME (ospf, type), |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7163 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7164 | |
| 7165 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7166 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7167 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7168 | vty_out (vty, " default-information originate"); |
| 7169 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7170 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7171 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7172 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7173 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7174 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7175 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7176 | vty_out (vty, " metric-type 1"); |
| 7177 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7178 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7179 | vty_out (vty, " route-map %s", |
| 7180 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7181 | |
| 7182 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7183 | } |
| 7184 | |
| 7185 | } |
| 7186 | |
| 7187 | return 0; |
| 7188 | } |
| 7189 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7190 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7191 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7192 | { |
| 7193 | struct route_node *rn; |
| 7194 | struct ospf_distance *odistance; |
| 7195 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7196 | if (ospf->distance_all) |
| 7197 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7198 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7199 | if (ospf->distance_intra |
| 7200 | || ospf->distance_inter |
| 7201 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7202 | { |
| 7203 | vty_out (vty, " distance ospf"); |
| 7204 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7205 | if (ospf->distance_intra) |
| 7206 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7207 | if (ospf->distance_inter) |
| 7208 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7209 | if (ospf->distance_external) |
| 7210 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7211 | |
| 7212 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7213 | } |
| 7214 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7215 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7216 | if ((odistance = rn->info) != NULL) |
| 7217 | { |
| 7218 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7219 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7220 | odistance->access_list ? odistance->access_list : "", |
| 7221 | VTY_NEWLINE); |
| 7222 | } |
| 7223 | return 0; |
| 7224 | } |
| 7225 | |
| 7226 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7227 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7228 | ospf_config_write (struct vty *vty) |
| 7229 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7230 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7231 | struct interface *ifp; |
| 7232 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7233 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7234 | int write = 0; |
| 7235 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7236 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7237 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7238 | { |
| 7239 | /* `router ospf' print. */ |
| 7240 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7241 | |
| 7242 | write++; |
| 7243 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7244 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | return write; |
| 7246 | |
| 7247 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7248 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7249 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7250 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7251 | |
| 7252 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7253 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7254 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7255 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7256 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7257 | /* log-adjacency-changes flag print. */ |
| 7258 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 7259 | { |
| 7260 | vty_out(vty, " log-adjacency-changes"); |
| 7261 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 7262 | vty_out(vty, " detail"); |
| 7263 | vty_out(vty, "%s", VTY_NEWLINE); |
| 7264 | } |
| 7265 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7266 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7267 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7268 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7269 | |
| 7270 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7271 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7272 | { |
| 7273 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7274 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7275 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7276 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7277 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7278 | |
| 7279 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7280 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7281 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7282 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7283 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7284 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7285 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7286 | |
| 7287 | /* Max-metric router-lsa print */ |
| 7288 | config_write_stub_router (vty, ospf); |
| 7289 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7290 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7291 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7292 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7293 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7294 | |
| 7295 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7296 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7297 | |
| 7298 | /* passive-interface print. */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7299 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
| 7300 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); |
| 7301 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7302 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7303 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
| 7304 | && IF_DEF_PARAMS (ifp)->passive_interface != |
| 7305 | ospf->passive_interface_default) |
| 7306 | { |
| 7307 | vty_out (vty, " %spassive-interface %s%s", |
| 7308 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", |
| 7309 | ifp->name, VTY_NEWLINE); |
| 7310 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7311 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7312 | { |
| 7313 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) |
| 7314 | continue; |
| 7315 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), |
| 7316 | passive_interface)) |
| 7317 | { |
| 7318 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) |
| 7319 | continue; |
| 7320 | } |
| 7321 | else if (oi->params->passive_interface == ospf->passive_interface_default) |
| 7322 | continue; |
| 7323 | |
| 7324 | vty_out (vty, " %spassive-interface %s %s%s", |
| 7325 | oi->params->passive_interface ? "" : "no ", |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7326 | oi->ifp->name, |
| 7327 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7328 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7329 | |
| 7330 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7331 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7332 | |
| 7333 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7334 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7335 | |
| 7336 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7337 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7338 | |
| 7339 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7340 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7341 | |
| 7342 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7343 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7344 | |
| 7345 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7346 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7347 | |
| 7348 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7349 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7350 | |
| 7351 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7352 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7353 | #endif /* HAVE_OPAQUE_LSA */ |
| 7354 | } |
| 7355 | |
| 7356 | return write; |
| 7357 | } |
| 7358 | |
| 7359 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7360 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7361 | { |
| 7362 | /* "show ip ospf" commands. */ |
| 7363 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7364 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7365 | |
| 7366 | /* "show ip ospf database" commands. */ |
| 7367 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7368 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7369 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7370 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7371 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7372 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7373 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7374 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7375 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7376 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7377 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7378 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7379 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7380 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7381 | |
| 7382 | /* "show ip ospf interface" commands. */ |
| 7383 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7384 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7385 | |
| 7386 | /* "show ip ospf neighbor" commands. */ |
| 7387 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7388 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7389 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7390 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7391 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7392 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7393 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7394 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7395 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7396 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7397 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7398 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7399 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7400 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7401 | |
| 7402 | /* "show ip ospf route" commands. */ |
| 7403 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7404 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7405 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7406 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7407 | } |
| 7408 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7409 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7410 | /* ospfd's interface node. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 7411 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7412 | { |
| 7413 | INTERFACE_NODE, |
| 7414 | "%s(config-if)# ", |
| 7415 | 1 |
| 7416 | }; |
| 7417 | |
| 7418 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7419 | static void |
| 7420 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7421 | { |
| 7422 | /* Install interface node. */ |
| 7423 | install_node (&interface_node, config_write_interface); |
| 7424 | |
| 7425 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7426 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7427 | install_default (INTERFACE_NODE); |
| 7428 | |
| 7429 | /* "description" commands. */ |
| 7430 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7431 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7432 | |
| 7433 | /* "ip ospf authentication" commands. */ |
| 7434 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7435 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7436 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7437 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7438 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7439 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7440 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7441 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7442 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7443 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7444 | |
| 7445 | /* "ip ospf message-digest-key" commands. */ |
| 7446 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7447 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7448 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7449 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7450 | |
| 7451 | /* "ip ospf cost" commands. */ |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7452 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
| 7453 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 7454 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
| 7455 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7456 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7457 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7458 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7459 | /* "ip ospf mtu-ignore" commands. */ |
| 7460 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7461 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7462 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7463 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7464 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7465 | /* "ip ospf dead-interval" commands. */ |
| 7466 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7467 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7468 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 7469 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7470 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7471 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7472 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7473 | /* "ip ospf hello-interval" commands. */ |
| 7474 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7475 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7476 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7477 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7478 | |
| 7479 | /* "ip ospf network" commands. */ |
| 7480 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7481 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7482 | |
| 7483 | /* "ip ospf priority" commands. */ |
| 7484 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7485 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7486 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7487 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7488 | |
| 7489 | /* "ip ospf retransmit-interval" commands. */ |
| 7490 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7491 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7492 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7493 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7494 | |
| 7495 | /* "ip ospf transmit-delay" commands. */ |
| 7496 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7497 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7498 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7499 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7500 | |
| 7501 | /* These commands are compatibitliy for previous version. */ |
| 7502 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7503 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7504 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7505 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7506 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
| 7507 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7508 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 7509 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
| 7510 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7511 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7512 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7513 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7514 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7515 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7516 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7517 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7518 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7519 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7520 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7521 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7522 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7523 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7524 | } |
| 7525 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7526 | static void |
| 7527 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7528 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7529 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7530 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7531 | |
| 7532 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7533 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7534 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7535 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7536 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7537 | |
| 7538 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7539 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7540 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7541 | |
| 7542 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7543 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7544 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 7545 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7546 | #if 0 |
| 7547 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7548 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7549 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7550 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7551 | #endif /* 0 */ |
| 7552 | } |
| 7553 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 7554 | static struct cmd_node ospf_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7555 | { |
| 7556 | OSPF_NODE, |
| 7557 | "%s(config-router)# ", |
| 7558 | 1 |
| 7559 | }; |
| 7560 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7561 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7562 | /* Install OSPF related vty commands. */ |
| 7563 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7564 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7565 | { |
| 7566 | /* Install ospf top node. */ |
| 7567 | install_node (&ospf_node, ospf_config_write); |
| 7568 | |
| 7569 | /* "router ospf" commands. */ |
| 7570 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7571 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7572 | |
| 7573 | install_default (OSPF_NODE); |
| 7574 | |
| 7575 | /* "ospf router-id" commands. */ |
| 7576 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7577 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7578 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7579 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7580 | |
| 7581 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7582 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7583 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7584 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7585 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7586 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7587 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7588 | |
| 7589 | /* "ospf abr-type" commands. */ |
| 7590 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7591 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7592 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7593 | /* "ospf log-adjacency-changes" commands. */ |
| 7594 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); |
| 7595 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); |
| 7596 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); |
| 7597 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); |
| 7598 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7599 | /* "ospf rfc1583-compatible" commands. */ |
| 7600 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7601 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7602 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7603 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7604 | |
| 7605 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7606 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7607 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7608 | |
| 7609 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7610 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7611 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7612 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7613 | |
| 7614 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7615 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7616 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7617 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7618 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7619 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7620 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7621 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7622 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7623 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7624 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7625 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7626 | |
| 7627 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7628 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7629 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7630 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7631 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7632 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7633 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7634 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7635 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7636 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7637 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7638 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7639 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7640 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7641 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7642 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7643 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7644 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7645 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7646 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7647 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7648 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7649 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7650 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7651 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7652 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7653 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7654 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7655 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7656 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7657 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7658 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7659 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7660 | |
| 7661 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7662 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7663 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7664 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7665 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7666 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7667 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7668 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7669 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7670 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7671 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7672 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7673 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7674 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7675 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7676 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7677 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7678 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7679 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7680 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7681 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 7682 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7683 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7684 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 7685 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7686 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7687 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 7688 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7689 | |
| 7690 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7691 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 7692 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 7693 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 7694 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 7695 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7696 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7697 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 7698 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7699 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7700 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7701 | /* max-metric commands */ |
| 7702 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 7703 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 7704 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 7705 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 7706 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 7707 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 7708 | |
| 7709 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7710 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 7711 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7712 | |
| 7713 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7714 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7715 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7716 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7717 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7718 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7719 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7720 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7721 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7722 | |
| 7723 | /* Init interface related vty commands. */ |
| 7724 | ospf_vty_if_init (); |
| 7725 | |
| 7726 | /* Init zebra related vty commands. */ |
| 7727 | ospf_vty_zebra_init (); |
| 7728 | } |