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 |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 257 | ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp, |
| 258 | struct ospf_if_params *params, u_char value, |
| 259 | struct in_addr addr) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 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 | } |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | static void |
| 282 | ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp, |
| 283 | struct ospf_if_params *params, u_char value) |
| 284 | { |
| 285 | params->passive_interface = value; |
| 286 | if (params == IF_DEF_PARAMS (ifp)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 287 | { |
| 288 | if (value != ospf->passive_interface_default) |
| 289 | SET_IF_PARAM (params, passive_interface); |
| 290 | else |
| 291 | UNSET_IF_PARAM (params, passive_interface); |
| 292 | } |
| 293 | } |
| 294 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 295 | DEFUN (ospf_passive_interface, |
| 296 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 297 | "passive-interface IFNAME A.B.C.D", |
| 298 | "Suppress routing updates on an interface\n" |
| 299 | "Interface's name\n") |
| 300 | { |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 301 | struct interface *ifp; |
| 302 | struct in_addr addr; |
| 303 | int ret; |
| 304 | struct ospf_if_params *params; |
| 305 | struct route_node *rn; |
| 306 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 307 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 308 | if (argc == 0) |
| 309 | { |
| 310 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); |
| 311 | return CMD_SUCCESS; |
| 312 | } |
| 313 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 314 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 315 | |
| 316 | params = IF_DEF_PARAMS (ifp); |
| 317 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 318 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 319 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 320 | ret = inet_aton(argv[1], &addr); |
| 321 | if (!ret) |
| 322 | { |
| 323 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 324 | VTY_NEWLINE); |
| 325 | return CMD_WARNING; |
| 326 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 327 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 328 | params = ospf_get_if_params (ifp, addr); |
| 329 | ospf_if_update_params (ifp, addr); |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 330 | ospf_passive_interface_update_addr (ospf, ifp, params, |
| 331 | OSPF_IF_PASSIVE, addr); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 332 | } |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 333 | |
| 334 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 335 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 336 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 337 | * interfaces for which the passive property changed. It is too much |
| 338 | * work to determine this set, so we do this for every interface. |
| 339 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 340 | * record of joined groups to avoid systems calls if the desired |
| 341 | * memberships match the current memership. |
| 342 | */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 343 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 344 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 345 | { |
| 346 | struct ospf_interface *oi = rn->info; |
| 347 | |
| 348 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 349 | ospf_if_set_multicast(oi); |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 350 | } |
| 351 | /* |
| 352 | * XXX It is not clear what state transitions the interface needs to |
| 353 | * undergo when going from active to passive. Fixing this will |
| 354 | * require precise identification of interfaces having such a |
| 355 | * transition. |
| 356 | */ |
| 357 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 358 | return CMD_SUCCESS; |
| 359 | } |
| 360 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 361 | ALIAS (ospf_passive_interface, |
| 362 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 363 | "passive-interface IFNAME", |
| 364 | "Suppress routing updates on an interface\n" |
| 365 | "Interface's name\n") |
| 366 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 367 | ALIAS (ospf_passive_interface, |
| 368 | ospf_passive_interface_default_cmd, |
| 369 | "passive-interface default", |
| 370 | "Suppress routing updates on an interface\n" |
| 371 | "Suppress routing updates on interfaces by default\n") |
| 372 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 373 | DEFUN (no_ospf_passive_interface, |
| 374 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 375 | "no passive-interface IFNAME A.B.C.D", |
| 376 | NO_STR |
| 377 | "Allow routing updates on an interface\n" |
| 378 | "Interface's name\n") |
| 379 | { |
| 380 | struct interface *ifp; |
| 381 | struct in_addr addr; |
| 382 | struct ospf_if_params *params; |
| 383 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 384 | struct route_node *rn; |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 385 | struct ospf *ospf = vty->index; |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 386 | |
| 387 | if (argc == 0) |
| 388 | { |
| 389 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); |
| 390 | return CMD_SUCCESS; |
| 391 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 392 | |
Andrew J. Schorr | 6e72cb6 | 2006-06-18 00:45:48 +0000 | [diff] [blame] | 393 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 394 | |
| 395 | params = IF_DEF_PARAMS (ifp); |
| 396 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 397 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 398 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 399 | ret = inet_aton(argv[1], &addr); |
| 400 | if (!ret) |
| 401 | { |
| 402 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 403 | VTY_NEWLINE); |
| 404 | return CMD_WARNING; |
| 405 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 406 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 407 | params = ospf_lookup_if_params (ifp, addr); |
| 408 | if (params == NULL) |
| 409 | return CMD_SUCCESS; |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 410 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
| 411 | addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 412 | } |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 413 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
| 414 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 415 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 416 | * interfaces for which the passive property changed. It is too much |
| 417 | * work to determine this set, so we do this for every interface. |
| 418 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 419 | * record of joined groups to avoid systems calls if the desired |
| 420 | * memberships match the current memership. |
| 421 | */ |
| 422 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 423 | { |
| 424 | struct ospf_interface *oi = rn->info; |
| 425 | |
| 426 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 427 | ospf_if_set_multicast(oi); |
| 428 | } |
| 429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 430 | return CMD_SUCCESS; |
| 431 | } |
| 432 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 433 | ALIAS (no_ospf_passive_interface, |
| 434 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 435 | "no passive-interface IFNAME", |
| 436 | NO_STR |
| 437 | "Allow routing updates on an interface\n" |
| 438 | "Interface's name\n") |
| 439 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 440 | ALIAS (no_ospf_passive_interface, |
| 441 | no_ospf_passive_interface_default_cmd, |
| 442 | "no passive-interface default", |
| 443 | NO_STR |
| 444 | "Allow routing updates on an interface\n" |
| 445 | "Allow routing updates on interfaces by default\n") |
| 446 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 447 | DEFUN (ospf_network_area, |
| 448 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 449 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 450 | "Enable routing on an IP network\n" |
| 451 | "OSPF network prefix\n" |
| 452 | "Set the OSPF area ID\n" |
| 453 | "OSPF area ID in IP address format\n" |
| 454 | "OSPF area ID as a decimal value\n") |
| 455 | { |
| 456 | struct ospf *ospf= vty->index; |
| 457 | struct prefix_ipv4 p; |
| 458 | struct in_addr area_id; |
| 459 | int ret, format; |
| 460 | |
| 461 | /* Get network prefix and Area ID. */ |
| 462 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 463 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 464 | |
| 465 | ret = ospf_network_set (ospf, &p, area_id); |
| 466 | if (ret == 0) |
| 467 | { |
| 468 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 469 | return CMD_WARNING; |
| 470 | } |
| 471 | |
| 472 | return CMD_SUCCESS; |
| 473 | } |
| 474 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 475 | DEFUN (no_ospf_network_area, |
| 476 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 477 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 478 | NO_STR |
| 479 | "Enable routing on an IP network\n" |
| 480 | "OSPF network prefix\n" |
| 481 | "Set the OSPF area ID\n" |
| 482 | "OSPF area ID in IP address format\n" |
| 483 | "OSPF area ID as a decimal value\n") |
| 484 | { |
| 485 | struct ospf *ospf = (struct ospf *) vty->index; |
| 486 | struct prefix_ipv4 p; |
| 487 | struct in_addr area_id; |
| 488 | int ret, format; |
| 489 | |
| 490 | /* Get network prefix and Area ID. */ |
| 491 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 492 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 493 | |
| 494 | ret = ospf_network_unset (ospf, &p, area_id); |
| 495 | if (ret == 0) |
| 496 | { |
| 497 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 498 | VTY_NEWLINE); |
| 499 | return CMD_WARNING; |
| 500 | } |
| 501 | |
| 502 | return CMD_SUCCESS; |
| 503 | } |
| 504 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 505 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 506 | DEFUN (ospf_area_range, |
| 507 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 509 | "OSPF area parameters\n" |
| 510 | "OSPF area ID in IP address format\n" |
| 511 | "OSPF area ID as a decimal value\n" |
| 512 | "Summarize routes matching address/mask (border routers only)\n" |
| 513 | "Area range prefix\n") |
| 514 | { |
| 515 | struct ospf *ospf = vty->index; |
| 516 | struct prefix_ipv4 p; |
| 517 | struct in_addr area_id; |
| 518 | int format; |
| 519 | u_int32_t cost; |
| 520 | |
| 521 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 522 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 523 | |
| 524 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 525 | if (argc > 2) |
| 526 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 527 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 528 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 529 | } |
| 530 | |
| 531 | return CMD_SUCCESS; |
| 532 | } |
| 533 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 534 | ALIAS (ospf_area_range, |
| 535 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 537 | "OSPF area parameters\n" |
| 538 | "OSPF area ID in IP address format\n" |
| 539 | "OSPF area ID as a decimal value\n" |
| 540 | "OSPF area range for route advertise (default)\n" |
| 541 | "Area range prefix\n" |
| 542 | "Advertise this range (default)\n") |
| 543 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 544 | ALIAS (ospf_area_range, |
| 545 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 546 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 547 | "OSPF area parameters\n" |
| 548 | "OSPF area ID in IP address format\n" |
| 549 | "OSPF area ID as a decimal value\n" |
| 550 | "Summarize routes matching address/mask (border routers only)\n" |
| 551 | "Area range prefix\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 | ALIAS (ospf_area_range, |
| 556 | ospf_area_range_advertise_cost_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 advertise cost <0-16777215>", |
| 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 | "Advertise this range (default)\n" |
| 564 | "User specified metric for this range\n" |
| 565 | "Advertised metric for this range\n") |
| 566 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 567 | DEFUN (ospf_area_range_not_advertise, |
| 568 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 569 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 570 | "OSPF area parameters\n" |
| 571 | "OSPF area ID in IP address format\n" |
| 572 | "OSPF area ID as a decimal value\n" |
| 573 | "Summarize routes matching address/mask (border routers only)\n" |
| 574 | "Area range prefix\n" |
| 575 | "DoNotAdvertise this range\n") |
| 576 | { |
| 577 | struct ospf *ospf = vty->index; |
| 578 | struct prefix_ipv4 p; |
| 579 | struct in_addr area_id; |
| 580 | int format; |
| 581 | |
| 582 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 583 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 584 | |
| 585 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 586 | |
| 587 | return CMD_SUCCESS; |
| 588 | } |
| 589 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 590 | DEFUN (no_ospf_area_range, |
| 591 | no_ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 592 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 593 | NO_STR |
| 594 | "OSPF area parameters\n" |
| 595 | "OSPF area ID in IP address format\n" |
| 596 | "OSPF area ID as a decimal value\n" |
| 597 | "Summarize routes matching address/mask (border routers only)\n" |
| 598 | "Area range prefix\n") |
| 599 | { |
| 600 | struct ospf *ospf = vty->index; |
| 601 | struct prefix_ipv4 p; |
| 602 | struct in_addr area_id; |
| 603 | int format; |
| 604 | |
| 605 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 606 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 607 | |
| 608 | ospf_area_range_unset (ospf, area_id, &p); |
| 609 | |
| 610 | return CMD_SUCCESS; |
| 611 | } |
| 612 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 613 | ALIAS (no_ospf_area_range, |
| 614 | no_ospf_area_range_advertise_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 (advertise|not-advertise)", |
| 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 | "Advertise this range (default)\n" |
| 623 | "DoNotAdvertise 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_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 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 | "User specified metric for this range\n" |
| 635 | "Advertised metric for this range\n") |
| 636 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 637 | ALIAS (no_ospf_area_range, |
| 638 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 639 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 640 | NO_STR |
| 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 | "Advertise this range (default)\n" |
| 647 | "User specified metric for this range\n" |
| 648 | "Advertised metric for this range\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 649 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 650 | DEFUN (ospf_area_range_substitute, |
| 651 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 652 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 653 | "OSPF area parameters\n" |
| 654 | "OSPF area ID in IP address format\n" |
| 655 | "OSPF area ID as a decimal value\n" |
| 656 | "Summarize routes matching address/mask (border routers only)\n" |
| 657 | "Area range prefix\n" |
| 658 | "Announce area range as another prefix\n" |
| 659 | "Network prefix to be announced instead of range\n") |
| 660 | { |
| 661 | struct ospf *ospf = vty->index; |
| 662 | struct prefix_ipv4 p, s; |
| 663 | struct in_addr area_id; |
| 664 | int format; |
| 665 | |
| 666 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 667 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 668 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 669 | |
| 670 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 671 | |
| 672 | return CMD_SUCCESS; |
| 673 | } |
| 674 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 675 | DEFUN (no_ospf_area_range_substitute, |
| 676 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 677 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 678 | NO_STR |
| 679 | "OSPF area parameters\n" |
| 680 | "OSPF area ID in IP address format\n" |
| 681 | "OSPF area ID as a decimal value\n" |
| 682 | "Summarize routes matching address/mask (border routers only)\n" |
| 683 | "Area range prefix\n" |
| 684 | "Announce area range as another prefix\n" |
| 685 | "Network prefix to be announced instead of range\n") |
| 686 | { |
| 687 | struct ospf *ospf = vty->index; |
| 688 | struct prefix_ipv4 p, s; |
| 689 | struct in_addr area_id; |
| 690 | int format; |
| 691 | |
| 692 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 693 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 694 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 695 | |
| 696 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 697 | |
| 698 | return CMD_SUCCESS; |
| 699 | } |
| 700 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 701 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 702 | /* Command Handler Logic in VLink stuff is delicate!! |
| 703 | |
| 704 | ALTER AT YOUR OWN RISK!!!! |
| 705 | |
| 706 | Various dummy values are used to represent 'NoChange' state for |
| 707 | VLink configuration NOT being changed by a VLink command, and |
| 708 | special syntax is used within the command strings so that the |
| 709 | typed in command verbs can be seen in the configuration command |
| 710 | bacckend handler. This is to drastically reduce the verbeage |
| 711 | required to coe up with a reasonably compatible Cisco VLink command |
| 712 | |
| 713 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 714 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 715 | */ |
| 716 | |
| 717 | |
| 718 | /* Configuration data for virtual links |
| 719 | */ |
| 720 | struct ospf_vl_config_data { |
| 721 | struct vty *vty; /* vty stuff */ |
| 722 | struct in_addr area_id; /* area ID from command line */ |
| 723 | int format; /* command line area ID format */ |
| 724 | struct in_addr vl_peer; /* command line vl_peer */ |
| 725 | int auth_type; /* Authehntication type, if given */ |
| 726 | char *auth_key; /* simple password if present */ |
| 727 | int crypto_key_id; /* Cryptographic key ID */ |
| 728 | char *md5_key; /* MD5 authentication key */ |
| 729 | int hello_interval; /* Obvious what these are... */ |
| 730 | int retransmit_interval; |
| 731 | int transmit_delay; |
| 732 | int dead_interval; |
| 733 | }; |
| 734 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 735 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 736 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 737 | struct vty *vty) |
| 738 | { |
| 739 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 740 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 741 | vl_config->vty = vty; |
| 742 | } |
| 743 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 744 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 745 | 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] | 746 | { |
| 747 | struct ospf_area *area; |
| 748 | struct ospf_vl_data *vl_data; |
| 749 | struct vty *vty; |
| 750 | struct in_addr area_id; |
| 751 | |
| 752 | vty = vl_config->vty; |
| 753 | area_id = vl_config->area_id; |
| 754 | |
| 755 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 756 | { |
| 757 | vty_out (vty, |
| 758 | "Configuring VLs over the backbone is not allowed%s", |
| 759 | VTY_NEWLINE); |
| 760 | return NULL; |
| 761 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 762 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 763 | |
| 764 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 765 | { |
| 766 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 767 | vty_out (vty, "Area %s is %s%s", |
| 768 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 769 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 770 | VTY_NEWLINE); |
| 771 | else |
| 772 | vty_out (vty, "Area %ld is %s%s", |
| 773 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 774 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | VTY_NEWLINE); |
| 776 | return NULL; |
| 777 | } |
| 778 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 779 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 780 | { |
| 781 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 782 | if (vl_data->vl_oi == NULL) |
| 783 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 784 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 785 | ospf_vl_add (ospf, vl_data); |
Paul Jakma | b6eef00 | 2014-10-09 14:19:51 +0100 | [diff] [blame] | 786 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 787 | } |
| 788 | } |
| 789 | return vl_data; |
| 790 | } |
| 791 | |
| 792 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 793 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 794 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 795 | struct ospf_vl_config_data *vl_config) |
| 796 | { |
| 797 | struct crypt_key *ck; |
| 798 | struct vty *vty; |
| 799 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 800 | |
| 801 | vty = vl_config->vty; |
| 802 | |
| 803 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 804 | { |
| 805 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 806 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 807 | } |
| 808 | |
| 809 | if (vl_config->auth_key) |
| 810 | { |
| 811 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 812 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | OSPF_AUTH_SIMPLE_SIZE); |
| 814 | } |
| 815 | else if (vl_config->md5_key) |
| 816 | { |
| 817 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 818 | != NULL) |
| 819 | { |
| 820 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 821 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 822 | return CMD_WARNING; |
| 823 | } |
| 824 | ck = ospf_crypt_key_new (); |
| 825 | ck->key_id = vl_config->crypto_key_id; |
| 826 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 827 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 828 | |
| 829 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 830 | } |
| 831 | else if (vl_config->crypto_key_id != 0) |
| 832 | { |
| 833 | /* Delete a key */ |
| 834 | |
| 835 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 836 | vl_config->crypto_key_id) == NULL) |
| 837 | { |
| 838 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 839 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 840 | return CMD_WARNING; |
| 841 | } |
| 842 | |
| 843 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 844 | |
| 845 | } |
| 846 | |
| 847 | return CMD_SUCCESS; |
| 848 | } |
| 849 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 850 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 852 | struct ospf_vl_config_data *vl_config) |
| 853 | { |
| 854 | struct interface *ifp = ifp = vl_data->vl_oi->ifp; |
| 855 | /* Virtual Link data initialised to defaults, so only set |
| 856 | if a value given */ |
| 857 | if (vl_config->hello_interval) |
| 858 | { |
| 859 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 860 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 861 | } |
| 862 | |
| 863 | if (vl_config->dead_interval) |
| 864 | { |
| 865 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 866 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 867 | } |
| 868 | |
| 869 | if (vl_config->retransmit_interval) |
| 870 | { |
| 871 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 872 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 873 | } |
| 874 | |
| 875 | if (vl_config->transmit_delay) |
| 876 | { |
| 877 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 878 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 879 | } |
| 880 | |
| 881 | return CMD_SUCCESS; |
| 882 | } |
| 883 | |
| 884 | |
| 885 | |
| 886 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 887 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 888 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 889 | { |
| 890 | struct ospf_vl_data *vl_data; |
| 891 | int ret; |
| 892 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 893 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 894 | if (!vl_data) |
| 895 | return CMD_WARNING; |
| 896 | |
| 897 | /* Process this one first as it can have a fatal result, which can |
| 898 | only logically occur if the virtual link exists already |
| 899 | Thus a command error does not result in a change to the |
| 900 | running configuration such as unexpectedly altered timer |
| 901 | values etc.*/ |
| 902 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 903 | if (ret != CMD_SUCCESS) |
| 904 | return ret; |
| 905 | |
| 906 | /* Set any time based parameters, these area already range checked */ |
| 907 | |
| 908 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 909 | if (ret != CMD_SUCCESS) |
| 910 | return ret; |
| 911 | |
| 912 | return CMD_SUCCESS; |
| 913 | |
| 914 | } |
| 915 | |
| 916 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 917 | */ |
| 918 | #define VLINK_HELPSTR_IPADDR \ |
| 919 | "OSPF area parameters\n" \ |
| 920 | "OSPF area ID in IP address format\n" \ |
| 921 | "OSPF area ID as a decimal value\n" \ |
| 922 | "Configure a virtual link\n" \ |
| 923 | "Router ID of the remote ABR\n" |
| 924 | |
| 925 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 926 | "Enable authentication on this virtual link\n" \ |
| 927 | "dummy string \n" |
| 928 | |
| 929 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 930 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 931 | "Use null authentication\n" \ |
| 932 | "Use message-digest authentication\n" |
| 933 | |
| 934 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 935 | "Time between HELLO packets\n" \ |
| 936 | "Time between retransmitting lost link state advertisements\n" \ |
| 937 | "Link state transmit delay\n" \ |
| 938 | "Interval after which a neighbor is declared dead\n" |
| 939 | |
| 940 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 941 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 942 | "Seconds\n" |
| 943 | |
| 944 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 945 | "Authentication password (key)\n" \ |
| 946 | "The OSPF password (key)" |
| 947 | |
| 948 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 949 | "Message digest authentication password (key)\n" \ |
| 950 | "dummy string \n" \ |
| 951 | "Key ID\n" \ |
| 952 | "Use MD5 algorithm\n" \ |
| 953 | "The OSPF password (key)" |
| 954 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 955 | DEFUN (ospf_area_vlink, |
| 956 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 957 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 958 | VLINK_HELPSTR_IPADDR) |
| 959 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 960 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 961 | struct ospf_vl_config_data vl_config; |
| 962 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 963 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 964 | int i; |
| 965 | int ret; |
| 966 | |
| 967 | ospf_vl_config_data_init(&vl_config, vty); |
| 968 | |
| 969 | /* Read off first 2 parameters and check them */ |
| 970 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 971 | if (ret < 0) |
| 972 | { |
| 973 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 974 | return CMD_WARNING; |
| 975 | } |
| 976 | |
| 977 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 978 | if (! ret) |
| 979 | { |
| 980 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 981 | VTY_NEWLINE); |
| 982 | return CMD_WARNING; |
| 983 | } |
| 984 | |
| 985 | if (argc <=2) |
| 986 | { |
| 987 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 988 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 989 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | /* Deal with other parameters */ |
| 993 | for (i=2; i < argc; i++) |
| 994 | { |
| 995 | |
| 996 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 997 | |
| 998 | switch (argv[i][0]) |
| 999 | { |
| 1000 | |
| 1001 | case 'a': |
| 1002 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1003 | { |
| 1004 | /* authentication-key - this option can occur anywhere on |
| 1005 | command line. At start of command line |
| 1006 | must check for authentication option. */ |
| 1007 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1008 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 1009 | vl_config.auth_key = auth_key; |
| 1010 | i++; |
| 1011 | } |
| 1012 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1013 | { |
| 1014 | /* authentication - this option can only occur at start |
| 1015 | of command line */ |
| 1016 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 1017 | if ((i+1) < argc) |
| 1018 | { |
| 1019 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 1020 | { |
| 1021 | /* "authentication null" */ |
| 1022 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 1023 | i++; |
| 1024 | } |
| 1025 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 1026 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 1027 | { |
| 1028 | /* "authentication message-digest" */ |
| 1029 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1030 | i++; |
| 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | break; |
| 1035 | |
| 1036 | case 'm': |
| 1037 | /* message-digest-key */ |
| 1038 | i++; |
| 1039 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1040 | if (vl_config.crypto_key_id < 0) |
| 1041 | return CMD_WARNING; |
| 1042 | i++; |
| 1043 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 1044 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 1045 | vl_config.md5_key = md5_key; |
| 1046 | break; |
| 1047 | |
| 1048 | case 'h': |
| 1049 | /* Hello interval */ |
| 1050 | i++; |
| 1051 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 1052 | if (vl_config.hello_interval < 0) |
| 1053 | return CMD_WARNING; |
| 1054 | break; |
| 1055 | |
| 1056 | case 'r': |
| 1057 | /* Retransmit Interval */ |
| 1058 | i++; |
| 1059 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1060 | if (vl_config.retransmit_interval < 0) |
| 1061 | return CMD_WARNING; |
| 1062 | break; |
| 1063 | |
| 1064 | case 't': |
| 1065 | /* Transmit Delay */ |
| 1066 | i++; |
| 1067 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1068 | if (vl_config.transmit_delay < 0) |
| 1069 | return CMD_WARNING; |
| 1070 | break; |
| 1071 | |
| 1072 | case 'd': |
| 1073 | /* Dead Interval */ |
| 1074 | i++; |
| 1075 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1076 | if (vl_config.dead_interval < 0) |
| 1077 | return CMD_WARNING; |
| 1078 | break; |
| 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | |
| 1083 | /* Action configuration */ |
| 1084 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1085 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1086 | |
| 1087 | } |
| 1088 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1089 | DEFUN (no_ospf_area_vlink, |
| 1090 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1091 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1092 | NO_STR |
| 1093 | VLINK_HELPSTR_IPADDR) |
| 1094 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1095 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1096 | struct ospf_area *area; |
| 1097 | struct ospf_vl_config_data vl_config; |
| 1098 | struct ospf_vl_data *vl_data = NULL; |
| 1099 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1100 | int i; |
| 1101 | int ret, format; |
| 1102 | |
| 1103 | ospf_vl_config_data_init(&vl_config, vty); |
| 1104 | |
| 1105 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1106 | if (ret < 0) |
| 1107 | { |
| 1108 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1109 | return CMD_WARNING; |
| 1110 | } |
| 1111 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1112 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1113 | if (!area) |
| 1114 | { |
| 1115 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1116 | return CMD_WARNING; |
| 1117 | } |
| 1118 | |
| 1119 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1120 | if (! ret) |
| 1121 | { |
| 1122 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1123 | VTY_NEWLINE); |
| 1124 | return CMD_WARNING; |
| 1125 | } |
| 1126 | |
| 1127 | if (argc <=2) |
| 1128 | { |
| 1129 | /* Basic VLink no command */ |
| 1130 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 1131 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1132 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1133 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1134 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1135 | |
| 1136 | return CMD_SUCCESS; |
| 1137 | } |
| 1138 | |
| 1139 | /* If we are down here, we are reseting parameters */ |
| 1140 | |
| 1141 | /* Deal with other parameters */ |
| 1142 | for (i=2; i < argc; i++) |
| 1143 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1144 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1145 | |
| 1146 | switch (argv[i][0]) |
| 1147 | { |
| 1148 | |
| 1149 | case 'a': |
| 1150 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1151 | { |
| 1152 | /* authentication-key - this option can occur anywhere on |
| 1153 | command line. At start of command line |
| 1154 | must check for authentication option. */ |
| 1155 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1156 | vl_config.auth_key = auth_key; |
| 1157 | } |
| 1158 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1159 | { |
| 1160 | /* authentication - this option can only occur at start |
| 1161 | of command line */ |
| 1162 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1163 | } |
| 1164 | break; |
| 1165 | |
| 1166 | case 'm': |
| 1167 | /* message-digest-key */ |
| 1168 | /* Delete one key */ |
| 1169 | i++; |
| 1170 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1171 | if (vl_config.crypto_key_id < 0) |
| 1172 | return CMD_WARNING; |
| 1173 | vl_config.md5_key = NULL; |
| 1174 | break; |
| 1175 | |
| 1176 | case 'h': |
| 1177 | /* Hello interval */ |
| 1178 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1179 | break; |
| 1180 | |
| 1181 | case 'r': |
| 1182 | /* Retransmit Interval */ |
| 1183 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1184 | break; |
| 1185 | |
| 1186 | case 't': |
| 1187 | /* Transmit Delay */ |
| 1188 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1189 | break; |
| 1190 | |
| 1191 | case 'd': |
| 1192 | /* Dead Interval */ |
| 1193 | i++; |
| 1194 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1195 | break; |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | /* Action configuration */ |
| 1201 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1202 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1203 | } |
| 1204 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1205 | ALIAS (ospf_area_vlink, |
| 1206 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1207 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1208 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1209 | VLINK_HELPSTR_IPADDR |
| 1210 | VLINK_HELPSTR_TIME_PARAM) |
| 1211 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1212 | ALIAS (no_ospf_area_vlink, |
| 1213 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1214 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1215 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1216 | NO_STR |
| 1217 | VLINK_HELPSTR_IPADDR |
| 1218 | VLINK_HELPSTR_TIME_PARAM) |
| 1219 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1220 | ALIAS (ospf_area_vlink, |
| 1221 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1222 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1223 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1224 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1225 | VLINK_HELPSTR_IPADDR |
| 1226 | VLINK_HELPSTR_TIME_PARAM |
| 1227 | VLINK_HELPSTR_TIME_PARAM) |
| 1228 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1229 | ALIAS (no_ospf_area_vlink, |
| 1230 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1231 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1232 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1233 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1234 | NO_STR |
| 1235 | VLINK_HELPSTR_IPADDR |
| 1236 | VLINK_HELPSTR_TIME_PARAM |
| 1237 | VLINK_HELPSTR_TIME_PARAM) |
| 1238 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1239 | ALIAS (ospf_area_vlink, |
| 1240 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1241 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1242 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1243 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1244 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 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 (no_ospf_area_vlink, |
| 1251 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1252 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1253 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1254 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1255 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1256 | NO_STR |
| 1257 | VLINK_HELPSTR_IPADDR |
| 1258 | VLINK_HELPSTR_TIME_PARAM |
| 1259 | VLINK_HELPSTR_TIME_PARAM |
| 1260 | VLINK_HELPSTR_TIME_PARAM) |
| 1261 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1262 | ALIAS (ospf_area_vlink, |
| 1263 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1264 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1265 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1266 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1267 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1268 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1269 | VLINK_HELPSTR_IPADDR |
| 1270 | VLINK_HELPSTR_TIME_PARAM |
| 1271 | VLINK_HELPSTR_TIME_PARAM |
| 1272 | VLINK_HELPSTR_TIME_PARAM |
| 1273 | VLINK_HELPSTR_TIME_PARAM) |
| 1274 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1275 | ALIAS (no_ospf_area_vlink, |
| 1276 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1277 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1278 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1279 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1280 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1281 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1282 | NO_STR |
| 1283 | VLINK_HELPSTR_IPADDR |
| 1284 | VLINK_HELPSTR_TIME_PARAM |
| 1285 | VLINK_HELPSTR_TIME_PARAM |
| 1286 | VLINK_HELPSTR_TIME_PARAM |
| 1287 | VLINK_HELPSTR_TIME_PARAM) |
| 1288 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1289 | ALIAS (ospf_area_vlink, |
| 1290 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1291 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1292 | "(authentication|) (message-digest|null)", |
| 1293 | VLINK_HELPSTR_IPADDR |
| 1294 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1295 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1296 | ALIAS (ospf_area_vlink, |
| 1297 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1298 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1299 | "(authentication|)", |
| 1300 | VLINK_HELPSTR_IPADDR |
| 1301 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1302 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1303 | ALIAS (no_ospf_area_vlink, |
| 1304 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1305 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1306 | "(authentication|)", |
| 1307 | NO_STR |
| 1308 | VLINK_HELPSTR_IPADDR |
| 1309 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1310 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1311 | ALIAS (ospf_area_vlink, |
| 1312 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1313 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1314 | "(message-digest-key|) <1-255> md5 KEY", |
| 1315 | VLINK_HELPSTR_IPADDR |
| 1316 | VLINK_HELPSTR_AUTH_MD5) |
| 1317 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1318 | ALIAS (no_ospf_area_vlink, |
| 1319 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1320 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1321 | "(message-digest-key|) <1-255>", |
| 1322 | NO_STR |
| 1323 | VLINK_HELPSTR_IPADDR |
| 1324 | VLINK_HELPSTR_AUTH_MD5) |
| 1325 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1326 | ALIAS (ospf_area_vlink, |
| 1327 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1328 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1329 | "(authentication-key|) AUTH_KEY", |
| 1330 | VLINK_HELPSTR_IPADDR |
| 1331 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1332 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1333 | ALIAS (no_ospf_area_vlink, |
| 1334 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1335 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1336 | "(authentication-key|)", |
| 1337 | NO_STR |
| 1338 | VLINK_HELPSTR_IPADDR |
| 1339 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1340 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1341 | ALIAS (ospf_area_vlink, |
| 1342 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1343 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1344 | "(authentication|) (message-digest|null) " |
| 1345 | "(authentication-key|) AUTH_KEY", |
| 1346 | VLINK_HELPSTR_IPADDR |
| 1347 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1348 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1349 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1350 | ALIAS (ospf_area_vlink, |
| 1351 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1352 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1353 | "(authentication|) " |
| 1354 | "(authentication-key|) AUTH_KEY", |
| 1355 | VLINK_HELPSTR_IPADDR |
| 1356 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1357 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1358 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1359 | ALIAS (no_ospf_area_vlink, |
| 1360 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1361 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1362 | "(authentication|) " |
| 1363 | "(authentication-key|)", |
| 1364 | NO_STR |
| 1365 | VLINK_HELPSTR_IPADDR |
| 1366 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1367 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1368 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1369 | ALIAS (ospf_area_vlink, |
| 1370 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1371 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1372 | "(authentication|) (message-digest|null) " |
| 1373 | "(message-digest-key|) <1-255> md5 KEY", |
| 1374 | VLINK_HELPSTR_IPADDR |
| 1375 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1376 | VLINK_HELPSTR_AUTH_MD5) |
| 1377 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1378 | ALIAS (ospf_area_vlink, |
| 1379 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1380 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1381 | "(authentication|) " |
| 1382 | "(message-digest-key|) <1-255> md5 KEY", |
| 1383 | VLINK_HELPSTR_IPADDR |
| 1384 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1385 | VLINK_HELPSTR_AUTH_MD5) |
| 1386 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1387 | ALIAS (no_ospf_area_vlink, |
| 1388 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1389 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1390 | "(authentication|) " |
| 1391 | "(message-digest-key|)", |
| 1392 | NO_STR |
| 1393 | VLINK_HELPSTR_IPADDR |
| 1394 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1395 | VLINK_HELPSTR_AUTH_MD5) |
| 1396 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1397 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1398 | DEFUN (ospf_area_shortcut, |
| 1399 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1400 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1401 | "OSPF area parameters\n" |
| 1402 | "OSPF area ID in IP address format\n" |
| 1403 | "OSPF area ID as a decimal value\n" |
| 1404 | "Configure the area's shortcutting mode\n" |
| 1405 | "Set default shortcutting behavior\n" |
| 1406 | "Enable shortcutting through the area\n" |
| 1407 | "Disable shortcutting through the area\n") |
| 1408 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1409 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1410 | struct ospf_area *area; |
| 1411 | struct in_addr area_id; |
| 1412 | int mode; |
| 1413 | int format; |
| 1414 | |
| 1415 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1416 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1417 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | |
| 1419 | if (strncmp (argv[1], "de", 2) == 0) |
| 1420 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1421 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1422 | mode = OSPF_SHORTCUT_DISABLE; |
| 1423 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1424 | mode = OSPF_SHORTCUT_ENABLE; |
| 1425 | else |
| 1426 | return CMD_WARNING; |
| 1427 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1428 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1429 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1430 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1431 | vty_out (vty, "Shortcut area setting will take effect " |
| 1432 | "only when the router is configured as Shortcut ABR%s", |
| 1433 | VTY_NEWLINE); |
| 1434 | |
| 1435 | return CMD_SUCCESS; |
| 1436 | } |
| 1437 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1438 | DEFUN (no_ospf_area_shortcut, |
| 1439 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1440 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1441 | NO_STR |
| 1442 | "OSPF area parameters\n" |
| 1443 | "OSPF area ID in IP address format\n" |
| 1444 | "OSPF area ID as a decimal value\n" |
| 1445 | "Deconfigure the area's shortcutting mode\n" |
| 1446 | "Deconfigure enabled shortcutting through the area\n" |
| 1447 | "Deconfigure disabled shortcutting through the area\n") |
| 1448 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1449 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1450 | struct ospf_area *area; |
| 1451 | struct in_addr area_id; |
| 1452 | int format; |
| 1453 | |
| 1454 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1455 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1456 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1457 | if (!area) |
| 1458 | return CMD_SUCCESS; |
| 1459 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1460 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1461 | |
| 1462 | return CMD_SUCCESS; |
| 1463 | } |
| 1464 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1465 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1466 | DEFUN (ospf_area_stub, |
| 1467 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1468 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1469 | "OSPF area parameters\n" |
| 1470 | "OSPF area ID in IP address format\n" |
| 1471 | "OSPF area ID as a decimal value\n" |
| 1472 | "Configure OSPF area as stub\n") |
| 1473 | { |
| 1474 | struct ospf *ospf = vty->index; |
| 1475 | struct in_addr area_id; |
| 1476 | int ret, format; |
| 1477 | |
| 1478 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1479 | |
| 1480 | ret = ospf_area_stub_set (ospf, area_id); |
| 1481 | if (ret == 0) |
| 1482 | { |
| 1483 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1484 | VTY_NEWLINE); |
| 1485 | return CMD_WARNING; |
| 1486 | } |
| 1487 | |
| 1488 | ospf_area_no_summary_unset (ospf, area_id); |
| 1489 | |
| 1490 | return CMD_SUCCESS; |
| 1491 | } |
| 1492 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1493 | DEFUN (ospf_area_stub_no_summary, |
| 1494 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1495 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1496 | "OSPF stub parameters\n" |
| 1497 | "OSPF area ID in IP address format\n" |
| 1498 | "OSPF area ID as a decimal value\n" |
| 1499 | "Configure OSPF area as stub\n" |
| 1500 | "Do not inject inter-area routes into stub\n") |
| 1501 | { |
| 1502 | struct ospf *ospf = vty->index; |
| 1503 | struct in_addr area_id; |
| 1504 | int ret, format; |
| 1505 | |
| 1506 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1507 | |
| 1508 | ret = ospf_area_stub_set (ospf, area_id); |
| 1509 | if (ret == 0) |
| 1510 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1511 | 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] | 1512 | VTY_NEWLINE); |
| 1513 | return CMD_WARNING; |
| 1514 | } |
| 1515 | |
| 1516 | ospf_area_no_summary_set (ospf, area_id); |
| 1517 | |
| 1518 | return CMD_SUCCESS; |
| 1519 | } |
| 1520 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1521 | DEFUN (no_ospf_area_stub, |
| 1522 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1523 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1524 | NO_STR |
| 1525 | "OSPF area parameters\n" |
| 1526 | "OSPF area ID in IP address format\n" |
| 1527 | "OSPF area ID as a decimal value\n" |
| 1528 | "Configure OSPF area as stub\n") |
| 1529 | { |
| 1530 | struct ospf *ospf = vty->index; |
| 1531 | struct in_addr area_id; |
| 1532 | int format; |
| 1533 | |
| 1534 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1535 | |
| 1536 | ospf_area_stub_unset (ospf, area_id); |
| 1537 | ospf_area_no_summary_unset (ospf, area_id); |
| 1538 | |
| 1539 | return CMD_SUCCESS; |
| 1540 | } |
| 1541 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1542 | DEFUN (no_ospf_area_stub_no_summary, |
| 1543 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1544 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1545 | NO_STR |
| 1546 | "OSPF area parameters\n" |
| 1547 | "OSPF area ID in IP address format\n" |
| 1548 | "OSPF area ID as a decimal value\n" |
| 1549 | "Configure OSPF area as stub\n" |
| 1550 | "Do not inject inter-area routes into area\n") |
| 1551 | { |
| 1552 | struct ospf *ospf = vty->index; |
| 1553 | struct in_addr area_id; |
| 1554 | int format; |
| 1555 | |
| 1556 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1557 | ospf_area_no_summary_unset (ospf, area_id); |
| 1558 | |
| 1559 | return CMD_SUCCESS; |
| 1560 | } |
| 1561 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1562 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1563 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1564 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1565 | { |
| 1566 | struct ospf *ospf = vty->index; |
| 1567 | struct in_addr area_id; |
| 1568 | int ret, format; |
| 1569 | |
| 1570 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1571 | |
| 1572 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1573 | if (ret == 0) |
| 1574 | { |
| 1575 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1576 | VTY_NEWLINE); |
| 1577 | return CMD_WARNING; |
| 1578 | } |
| 1579 | |
| 1580 | if (argc > 1) |
| 1581 | { |
| 1582 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1583 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1584 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1585 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1586 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1587 | OSPF_NSSA_ROLE_NEVER); |
| 1588 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1589 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1590 | OSPF_NSSA_ROLE_ALWAYS); |
| 1591 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1592 | else |
| 1593 | { |
| 1594 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1595 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1596 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1597 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1598 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1599 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1600 | else |
| 1601 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1602 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1603 | ospf_schedule_abr_task (ospf); |
| 1604 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1605 | return CMD_SUCCESS; |
| 1606 | } |
| 1607 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1608 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1609 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1610 | "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] | 1611 | "OSPF area parameters\n" |
| 1612 | "OSPF area ID in IP address format\n" |
| 1613 | "OSPF area ID as a decimal value\n" |
| 1614 | "Configure OSPF area as nssa\n" |
| 1615 | "Configure NSSA-ABR for translate election (default)\n" |
| 1616 | "Configure NSSA-ABR to never translate\n" |
| 1617 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1618 | "Do not inject inter-area routes into nssa\n") |
| 1619 | { |
| 1620 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1621 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1622 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1623 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1624 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1625 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1626 | "OSPF area parameters\n" |
| 1627 | "OSPF area ID in IP address format\n" |
| 1628 | "OSPF area ID as a decimal value\n" |
| 1629 | "Configure OSPF area as nssa\n" |
| 1630 | "Configure NSSA-ABR for translate election (default)\n" |
| 1631 | "Configure NSSA-ABR to never translate\n" |
| 1632 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1633 | { |
| 1634 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1635 | } |
| 1636 | |
| 1637 | DEFUN (ospf_area_nssa, |
| 1638 | ospf_area_nssa_cmd, |
| 1639 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1640 | "OSPF area parameters\n" |
| 1641 | "OSPF area ID in IP address format\n" |
| 1642 | "OSPF area ID as a decimal value\n" |
| 1643 | "Configure OSPF area as nssa\n") |
| 1644 | { |
| 1645 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1646 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1647 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1648 | DEFUN (ospf_area_nssa_no_summary, |
| 1649 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1650 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1651 | "OSPF area parameters\n" |
| 1652 | "OSPF area ID in IP address format\n" |
| 1653 | "OSPF area ID as a decimal value\n" |
| 1654 | "Configure OSPF area as nssa\n" |
| 1655 | "Do not inject inter-area routes into nssa\n") |
| 1656 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1657 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1658 | } |
| 1659 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1660 | DEFUN (no_ospf_area_nssa, |
| 1661 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1662 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1663 | NO_STR |
| 1664 | "OSPF area parameters\n" |
| 1665 | "OSPF area ID in IP address format\n" |
| 1666 | "OSPF area ID as a decimal value\n" |
| 1667 | "Configure OSPF area as nssa\n") |
| 1668 | { |
| 1669 | struct ospf *ospf = vty->index; |
| 1670 | struct in_addr area_id; |
| 1671 | int format; |
| 1672 | |
| 1673 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1674 | |
| 1675 | ospf_area_nssa_unset (ospf, area_id); |
| 1676 | ospf_area_no_summary_unset (ospf, area_id); |
| 1677 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1678 | ospf_schedule_abr_task (ospf); |
| 1679 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1680 | return CMD_SUCCESS; |
| 1681 | } |
| 1682 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1683 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1684 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1685 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1686 | NO_STR |
| 1687 | "OSPF area parameters\n" |
| 1688 | "OSPF area ID in IP address format\n" |
| 1689 | "OSPF area ID as a decimal value\n" |
| 1690 | "Configure OSPF area as nssa\n" |
| 1691 | "Do not inject inter-area routes into nssa\n") |
| 1692 | { |
| 1693 | struct ospf *ospf = vty->index; |
| 1694 | struct in_addr area_id; |
| 1695 | int format; |
| 1696 | |
| 1697 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1698 | ospf_area_no_summary_unset (ospf, area_id); |
| 1699 | |
| 1700 | return CMD_SUCCESS; |
| 1701 | } |
| 1702 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1703 | DEFUN (ospf_area_default_cost, |
| 1704 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1705 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1706 | "OSPF area parameters\n" |
| 1707 | "OSPF area ID in IP address format\n" |
| 1708 | "OSPF area ID as a decimal value\n" |
| 1709 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1710 | "Stub's advertised default summary cost\n") |
| 1711 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1712 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1713 | struct ospf_area *area; |
| 1714 | struct in_addr area_id; |
| 1715 | u_int32_t cost; |
| 1716 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1717 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1718 | |
| 1719 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1720 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1721 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1722 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1723 | |
| 1724 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1725 | { |
| 1726 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1727 | return CMD_WARNING; |
| 1728 | } |
| 1729 | |
| 1730 | area->default_cost = cost; |
| 1731 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1732 | p.family = AF_INET; |
| 1733 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1734 | p.prefixlen = 0; |
| 1735 | if (IS_DEBUG_OSPF_EVENT) |
| 1736 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1737 | "announcing 0.0.0.0/0 to area %s", |
| 1738 | inet_ntoa (area->area_id)); |
| 1739 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1740 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1741 | return CMD_SUCCESS; |
| 1742 | } |
| 1743 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1744 | DEFUN (no_ospf_area_default_cost, |
| 1745 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1746 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1747 | NO_STR |
| 1748 | "OSPF area parameters\n" |
| 1749 | "OSPF area ID in IP address format\n" |
| 1750 | "OSPF area ID as a decimal value\n" |
| 1751 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1752 | "Stub's advertised default summary cost\n") |
| 1753 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1754 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1755 | struct ospf_area *area; |
| 1756 | struct in_addr area_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1757 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1758 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1759 | |
| 1760 | 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] | 1761 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1762 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1763 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1764 | if (area == NULL) |
| 1765 | return CMD_SUCCESS; |
| 1766 | |
| 1767 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1768 | { |
| 1769 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1770 | return CMD_WARNING; |
| 1771 | } |
| 1772 | |
| 1773 | area->default_cost = 1; |
| 1774 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1775 | p.family = AF_INET; |
| 1776 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1777 | p.prefixlen = 0; |
| 1778 | if (IS_DEBUG_OSPF_EVENT) |
| 1779 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1780 | "announcing 0.0.0.0/0 to area %s", |
| 1781 | inet_ntoa (area->area_id)); |
| 1782 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1783 | |
| 1784 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1785 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1786 | |
| 1787 | return CMD_SUCCESS; |
| 1788 | } |
| 1789 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1790 | DEFUN (ospf_area_export_list, |
| 1791 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1793 | "OSPF area parameters\n" |
| 1794 | "OSPF area ID in IP address format\n" |
| 1795 | "OSPF area ID as a decimal value\n" |
| 1796 | "Set the filter for networks announced to other areas\n" |
| 1797 | "Name of the access-list\n") |
| 1798 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1799 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1800 | struct ospf_area *area; |
| 1801 | struct in_addr area_id; |
| 1802 | int format; |
| 1803 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1804 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1805 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1806 | area = ospf_area_get (ospf, area_id, format); |
| 1807 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1808 | |
| 1809 | return CMD_SUCCESS; |
| 1810 | } |
| 1811 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1812 | DEFUN (no_ospf_area_export_list, |
| 1813 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1814 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1815 | NO_STR |
| 1816 | "OSPF area parameters\n" |
| 1817 | "OSPF area ID in IP address format\n" |
| 1818 | "OSPF area ID as a decimal value\n" |
| 1819 | "Unset the filter for networks announced to other areas\n" |
| 1820 | "Name of the access-list\n") |
| 1821 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1822 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1823 | struct ospf_area *area; |
| 1824 | struct in_addr area_id; |
| 1825 | int format; |
| 1826 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1827 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1828 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1829 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1830 | if (area == NULL) |
| 1831 | return CMD_SUCCESS; |
| 1832 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1833 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1834 | |
| 1835 | return CMD_SUCCESS; |
| 1836 | } |
| 1837 | |
| 1838 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1839 | DEFUN (ospf_area_import_list, |
| 1840 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1841 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1842 | "OSPF area parameters\n" |
| 1843 | "OSPF area ID in IP address format\n" |
| 1844 | "OSPF area ID as a decimal value\n" |
| 1845 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1846 | "Name of the access-list\n") |
| 1847 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1848 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1849 | struct ospf_area *area; |
| 1850 | struct in_addr area_id; |
| 1851 | int format; |
| 1852 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1853 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1854 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1855 | area = ospf_area_get (ospf, area_id, format); |
| 1856 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1857 | |
| 1858 | return CMD_SUCCESS; |
| 1859 | } |
| 1860 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1861 | DEFUN (no_ospf_area_import_list, |
| 1862 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1863 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1864 | NO_STR |
| 1865 | "OSPF area parameters\n" |
| 1866 | "OSPF area ID in IP address format\n" |
| 1867 | "OSPF area ID as a decimal value\n" |
| 1868 | "Unset the filter for networks announced to other areas\n" |
| 1869 | "Name of the access-list\n") |
| 1870 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1871 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1872 | struct ospf_area *area; |
| 1873 | struct in_addr area_id; |
| 1874 | int format; |
| 1875 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1876 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1877 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1878 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1879 | if (area == NULL) |
| 1880 | return CMD_SUCCESS; |
| 1881 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1882 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1883 | |
| 1884 | return CMD_SUCCESS; |
| 1885 | } |
| 1886 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1887 | DEFUN (ospf_area_filter_list, |
| 1888 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1889 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1890 | "OSPF area parameters\n" |
| 1891 | "OSPF area ID in IP address format\n" |
| 1892 | "OSPF area ID as a decimal value\n" |
| 1893 | "Filter networks between OSPF areas\n" |
| 1894 | "Filter prefixes between OSPF areas\n" |
| 1895 | "Name of an IP prefix-list\n" |
| 1896 | "Filter networks sent to this area\n" |
| 1897 | "Filter networks sent from this area\n") |
| 1898 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1899 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1900 | struct ospf_area *area; |
| 1901 | struct in_addr area_id; |
| 1902 | struct prefix_list *plist; |
| 1903 | int format; |
| 1904 | |
| 1905 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1906 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1907 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1908 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1909 | if (strncmp (argv[2], "in", 2) == 0) |
| 1910 | { |
| 1911 | PREFIX_LIST_IN (area) = plist; |
| 1912 | if (PREFIX_NAME_IN (area)) |
| 1913 | free (PREFIX_NAME_IN (area)); |
| 1914 | |
| 1915 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1916 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1917 | } |
| 1918 | else |
| 1919 | { |
| 1920 | PREFIX_LIST_OUT (area) = plist; |
| 1921 | if (PREFIX_NAME_OUT (area)) |
| 1922 | free (PREFIX_NAME_OUT (area)); |
| 1923 | |
| 1924 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1925 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1926 | } |
| 1927 | |
| 1928 | return CMD_SUCCESS; |
| 1929 | } |
| 1930 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1931 | DEFUN (no_ospf_area_filter_list, |
| 1932 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1933 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1934 | NO_STR |
| 1935 | "OSPF area parameters\n" |
| 1936 | "OSPF area ID in IP address format\n" |
| 1937 | "OSPF area ID as a decimal value\n" |
| 1938 | "Filter networks between OSPF areas\n" |
| 1939 | "Filter prefixes between OSPF areas\n" |
| 1940 | "Name of an IP prefix-list\n" |
| 1941 | "Filter networks sent to this area\n" |
| 1942 | "Filter networks sent from this area\n") |
| 1943 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1944 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1945 | struct ospf_area *area; |
| 1946 | struct in_addr area_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1947 | int format; |
| 1948 | |
| 1949 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1950 | |
Paul Jakma | 1a8ec2b | 2006-05-11 13:34:08 +0000 | [diff] [blame] | 1951 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
| 1952 | return CMD_SUCCESS; |
| 1953 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1954 | if (strncmp (argv[2], "in", 2) == 0) |
| 1955 | { |
| 1956 | if (PREFIX_NAME_IN (area)) |
| 1957 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1958 | return CMD_SUCCESS; |
| 1959 | |
| 1960 | PREFIX_LIST_IN (area) = NULL; |
| 1961 | if (PREFIX_NAME_IN (area)) |
| 1962 | free (PREFIX_NAME_IN (area)); |
| 1963 | |
| 1964 | PREFIX_NAME_IN (area) = NULL; |
| 1965 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1966 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1967 | } |
| 1968 | else |
| 1969 | { |
| 1970 | if (PREFIX_NAME_OUT (area)) |
| 1971 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 1972 | return CMD_SUCCESS; |
| 1973 | |
| 1974 | PREFIX_LIST_OUT (area) = NULL; |
| 1975 | if (PREFIX_NAME_OUT (area)) |
| 1976 | free (PREFIX_NAME_OUT (area)); |
| 1977 | |
| 1978 | PREFIX_NAME_OUT (area) = NULL; |
| 1979 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1980 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1981 | } |
| 1982 | |
| 1983 | return CMD_SUCCESS; |
| 1984 | } |
| 1985 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1986 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1987 | DEFUN (ospf_area_authentication_message_digest, |
| 1988 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1989 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 1990 | "OSPF area parameters\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 1991 | "OSPF area ID in IP address format\n" |
| 1992 | "OSPF area ID as a decimal value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1993 | "Enable authentication\n" |
| 1994 | "Use message-digest authentication\n") |
| 1995 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1996 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1997 | struct ospf_area *area; |
| 1998 | struct in_addr area_id; |
| 1999 | int format; |
| 2000 | |
| 2001 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2002 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2003 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2004 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 2005 | |
| 2006 | return CMD_SUCCESS; |
| 2007 | } |
| 2008 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2009 | DEFUN (ospf_area_authentication, |
| 2010 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2011 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 2012 | "OSPF area parameters\n" |
| 2013 | "OSPF area ID in IP address format\n" |
| 2014 | "OSPF area ID as a decimal value\n" |
| 2015 | "Enable authentication\n") |
| 2016 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2017 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2018 | struct ospf_area *area; |
| 2019 | struct in_addr area_id; |
| 2020 | int format; |
| 2021 | |
| 2022 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2023 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2024 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2025 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 2026 | |
| 2027 | return CMD_SUCCESS; |
| 2028 | } |
| 2029 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2030 | DEFUN (no_ospf_area_authentication, |
| 2031 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2032 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 2033 | NO_STR |
| 2034 | "OSPF area parameters\n" |
| 2035 | "OSPF area ID in IP address format\n" |
| 2036 | "OSPF area ID as a decimal value\n" |
| 2037 | "Enable authentication\n") |
| 2038 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2039 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2040 | struct ospf_area *area; |
| 2041 | struct in_addr area_id; |
| 2042 | int format; |
| 2043 | |
| 2044 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2045 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2046 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2047 | if (area == NULL) |
| 2048 | return CMD_SUCCESS; |
| 2049 | |
| 2050 | area->auth_type = OSPF_AUTH_NULL; |
| 2051 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2052 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2053 | |
| 2054 | return CMD_SUCCESS; |
| 2055 | } |
| 2056 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2057 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2058 | DEFUN (ospf_abr_type, |
| 2059 | ospf_abr_type_cmd, |
| 2060 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 2061 | "OSPF specific commands\n" |
| 2062 | "Set OSPF ABR type\n" |
| 2063 | "Alternative ABR, cisco implementation\n" |
| 2064 | "Alternative ABR, IBM implementation\n" |
| 2065 | "Shortcut ABR\n" |
| 2066 | "Standard behavior (RFC2328)\n") |
| 2067 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2068 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2069 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2070 | |
| 2071 | if (strncmp (argv[0], "c", 1) == 0) |
| 2072 | abr_type = OSPF_ABR_CISCO; |
| 2073 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2074 | abr_type = OSPF_ABR_IBM; |
| 2075 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2076 | abr_type = OSPF_ABR_SHORTCUT; |
| 2077 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2078 | abr_type = OSPF_ABR_STAND; |
| 2079 | else |
| 2080 | return CMD_WARNING; |
| 2081 | |
| 2082 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2083 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2084 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2085 | ospf->abr_type = abr_type; |
| 2086 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | return CMD_SUCCESS; |
| 2090 | } |
| 2091 | |
| 2092 | DEFUN (no_ospf_abr_type, |
| 2093 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2094 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2095 | NO_STR |
| 2096 | "OSPF specific commands\n" |
| 2097 | "Set OSPF ABR type\n" |
| 2098 | "Alternative ABR, cisco implementation\n" |
| 2099 | "Alternative ABR, IBM implementation\n" |
| 2100 | "Shortcut ABR\n") |
| 2101 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2102 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2103 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2104 | |
| 2105 | if (strncmp (argv[0], "c", 1) == 0) |
| 2106 | abr_type = OSPF_ABR_CISCO; |
| 2107 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2108 | abr_type = OSPF_ABR_IBM; |
Francesco Dolcini | 04d2331 | 2009-06-02 18:20:09 +0100 | [diff] [blame] | 2109 | else if (strncmp (argv[0], "sh", 2) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2110 | abr_type = OSPF_ABR_SHORTCUT; |
Francesco Dolcini | 04d2331 | 2009-06-02 18:20:09 +0100 | [diff] [blame] | 2111 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2112 | abr_type = OSPF_ABR_STAND; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2113 | else |
| 2114 | return CMD_WARNING; |
| 2115 | |
| 2116 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2117 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2118 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2119 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2120 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2121 | } |
| 2122 | |
| 2123 | return CMD_SUCCESS; |
| 2124 | } |
| 2125 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2126 | DEFUN (ospf_log_adjacency_changes, |
| 2127 | ospf_log_adjacency_changes_cmd, |
| 2128 | "log-adjacency-changes", |
| 2129 | "Log changes in adjacency state\n") |
| 2130 | { |
| 2131 | struct ospf *ospf = vty->index; |
| 2132 | |
| 2133 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2134 | return CMD_SUCCESS; |
| 2135 | } |
| 2136 | |
| 2137 | DEFUN (ospf_log_adjacency_changes_detail, |
| 2138 | ospf_log_adjacency_changes_detail_cmd, |
| 2139 | "log-adjacency-changes detail", |
| 2140 | "Log changes in adjacency state\n" |
| 2141 | "Log all state changes\n") |
| 2142 | { |
| 2143 | struct ospf *ospf = vty->index; |
| 2144 | |
| 2145 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2146 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2147 | return CMD_SUCCESS; |
| 2148 | } |
| 2149 | |
| 2150 | DEFUN (no_ospf_log_adjacency_changes, |
| 2151 | no_ospf_log_adjacency_changes_cmd, |
| 2152 | "no log-adjacency-changes", |
| 2153 | NO_STR |
| 2154 | "Log changes in adjacency state\n") |
| 2155 | { |
| 2156 | struct ospf *ospf = vty->index; |
| 2157 | |
| 2158 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2159 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2160 | return CMD_SUCCESS; |
| 2161 | } |
| 2162 | |
| 2163 | DEFUN (no_ospf_log_adjacency_changes_detail, |
| 2164 | no_ospf_log_adjacency_changes_detail_cmd, |
| 2165 | "no log-adjacency-changes detail", |
| 2166 | NO_STR |
| 2167 | "Log changes in adjacency state\n" |
| 2168 | "Log all state changes\n") |
| 2169 | { |
| 2170 | struct ospf *ospf = vty->index; |
| 2171 | |
| 2172 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2173 | return CMD_SUCCESS; |
| 2174 | } |
| 2175 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2176 | DEFUN (ospf_compatible_rfc1583, |
| 2177 | ospf_compatible_rfc1583_cmd, |
| 2178 | "compatible rfc1583", |
| 2179 | "OSPF compatibility list\n" |
| 2180 | "compatible with RFC 1583\n") |
| 2181 | { |
| 2182 | struct ospf *ospf = vty->index; |
| 2183 | |
| 2184 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2185 | { |
| 2186 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
Paul Jakma | b6eef00 | 2014-10-09 14:19:51 +0100 | [diff] [blame] | 2187 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2188 | } |
| 2189 | return CMD_SUCCESS; |
| 2190 | } |
| 2191 | |
| 2192 | DEFUN (no_ospf_compatible_rfc1583, |
| 2193 | no_ospf_compatible_rfc1583_cmd, |
| 2194 | "no compatible rfc1583", |
| 2195 | NO_STR |
| 2196 | "OSPF compatibility list\n" |
| 2197 | "compatible with RFC 1583\n") |
| 2198 | { |
| 2199 | struct ospf *ospf = vty->index; |
| 2200 | |
| 2201 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2202 | { |
| 2203 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
Paul Jakma | b6eef00 | 2014-10-09 14:19:51 +0100 | [diff] [blame] | 2204 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2205 | } |
| 2206 | return CMD_SUCCESS; |
| 2207 | } |
| 2208 | |
| 2209 | ALIAS (ospf_compatible_rfc1583, |
| 2210 | ospf_rfc1583_flag_cmd, |
| 2211 | "ospf rfc1583compatibility", |
| 2212 | "OSPF specific commands\n" |
| 2213 | "Enable the RFC1583Compatibility flag\n") |
| 2214 | |
| 2215 | ALIAS (no_ospf_compatible_rfc1583, |
| 2216 | no_ospf_rfc1583_flag_cmd, |
| 2217 | "no ospf rfc1583compatibility", |
| 2218 | NO_STR |
| 2219 | "OSPF specific commands\n" |
| 2220 | "Disable the RFC1583Compatibility flag\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2221 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2222 | static int |
| 2223 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2224 | unsigned int hold, |
| 2225 | unsigned int max) |
| 2226 | { |
| 2227 | struct ospf *ospf = vty->index; |
| 2228 | |
| 2229 | ospf->spf_delay = delay; |
| 2230 | ospf->spf_holdtime = hold; |
| 2231 | ospf->spf_max_holdtime = max; |
| 2232 | |
| 2233 | return CMD_SUCCESS; |
| 2234 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2235 | |
Michael Rossberg | 2ef762e | 2015-07-27 07:56:25 +0200 | [diff] [blame] | 2236 | DEFUN (ospf_timers_min_ls_interval, |
| 2237 | ospf_timers_min_ls_interval_cmd, |
| 2238 | "timers throttle lsa all <0-5000>", |
| 2239 | "Adjust routing timers\n" |
| 2240 | "Throttling adaptive timer\n" |
| 2241 | "LSA delay between transmissions\n" |
| 2242 | NO_STR |
| 2243 | "Delay (msec) between sending LSAs\n") |
| 2244 | { |
| 2245 | struct ospf *ospf = vty->index; |
| 2246 | unsigned int interval; |
| 2247 | |
| 2248 | if (argc != 1) |
| 2249 | { |
| 2250 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2251 | return CMD_WARNING; |
| 2252 | } |
| 2253 | |
| 2254 | VTY_GET_INTEGER ("LSA interval", interval, argv[0]); |
| 2255 | |
| 2256 | ospf->min_ls_interval = interval; |
| 2257 | |
| 2258 | return CMD_SUCCESS; |
| 2259 | } |
| 2260 | |
| 2261 | DEFUN (no_ospf_timers_min_ls_interval, |
| 2262 | no_ospf_timers_min_ls_interval_cmd, |
| 2263 | "no timers throttle lsa all", |
| 2264 | NO_STR |
| 2265 | "Adjust routing timers\n" |
| 2266 | "Throttling adaptive timer\n" |
| 2267 | "LSA delay between transmissions\n") |
| 2268 | { |
| 2269 | struct ospf *ospf = vty->index; |
| 2270 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; |
| 2271 | |
| 2272 | return CMD_SUCCESS; |
| 2273 | } |
| 2274 | |
| 2275 | DEFUN (ospf_timers_min_ls_arrival, |
| 2276 | ospf_timers_min_ls_arrival_cmd, |
| 2277 | "timers lsa arrival <0-1000>", |
| 2278 | "Adjust routing timers\n" |
| 2279 | "Throttling link state advertisement delays\n" |
| 2280 | "OSPF minimum arrival interval delay\n" |
| 2281 | "Delay (msec) between accepted LSAs\n") |
| 2282 | { |
| 2283 | struct ospf *ospf = vty->index; |
| 2284 | unsigned int arrival; |
| 2285 | |
| 2286 | if (argc != 1) |
| 2287 | { |
| 2288 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2289 | return CMD_WARNING; |
| 2290 | } |
| 2291 | |
| 2292 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); |
| 2293 | |
| 2294 | ospf->min_ls_arrival = arrival; |
| 2295 | |
| 2296 | return CMD_SUCCESS; |
| 2297 | } |
| 2298 | |
| 2299 | DEFUN (no_ospf_timers_min_ls_arrival, |
| 2300 | no_ospf_timers_min_ls_arrival_cmd, |
| 2301 | "no timers lsa arrival", |
| 2302 | NO_STR |
| 2303 | "Adjust routing timers\n" |
| 2304 | "Throttling link state advertisement delays\n" |
| 2305 | "OSPF minimum arrival interval delay\n") |
| 2306 | { |
| 2307 | struct ospf *ospf = vty->index; |
| 2308 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
| 2309 | |
| 2310 | return CMD_SUCCESS; |
| 2311 | } |
| 2312 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2313 | DEFUN (ospf_timers_throttle_spf, |
| 2314 | ospf_timers_throttle_spf_cmd, |
| 2315 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2316 | "Adjust routing timers\n" |
| 2317 | "Throttling adaptive timer\n" |
| 2318 | "OSPF SPF timers\n" |
| 2319 | "Delay (msec) from first change received till SPF calculation\n" |
| 2320 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2321 | "Maximum hold time (msec)\n") |
| 2322 | { |
| 2323 | unsigned int delay, hold, max; |
| 2324 | |
| 2325 | if (argc != 3) |
| 2326 | { |
| 2327 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2328 | return CMD_WARNING; |
| 2329 | } |
| 2330 | |
| 2331 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2332 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2333 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2334 | |
| 2335 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2336 | } |
| 2337 | |
| 2338 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2339 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2340 | "timers spf <0-4294967295> <0-4294967295>", |
| 2341 | "Adjust routing timers\n" |
| 2342 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2343 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2344 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2345 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2346 | unsigned int delay, hold; |
| 2347 | |
| 2348 | if (argc != 2) |
| 2349 | { |
| 2350 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2351 | return CMD_WARNING; |
| 2352 | } |
| 2353 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2354 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2355 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2356 | |
| 2357 | /* truncate down the second values if they're greater than 600000ms */ |
| 2358 | if (delay > (600000 / 1000)) |
| 2359 | delay = 600000; |
| 2360 | else if (delay == 0) |
| 2361 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2362 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2363 | if (hold > (600000 / 1000)) |
| 2364 | hold = 600000; |
| 2365 | |
| 2366 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2367 | } |
| 2368 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2369 | DEFUN (no_ospf_timers_throttle_spf, |
| 2370 | no_ospf_timers_throttle_spf_cmd, |
| 2371 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2372 | NO_STR |
| 2373 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2374 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | "OSPF SPF timers\n") |
| 2376 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2377 | return ospf_timers_spf_set (vty, |
| 2378 | OSPF_SPF_DELAY_DEFAULT, |
| 2379 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2380 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2381 | } |
| 2382 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2383 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2384 | no_ospf_timers_spf_cmd, |
| 2385 | "no timers spf", |
| 2386 | NO_STR |
| 2387 | "Adjust routing timers\n" |
| 2388 | "OSPF SPF timers\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2389 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2390 | DEFUN (ospf_neighbor, |
| 2391 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2392 | "neighbor A.B.C.D", |
| 2393 | NEIGHBOR_STR |
| 2394 | "Neighbor IP address\n") |
| 2395 | { |
| 2396 | struct ospf *ospf = vty->index; |
| 2397 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2398 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2399 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2400 | |
| 2401 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2402 | |
| 2403 | if (argc > 1) |
| 2404 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2405 | |
| 2406 | if (argc > 2) |
| 2407 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2408 | |
| 2409 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2410 | if (argc > 1) |
| 2411 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2412 | if (argc > 2) |
Andrew Certain | 1a61ad1 | 2012-12-04 12:50:23 -0800 | [diff] [blame] | 2413 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2414 | |
| 2415 | return CMD_SUCCESS; |
| 2416 | } |
| 2417 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2418 | ALIAS (ospf_neighbor, |
| 2419 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2420 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2421 | NEIGHBOR_STR |
| 2422 | "Neighbor IP address\n" |
| 2423 | "Neighbor Priority\n" |
| 2424 | "Priority\n" |
| 2425 | "Dead Neighbor Polling interval\n" |
| 2426 | "Seconds\n") |
| 2427 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2428 | ALIAS (ospf_neighbor, |
| 2429 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2430 | "neighbor A.B.C.D priority <0-255>", |
| 2431 | NEIGHBOR_STR |
| 2432 | "Neighbor IP address\n" |
| 2433 | "Neighbor Priority\n" |
| 2434 | "Seconds\n") |
| 2435 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2436 | DEFUN (ospf_neighbor_poll_interval, |
| 2437 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2438 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2439 | NEIGHBOR_STR |
| 2440 | "Neighbor IP address\n" |
| 2441 | "Dead Neighbor Polling interval\n" |
| 2442 | "Seconds\n") |
| 2443 | { |
| 2444 | struct ospf *ospf = vty->index; |
| 2445 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2446 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2447 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2448 | |
| 2449 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2450 | |
| 2451 | if (argc > 1) |
| 2452 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2453 | |
| 2454 | if (argc > 2) |
| 2455 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2456 | |
| 2457 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2458 | if (argc > 1) |
| 2459 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2460 | if (argc > 2) |
| 2461 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2462 | |
| 2463 | return CMD_SUCCESS; |
| 2464 | } |
| 2465 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2466 | ALIAS (ospf_neighbor_poll_interval, |
| 2467 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2468 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2469 | NEIGHBOR_STR |
| 2470 | "Neighbor address\n" |
| 2471 | "OSPF dead-router polling interval\n" |
| 2472 | "Seconds\n" |
| 2473 | "OSPF priority of non-broadcast neighbor\n" |
| 2474 | "Priority\n") |
| 2475 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2476 | DEFUN (no_ospf_neighbor, |
| 2477 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2478 | "no neighbor A.B.C.D", |
| 2479 | NO_STR |
| 2480 | NEIGHBOR_STR |
| 2481 | "Neighbor IP address\n") |
| 2482 | { |
| 2483 | struct ospf *ospf = vty->index; |
| 2484 | struct in_addr nbr_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2485 | |
| 2486 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2487 | |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 2488 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2489 | |
| 2490 | return CMD_SUCCESS; |
| 2491 | } |
| 2492 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2493 | ALIAS (no_ospf_neighbor, |
| 2494 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2495 | "no neighbor A.B.C.D priority <0-255>", |
| 2496 | NO_STR |
| 2497 | NEIGHBOR_STR |
| 2498 | "Neighbor IP address\n" |
| 2499 | "Neighbor Priority\n" |
| 2500 | "Priority\n") |
| 2501 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2502 | ALIAS (no_ospf_neighbor, |
| 2503 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2504 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2505 | NO_STR |
| 2506 | NEIGHBOR_STR |
| 2507 | "Neighbor IP address\n" |
| 2508 | "Dead Neighbor Polling interval\n" |
| 2509 | "Seconds\n") |
| 2510 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2511 | ALIAS (no_ospf_neighbor, |
| 2512 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2513 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2514 | NO_STR |
| 2515 | NEIGHBOR_STR |
| 2516 | "Neighbor IP address\n" |
| 2517 | "Neighbor Priority\n" |
| 2518 | "Priority\n" |
| 2519 | "Dead Neighbor Polling interval\n" |
| 2520 | "Seconds\n") |
| 2521 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2522 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2523 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2524 | "refresh timer <10-1800>", |
| 2525 | "Adjust refresh parameters\n" |
| 2526 | "Set refresh timer\n" |
| 2527 | "Timer value in seconds\n") |
| 2528 | { |
| 2529 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2530 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2531 | |
| 2532 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2533 | interval = (interval / 10) * 10; |
| 2534 | |
| 2535 | ospf_timers_refresh_set (ospf, interval); |
| 2536 | |
| 2537 | return CMD_SUCCESS; |
| 2538 | } |
| 2539 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2540 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2541 | "no refresh timer <10-1800>", |
| 2542 | "Adjust refresh parameters\n" |
| 2543 | "Unset refresh timer\n" |
| 2544 | "Timer value in seconds\n") |
| 2545 | { |
| 2546 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2547 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2548 | |
| 2549 | if (argc == 1) |
| 2550 | { |
| 2551 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2552 | |
| 2553 | if (ospf->lsa_refresh_interval != interval || |
| 2554 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2555 | return CMD_SUCCESS; |
| 2556 | } |
| 2557 | |
| 2558 | ospf_timers_refresh_unset (ospf); |
| 2559 | |
| 2560 | return CMD_SUCCESS; |
| 2561 | } |
| 2562 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2563 | ALIAS (no_ospf_refresh_timer, |
| 2564 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2565 | "no refresh timer", |
| 2566 | "Adjust refresh parameters\n" |
| 2567 | "Unset refresh timer\n") |
| 2568 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2569 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2570 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2571 | "auto-cost reference-bandwidth <1-4294967>", |
| 2572 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2573 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2574 | "The reference bandwidth in terms of Mbits per second\n") |
| 2575 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2576 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2577 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2578 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2579 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2580 | |
| 2581 | refbw = strtol (argv[0], NULL, 10); |
| 2582 | if (refbw < 1 || refbw > 4294967) |
| 2583 | { |
| 2584 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2585 | return CMD_WARNING; |
| 2586 | } |
| 2587 | |
| 2588 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2589 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2590 | return CMD_SUCCESS; |
| 2591 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2592 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2593 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2594 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2595 | |
| 2596 | return CMD_SUCCESS; |
| 2597 | } |
| 2598 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2599 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2600 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2601 | "no auto-cost reference-bandwidth", |
| 2602 | NO_STR |
| 2603 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2604 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2605 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2606 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2607 | struct listnode *node, *nnode; |
| 2608 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2609 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2610 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2611 | return CMD_SUCCESS; |
| 2612 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2613 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2614 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2615 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2616 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2617 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2618 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2619 | |
| 2620 | return CMD_SUCCESS; |
| 2621 | } |
| 2622 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2623 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2624 | { |
| 2625 | "Unknown", |
| 2626 | "Standard (RFC2328)", |
| 2627 | "Alternative IBM", |
| 2628 | "Alternative Cisco", |
| 2629 | "Alternative Shortcut" |
| 2630 | }; |
| 2631 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2632 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2633 | { |
| 2634 | "Default", |
| 2635 | "Enabled", |
| 2636 | "Disabled" |
| 2637 | }; |
| 2638 | |
| 2639 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2640 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2641 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2642 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2643 | { |
| 2644 | /* Show Area ID. */ |
| 2645 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2646 | |
| 2647 | /* Show Area type/mode. */ |
| 2648 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2649 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2650 | else |
| 2651 | { |
| 2652 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2653 | vty_out (vty, " (Stub%s%s)", |
| 2654 | area->no_summary ? ", no summary" : "", |
| 2655 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2656 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2657 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2658 | vty_out (vty, " (NSSA%s%s)", |
| 2659 | area->no_summary ? ", no summary" : "", |
| 2660 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2661 | |
| 2662 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2663 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2664 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2665 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2666 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2667 | } |
| 2668 | |
| 2669 | /* Show number of interfaces. */ |
| 2670 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2671 | "Active: %d%s", listcount (area->oiflist), |
| 2672 | area->act_ints, VTY_NEWLINE); |
| 2673 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2674 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2675 | { |
| 2676 | 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] | 2677 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2678 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2679 | VTY_NEWLINE); |
| 2680 | else if (area->NSSATranslatorState) |
| 2681 | { |
| 2682 | vty_out (vty, " We are an ABR and "); |
| 2683 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2684 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2685 | VTY_NEWLINE); |
| 2686 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2687 | vty_out (vty, "always an NSSA Translator. %s", |
| 2688 | VTY_NEWLINE); |
| 2689 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2690 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2691 | { |
| 2692 | vty_out (vty, " We are an ABR, but "); |
| 2693 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2694 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2695 | VTY_NEWLINE); |
| 2696 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2697 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2698 | VTY_NEWLINE); |
| 2699 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2700 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2701 | /* Stub-router state for this area */ |
| 2702 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2703 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2704 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2705 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2706 | VTY_NEWLINE); |
| 2707 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2708 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2709 | VTY_NEWLINE); |
| 2710 | if (area->t_stub_router) |
| 2711 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2712 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2713 | sizeof(timebuf)), VTY_NEWLINE); |
| 2714 | } |
| 2715 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2716 | /* Show number of fully adjacent neighbors. */ |
| 2717 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2718 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2719 | |
| 2720 | /* Show authentication type. */ |
| 2721 | vty_out (vty, " Area has "); |
| 2722 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2723 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2724 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2725 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2726 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2727 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2728 | |
| 2729 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2730 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2731 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2732 | |
| 2733 | /* Show SPF calculation times. */ |
| 2734 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2735 | area->spf_calculation, VTY_NEWLINE); |
| 2736 | |
| 2737 | /* Show number of LSA. */ |
| 2738 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2739 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2740 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2741 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2742 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2743 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2744 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2745 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2746 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2747 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2748 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2749 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2750 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2751 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2752 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2753 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
| 2754 | #ifdef HAVE_OPAQUE_LSA |
| 2755 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2756 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2757 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2758 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2759 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2760 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
| 2761 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2762 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2763 | } |
| 2764 | |
| 2765 | DEFUN (show_ip_ospf, |
| 2766 | show_ip_ospf_cmd, |
| 2767 | "show ip ospf", |
| 2768 | SHOW_STR |
| 2769 | IP_STR |
| 2770 | "OSPF information\n") |
| 2771 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2772 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2773 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2774 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2775 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2776 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2777 | |
| 2778 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2779 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2780 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2781 | { |
| 2782 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2783 | return CMD_SUCCESS; |
| 2784 | } |
| 2785 | |
| 2786 | /* Show Router ID. */ |
| 2787 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2788 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2789 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2790 | |
| 2791 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2792 | if (ospf->t_deferred_shutdown) |
| 2793 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2794 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2795 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2796 | /* Show capability. */ |
| 2797 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2798 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2799 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2800 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2801 | "enabled" : "disabled", VTY_NEWLINE); |
| 2802 | #ifdef HAVE_OPAQUE_LSA |
Paul Jakma | e30677a | 2015-01-20 15:45:36 +0000 | [diff] [blame] | 2803 | vty_out (vty, " OpaqueCapability flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2804 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2805 | "enabled" : "disabled", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2806 | VTY_NEWLINE); |
| 2807 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2808 | |
| 2809 | /* Show stub-router configuration */ |
| 2810 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2811 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2812 | { |
| 2813 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2814 | VTY_NEWLINE); |
| 2815 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2816 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2817 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2818 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2819 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2820 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2821 | } |
| 2822 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2823 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2824 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2825 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2826 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2827 | " Hold time multiplier is currently %d%s", |
| 2828 | ospf->spf_delay, VTY_NEWLINE, |
| 2829 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2830 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2831 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2832 | vty_out (vty, " SPF algorithm "); |
| 2833 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2834 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 2835 | result = tv_sub (recent_relative_time (), ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2836 | vty_out (vty, "last executed %s ago%s", |
| 2837 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2838 | VTY_NEWLINE); |
Dinesh G Dutt | 50f38b3 | 2014-09-30 12:53:28 -0700 | [diff] [blame] | 2839 | vty_out (vty, " Last SPF duration %s%s", |
| 2840 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), |
| 2841 | VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2842 | } |
| 2843 | else |
| 2844 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2845 | vty_out (vty, " SPF timer %s%s%s", |
| 2846 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2847 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2848 | VTY_NEWLINE); |
| 2849 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2850 | /* Show refresh parameters. */ |
| 2851 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2852 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2853 | |
| 2854 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2855 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2856 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2857 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2858 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2859 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2860 | vty_out (vty, " This router is an ASBR " |
| 2861 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2862 | |
| 2863 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2864 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2865 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2866 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
| 2867 | #ifdef HAVE_OPAQUE_LSA |
| 2868 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2869 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2870 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
| 2871 | #endif /* HAVE_OPAQUE_LSA */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2872 | /* Show number of areas attached. */ |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2873 | vty_out (vty, " Number of areas attached to this router: %d%s", |
| 2874 | listcount (ospf->areas), VTY_NEWLINE); |
| 2875 | |
| 2876 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 2877 | { |
| 2878 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 2879 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); |
| 2880 | else |
| 2881 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); |
| 2882 | } |
| 2883 | |
| 2884 | vty_out (vty, "%s",VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2885 | |
| 2886 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2887 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2888 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2889 | |
| 2890 | return CMD_SUCCESS; |
| 2891 | } |
| 2892 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2893 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2894 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2895 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2896 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2897 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2898 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2899 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2900 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2901 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2902 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2903 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2904 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2905 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2906 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2907 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2908 | |
| 2909 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2910 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2911 | { |
| 2912 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2913 | return; |
| 2914 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2915 | else if (!is_up) |
| 2916 | { |
| 2917 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2918 | VTY_NEWLINE); |
| 2919 | return; |
| 2920 | } |
| 2921 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2922 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2923 | { |
| 2924 | struct ospf_interface *oi = rn->info; |
| 2925 | |
| 2926 | if (oi == NULL) |
| 2927 | continue; |
| 2928 | |
| 2929 | /* Show OSPF interface information. */ |
| 2930 | vty_out (vty, " Internet Address %s/%d,", |
| 2931 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2932 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2933 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2934 | { |
| 2935 | struct in_addr *dest; |
| 2936 | const char *dstr; |
| 2937 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 2938 | if (CONNECTED_PEER(oi->connected) |
| 2939 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2940 | dstr = "Peer"; |
| 2941 | else |
| 2942 | dstr = "Broadcast"; |
| 2943 | |
| 2944 | /* For Vlinks, showing the peer address is probably more |
| 2945 | * informative than the local interface that is being used |
| 2946 | */ |
| 2947 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2948 | dest = &oi->vl_data->peer_addr; |
| 2949 | else |
| 2950 | dest = &oi->connected->destination->u.prefix4; |
| 2951 | |
| 2952 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); |
| 2953 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2954 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2955 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2956 | VTY_NEWLINE); |
| 2957 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2958 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2959 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2960 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2961 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2962 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2963 | oi->output_cost, VTY_NEWLINE); |
| 2964 | |
| 2965 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2966 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2967 | PRIORITY (oi), VTY_NEWLINE); |
| 2968 | |
| 2969 | /* Show DR information. */ |
| 2970 | if (DR (oi).s_addr == 0) |
| 2971 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2972 | else |
| 2973 | { |
| 2974 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 2975 | if (nbr == NULL) |
| 2976 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 2977 | else |
| 2978 | { |
| 2979 | vty_out (vty, " Designated Router (ID) %s,", |
| 2980 | inet_ntoa (nbr->router_id)); |
| 2981 | vty_out (vty, " Interface Address %s%s", |
| 2982 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 2983 | } |
| 2984 | } |
| 2985 | |
| 2986 | /* Show BDR information. */ |
| 2987 | if (BDR (oi).s_addr == 0) |
| 2988 | vty_out (vty, " No backup designated router on this network%s", |
| 2989 | VTY_NEWLINE); |
| 2990 | else |
| 2991 | { |
| 2992 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 2993 | if (nbr == NULL) |
| 2994 | vty_out (vty, " No backup designated router on this network%s", |
| 2995 | VTY_NEWLINE); |
| 2996 | else |
| 2997 | { |
| 2998 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 2999 | inet_ntoa (nbr->router_id)); |
| 3000 | vty_out (vty, " Interface Address %s%s", |
| 3001 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3002 | } |
| 3003 | } |
Paul Jakma | 7eb5b47 | 2009-10-13 16:13:13 +0100 | [diff] [blame] | 3004 | |
| 3005 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
| 3006 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) |
| 3007 | != OSPF_INITIAL_SEQUENCE_NUMBER) |
| 3008 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", |
| 3009 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); |
| 3010 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 3011 | vty_out (vty, " Multicast group memberships:"); |
Paul Jakma | 429ac78 | 2006-06-15 18:40:49 +0000 | [diff] [blame] | 3012 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
| 3013 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 3014 | { |
| 3015 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) |
| 3016 | vty_out (vty, " OSPFAllRouters"); |
| 3017 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 3018 | vty_out (vty, " OSPFDesignatedRouters"); |
| 3019 | } |
| 3020 | else |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 3021 | vty_out (vty, " <None>"); |
| 3022 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3023 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3024 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3025 | vty_out (vty, " Hello "); |
| 3026 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 3027 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 3028 | else |
| 3029 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 3030 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 3031 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3032 | OSPF_IF_PARAM (oi, v_wait), |
| 3033 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 3034 | VTY_NEWLINE); |
| 3035 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 3036 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3037 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3038 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3039 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3040 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3041 | VTY_NEWLINE); |
| 3042 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 3043 | else /* passive-interface is set */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3044 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 3045 | |
| 3046 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3047 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3048 | VTY_NEWLINE); |
| 3049 | } |
| 3050 | } |
| 3051 | |
| 3052 | DEFUN (show_ip_ospf_interface, |
| 3053 | show_ip_ospf_interface_cmd, |
| 3054 | "show ip ospf interface [INTERFACE]", |
| 3055 | SHOW_STR |
| 3056 | IP_STR |
| 3057 | "OSPF information\n" |
| 3058 | "Interface information\n" |
| 3059 | "Interface name\n") |
| 3060 | { |
| 3061 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3062 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3063 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3064 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3065 | ospf = ospf_lookup (); |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 3066 | if (ospf == NULL) |
| 3067 | { |
| 3068 | vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3069 | return CMD_SUCCESS; |
| 3070 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3071 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3072 | /* Show All Interfaces. */ |
| 3073 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3074 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 3075 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3076 | /* Interface name is specified. */ |
| 3077 | else |
| 3078 | { |
| 3079 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 3080 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 3081 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3082 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3083 | } |
| 3084 | |
| 3085 | return CMD_SUCCESS; |
| 3086 | } |
| 3087 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3088 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3089 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 3090 | { |
| 3091 | vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
| 3092 | VTY_NEWLINE, |
| 3093 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 3094 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 3095 | VTY_NEWLINE); |
| 3096 | } |
| 3097 | |
| 3098 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3099 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 3100 | { |
| 3101 | struct route_node *rn; |
| 3102 | struct ospf_neighbor *nbr; |
| 3103 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3104 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3105 | |
| 3106 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3107 | if ((nbr = rn->info)) |
| 3108 | /* Do not show myself. */ |
| 3109 | if (nbr != oi->nbr_self) |
| 3110 | /* Down state is not shown. */ |
| 3111 | if (nbr->state != NSM_Down) |
| 3112 | { |
| 3113 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 3114 | |
| 3115 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3116 | vty_out (vty, "%-15s %3d %-15s ", |
| 3117 | "-", nbr->priority, |
| 3118 | msgbuf); |
| 3119 | else |
| 3120 | vty_out (vty, "%-15s %3d %-15s ", |
| 3121 | inet_ntoa (nbr->router_id), nbr->priority, |
| 3122 | msgbuf); |
| 3123 | |
| 3124 | vty_out (vty, "%9s ", |
| 3125 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 3126 | sizeof(timebuf))); |
| 3127 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3128 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3129 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3130 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 3131 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 3132 | VTY_NEWLINE); |
| 3133 | } |
| 3134 | } |
| 3135 | |
| 3136 | DEFUN (show_ip_ospf_neighbor, |
| 3137 | show_ip_ospf_neighbor_cmd, |
| 3138 | "show ip ospf neighbor", |
| 3139 | SHOW_STR |
| 3140 | IP_STR |
| 3141 | "OSPF information\n" |
| 3142 | "Neighbor list\n") |
| 3143 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3144 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3145 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3146 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3147 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3148 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3149 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3150 | { |
| 3151 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3152 | return CMD_SUCCESS; |
| 3153 | } |
| 3154 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3155 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3156 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3157 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3158 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3159 | |
| 3160 | return CMD_SUCCESS; |
| 3161 | } |
| 3162 | |
| 3163 | DEFUN (show_ip_ospf_neighbor_all, |
| 3164 | show_ip_ospf_neighbor_all_cmd, |
| 3165 | "show ip ospf neighbor all", |
| 3166 | SHOW_STR |
| 3167 | IP_STR |
| 3168 | "OSPF information\n" |
| 3169 | "Neighbor list\n" |
| 3170 | "include down status neighbor\n") |
| 3171 | { |
Joakim Tjernlund | 35f8914 | 2008-07-01 16:54:07 +0200 | [diff] [blame] | 3172 | struct ospf *ospf = ospf_lookup (); |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3173 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3174 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3175 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3176 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3177 | { |
| 3178 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3179 | return CMD_SUCCESS; |
| 3180 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3181 | |
| 3182 | show_ip_ospf_neighbour_header (vty); |
| 3183 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3184 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3185 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3186 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3187 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3188 | |
| 3189 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3190 | |
| 3191 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3192 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3193 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3194 | if (nbr_nbma->nbr == NULL |
| 3195 | || nbr_nbma->nbr->state == NSM_Down) |
| 3196 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3197 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3198 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3199 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3200 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 3201 | 0, 0, 0, VTY_NEWLINE); |
| 3202 | } |
| 3203 | } |
| 3204 | } |
| 3205 | |
| 3206 | return CMD_SUCCESS; |
| 3207 | } |
| 3208 | |
| 3209 | DEFUN (show_ip_ospf_neighbor_int, |
| 3210 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3211 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3212 | SHOW_STR |
| 3213 | IP_STR |
| 3214 | "OSPF information\n" |
| 3215 | "Neighbor list\n" |
| 3216 | "Interface name\n") |
| 3217 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3218 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3219 | struct interface *ifp; |
| 3220 | struct route_node *rn; |
| 3221 | |
| 3222 | ifp = if_lookup_by_name (argv[0]); |
| 3223 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3224 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3225 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3226 | return CMD_WARNING; |
| 3227 | } |
| 3228 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3229 | ospf = ospf_lookup (); |
| 3230 | if (ospf == NULL) |
| 3231 | { |
| 3232 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3233 | return CMD_SUCCESS; |
| 3234 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3235 | |
| 3236 | show_ip_ospf_neighbour_header (vty); |
| 3237 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3238 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3239 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3240 | struct ospf_interface *oi = rn->info; |
| 3241 | |
| 3242 | if (oi == NULL) |
| 3243 | continue; |
| 3244 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3245 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3246 | } |
| 3247 | |
| 3248 | return CMD_SUCCESS; |
| 3249 | } |
| 3250 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3251 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3252 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3253 | struct ospf_nbr_nbma *nbr_nbma) |
| 3254 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3255 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3256 | |
| 3257 | /* Show neighbor ID. */ |
| 3258 | vty_out (vty, " Neighbor %s,", "-"); |
| 3259 | |
| 3260 | /* Show interface address. */ |
| 3261 | vty_out (vty, " interface address %s%s", |
| 3262 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3263 | /* Show Area ID. */ |
| 3264 | vty_out (vty, " In the area %s via interface %s%s", |
| 3265 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3266 | /* Show neighbor priority and state. */ |
| 3267 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3268 | nbr_nbma->priority, "Down"); |
| 3269 | /* Show state changes. */ |
| 3270 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3271 | |
| 3272 | /* Show PollInterval */ |
| 3273 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3274 | |
| 3275 | /* Show poll-interval timer. */ |
| 3276 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3277 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3278 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3279 | |
| 3280 | /* Show poll-interval timer thread. */ |
| 3281 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3282 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3283 | } |
| 3284 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3285 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3286 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3287 | struct ospf_neighbor *nbr) |
| 3288 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3289 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3290 | |
| 3291 | /* Show neighbor ID. */ |
| 3292 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3293 | vty_out (vty, " Neighbor %s,", "-"); |
| 3294 | else |
| 3295 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3296 | |
| 3297 | /* Show interface address. */ |
| 3298 | vty_out (vty, " interface address %s%s", |
| 3299 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3300 | /* Show Area ID. */ |
| 3301 | vty_out (vty, " In the area %s via interface %s%s", |
| 3302 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3303 | /* Show neighbor priority and state. */ |
| 3304 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3305 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3306 | /* Show state changes. */ |
| 3307 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3308 | 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] | 3309 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3310 | struct timeval res |
| 3311 | = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3312 | vty_out (vty, " Most recent state change statistics:%s", |
| 3313 | VTY_NEWLINE); |
| 3314 | vty_out (vty, " Progressive change %s ago%s", |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3315 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3316 | VTY_NEWLINE); |
| 3317 | } |
| 3318 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
| 3319 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3320 | struct timeval res |
| 3321 | = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3322 | vty_out (vty, " Regressive change %s ago, due to %s%s", |
| 3323 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
| 3324 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3325 | VTY_NEWLINE); |
| 3326 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3327 | /* Show Designated Rotuer ID. */ |
| 3328 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3329 | /* Show Backup Designated Rotuer ID. */ |
| 3330 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3331 | /* Show options. */ |
| 3332 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3333 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3334 | /* Show Router Dead interval timer. */ |
| 3335 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3336 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3337 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3338 | /* Show Database Summary list. */ |
| 3339 | vty_out (vty, " Database Summary List %d%s", |
| 3340 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3341 | /* Show Link State Request list. */ |
| 3342 | vty_out (vty, " Link State Request List %ld%s", |
| 3343 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3344 | /* Show Link State Retransmission list. */ |
| 3345 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3346 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3347 | /* Show inactivity timer thread. */ |
| 3348 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3349 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3350 | /* Show Database Description retransmission thread. */ |
| 3351 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3352 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3353 | /* Show Link State Request Retransmission thread. */ |
| 3354 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3355 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3356 | /* Show Link State Update Retransmission thread. */ |
| 3357 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3358 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3359 | } |
| 3360 | |
| 3361 | DEFUN (show_ip_ospf_neighbor_id, |
| 3362 | show_ip_ospf_neighbor_id_cmd, |
| 3363 | "show ip ospf neighbor A.B.C.D", |
| 3364 | SHOW_STR |
| 3365 | IP_STR |
| 3366 | "OSPF information\n" |
| 3367 | "Neighbor list\n" |
| 3368 | "Neighbor ID\n") |
| 3369 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3370 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3371 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3372 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3373 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3374 | struct in_addr router_id; |
| 3375 | int ret; |
| 3376 | |
| 3377 | ret = inet_aton (argv[0], &router_id); |
| 3378 | if (!ret) |
| 3379 | { |
| 3380 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3381 | return CMD_WARNING; |
| 3382 | } |
| 3383 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3384 | ospf = ospf_lookup (); |
| 3385 | if (ospf == NULL) |
| 3386 | { |
| 3387 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3388 | return CMD_SUCCESS; |
| 3389 | } |
| 3390 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3391 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3392 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
Andrew J. Schorr | 1c066bf | 2006-06-30 16:53:47 +0000 | [diff] [blame] | 3393 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3394 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3395 | return CMD_SUCCESS; |
| 3396 | } |
| 3397 | |
| 3398 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3399 | show_ip_ospf_neighbor_detail_cmd, |
| 3400 | "show ip ospf neighbor detail", |
| 3401 | SHOW_STR |
| 3402 | IP_STR |
| 3403 | "OSPF information\n" |
| 3404 | "Neighbor list\n" |
| 3405 | "detail of all neighbors\n") |
| 3406 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3407 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3408 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3409 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3410 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3411 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3412 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3413 | { |
| 3414 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3415 | return CMD_SUCCESS; |
| 3416 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3417 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3418 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3419 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3420 | struct route_node *rn; |
| 3421 | struct ospf_neighbor *nbr; |
| 3422 | |
| 3423 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3424 | if ((nbr = rn->info)) |
| 3425 | if (nbr != oi->nbr_self) |
| 3426 | if (nbr->state != NSM_Down) |
| 3427 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3428 | } |
| 3429 | |
| 3430 | return CMD_SUCCESS; |
| 3431 | } |
| 3432 | |
| 3433 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3434 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3435 | "show ip ospf neighbor detail all", |
| 3436 | SHOW_STR |
| 3437 | IP_STR |
| 3438 | "OSPF information\n" |
| 3439 | "Neighbor list\n" |
| 3440 | "detail of all neighbors\n" |
| 3441 | "include down status neighbor\n") |
| 3442 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3443 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3444 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3445 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3446 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3447 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3448 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3449 | { |
| 3450 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3451 | return CMD_SUCCESS; |
| 3452 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3453 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3454 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3455 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3456 | struct route_node *rn; |
| 3457 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3458 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3459 | |
| 3460 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3461 | if ((nbr = rn->info)) |
| 3462 | if (nbr != oi->nbr_self) |
| 3463 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3464 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3465 | |
| 3466 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3467 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3468 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3469 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3470 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3471 | if (nbr_nbma->nbr == NULL |
| 3472 | || nbr_nbma->nbr->state == NSM_Down) |
| 3473 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3474 | } |
| 3475 | } |
| 3476 | |
| 3477 | return CMD_SUCCESS; |
| 3478 | } |
| 3479 | |
| 3480 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3481 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3482 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3483 | SHOW_STR |
| 3484 | IP_STR |
| 3485 | "OSPF information\n" |
| 3486 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3487 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3488 | "detail of all neighbors") |
| 3489 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3490 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3491 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3492 | struct interface *ifp; |
| 3493 | struct route_node *rn, *nrn; |
| 3494 | struct ospf_neighbor *nbr; |
| 3495 | |
| 3496 | ifp = if_lookup_by_name (argv[0]); |
| 3497 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3499 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3500 | return CMD_WARNING; |
| 3501 | } |
| 3502 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3503 | ospf = ospf_lookup (); |
| 3504 | if (ospf == NULL) |
| 3505 | { |
| 3506 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3507 | return CMD_SUCCESS; |
| 3508 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3509 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3510 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3511 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3512 | if ((oi = rn->info)) |
| 3513 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3514 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3515 | if (nbr != oi->nbr_self) |
| 3516 | if (nbr->state != NSM_Down) |
| 3517 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3518 | |
| 3519 | return CMD_SUCCESS; |
| 3520 | } |
| 3521 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3522 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3523 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3524 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3525 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3526 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3527 | struct router_lsa *rl; |
| 3528 | struct summary_lsa *sl; |
| 3529 | struct as_external_lsa *asel; |
| 3530 | struct prefix_ipv4 p; |
| 3531 | |
| 3532 | if (lsa != NULL) |
| 3533 | /* If self option is set, check LSA self flag. */ |
| 3534 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3535 | { |
| 3536 | /* LSA common part show. */ |
| 3537 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3538 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3539 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3540 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3541 | /* LSA specific part show. */ |
| 3542 | switch (lsa->data->type) |
| 3543 | { |
| 3544 | case OSPF_ROUTER_LSA: |
| 3545 | rl = (struct router_lsa *) lsa->data; |
| 3546 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3547 | break; |
| 3548 | case OSPF_SUMMARY_LSA: |
| 3549 | sl = (struct summary_lsa *) lsa->data; |
| 3550 | |
| 3551 | p.family = AF_INET; |
| 3552 | p.prefix = sl->header.id; |
| 3553 | p.prefixlen = ip_masklen (sl->mask); |
| 3554 | apply_mask_ipv4 (&p); |
| 3555 | |
| 3556 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3557 | break; |
| 3558 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3559 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3560 | asel = (struct as_external_lsa *) lsa->data; |
| 3561 | |
| 3562 | p.family = AF_INET; |
| 3563 | p.prefix = asel->header.id; |
| 3564 | p.prefixlen = ip_masklen (asel->mask); |
| 3565 | apply_mask_ipv4 (&p); |
| 3566 | |
| 3567 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3568 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3569 | inet_ntoa (p.prefix), p.prefixlen, |
| 3570 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3571 | break; |
| 3572 | case OSPF_NETWORK_LSA: |
| 3573 | case OSPF_ASBR_SUMMARY_LSA: |
| 3574 | #ifdef HAVE_OPAQUE_LSA |
| 3575 | case OSPF_OPAQUE_LINK_LSA: |
| 3576 | case OSPF_OPAQUE_AREA_LSA: |
| 3577 | case OSPF_OPAQUE_AS_LSA: |
| 3578 | #endif /* HAVE_OPAQUE_LSA */ |
| 3579 | default: |
| 3580 | break; |
| 3581 | } |
| 3582 | vty_out (vty, VTY_NEWLINE); |
| 3583 | } |
| 3584 | |
| 3585 | return 0; |
| 3586 | } |
| 3587 | |
Stephen Hemminger | 8b6a15b | 2009-12-03 19:25:04 +0300 | [diff] [blame] | 3588 | static const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3589 | { |
| 3590 | "unknown", |
| 3591 | "Router Link States", |
| 3592 | "Net Link States", |
| 3593 | "Summary Link States", |
| 3594 | "ASBR-Summary Link States", |
| 3595 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3596 | "Group Membership LSA", |
| 3597 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3598 | #ifdef HAVE_OPAQUE_LSA |
| 3599 | "Type-8 LSA", |
| 3600 | "Link-Local Opaque-LSA", |
| 3601 | "Area-Local Opaque-LSA", |
| 3602 | "AS-external Opaque-LSA", |
| 3603 | #endif /* HAVE_OPAQUE_LSA */ |
| 3604 | }; |
| 3605 | |
Stephen Hemminger | 8b6a15b | 2009-12-03 19:25:04 +0300 | [diff] [blame] | 3606 | static const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3607 | { |
| 3608 | "", |
| 3609 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3610 | "Link ID ADV Router Age Seq# CkSum", |
| 3611 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3612 | "Link ID ADV Router Age Seq# CkSum", |
| 3613 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3614 | " --- header for Group Member ----", |
| 3615 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3616 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3617 | " --- type-8 ---", |
| 3618 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3619 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3620 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3621 | #endif /* HAVE_OPAQUE_LSA */ |
| 3622 | }; |
| 3623 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3624 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3626 | { |
| 3627 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3628 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3629 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3630 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3631 | lsa->data->options, |
| 3632 | ospf_options_dump(lsa->data->options), |
| 3633 | VTY_NEWLINE); |
| 3634 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3635 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3636 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3637 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3638 | |
| 3639 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3640 | { |
| 3641 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3642 | |
| 3643 | if (rlsa->flags) |
| 3644 | vty_out (vty, " :%s%s%s%s", |
| 3645 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3646 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3647 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3648 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3649 | |
| 3650 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3651 | } |
| 3652 | vty_out (vty, " LS Type: %s%s", |
| 3653 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3654 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3655 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3656 | vty_out (vty, " Advertising Router: %s%s", |
| 3657 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3658 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3659 | VTY_NEWLINE); |
| 3660 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3661 | VTY_NEWLINE); |
| 3662 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3663 | } |
| 3664 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3665 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3666 | { |
| 3667 | "(null)", |
| 3668 | "another Router (point-to-point)", |
| 3669 | "a Transit Network", |
| 3670 | "Stub Network", |
| 3671 | "a Virtual Link", |
| 3672 | }; |
| 3673 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3674 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3675 | { |
| 3676 | "(null)", |
| 3677 | "Neighboring Router ID", |
| 3678 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3679 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3680 | "Neighboring Router ID", |
| 3681 | }; |
| 3682 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3683 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3684 | { |
| 3685 | "(null)", |
| 3686 | "Router Interface address", |
| 3687 | "Router Interface address", |
| 3688 | "Network Mask", |
| 3689 | "Router Interface address", |
| 3690 | }; |
| 3691 | |
| 3692 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3693 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3694 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3695 | struct router_lsa *rl) |
| 3696 | { |
| 3697 | int len, i, type; |
| 3698 | |
| 3699 | len = ntohs (rl->header.length) - 4; |
| 3700 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3701 | { |
| 3702 | type = rl->link[i].type; |
| 3703 | |
| 3704 | vty_out (vty, " Link connected to: %s%s", |
| 3705 | link_type_desc[type], VTY_NEWLINE); |
| 3706 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3707 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3708 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3709 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3710 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3711 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3712 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3713 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3714 | } |
| 3715 | } |
| 3716 | |
| 3717 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3718 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3719 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3720 | { |
| 3721 | if (lsa != NULL) |
| 3722 | { |
| 3723 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3724 | |
| 3725 | show_ip_ospf_database_header (vty, lsa); |
| 3726 | |
| 3727 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3728 | VTY_NEWLINE, VTY_NEWLINE); |
| 3729 | |
| 3730 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3731 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3732 | } |
| 3733 | |
| 3734 | return 0; |
| 3735 | } |
| 3736 | |
| 3737 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3738 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3739 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3740 | { |
| 3741 | int length, i; |
| 3742 | |
| 3743 | if (lsa != NULL) |
| 3744 | { |
| 3745 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3746 | |
| 3747 | show_ip_ospf_database_header (vty, lsa); |
| 3748 | |
| 3749 | vty_out (vty, " Network Mask: /%d%s", |
| 3750 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3751 | |
| 3752 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3753 | |
| 3754 | for (i = 0; length > 0; i++, length -= 4) |
| 3755 | vty_out (vty, " Attached Router: %s%s", |
| 3756 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3757 | |
| 3758 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3759 | } |
| 3760 | |
| 3761 | return 0; |
| 3762 | } |
| 3763 | |
| 3764 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3765 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3766 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3767 | { |
| 3768 | if (lsa != NULL) |
| 3769 | { |
| 3770 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3771 | |
| 3772 | show_ip_ospf_database_header (vty, lsa); |
| 3773 | |
| 3774 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3775 | VTY_NEWLINE); |
| 3776 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3777 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3778 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3779 | } |
| 3780 | |
| 3781 | return 0; |
| 3782 | } |
| 3783 | |
| 3784 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3785 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3786 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3787 | { |
| 3788 | if (lsa != NULL) |
| 3789 | { |
| 3790 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3791 | |
| 3792 | show_ip_ospf_database_header (vty, lsa); |
| 3793 | |
| 3794 | vty_out (vty, " Network Mask: /%d%s", |
| 3795 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3796 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3797 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3798 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3799 | } |
| 3800 | |
| 3801 | return 0; |
| 3802 | } |
| 3803 | |
| 3804 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3805 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3806 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3807 | { |
| 3808 | if (lsa != NULL) |
| 3809 | { |
| 3810 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3811 | |
| 3812 | show_ip_ospf_database_header (vty, lsa); |
| 3813 | |
| 3814 | vty_out (vty, " Network Mask: /%d%s", |
| 3815 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3816 | vty_out (vty, " Metric Type: %s%s", |
| 3817 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3818 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3819 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3820 | vty_out (vty, " Metric: %d%s", |
| 3821 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3822 | vty_out (vty, " Forward Address: %s%s", |
| 3823 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3824 | |
| 3825 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3826 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3827 | } |
| 3828 | |
| 3829 | return 0; |
| 3830 | } |
| 3831 | |
Stephen Hemminger | 075e12f | 2011-12-06 23:54:17 +0400 | [diff] [blame] | 3832 | #if 0 |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3833 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3834 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3835 | { |
| 3836 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3837 | |
| 3838 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3839 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3840 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3841 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3842 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3843 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3844 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3845 | zlog_debug( " TOS: 0%s", "\n"); |
| 3846 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3847 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3848 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3849 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3850 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3851 | zlog_debug( " External Route Tag: %u%s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3852 | ntohl (al->e[0].route_tag), "\n", "\n"); |
| 3853 | |
| 3854 | return 0; |
| 3855 | } |
Stephen Hemminger | 075e12f | 2011-12-06 23:54:17 +0400 | [diff] [blame] | 3856 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3857 | |
| 3858 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3859 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3860 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3861 | { |
| 3862 | if (lsa != NULL) |
| 3863 | { |
| 3864 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3865 | |
| 3866 | show_ip_ospf_database_header (vty, lsa); |
| 3867 | |
| 3868 | vty_out (vty, " Network Mask: /%d%s", |
| 3869 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3870 | vty_out (vty, " Metric Type: %s%s", |
| 3871 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3872 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3873 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3874 | vty_out (vty, " Metric: %d%s", |
| 3875 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3876 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3877 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3878 | |
| 3879 | vty_out (vty, " External Route Tag: %u%s%s", |
| 3880 | ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3881 | } |
| 3882 | |
| 3883 | return 0; |
| 3884 | } |
| 3885 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3886 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3887 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3888 | { |
| 3889 | return 0; |
| 3890 | } |
| 3891 | |
| 3892 | #ifdef HAVE_OPAQUE_LSA |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3893 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3894 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3895 | { |
| 3896 | if (lsa != NULL) |
| 3897 | { |
| 3898 | show_ip_ospf_database_header (vty, lsa); |
| 3899 | show_opaque_info_detail (vty, lsa); |
| 3900 | |
| 3901 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3902 | } |
| 3903 | return 0; |
| 3904 | } |
| 3905 | #endif /* HAVE_OPAQUE_LSA */ |
| 3906 | |
| 3907 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3908 | { |
| 3909 | NULL, |
| 3910 | show_router_lsa_detail, |
| 3911 | show_network_lsa_detail, |
| 3912 | show_summary_lsa_detail, |
| 3913 | show_summary_asbr_lsa_detail, |
| 3914 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3915 | show_func_dummy, |
| 3916 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3917 | #ifdef HAVE_OPAQUE_LSA |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3918 | NULL, /* type-8 */ |
| 3919 | show_opaque_lsa_detail, |
| 3920 | show_opaque_lsa_detail, |
| 3921 | show_opaque_lsa_detail, |
| 3922 | #endif /* HAVE_OPAQUE_LSA */ |
| 3923 | }; |
| 3924 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3925 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3926 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3927 | struct in_addr *adv_router) |
| 3928 | { |
| 3929 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3930 | lp->family = 0; |
| 3931 | if (id == NULL) |
| 3932 | lp->prefixlen = 0; |
| 3933 | else if (adv_router == NULL) |
| 3934 | { |
| 3935 | lp->prefixlen = 32; |
| 3936 | lp->id = *id; |
| 3937 | } |
| 3938 | else |
| 3939 | { |
| 3940 | lp->prefixlen = 64; |
| 3941 | lp->id = *id; |
| 3942 | lp->adv_router = *adv_router; |
| 3943 | } |
| 3944 | } |
| 3945 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3946 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3947 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3948 | struct in_addr *id, struct in_addr *adv_router) |
| 3949 | { |
| 3950 | struct prefix_ls lp; |
| 3951 | struct route_node *rn, *start; |
| 3952 | struct ospf_lsa *lsa; |
| 3953 | |
| 3954 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3955 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3956 | if (start) |
| 3957 | { |
| 3958 | route_lock_node (start); |
| 3959 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3960 | if ((lsa = rn->info)) |
| 3961 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3962 | if (show_function[lsa->data->type] != NULL) |
| 3963 | show_function[lsa->data->type] (vty, lsa); |
| 3964 | } |
| 3965 | route_unlock_node (start); |
| 3966 | } |
| 3967 | } |
| 3968 | |
| 3969 | /* Show detail LSA information |
| 3970 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3971 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3972 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3973 | struct in_addr *id, struct in_addr *adv_router) |
| 3974 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3975 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3976 | struct ospf_area *area; |
| 3977 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3978 | switch (type) |
| 3979 | { |
| 3980 | case OSPF_AS_EXTERNAL_LSA: |
| 3981 | #ifdef HAVE_OPAQUE_LSA |
| 3982 | case OSPF_OPAQUE_AS_LSA: |
| 3983 | #endif /* HAVE_OPAQUE_LSA */ |
| 3984 | vty_out (vty, " %s %s%s", |
| 3985 | show_database_desc[type], |
| 3986 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3987 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3988 | break; |
| 3989 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3990 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3991 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3992 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 3993 | VTY_NEWLINE, show_database_desc[type], |
| 3994 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 3995 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 3996 | } |
| 3997 | break; |
| 3998 | } |
| 3999 | } |
| 4000 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4001 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4002 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 4003 | struct in_addr *adv_router) |
| 4004 | { |
| 4005 | struct route_node *rn; |
| 4006 | struct ospf_lsa *lsa; |
| 4007 | |
| 4008 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 4009 | if ((lsa = rn->info)) |
| 4010 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 4011 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4012 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 4013 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4014 | if (show_function[lsa->data->type] != NULL) |
| 4015 | show_function[lsa->data->type] (vty, lsa); |
| 4016 | } |
| 4017 | } |
| 4018 | |
| 4019 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4020 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4021 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4022 | struct in_addr *adv_router) |
| 4023 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 4024 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4025 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4026 | |
| 4027 | switch (type) |
| 4028 | { |
| 4029 | case OSPF_AS_EXTERNAL_LSA: |
| 4030 | #ifdef HAVE_OPAQUE_LSA |
| 4031 | case OSPF_OPAQUE_AS_LSA: |
| 4032 | #endif /* HAVE_OPAQUE_LSA */ |
| 4033 | vty_out (vty, " %s %s%s", |
| 4034 | show_database_desc[type], |
| 4035 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4036 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4037 | adv_router); |
| 4038 | break; |
| 4039 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4040 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4041 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4042 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 4043 | VTY_NEWLINE, show_database_desc[type], |
| 4044 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 4045 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 4046 | adv_router); |
| 4047 | } |
| 4048 | break; |
| 4049 | } |
| 4050 | } |
| 4051 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4052 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4053 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4054 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4055 | struct ospf_lsa *lsa; |
| 4056 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4057 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 4058 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4059 | int type; |
| 4060 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4061 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4062 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4063 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4064 | { |
| 4065 | switch (type) |
| 4066 | { |
| 4067 | case OSPF_AS_EXTERNAL_LSA: |
| 4068 | #ifdef HAVE_OPAQUE_LSA |
| 4069 | case OSPF_OPAQUE_AS_LSA: |
| 4070 | #endif /* HAVE_OPAQUE_LSA */ |
| 4071 | continue; |
| 4072 | default: |
| 4073 | break; |
| 4074 | } |
| 4075 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 4076 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 4077 | { |
| 4078 | vty_out (vty, " %s (Area %s)%s%s", |
| 4079 | show_database_desc[type], |
| 4080 | ospf_area_desc_string (area), |
| 4081 | VTY_NEWLINE, VTY_NEWLINE); |
| 4082 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 4083 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4084 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 4085 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4086 | |
| 4087 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4088 | } |
| 4089 | } |
| 4090 | } |
| 4091 | |
| 4092 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4093 | { |
| 4094 | switch (type) |
| 4095 | { |
| 4096 | case OSPF_AS_EXTERNAL_LSA: |
| 4097 | #ifdef HAVE_OPAQUE_LSA |
| 4098 | case OSPF_OPAQUE_AS_LSA: |
| 4099 | #endif /* HAVE_OPAQUE_LSA */ |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 4100 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4101 | default: |
| 4102 | continue; |
| 4103 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4104 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 4105 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4106 | { |
| 4107 | vty_out (vty, " %s%s%s", |
| 4108 | show_database_desc[type], |
| 4109 | VTY_NEWLINE, VTY_NEWLINE); |
| 4110 | vty_out (vty, "%s%s", show_database_header[type], |
| 4111 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4112 | |
| 4113 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 4114 | show_lsa_summary (vty, lsa, self); |
| 4115 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4116 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4117 | } |
| 4118 | } |
| 4119 | |
| 4120 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4121 | } |
| 4122 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4123 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4124 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4125 | { |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4126 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4127 | |
| 4128 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 4129 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 4130 | |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4131 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4132 | { |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4133 | struct ospf_lsa *lsa; |
| 4134 | |
| 4135 | if ((lsa = rn->info) != NULL) |
| 4136 | { |
| 4137 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 4138 | vty_out (vty, "Link State ID: %s%s", |
| 4139 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 4140 | vty_out (vty, "Advertising Router: %s%s", |
| 4141 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 4142 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 4143 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4144 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4145 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4146 | } |
| 4147 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4148 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 4149 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4150 | |
| 4151 | #ifdef HAVE_OPAQUE_LSA |
| 4152 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 4153 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 4154 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 4155 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
| 4156 | #else /* HAVE_OPAQUE_LSA */ |
| 4157 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "" |
| 4158 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "" |
| 4159 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "" |
| 4160 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "" |
| 4161 | #endif /* HAVE_OPAQUE_LSA */ |
| 4162 | |
| 4163 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 4164 | "asbr-summary|external|network|router|summary" \ |
| 4165 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 4166 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 4167 | |
| 4168 | #define OSPF_LSA_TYPES_DESC \ |
| 4169 | "ASBR summary link states\n" \ |
| 4170 | "External link states\n" \ |
| 4171 | "Network link states\n" \ |
| 4172 | "Router link states\n" \ |
| 4173 | "Network summary link states\n" \ |
| 4174 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 4175 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 4176 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 4177 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 4178 | |
| 4179 | DEFUN (show_ip_ospf_database, |
| 4180 | show_ip_ospf_database_cmd, |
| 4181 | "show ip ospf database", |
| 4182 | SHOW_STR |
| 4183 | IP_STR |
| 4184 | "OSPF information\n" |
| 4185 | "Database summary\n") |
| 4186 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4187 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4188 | int type, ret; |
| 4189 | struct in_addr id, adv_router; |
| 4190 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4191 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4192 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4193 | { |
| 4194 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4195 | return CMD_SUCCESS; |
| 4196 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4197 | |
| 4198 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4199 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4200 | |
| 4201 | /* Show all LSA. */ |
| 4202 | if (argc == 0) |
| 4203 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4204 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4205 | return CMD_SUCCESS; |
| 4206 | } |
| 4207 | |
| 4208 | /* Set database type to show. */ |
| 4209 | if (strncmp (argv[0], "r", 1) == 0) |
| 4210 | type = OSPF_ROUTER_LSA; |
| 4211 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4212 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4213 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4214 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4215 | else if (strncmp (argv[0], "su", 2) == 0) |
| 4216 | type = OSPF_SUMMARY_LSA; |
| 4217 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4218 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4219 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4220 | type = OSPF_AS_EXTERNAL_LSA; |
| 4221 | else if (strncmp (argv[0], "se", 2) == 0) |
| 4222 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4223 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4224 | return CMD_SUCCESS; |
| 4225 | } |
| 4226 | else if (strncmp (argv[0], "m", 1) == 0) |
| 4227 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4228 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4229 | return CMD_SUCCESS; |
| 4230 | } |
| 4231 | #ifdef HAVE_OPAQUE_LSA |
| 4232 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4233 | type = OSPF_OPAQUE_LINK_LSA; |
| 4234 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4235 | type = OSPF_OPAQUE_AREA_LSA; |
| 4236 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4237 | type = OSPF_OPAQUE_AS_LSA; |
| 4238 | #endif /* HAVE_OPAQUE_LSA */ |
| 4239 | else |
| 4240 | return CMD_WARNING; |
| 4241 | |
| 4242 | /* `show ip ospf database LSA'. */ |
| 4243 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4244 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4245 | else if (argc >= 2) |
| 4246 | { |
| 4247 | ret = inet_aton (argv[1], &id); |
| 4248 | if (!ret) |
| 4249 | return CMD_WARNING; |
| 4250 | |
| 4251 | /* `show ip ospf database LSA ID'. */ |
| 4252 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4253 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4254 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4255 | else if (argc == 3) |
| 4256 | { |
| 4257 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4258 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4259 | else |
| 4260 | { |
| 4261 | ret = inet_aton (argv[2], &adv_router); |
| 4262 | if (!ret) |
| 4263 | return CMD_WARNING; |
| 4264 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4265 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4266 | } |
| 4267 | } |
| 4268 | |
| 4269 | return CMD_SUCCESS; |
| 4270 | } |
| 4271 | |
| 4272 | ALIAS (show_ip_ospf_database, |
| 4273 | show_ip_ospf_database_type_cmd, |
| 4274 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4275 | SHOW_STR |
| 4276 | IP_STR |
| 4277 | "OSPF information\n" |
| 4278 | "Database summary\n" |
| 4279 | OSPF_LSA_TYPES_DESC |
| 4280 | "LSAs in MaxAge list\n" |
| 4281 | "Self-originated link states\n") |
| 4282 | |
| 4283 | ALIAS (show_ip_ospf_database, |
| 4284 | show_ip_ospf_database_type_id_cmd, |
| 4285 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4286 | SHOW_STR |
| 4287 | IP_STR |
| 4288 | "OSPF information\n" |
| 4289 | "Database summary\n" |
| 4290 | OSPF_LSA_TYPES_DESC |
| 4291 | "Link State ID (as an IP address)\n") |
| 4292 | |
| 4293 | ALIAS (show_ip_ospf_database, |
| 4294 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4295 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4296 | SHOW_STR |
| 4297 | IP_STR |
| 4298 | "OSPF information\n" |
| 4299 | "Database summary\n" |
| 4300 | OSPF_LSA_TYPES_DESC |
| 4301 | "Link State ID (as an IP address)\n" |
| 4302 | "Advertising Router link states\n" |
| 4303 | "Advertising Router (as an IP address)\n") |
| 4304 | |
| 4305 | ALIAS (show_ip_ospf_database, |
| 4306 | show_ip_ospf_database_type_id_self_cmd, |
| 4307 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4308 | SHOW_STR |
| 4309 | IP_STR |
| 4310 | "OSPF information\n" |
| 4311 | "Database summary\n" |
| 4312 | OSPF_LSA_TYPES_DESC |
| 4313 | "Link State ID (as an IP address)\n" |
| 4314 | "Self-originated link states\n" |
| 4315 | "\n") |
| 4316 | |
| 4317 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4318 | show_ip_ospf_database_type_adv_router_cmd, |
| 4319 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4320 | SHOW_STR |
| 4321 | IP_STR |
| 4322 | "OSPF information\n" |
| 4323 | "Database summary\n" |
| 4324 | OSPF_LSA_TYPES_DESC |
| 4325 | "Advertising Router link states\n" |
| 4326 | "Advertising Router (as an IP address)\n") |
| 4327 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4328 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4329 | int type, ret; |
| 4330 | struct in_addr adv_router; |
| 4331 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4332 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4333 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4334 | { |
| 4335 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4336 | return CMD_SUCCESS; |
| 4337 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4338 | |
| 4339 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4340 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4341 | |
| 4342 | if (argc != 2) |
| 4343 | return CMD_WARNING; |
| 4344 | |
| 4345 | /* Set database type to show. */ |
| 4346 | if (strncmp (argv[0], "r", 1) == 0) |
| 4347 | type = OSPF_ROUTER_LSA; |
| 4348 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4349 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4350 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4351 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4352 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4353 | type = OSPF_SUMMARY_LSA; |
| 4354 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4355 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4356 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4357 | type = OSPF_AS_EXTERNAL_LSA; |
| 4358 | #ifdef HAVE_OPAQUE_LSA |
| 4359 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4360 | type = OSPF_OPAQUE_LINK_LSA; |
| 4361 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4362 | type = OSPF_OPAQUE_AREA_LSA; |
| 4363 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4364 | type = OSPF_OPAQUE_AS_LSA; |
| 4365 | #endif /* HAVE_OPAQUE_LSA */ |
| 4366 | else |
| 4367 | return CMD_WARNING; |
| 4368 | |
| 4369 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4370 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4371 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4372 | else |
| 4373 | { |
| 4374 | ret = inet_aton (argv[1], &adv_router); |
| 4375 | if (!ret) |
| 4376 | return CMD_WARNING; |
| 4377 | } |
| 4378 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4379 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4380 | |
| 4381 | return CMD_SUCCESS; |
| 4382 | } |
| 4383 | |
| 4384 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4385 | show_ip_ospf_database_type_self_cmd, |
| 4386 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4387 | SHOW_STR |
| 4388 | IP_STR |
| 4389 | "OSPF information\n" |
| 4390 | "Database summary\n" |
| 4391 | OSPF_LSA_TYPES_DESC |
| 4392 | "Self-originated link states\n") |
| 4393 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4394 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4395 | DEFUN (ip_ospf_authentication_args, |
| 4396 | ip_ospf_authentication_args_addr_cmd, |
| 4397 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4398 | "IP Information\n" |
| 4399 | "OSPF interface commands\n" |
| 4400 | "Enable authentication on this interface\n" |
| 4401 | "Use null authentication\n" |
| 4402 | "Use message-digest authentication\n" |
| 4403 | "Address of interface") |
| 4404 | { |
| 4405 | struct interface *ifp; |
| 4406 | struct in_addr addr; |
| 4407 | int ret; |
| 4408 | struct ospf_if_params *params; |
| 4409 | |
| 4410 | ifp = vty->index; |
| 4411 | params = IF_DEF_PARAMS (ifp); |
| 4412 | |
| 4413 | if (argc == 2) |
| 4414 | { |
| 4415 | ret = inet_aton(argv[1], &addr); |
| 4416 | if (!ret) |
| 4417 | { |
| 4418 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4419 | VTY_NEWLINE); |
| 4420 | return CMD_WARNING; |
| 4421 | } |
| 4422 | |
| 4423 | params = ospf_get_if_params (ifp, addr); |
| 4424 | ospf_if_update_params (ifp, addr); |
| 4425 | } |
| 4426 | |
| 4427 | /* Handle null authentication */ |
| 4428 | if ( argv[0][0] == 'n' ) |
| 4429 | { |
| 4430 | SET_IF_PARAM (params, auth_type); |
| 4431 | params->auth_type = OSPF_AUTH_NULL; |
| 4432 | return CMD_SUCCESS; |
| 4433 | } |
| 4434 | |
| 4435 | /* Handle message-digest authentication */ |
| 4436 | if ( argv[0][0] == 'm' ) |
| 4437 | { |
| 4438 | SET_IF_PARAM (params, auth_type); |
| 4439 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4440 | return CMD_SUCCESS; |
| 4441 | } |
| 4442 | |
| 4443 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4444 | return CMD_WARNING; |
| 4445 | } |
| 4446 | |
| 4447 | ALIAS (ip_ospf_authentication_args, |
| 4448 | ip_ospf_authentication_args_cmd, |
| 4449 | "ip ospf authentication (null|message-digest)", |
| 4450 | "IP Information\n" |
| 4451 | "OSPF interface commands\n" |
| 4452 | "Enable authentication on this interface\n" |
| 4453 | "Use null authentication\n" |
| 4454 | "Use message-digest authentication\n") |
| 4455 | |
| 4456 | DEFUN (ip_ospf_authentication, |
| 4457 | ip_ospf_authentication_addr_cmd, |
| 4458 | "ip ospf authentication A.B.C.D", |
| 4459 | "IP Information\n" |
| 4460 | "OSPF interface commands\n" |
| 4461 | "Enable authentication on this interface\n" |
| 4462 | "Address of interface") |
| 4463 | { |
| 4464 | struct interface *ifp; |
| 4465 | struct in_addr addr; |
| 4466 | int ret; |
| 4467 | struct ospf_if_params *params; |
| 4468 | |
| 4469 | ifp = vty->index; |
| 4470 | params = IF_DEF_PARAMS (ifp); |
| 4471 | |
| 4472 | if (argc == 1) |
| 4473 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4474 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4475 | if (!ret) |
| 4476 | { |
| 4477 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4478 | VTY_NEWLINE); |
| 4479 | return CMD_WARNING; |
| 4480 | } |
| 4481 | |
| 4482 | params = ospf_get_if_params (ifp, addr); |
| 4483 | ospf_if_update_params (ifp, addr); |
| 4484 | } |
| 4485 | |
| 4486 | SET_IF_PARAM (params, auth_type); |
| 4487 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4488 | |
| 4489 | return CMD_SUCCESS; |
| 4490 | } |
| 4491 | |
| 4492 | ALIAS (ip_ospf_authentication, |
| 4493 | ip_ospf_authentication_cmd, |
| 4494 | "ip ospf authentication", |
| 4495 | "IP Information\n" |
| 4496 | "OSPF interface commands\n" |
| 4497 | "Enable authentication on this interface\n") |
| 4498 | |
| 4499 | DEFUN (no_ip_ospf_authentication, |
| 4500 | no_ip_ospf_authentication_addr_cmd, |
| 4501 | "no ip ospf authentication A.B.C.D", |
| 4502 | NO_STR |
| 4503 | "IP Information\n" |
| 4504 | "OSPF interface commands\n" |
| 4505 | "Enable authentication on this interface\n" |
| 4506 | "Address of interface") |
| 4507 | { |
| 4508 | struct interface *ifp; |
| 4509 | struct in_addr addr; |
| 4510 | int ret; |
| 4511 | struct ospf_if_params *params; |
| 4512 | |
| 4513 | ifp = vty->index; |
| 4514 | params = IF_DEF_PARAMS (ifp); |
| 4515 | |
| 4516 | if (argc == 1) |
| 4517 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4518 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4519 | if (!ret) |
| 4520 | { |
| 4521 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4522 | VTY_NEWLINE); |
| 4523 | return CMD_WARNING; |
| 4524 | } |
| 4525 | |
| 4526 | params = ospf_lookup_if_params (ifp, addr); |
| 4527 | if (params == NULL) |
| 4528 | return CMD_SUCCESS; |
| 4529 | } |
| 4530 | |
| 4531 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4532 | UNSET_IF_PARAM (params, auth_type); |
| 4533 | |
| 4534 | if (params != IF_DEF_PARAMS (ifp)) |
| 4535 | { |
| 4536 | ospf_free_if_params (ifp, addr); |
| 4537 | ospf_if_update_params (ifp, addr); |
| 4538 | } |
| 4539 | |
| 4540 | return CMD_SUCCESS; |
| 4541 | } |
| 4542 | |
| 4543 | ALIAS (no_ip_ospf_authentication, |
| 4544 | no_ip_ospf_authentication_cmd, |
| 4545 | "no ip ospf authentication", |
| 4546 | NO_STR |
| 4547 | "IP Information\n" |
| 4548 | "OSPF interface commands\n" |
| 4549 | "Enable authentication on this interface\n") |
| 4550 | |
| 4551 | DEFUN (ip_ospf_authentication_key, |
| 4552 | ip_ospf_authentication_key_addr_cmd, |
| 4553 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4554 | "IP Information\n" |
| 4555 | "OSPF interface commands\n" |
| 4556 | "Authentication password (key)\n" |
| 4557 | "The OSPF password (key)\n" |
| 4558 | "Address of interface") |
| 4559 | { |
| 4560 | struct interface *ifp; |
| 4561 | struct in_addr addr; |
| 4562 | int ret; |
| 4563 | struct ospf_if_params *params; |
| 4564 | |
| 4565 | ifp = vty->index; |
| 4566 | params = IF_DEF_PARAMS (ifp); |
| 4567 | |
| 4568 | if (argc == 2) |
| 4569 | { |
| 4570 | ret = inet_aton(argv[1], &addr); |
| 4571 | if (!ret) |
| 4572 | { |
| 4573 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4574 | VTY_NEWLINE); |
| 4575 | return CMD_WARNING; |
| 4576 | } |
| 4577 | |
| 4578 | params = ospf_get_if_params (ifp, addr); |
| 4579 | ospf_if_update_params (ifp, addr); |
| 4580 | } |
| 4581 | |
| 4582 | |
| 4583 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4584 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4585 | SET_IF_PARAM (params, auth_simple); |
| 4586 | |
| 4587 | return CMD_SUCCESS; |
| 4588 | } |
| 4589 | |
| 4590 | ALIAS (ip_ospf_authentication_key, |
| 4591 | ip_ospf_authentication_key_cmd, |
| 4592 | "ip ospf authentication-key AUTH_KEY", |
| 4593 | "IP Information\n" |
| 4594 | "OSPF interface commands\n" |
| 4595 | "Authentication password (key)\n" |
| 4596 | "The OSPF password (key)") |
| 4597 | |
| 4598 | ALIAS (ip_ospf_authentication_key, |
| 4599 | ospf_authentication_key_cmd, |
| 4600 | "ospf authentication-key AUTH_KEY", |
| 4601 | "OSPF interface commands\n" |
| 4602 | "Authentication password (key)\n" |
| 4603 | "The OSPF password (key)") |
| 4604 | |
| 4605 | DEFUN (no_ip_ospf_authentication_key, |
| 4606 | no_ip_ospf_authentication_key_addr_cmd, |
| 4607 | "no ip ospf authentication-key A.B.C.D", |
| 4608 | NO_STR |
| 4609 | "IP Information\n" |
| 4610 | "OSPF interface commands\n" |
| 4611 | "Authentication password (key)\n" |
| 4612 | "Address of interface") |
| 4613 | { |
| 4614 | struct interface *ifp; |
| 4615 | struct in_addr addr; |
| 4616 | int ret; |
| 4617 | struct ospf_if_params *params; |
| 4618 | |
| 4619 | ifp = vty->index; |
| 4620 | params = IF_DEF_PARAMS (ifp); |
| 4621 | |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4622 | if (argc == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4623 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4624 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4625 | if (!ret) |
| 4626 | { |
| 4627 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4628 | VTY_NEWLINE); |
| 4629 | return CMD_WARNING; |
| 4630 | } |
| 4631 | |
| 4632 | params = ospf_lookup_if_params (ifp, addr); |
| 4633 | if (params == NULL) |
| 4634 | return CMD_SUCCESS; |
| 4635 | } |
| 4636 | |
| 4637 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4638 | UNSET_IF_PARAM (params, auth_simple); |
| 4639 | |
| 4640 | if (params != IF_DEF_PARAMS (ifp)) |
| 4641 | { |
| 4642 | ospf_free_if_params (ifp, addr); |
| 4643 | ospf_if_update_params (ifp, addr); |
| 4644 | } |
| 4645 | |
| 4646 | return CMD_SUCCESS; |
| 4647 | } |
| 4648 | |
| 4649 | ALIAS (no_ip_ospf_authentication_key, |
| 4650 | no_ip_ospf_authentication_key_cmd, |
| 4651 | "no ip ospf authentication-key", |
| 4652 | NO_STR |
| 4653 | "IP Information\n" |
| 4654 | "OSPF interface commands\n" |
| 4655 | "Authentication password (key)\n") |
| 4656 | |
| 4657 | ALIAS (no_ip_ospf_authentication_key, |
| 4658 | no_ospf_authentication_key_cmd, |
| 4659 | "no ospf authentication-key", |
| 4660 | NO_STR |
| 4661 | "OSPF interface commands\n" |
| 4662 | "Authentication password (key)\n") |
| 4663 | |
| 4664 | DEFUN (ip_ospf_message_digest_key, |
| 4665 | ip_ospf_message_digest_key_addr_cmd, |
| 4666 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4667 | "IP Information\n" |
| 4668 | "OSPF interface commands\n" |
| 4669 | "Message digest authentication password (key)\n" |
| 4670 | "Key ID\n" |
| 4671 | "Use MD5 algorithm\n" |
| 4672 | "The OSPF password (key)" |
| 4673 | "Address of interface") |
| 4674 | { |
| 4675 | struct interface *ifp; |
| 4676 | struct crypt_key *ck; |
| 4677 | u_char key_id; |
| 4678 | struct in_addr addr; |
| 4679 | int ret; |
| 4680 | struct ospf_if_params *params; |
| 4681 | |
| 4682 | ifp = vty->index; |
| 4683 | params = IF_DEF_PARAMS (ifp); |
| 4684 | |
| 4685 | if (argc == 3) |
| 4686 | { |
| 4687 | ret = inet_aton(argv[2], &addr); |
| 4688 | if (!ret) |
| 4689 | { |
| 4690 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4691 | VTY_NEWLINE); |
| 4692 | return CMD_WARNING; |
| 4693 | } |
| 4694 | |
| 4695 | params = ospf_get_if_params (ifp, addr); |
| 4696 | ospf_if_update_params (ifp, addr); |
| 4697 | } |
| 4698 | |
| 4699 | key_id = strtol (argv[0], NULL, 10); |
| 4700 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4701 | { |
| 4702 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4703 | return CMD_WARNING; |
| 4704 | } |
| 4705 | |
| 4706 | ck = ospf_crypt_key_new (); |
| 4707 | ck->key_id = (u_char) key_id; |
| 4708 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4709 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4710 | |
| 4711 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4712 | SET_IF_PARAM (params, auth_crypt); |
| 4713 | |
| 4714 | return CMD_SUCCESS; |
| 4715 | } |
| 4716 | |
| 4717 | ALIAS (ip_ospf_message_digest_key, |
| 4718 | ip_ospf_message_digest_key_cmd, |
| 4719 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4720 | "IP Information\n" |
| 4721 | "OSPF interface commands\n" |
| 4722 | "Message digest authentication password (key)\n" |
| 4723 | "Key ID\n" |
| 4724 | "Use MD5 algorithm\n" |
| 4725 | "The OSPF password (key)") |
| 4726 | |
| 4727 | ALIAS (ip_ospf_message_digest_key, |
| 4728 | ospf_message_digest_key_cmd, |
| 4729 | "ospf message-digest-key <1-255> md5 KEY", |
| 4730 | "OSPF interface commands\n" |
| 4731 | "Message digest authentication password (key)\n" |
| 4732 | "Key ID\n" |
| 4733 | "Use MD5 algorithm\n" |
| 4734 | "The OSPF password (key)") |
| 4735 | |
| 4736 | DEFUN (no_ip_ospf_message_digest_key, |
| 4737 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4738 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4739 | NO_STR |
| 4740 | "IP Information\n" |
| 4741 | "OSPF interface commands\n" |
| 4742 | "Message digest authentication password (key)\n" |
| 4743 | "Key ID\n" |
| 4744 | "Address of interface") |
| 4745 | { |
| 4746 | struct interface *ifp; |
| 4747 | struct crypt_key *ck; |
| 4748 | int key_id; |
| 4749 | struct in_addr addr; |
| 4750 | int ret; |
| 4751 | struct ospf_if_params *params; |
| 4752 | |
| 4753 | ifp = vty->index; |
| 4754 | params = IF_DEF_PARAMS (ifp); |
| 4755 | |
| 4756 | if (argc == 2) |
| 4757 | { |
| 4758 | ret = inet_aton(argv[1], &addr); |
| 4759 | if (!ret) |
| 4760 | { |
| 4761 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4762 | VTY_NEWLINE); |
| 4763 | return CMD_WARNING; |
| 4764 | } |
| 4765 | |
| 4766 | params = ospf_lookup_if_params (ifp, addr); |
| 4767 | if (params == NULL) |
| 4768 | return CMD_SUCCESS; |
| 4769 | } |
| 4770 | |
| 4771 | key_id = strtol (argv[0], NULL, 10); |
| 4772 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4773 | if (ck == NULL) |
| 4774 | { |
| 4775 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4776 | return CMD_WARNING; |
| 4777 | } |
| 4778 | |
| 4779 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4780 | |
| 4781 | if (params != IF_DEF_PARAMS (ifp)) |
| 4782 | { |
| 4783 | ospf_free_if_params (ifp, addr); |
| 4784 | ospf_if_update_params (ifp, addr); |
| 4785 | } |
| 4786 | |
| 4787 | return CMD_SUCCESS; |
| 4788 | } |
| 4789 | |
| 4790 | ALIAS (no_ip_ospf_message_digest_key, |
| 4791 | no_ip_ospf_message_digest_key_cmd, |
| 4792 | "no ip ospf message-digest-key <1-255>", |
| 4793 | NO_STR |
| 4794 | "IP Information\n" |
| 4795 | "OSPF interface commands\n" |
| 4796 | "Message digest authentication password (key)\n" |
| 4797 | "Key ID\n") |
| 4798 | |
| 4799 | ALIAS (no_ip_ospf_message_digest_key, |
| 4800 | no_ospf_message_digest_key_cmd, |
| 4801 | "no ospf message-digest-key <1-255>", |
| 4802 | NO_STR |
| 4803 | "OSPF interface commands\n" |
| 4804 | "Message digest authentication password (key)\n" |
| 4805 | "Key ID\n") |
| 4806 | |
| 4807 | DEFUN (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4808 | ip_ospf_cost_u32_inet4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4809 | "ip ospf cost <1-65535> A.B.C.D", |
| 4810 | "IP Information\n" |
| 4811 | "OSPF interface commands\n" |
| 4812 | "Interface cost\n" |
| 4813 | "Cost\n" |
| 4814 | "Address of interface") |
| 4815 | { |
| 4816 | struct interface *ifp = vty->index; |
| 4817 | u_int32_t cost; |
| 4818 | struct in_addr addr; |
| 4819 | int ret; |
| 4820 | struct ospf_if_params *params; |
| 4821 | |
| 4822 | params = IF_DEF_PARAMS (ifp); |
| 4823 | |
| 4824 | cost = strtol (argv[0], NULL, 10); |
| 4825 | |
| 4826 | /* cost range is <1-65535>. */ |
| 4827 | if (cost < 1 || cost > 65535) |
| 4828 | { |
| 4829 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4830 | return CMD_WARNING; |
| 4831 | } |
| 4832 | |
| 4833 | if (argc == 2) |
| 4834 | { |
| 4835 | ret = inet_aton(argv[1], &addr); |
| 4836 | if (!ret) |
| 4837 | { |
| 4838 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4839 | VTY_NEWLINE); |
| 4840 | return CMD_WARNING; |
| 4841 | } |
| 4842 | |
| 4843 | params = ospf_get_if_params (ifp, addr); |
| 4844 | ospf_if_update_params (ifp, addr); |
| 4845 | } |
| 4846 | |
| 4847 | SET_IF_PARAM (params, output_cost_cmd); |
| 4848 | params->output_cost_cmd = cost; |
| 4849 | |
| 4850 | ospf_if_recalculate_output_cost (ifp); |
| 4851 | |
| 4852 | return CMD_SUCCESS; |
| 4853 | } |
| 4854 | |
| 4855 | ALIAS (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4856 | ip_ospf_cost_u32_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4857 | "ip ospf cost <1-65535>", |
| 4858 | "IP Information\n" |
| 4859 | "OSPF interface commands\n" |
| 4860 | "Interface cost\n" |
| 4861 | "Cost") |
| 4862 | |
| 4863 | ALIAS (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4864 | ospf_cost_u32_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4865 | "ospf cost <1-65535>", |
| 4866 | "OSPF interface commands\n" |
| 4867 | "Interface cost\n" |
| 4868 | "Cost") |
| 4869 | |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4870 | ALIAS (ip_ospf_cost, |
| 4871 | ospf_cost_u32_inet4_cmd, |
| 4872 | "ospf cost <1-65535> A.B.C.D", |
| 4873 | "OSPF interface commands\n" |
| 4874 | "Interface cost\n" |
| 4875 | "Cost\n" |
| 4876 | "Address of interface") |
| 4877 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4878 | DEFUN (no_ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4879 | no_ip_ospf_cost_inet4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4880 | "no ip ospf cost A.B.C.D", |
| 4881 | NO_STR |
| 4882 | "IP Information\n" |
| 4883 | "OSPF interface commands\n" |
| 4884 | "Interface cost\n" |
| 4885 | "Address of interface") |
| 4886 | { |
| 4887 | struct interface *ifp = vty->index; |
| 4888 | struct in_addr addr; |
| 4889 | int ret; |
| 4890 | struct ospf_if_params *params; |
| 4891 | |
| 4892 | ifp = vty->index; |
| 4893 | params = IF_DEF_PARAMS (ifp); |
| 4894 | |
| 4895 | if (argc == 1) |
| 4896 | { |
| 4897 | ret = inet_aton(argv[0], &addr); |
| 4898 | if (!ret) |
| 4899 | { |
| 4900 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4901 | VTY_NEWLINE); |
| 4902 | return CMD_WARNING; |
| 4903 | } |
| 4904 | |
| 4905 | params = ospf_lookup_if_params (ifp, addr); |
| 4906 | if (params == NULL) |
| 4907 | return CMD_SUCCESS; |
| 4908 | } |
| 4909 | |
| 4910 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4911 | |
| 4912 | if (params != IF_DEF_PARAMS (ifp)) |
| 4913 | { |
| 4914 | ospf_free_if_params (ifp, addr); |
| 4915 | ospf_if_update_params (ifp, addr); |
| 4916 | } |
| 4917 | |
| 4918 | ospf_if_recalculate_output_cost (ifp); |
| 4919 | |
| 4920 | return CMD_SUCCESS; |
| 4921 | } |
| 4922 | |
| 4923 | ALIAS (no_ip_ospf_cost, |
| 4924 | no_ip_ospf_cost_cmd, |
| 4925 | "no ip ospf cost", |
| 4926 | NO_STR |
| 4927 | "IP Information\n" |
| 4928 | "OSPF interface commands\n" |
| 4929 | "Interface cost\n") |
| 4930 | |
| 4931 | ALIAS (no_ip_ospf_cost, |
| 4932 | no_ospf_cost_cmd, |
| 4933 | "no ospf cost", |
| 4934 | NO_STR |
| 4935 | "OSPF interface commands\n" |
| 4936 | "Interface cost\n") |
| 4937 | |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4938 | ALIAS (no_ip_ospf_cost, |
| 4939 | no_ospf_cost_inet4_cmd, |
| 4940 | "no ospf cost A.B.C.D", |
| 4941 | NO_STR |
| 4942 | "OSPF interface commands\n" |
| 4943 | "Interface cost\n" |
| 4944 | "Address of interface") |
| 4945 | |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 4946 | DEFUN (no_ip_ospf_cost2, |
| 4947 | no_ip_ospf_cost_u32_cmd, |
| 4948 | "no ip ospf cost <1-65535>", |
| 4949 | NO_STR |
| 4950 | "IP Information\n" |
| 4951 | "OSPF interface commands\n" |
| 4952 | "Interface cost\n" |
| 4953 | "Cost") |
| 4954 | { |
| 4955 | struct interface *ifp = vty->index; |
| 4956 | struct in_addr addr; |
| 4957 | u_int32_t cost; |
| 4958 | int ret; |
| 4959 | struct ospf_if_params *params; |
| 4960 | |
| 4961 | ifp = vty->index; |
| 4962 | params = IF_DEF_PARAMS (ifp); |
| 4963 | |
| 4964 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
| 4965 | * always treated as "no ip ospf cost" regardless of the actual value |
| 4966 | * of N already configured for the interface. Thus the first argument |
| 4967 | * is always checked to be a number, but is ignored after that. |
| 4968 | */ |
| 4969 | cost = strtol (argv[0], NULL, 10); |
| 4970 | if (cost < 1 || cost > 65535) |
| 4971 | { |
| 4972 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4973 | return CMD_WARNING; |
| 4974 | } |
| 4975 | |
| 4976 | if (argc == 2) |
| 4977 | { |
| 4978 | ret = inet_aton(argv[1], &addr); |
| 4979 | if (!ret) |
| 4980 | { |
| 4981 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4982 | VTY_NEWLINE); |
| 4983 | return CMD_WARNING; |
| 4984 | } |
| 4985 | |
| 4986 | params = ospf_lookup_if_params (ifp, addr); |
| 4987 | if (params == NULL) |
| 4988 | return CMD_SUCCESS; |
| 4989 | } |
| 4990 | |
| 4991 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4992 | |
| 4993 | if (params != IF_DEF_PARAMS (ifp)) |
| 4994 | { |
| 4995 | ospf_free_if_params (ifp, addr); |
| 4996 | ospf_if_update_params (ifp, addr); |
| 4997 | } |
| 4998 | |
| 4999 | ospf_if_recalculate_output_cost (ifp); |
| 5000 | |
| 5001 | return CMD_SUCCESS; |
| 5002 | } |
| 5003 | |
| 5004 | ALIAS (no_ip_ospf_cost2, |
| 5005 | no_ospf_cost_u32_cmd, |
| 5006 | "no ospf cost <1-65535>", |
| 5007 | NO_STR |
| 5008 | "OSPF interface commands\n" |
| 5009 | "Interface cost\n" |
| 5010 | "Cost") |
| 5011 | |
| 5012 | ALIAS (no_ip_ospf_cost2, |
| 5013 | no_ip_ospf_cost_u32_inet4_cmd, |
| 5014 | "no ip ospf cost <1-65535> A.B.C.D", |
| 5015 | NO_STR |
| 5016 | "IP Information\n" |
| 5017 | "OSPF interface commands\n" |
| 5018 | "Interface cost\n" |
| 5019 | "Cost\n" |
| 5020 | "Address of interface") |
| 5021 | |
| 5022 | ALIAS (no_ip_ospf_cost2, |
| 5023 | no_ospf_cost_u32_inet4_cmd, |
| 5024 | "no ospf cost <1-65535> A.B.C.D", |
| 5025 | NO_STR |
| 5026 | "OSPF interface commands\n" |
| 5027 | "Interface cost\n" |
| 5028 | "Cost\n" |
| 5029 | "Address of interface") |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 5030 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 5031 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5032 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 5033 | { |
| 5034 | struct route_node *rn; |
| 5035 | struct ospf_neighbor *nbr; |
| 5036 | |
| 5037 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 5038 | if ((nbr = rn->info)) |
| 5039 | { |
| 5040 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 5041 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 5042 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 5043 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 5044 | } |
| 5045 | } |
| 5046 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5047 | static int |
| 5048 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 5049 | const char *nbr_str, |
| 5050 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5051 | { |
| 5052 | struct interface *ifp = vty->index; |
| 5053 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5054 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5055 | struct in_addr addr; |
| 5056 | int ret; |
| 5057 | struct ospf_if_params *params; |
| 5058 | struct ospf_interface *oi; |
| 5059 | struct route_node *rn; |
| 5060 | |
| 5061 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5062 | |
| 5063 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5064 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5065 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5066 | if (!ret) |
| 5067 | { |
| 5068 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5069 | VTY_NEWLINE); |
| 5070 | return CMD_WARNING; |
| 5071 | } |
| 5072 | |
| 5073 | params = ospf_get_if_params (ifp, addr); |
| 5074 | ospf_if_update_params (ifp, addr); |
| 5075 | } |
| 5076 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5077 | if (interval_str) |
| 5078 | { |
| 5079 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 5080 | 1, 65535); |
| 5081 | |
| 5082 | /* reset fast_hello too, just to be sure */ |
| 5083 | UNSET_IF_PARAM (params, fast_hello); |
| 5084 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 5085 | } |
| 5086 | else if (fast_hello_str) |
| 5087 | { |
| 5088 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 5089 | 1, 10); |
| 5090 | /* 1s dead-interval with sub-second hellos desired */ |
| 5091 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 5092 | SET_IF_PARAM (params, fast_hello); |
| 5093 | params->fast_hello = hellomult; |
| 5094 | } |
| 5095 | else |
| 5096 | { |
| 5097 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 5098 | VTY_NEWLINE); |
| 5099 | return CMD_WARNING; |
| 5100 | } |
| 5101 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5102 | SET_IF_PARAM (params, v_wait); |
| 5103 | params->v_wait = seconds; |
| 5104 | |
| 5105 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5106 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5107 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5108 | struct ospf *ospf; |
| 5109 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5110 | { |
| 5111 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5112 | if (oi) |
| 5113 | ospf_nbr_timer_update (oi); |
| 5114 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5115 | } |
| 5116 | else |
| 5117 | { |
| 5118 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5119 | if ((oi = rn->info)) |
| 5120 | ospf_nbr_timer_update (oi); |
| 5121 | } |
| 5122 | |
| 5123 | return CMD_SUCCESS; |
| 5124 | } |
| 5125 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5126 | |
| 5127 | DEFUN (ip_ospf_dead_interval, |
| 5128 | ip_ospf_dead_interval_addr_cmd, |
| 5129 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 5130 | "IP Information\n" |
| 5131 | "OSPF interface commands\n" |
| 5132 | "Interval after which a neighbor is declared dead\n" |
| 5133 | "Seconds\n" |
| 5134 | "Address of interface\n") |
| 5135 | { |
| 5136 | if (argc == 2) |
| 5137 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 5138 | else |
| 5139 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 5140 | } |
| 5141 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5142 | ALIAS (ip_ospf_dead_interval, |
| 5143 | ip_ospf_dead_interval_cmd, |
| 5144 | "ip ospf dead-interval <1-65535>", |
| 5145 | "IP Information\n" |
| 5146 | "OSPF interface commands\n" |
| 5147 | "Interval after which a neighbor is declared dead\n" |
| 5148 | "Seconds\n") |
| 5149 | |
| 5150 | ALIAS (ip_ospf_dead_interval, |
| 5151 | ospf_dead_interval_cmd, |
| 5152 | "ospf dead-interval <1-65535>", |
| 5153 | "OSPF interface commands\n" |
| 5154 | "Interval after which a neighbor is declared dead\n" |
| 5155 | "Seconds\n") |
| 5156 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5157 | DEFUN (ip_ospf_dead_interval_minimal, |
| 5158 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 5159 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 5160 | "IP Information\n" |
| 5161 | "OSPF interface commands\n" |
| 5162 | "Interval after which a neighbor is declared dead\n" |
| 5163 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5164 | "Hello multiplier factor\n" |
| 5165 | "Number of Hellos to send each second\n" |
| 5166 | "Address of interface\n") |
| 5167 | { |
| 5168 | if (argc == 2) |
| 5169 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 5170 | else |
| 5171 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 5172 | } |
| 5173 | |
| 5174 | ALIAS (ip_ospf_dead_interval_minimal, |
| 5175 | ip_ospf_dead_interval_minimal_cmd, |
| 5176 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 5177 | "IP Information\n" |
| 5178 | "OSPF interface commands\n" |
| 5179 | "Interval after which a neighbor is declared dead\n" |
| 5180 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5181 | "Hello multiplier factor\n" |
| 5182 | "Number of Hellos to send each second\n") |
| 5183 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5184 | DEFUN (no_ip_ospf_dead_interval, |
| 5185 | no_ip_ospf_dead_interval_addr_cmd, |
| 5186 | "no ip ospf dead-interval A.B.C.D", |
| 5187 | NO_STR |
| 5188 | "IP Information\n" |
| 5189 | "OSPF interface commands\n" |
| 5190 | "Interval after which a neighbor is declared dead\n" |
| 5191 | "Address of interface") |
| 5192 | { |
| 5193 | struct interface *ifp = vty->index; |
| 5194 | struct in_addr addr; |
| 5195 | int ret; |
| 5196 | struct ospf_if_params *params; |
| 5197 | struct ospf_interface *oi; |
| 5198 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5199 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5200 | ifp = vty->index; |
| 5201 | params = IF_DEF_PARAMS (ifp); |
| 5202 | |
| 5203 | if (argc == 1) |
| 5204 | { |
| 5205 | ret = inet_aton(argv[0], &addr); |
| 5206 | if (!ret) |
| 5207 | { |
| 5208 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5209 | VTY_NEWLINE); |
| 5210 | return CMD_WARNING; |
| 5211 | } |
| 5212 | |
| 5213 | params = ospf_lookup_if_params (ifp, addr); |
| 5214 | if (params == NULL) |
| 5215 | return CMD_SUCCESS; |
| 5216 | } |
| 5217 | |
| 5218 | UNSET_IF_PARAM (params, v_wait); |
| 5219 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5220 | |
| 5221 | UNSET_IF_PARAM (params, fast_hello); |
| 5222 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 5223 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5224 | if (params != IF_DEF_PARAMS (ifp)) |
| 5225 | { |
| 5226 | ospf_free_if_params (ifp, addr); |
| 5227 | ospf_if_update_params (ifp, addr); |
| 5228 | } |
| 5229 | |
| 5230 | /* Update timer values in neighbor structure. */ |
| 5231 | if (argc == 1) |
| 5232 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5233 | struct ospf *ospf; |
| 5234 | |
| 5235 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5236 | { |
| 5237 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5238 | if (oi) |
| 5239 | ospf_nbr_timer_update (oi); |
| 5240 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5241 | } |
| 5242 | else |
| 5243 | { |
| 5244 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5245 | if ((oi = rn->info)) |
| 5246 | ospf_nbr_timer_update (oi); |
| 5247 | } |
| 5248 | |
| 5249 | return CMD_SUCCESS; |
| 5250 | } |
| 5251 | |
| 5252 | ALIAS (no_ip_ospf_dead_interval, |
| 5253 | no_ip_ospf_dead_interval_cmd, |
| 5254 | "no ip ospf dead-interval", |
| 5255 | NO_STR |
| 5256 | "IP Information\n" |
| 5257 | "OSPF interface commands\n" |
| 5258 | "Interval after which a neighbor is declared dead\n") |
| 5259 | |
| 5260 | ALIAS (no_ip_ospf_dead_interval, |
| 5261 | no_ospf_dead_interval_cmd, |
| 5262 | "no ospf dead-interval", |
| 5263 | NO_STR |
| 5264 | "OSPF interface commands\n" |
| 5265 | "Interval after which a neighbor is declared dead\n") |
| 5266 | |
| 5267 | DEFUN (ip_ospf_hello_interval, |
| 5268 | ip_ospf_hello_interval_addr_cmd, |
| 5269 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 5270 | "IP Information\n" |
| 5271 | "OSPF interface commands\n" |
| 5272 | "Time between HELLO packets\n" |
| 5273 | "Seconds\n" |
| 5274 | "Address of interface") |
| 5275 | { |
| 5276 | struct interface *ifp = vty->index; |
| 5277 | u_int32_t seconds; |
| 5278 | struct in_addr addr; |
| 5279 | int ret; |
| 5280 | struct ospf_if_params *params; |
| 5281 | |
| 5282 | params = IF_DEF_PARAMS (ifp); |
| 5283 | |
| 5284 | seconds = strtol (argv[0], NULL, 10); |
| 5285 | |
| 5286 | /* HelloInterval range is <1-65535>. */ |
| 5287 | if (seconds < 1 || seconds > 65535) |
| 5288 | { |
| 5289 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 5290 | return CMD_WARNING; |
| 5291 | } |
| 5292 | |
| 5293 | if (argc == 2) |
| 5294 | { |
| 5295 | ret = inet_aton(argv[1], &addr); |
| 5296 | if (!ret) |
| 5297 | { |
| 5298 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5299 | VTY_NEWLINE); |
| 5300 | return CMD_WARNING; |
| 5301 | } |
| 5302 | |
| 5303 | params = ospf_get_if_params (ifp, addr); |
| 5304 | ospf_if_update_params (ifp, addr); |
| 5305 | } |
| 5306 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5307 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5308 | params->v_hello = seconds; |
| 5309 | |
| 5310 | return CMD_SUCCESS; |
| 5311 | } |
| 5312 | |
| 5313 | ALIAS (ip_ospf_hello_interval, |
| 5314 | ip_ospf_hello_interval_cmd, |
| 5315 | "ip ospf hello-interval <1-65535>", |
| 5316 | "IP Information\n" |
| 5317 | "OSPF interface commands\n" |
| 5318 | "Time between HELLO packets\n" |
| 5319 | "Seconds\n") |
| 5320 | |
| 5321 | ALIAS (ip_ospf_hello_interval, |
| 5322 | ospf_hello_interval_cmd, |
| 5323 | "ospf hello-interval <1-65535>", |
| 5324 | "OSPF interface commands\n" |
| 5325 | "Time between HELLO packets\n" |
| 5326 | "Seconds\n") |
| 5327 | |
| 5328 | DEFUN (no_ip_ospf_hello_interval, |
| 5329 | no_ip_ospf_hello_interval_addr_cmd, |
| 5330 | "no ip ospf hello-interval A.B.C.D", |
| 5331 | NO_STR |
| 5332 | "IP Information\n" |
| 5333 | "OSPF interface commands\n" |
| 5334 | "Time between HELLO packets\n" |
| 5335 | "Address of interface") |
| 5336 | { |
| 5337 | struct interface *ifp = vty->index; |
| 5338 | struct in_addr addr; |
| 5339 | int ret; |
| 5340 | struct ospf_if_params *params; |
| 5341 | |
| 5342 | ifp = vty->index; |
| 5343 | params = IF_DEF_PARAMS (ifp); |
| 5344 | |
| 5345 | if (argc == 1) |
| 5346 | { |
| 5347 | ret = inet_aton(argv[0], &addr); |
| 5348 | if (!ret) |
| 5349 | { |
| 5350 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5351 | VTY_NEWLINE); |
| 5352 | return CMD_WARNING; |
| 5353 | } |
| 5354 | |
| 5355 | params = ospf_lookup_if_params (ifp, addr); |
| 5356 | if (params == NULL) |
| 5357 | return CMD_SUCCESS; |
| 5358 | } |
| 5359 | |
| 5360 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5361 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5362 | |
| 5363 | if (params != IF_DEF_PARAMS (ifp)) |
| 5364 | { |
| 5365 | ospf_free_if_params (ifp, addr); |
| 5366 | ospf_if_update_params (ifp, addr); |
| 5367 | } |
| 5368 | |
| 5369 | return CMD_SUCCESS; |
| 5370 | } |
| 5371 | |
| 5372 | ALIAS (no_ip_ospf_hello_interval, |
| 5373 | no_ip_ospf_hello_interval_cmd, |
| 5374 | "no ip ospf hello-interval", |
| 5375 | NO_STR |
| 5376 | "IP Information\n" |
| 5377 | "OSPF interface commands\n" |
| 5378 | "Time between HELLO packets\n") |
| 5379 | |
| 5380 | ALIAS (no_ip_ospf_hello_interval, |
| 5381 | no_ospf_hello_interval_cmd, |
| 5382 | "no ospf hello-interval", |
| 5383 | NO_STR |
| 5384 | "OSPF interface commands\n" |
| 5385 | "Time between HELLO packets\n") |
| 5386 | |
| 5387 | DEFUN (ip_ospf_network, |
| 5388 | ip_ospf_network_cmd, |
| 5389 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5390 | "IP Information\n" |
| 5391 | "OSPF interface commands\n" |
| 5392 | "Network type\n" |
| 5393 | "Specify OSPF broadcast multi-access network\n" |
| 5394 | "Specify OSPF NBMA network\n" |
| 5395 | "Specify OSPF point-to-multipoint network\n" |
| 5396 | "Specify OSPF point-to-point network\n") |
| 5397 | { |
| 5398 | struct interface *ifp = vty->index; |
| 5399 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5400 | struct route_node *rn; |
Christian Franke | 4b4bda9 | 2013-07-11 07:56:29 +0000 | [diff] [blame] | 5401 | |
| 5402 | if (old_type == OSPF_IFTYPE_LOOPBACK) |
| 5403 | { |
| 5404 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); |
| 5405 | return CMD_WARNING; |
| 5406 | } |
| 5407 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5408 | if (strncmp (argv[0], "b", 1) == 0) |
| 5409 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5410 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5411 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5412 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5413 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5414 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5415 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5416 | |
| 5417 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5418 | return CMD_SUCCESS; |
| 5419 | |
| 5420 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5421 | |
| 5422 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5423 | { |
| 5424 | struct ospf_interface *oi = rn->info; |
| 5425 | |
| 5426 | if (!oi) |
| 5427 | continue; |
| 5428 | |
| 5429 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5430 | |
| 5431 | if (oi->state > ISM_Down) |
| 5432 | { |
| 5433 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5434 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5435 | } |
| 5436 | } |
| 5437 | |
| 5438 | return CMD_SUCCESS; |
| 5439 | } |
| 5440 | |
| 5441 | ALIAS (ip_ospf_network, |
| 5442 | ospf_network_cmd, |
| 5443 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5444 | "OSPF interface commands\n" |
| 5445 | "Network type\n" |
| 5446 | "Specify OSPF broadcast multi-access network\n" |
| 5447 | "Specify OSPF NBMA network\n" |
| 5448 | "Specify OSPF point-to-multipoint network\n" |
| 5449 | "Specify OSPF point-to-point network\n") |
| 5450 | |
| 5451 | DEFUN (no_ip_ospf_network, |
| 5452 | no_ip_ospf_network_cmd, |
| 5453 | "no ip ospf network", |
| 5454 | NO_STR |
| 5455 | "IP Information\n" |
| 5456 | "OSPF interface commands\n" |
| 5457 | "Network type\n") |
| 5458 | { |
| 5459 | struct interface *ifp = vty->index; |
| 5460 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5461 | struct route_node *rn; |
| 5462 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5463 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5464 | |
| 5465 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5466 | return CMD_SUCCESS; |
| 5467 | |
| 5468 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5469 | { |
| 5470 | struct ospf_interface *oi = rn->info; |
| 5471 | |
| 5472 | if (!oi) |
| 5473 | continue; |
| 5474 | |
| 5475 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5476 | |
| 5477 | if (oi->state > ISM_Down) |
| 5478 | { |
| 5479 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5480 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5481 | } |
| 5482 | } |
| 5483 | |
| 5484 | return CMD_SUCCESS; |
| 5485 | } |
| 5486 | |
| 5487 | ALIAS (no_ip_ospf_network, |
| 5488 | no_ospf_network_cmd, |
| 5489 | "no ospf network", |
| 5490 | NO_STR |
| 5491 | "OSPF interface commands\n" |
| 5492 | "Network type\n") |
| 5493 | |
| 5494 | DEFUN (ip_ospf_priority, |
| 5495 | ip_ospf_priority_addr_cmd, |
| 5496 | "ip ospf priority <0-255> A.B.C.D", |
| 5497 | "IP Information\n" |
| 5498 | "OSPF interface commands\n" |
| 5499 | "Router priority\n" |
| 5500 | "Priority\n" |
| 5501 | "Address of interface") |
| 5502 | { |
| 5503 | struct interface *ifp = vty->index; |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 5504 | long priority; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5505 | struct route_node *rn; |
| 5506 | struct in_addr addr; |
| 5507 | int ret; |
| 5508 | struct ospf_if_params *params; |
| 5509 | |
| 5510 | params = IF_DEF_PARAMS (ifp); |
| 5511 | |
| 5512 | priority = strtol (argv[0], NULL, 10); |
| 5513 | |
| 5514 | /* Router Priority range is <0-255>. */ |
| 5515 | if (priority < 0 || priority > 255) |
| 5516 | { |
| 5517 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5518 | return CMD_WARNING; |
| 5519 | } |
| 5520 | |
| 5521 | if (argc == 2) |
| 5522 | { |
| 5523 | ret = inet_aton(argv[1], &addr); |
| 5524 | if (!ret) |
| 5525 | { |
| 5526 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5527 | VTY_NEWLINE); |
| 5528 | return CMD_WARNING; |
| 5529 | } |
| 5530 | |
| 5531 | params = ospf_get_if_params (ifp, addr); |
| 5532 | ospf_if_update_params (ifp, addr); |
| 5533 | } |
| 5534 | |
| 5535 | SET_IF_PARAM (params, priority); |
| 5536 | params->priority = priority; |
| 5537 | |
| 5538 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5539 | { |
| 5540 | struct ospf_interface *oi = rn->info; |
| 5541 | |
| 5542 | if (!oi) |
| 5543 | continue; |
| 5544 | |
| 5545 | |
| 5546 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5547 | { |
| 5548 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5549 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5550 | } |
| 5551 | } |
| 5552 | |
| 5553 | return CMD_SUCCESS; |
| 5554 | } |
| 5555 | |
| 5556 | ALIAS (ip_ospf_priority, |
| 5557 | ip_ospf_priority_cmd, |
| 5558 | "ip ospf priority <0-255>", |
| 5559 | "IP Information\n" |
| 5560 | "OSPF interface commands\n" |
| 5561 | "Router priority\n" |
| 5562 | "Priority\n") |
| 5563 | |
| 5564 | ALIAS (ip_ospf_priority, |
| 5565 | ospf_priority_cmd, |
| 5566 | "ospf priority <0-255>", |
| 5567 | "OSPF interface commands\n" |
| 5568 | "Router priority\n" |
| 5569 | "Priority\n") |
| 5570 | |
| 5571 | DEFUN (no_ip_ospf_priority, |
| 5572 | no_ip_ospf_priority_addr_cmd, |
| 5573 | "no ip ospf priority A.B.C.D", |
| 5574 | NO_STR |
| 5575 | "IP Information\n" |
| 5576 | "OSPF interface commands\n" |
| 5577 | "Router priority\n" |
| 5578 | "Address of interface") |
| 5579 | { |
| 5580 | struct interface *ifp = vty->index; |
| 5581 | struct route_node *rn; |
| 5582 | struct in_addr addr; |
| 5583 | int ret; |
| 5584 | struct ospf_if_params *params; |
| 5585 | |
| 5586 | ifp = vty->index; |
| 5587 | params = IF_DEF_PARAMS (ifp); |
| 5588 | |
| 5589 | if (argc == 1) |
| 5590 | { |
| 5591 | ret = inet_aton(argv[0], &addr); |
| 5592 | if (!ret) |
| 5593 | { |
| 5594 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5595 | VTY_NEWLINE); |
| 5596 | return CMD_WARNING; |
| 5597 | } |
| 5598 | |
| 5599 | params = ospf_lookup_if_params (ifp, addr); |
| 5600 | if (params == NULL) |
| 5601 | return CMD_SUCCESS; |
| 5602 | } |
| 5603 | |
| 5604 | UNSET_IF_PARAM (params, priority); |
| 5605 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5606 | |
| 5607 | if (params != IF_DEF_PARAMS (ifp)) |
| 5608 | { |
| 5609 | ospf_free_if_params (ifp, addr); |
| 5610 | ospf_if_update_params (ifp, addr); |
| 5611 | } |
| 5612 | |
| 5613 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5614 | { |
| 5615 | struct ospf_interface *oi = rn->info; |
| 5616 | |
| 5617 | if (!oi) |
| 5618 | continue; |
| 5619 | |
| 5620 | |
| 5621 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5622 | { |
| 5623 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5624 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5625 | } |
| 5626 | } |
| 5627 | |
| 5628 | return CMD_SUCCESS; |
| 5629 | } |
| 5630 | |
| 5631 | ALIAS (no_ip_ospf_priority, |
| 5632 | no_ip_ospf_priority_cmd, |
| 5633 | "no ip ospf priority", |
| 5634 | NO_STR |
| 5635 | "IP Information\n" |
| 5636 | "OSPF interface commands\n" |
| 5637 | "Router priority\n") |
| 5638 | |
| 5639 | ALIAS (no_ip_ospf_priority, |
| 5640 | no_ospf_priority_cmd, |
| 5641 | "no ospf priority", |
| 5642 | NO_STR |
| 5643 | "OSPF interface commands\n" |
| 5644 | "Router priority\n") |
| 5645 | |
| 5646 | DEFUN (ip_ospf_retransmit_interval, |
| 5647 | ip_ospf_retransmit_interval_addr_cmd, |
| 5648 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5649 | "IP Information\n" |
| 5650 | "OSPF interface commands\n" |
| 5651 | "Time between retransmitting lost link state advertisements\n" |
| 5652 | "Seconds\n" |
| 5653 | "Address of interface") |
| 5654 | { |
| 5655 | struct interface *ifp = vty->index; |
| 5656 | u_int32_t seconds; |
| 5657 | struct in_addr addr; |
| 5658 | int ret; |
| 5659 | struct ospf_if_params *params; |
| 5660 | |
| 5661 | params = IF_DEF_PARAMS (ifp); |
| 5662 | seconds = strtol (argv[0], NULL, 10); |
| 5663 | |
| 5664 | /* Retransmit Interval range is <3-65535>. */ |
| 5665 | if (seconds < 3 || seconds > 65535) |
| 5666 | { |
| 5667 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5668 | return CMD_WARNING; |
| 5669 | } |
| 5670 | |
| 5671 | |
| 5672 | if (argc == 2) |
| 5673 | { |
| 5674 | ret = inet_aton(argv[1], &addr); |
| 5675 | if (!ret) |
| 5676 | { |
| 5677 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5678 | VTY_NEWLINE); |
| 5679 | return CMD_WARNING; |
| 5680 | } |
| 5681 | |
| 5682 | params = ospf_get_if_params (ifp, addr); |
| 5683 | ospf_if_update_params (ifp, addr); |
| 5684 | } |
| 5685 | |
| 5686 | SET_IF_PARAM (params, retransmit_interval); |
| 5687 | params->retransmit_interval = seconds; |
| 5688 | |
| 5689 | return CMD_SUCCESS; |
| 5690 | } |
| 5691 | |
| 5692 | ALIAS (ip_ospf_retransmit_interval, |
| 5693 | ip_ospf_retransmit_interval_cmd, |
| 5694 | "ip ospf retransmit-interval <3-65535>", |
| 5695 | "IP Information\n" |
| 5696 | "OSPF interface commands\n" |
| 5697 | "Time between retransmitting lost link state advertisements\n" |
| 5698 | "Seconds\n") |
| 5699 | |
| 5700 | ALIAS (ip_ospf_retransmit_interval, |
| 5701 | ospf_retransmit_interval_cmd, |
| 5702 | "ospf retransmit-interval <3-65535>", |
| 5703 | "OSPF interface commands\n" |
| 5704 | "Time between retransmitting lost link state advertisements\n" |
| 5705 | "Seconds\n") |
| 5706 | |
| 5707 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5708 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5709 | "no ip ospf retransmit-interval A.B.C.D", |
| 5710 | NO_STR |
| 5711 | "IP Information\n" |
| 5712 | "OSPF interface commands\n" |
| 5713 | "Time between retransmitting lost link state advertisements\n" |
| 5714 | "Address of interface") |
| 5715 | { |
| 5716 | struct interface *ifp = vty->index; |
| 5717 | struct in_addr addr; |
| 5718 | int ret; |
| 5719 | struct ospf_if_params *params; |
| 5720 | |
| 5721 | ifp = vty->index; |
| 5722 | params = IF_DEF_PARAMS (ifp); |
| 5723 | |
| 5724 | if (argc == 1) |
| 5725 | { |
| 5726 | ret = inet_aton(argv[0], &addr); |
| 5727 | if (!ret) |
| 5728 | { |
| 5729 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5730 | VTY_NEWLINE); |
| 5731 | return CMD_WARNING; |
| 5732 | } |
| 5733 | |
| 5734 | params = ospf_lookup_if_params (ifp, addr); |
| 5735 | if (params == NULL) |
| 5736 | return CMD_SUCCESS; |
| 5737 | } |
| 5738 | |
| 5739 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5740 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5741 | |
| 5742 | if (params != IF_DEF_PARAMS (ifp)) |
| 5743 | { |
| 5744 | ospf_free_if_params (ifp, addr); |
| 5745 | ospf_if_update_params (ifp, addr); |
| 5746 | } |
| 5747 | |
| 5748 | return CMD_SUCCESS; |
| 5749 | } |
| 5750 | |
| 5751 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5752 | no_ip_ospf_retransmit_interval_cmd, |
| 5753 | "no ip ospf retransmit-interval", |
| 5754 | NO_STR |
| 5755 | "IP Information\n" |
| 5756 | "OSPF interface commands\n" |
| 5757 | "Time between retransmitting lost link state advertisements\n") |
| 5758 | |
| 5759 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5760 | no_ospf_retransmit_interval_cmd, |
| 5761 | "no ospf retransmit-interval", |
| 5762 | NO_STR |
| 5763 | "OSPF interface commands\n" |
| 5764 | "Time between retransmitting lost link state advertisements\n") |
| 5765 | |
| 5766 | DEFUN (ip_ospf_transmit_delay, |
| 5767 | ip_ospf_transmit_delay_addr_cmd, |
| 5768 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5769 | "IP Information\n" |
| 5770 | "OSPF interface commands\n" |
| 5771 | "Link state transmit delay\n" |
| 5772 | "Seconds\n" |
| 5773 | "Address of interface") |
| 5774 | { |
| 5775 | struct interface *ifp = vty->index; |
| 5776 | u_int32_t seconds; |
| 5777 | struct in_addr addr; |
| 5778 | int ret; |
| 5779 | struct ospf_if_params *params; |
| 5780 | |
| 5781 | params = IF_DEF_PARAMS (ifp); |
| 5782 | seconds = strtol (argv[0], NULL, 10); |
| 5783 | |
| 5784 | /* Transmit Delay range is <1-65535>. */ |
| 5785 | if (seconds < 1 || seconds > 65535) |
| 5786 | { |
| 5787 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5788 | return CMD_WARNING; |
| 5789 | } |
| 5790 | |
| 5791 | if (argc == 2) |
| 5792 | { |
| 5793 | ret = inet_aton(argv[1], &addr); |
| 5794 | if (!ret) |
| 5795 | { |
| 5796 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5797 | VTY_NEWLINE); |
| 5798 | return CMD_WARNING; |
| 5799 | } |
| 5800 | |
| 5801 | params = ospf_get_if_params (ifp, addr); |
| 5802 | ospf_if_update_params (ifp, addr); |
| 5803 | } |
| 5804 | |
| 5805 | SET_IF_PARAM (params, transmit_delay); |
| 5806 | params->transmit_delay = seconds; |
| 5807 | |
| 5808 | return CMD_SUCCESS; |
| 5809 | } |
| 5810 | |
| 5811 | ALIAS (ip_ospf_transmit_delay, |
| 5812 | ip_ospf_transmit_delay_cmd, |
| 5813 | "ip ospf transmit-delay <1-65535>", |
| 5814 | "IP Information\n" |
| 5815 | "OSPF interface commands\n" |
| 5816 | "Link state transmit delay\n" |
| 5817 | "Seconds\n") |
| 5818 | |
| 5819 | ALIAS (ip_ospf_transmit_delay, |
| 5820 | ospf_transmit_delay_cmd, |
| 5821 | "ospf transmit-delay <1-65535>", |
| 5822 | "OSPF interface commands\n" |
| 5823 | "Link state transmit delay\n" |
| 5824 | "Seconds\n") |
| 5825 | |
| 5826 | DEFUN (no_ip_ospf_transmit_delay, |
| 5827 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5828 | "no ip ospf transmit-delay A.B.C.D", |
| 5829 | NO_STR |
| 5830 | "IP Information\n" |
| 5831 | "OSPF interface commands\n" |
| 5832 | "Link state transmit delay\n" |
| 5833 | "Address of interface") |
| 5834 | { |
| 5835 | struct interface *ifp = vty->index; |
| 5836 | struct in_addr addr; |
| 5837 | int ret; |
| 5838 | struct ospf_if_params *params; |
| 5839 | |
| 5840 | ifp = vty->index; |
| 5841 | params = IF_DEF_PARAMS (ifp); |
| 5842 | |
| 5843 | if (argc == 1) |
| 5844 | { |
| 5845 | ret = inet_aton(argv[0], &addr); |
| 5846 | if (!ret) |
| 5847 | { |
| 5848 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5849 | VTY_NEWLINE); |
| 5850 | return CMD_WARNING; |
| 5851 | } |
| 5852 | |
| 5853 | params = ospf_lookup_if_params (ifp, addr); |
| 5854 | if (params == NULL) |
| 5855 | return CMD_SUCCESS; |
| 5856 | } |
| 5857 | |
| 5858 | UNSET_IF_PARAM (params, transmit_delay); |
| 5859 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5860 | |
| 5861 | if (params != IF_DEF_PARAMS (ifp)) |
| 5862 | { |
| 5863 | ospf_free_if_params (ifp, addr); |
| 5864 | ospf_if_update_params (ifp, addr); |
| 5865 | } |
| 5866 | |
| 5867 | return CMD_SUCCESS; |
| 5868 | } |
| 5869 | |
| 5870 | ALIAS (no_ip_ospf_transmit_delay, |
| 5871 | no_ip_ospf_transmit_delay_cmd, |
| 5872 | "no ip ospf transmit-delay", |
| 5873 | NO_STR |
| 5874 | "IP Information\n" |
| 5875 | "OSPF interface commands\n" |
| 5876 | "Link state transmit delay\n") |
| 5877 | |
| 5878 | ALIAS (no_ip_ospf_transmit_delay, |
| 5879 | no_ospf_transmit_delay_cmd, |
| 5880 | "no ospf transmit-delay", |
| 5881 | NO_STR |
| 5882 | "OSPF interface commands\n" |
| 5883 | "Link state transmit delay\n") |
| 5884 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5885 | DEFUN (ospf_redistribute_source, |
| 5886 | ospf_redistribute_source_cmd, |
| 5887 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5888 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5889 | REDIST_STR |
| 5890 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5891 | "Metric for redistributed routes\n" |
| 5892 | "OSPF default metric\n" |
| 5893 | "OSPF exterior metric type for redistributed routes\n" |
| 5894 | "Set OSPF External Type 1 metrics\n" |
| 5895 | "Set OSPF External Type 2 metrics\n" |
| 5896 | "Route map reference\n" |
| 5897 | "Pointer to route-map entries\n") |
| 5898 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5899 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5900 | int source; |
| 5901 | int type = -1; |
| 5902 | int metric = -1; |
| 5903 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5904 | if (argc < 4) |
| 5905 | return CMD_WARNING; /* should not happen */ |
| 5906 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5907 | /* Get distribute source. */ |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5908 | source = proto_redistnum(AFI_IP, argv[0]); |
| 5909 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5910 | return CMD_WARNING; |
| 5911 | |
| 5912 | /* Get metric value. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5913 | if (argv[1] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5914 | if (!str2metric (argv[1], &metric)) |
| 5915 | return CMD_WARNING; |
| 5916 | |
| 5917 | /* Get metric type. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5918 | if (argv[2] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5919 | if (!str2metric_type (argv[2], &type)) |
| 5920 | return CMD_WARNING; |
| 5921 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5922 | if (argv[3] != NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5923 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5924 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5925 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5926 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5927 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5928 | } |
| 5929 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5930 | DEFUN (no_ospf_redistribute_source, |
| 5931 | no_ospf_redistribute_source_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5932 | "no redistribute " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5933 | NO_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5934 | REDIST_STR |
| 5935 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5936 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5937 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5938 | int source; |
| 5939 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5940 | source = proto_redistnum(AFI_IP, argv[0]); |
| 5941 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5942 | return CMD_WARNING; |
| 5943 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5944 | ospf_routemap_unset (ospf, source); |
| 5945 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5946 | } |
| 5947 | |
| 5948 | DEFUN (ospf_distribute_list_out, |
| 5949 | ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5950 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5951 | "Filter networks in routing updates\n" |
| 5952 | "Access-list name\n" |
| 5953 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5954 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5955 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5956 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5957 | int source; |
| 5958 | |
| 5959 | /* Get distribute source. */ |
Christian Franke | bda3c32 | 2012-12-04 11:31:16 -0800 | [diff] [blame] | 5960 | source = proto_redistnum(AFI_IP, argv[1]); |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5961 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5962 | return CMD_WARNING; |
| 5963 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5964 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5965 | } |
| 5966 | |
| 5967 | DEFUN (no_ospf_distribute_list_out, |
| 5968 | no_ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5969 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5970 | NO_STR |
| 5971 | "Filter networks in routing updates\n" |
| 5972 | "Access-list name\n" |
| 5973 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5974 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 source; |
| 5978 | |
Christian Franke | bda3c32 | 2012-12-04 11:31:16 -0800 | [diff] [blame] | 5979 | source = proto_redistnum(AFI_IP, argv[1]); |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5980 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5981 | return CMD_WARNING; |
| 5982 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5983 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5984 | } |
| 5985 | |
| 5986 | /* Default information originate. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5987 | DEFUN (ospf_default_information_originate, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5988 | ospf_default_information_originate_cmd, |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5989 | "default-information originate " |
| 5990 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5991 | "Control distribution of default information\n" |
| 5992 | "Distribute a default route\n" |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5993 | "Always advertise default route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5994 | "OSPF default metric\n" |
| 5995 | "OSPF metric\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5996 | "OSPF metric type for default routes\n" |
| 5997 | "Set OSPF External Type 1 metrics\n" |
| 5998 | "Set OSPF External Type 2 metrics\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | "Route map reference\n" |
| 6000 | "Pointer to route-map entries\n") |
| 6001 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6002 | struct ospf *ospf = vty->index; |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6003 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6004 | int type = -1; |
| 6005 | int metric = -1; |
| 6006 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6007 | if (argc < 4) |
| 6008 | return CMD_WARNING; /* this should not happen */ |
| 6009 | |
| 6010 | /* Check whether "always" was specified */ |
| 6011 | if (argv[0] != NULL) |
| 6012 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6013 | |
| 6014 | /* Get metric value. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6015 | if (argv[1] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6016 | if (!str2metric (argv[1], &metric)) |
| 6017 | return CMD_WARNING; |
| 6018 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6019 | /* Get metric type. */ |
| 6020 | if (argv[2] != NULL) |
| 6021 | if (!str2metric_type (argv[2], &type)) |
| 6022 | return CMD_WARNING; |
| 6023 | |
| 6024 | if (argv[3] != NULL) |
| 6025 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6026 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6027 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6028 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6029 | return ospf_redistribute_default_set (ospf, default_originate, |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6030 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6031 | } |
| 6032 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6033 | DEFUN (no_ospf_default_information_originate, |
| 6034 | no_ospf_default_information_originate_cmd, |
| 6035 | "no default-information originate", |
| 6036 | NO_STR |
| 6037 | "Control distribution of default information\n" |
| 6038 | "Distribute a default route\n") |
| 6039 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6040 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6041 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6042 | |
| 6043 | p.family = AF_INET; |
| 6044 | p.prefix.s_addr = 0; |
| 6045 | p.prefixlen = 0; |
| 6046 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6047 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6048 | |
| 6049 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6050 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6051 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6052 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6053 | } |
| 6054 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6055 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6056 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6057 | } |
| 6058 | |
| 6059 | DEFUN (ospf_default_metric, |
| 6060 | ospf_default_metric_cmd, |
| 6061 | "default-metric <0-16777214>", |
| 6062 | "Set metric of redistributed routes\n" |
| 6063 | "Default metric\n") |
| 6064 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6065 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6066 | int metric = -1; |
| 6067 | |
| 6068 | if (!str2metric (argv[0], &metric)) |
| 6069 | return CMD_WARNING; |
| 6070 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6071 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6072 | |
| 6073 | return CMD_SUCCESS; |
| 6074 | } |
| 6075 | |
| 6076 | DEFUN (no_ospf_default_metric, |
| 6077 | no_ospf_default_metric_cmd, |
| 6078 | "no default-metric", |
| 6079 | NO_STR |
| 6080 | "Set metric of redistributed routes\n") |
| 6081 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6082 | struct ospf *ospf = vty->index; |
| 6083 | |
| 6084 | ospf->default_metric = -1; |
| 6085 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6086 | return CMD_SUCCESS; |
| 6087 | } |
| 6088 | |
| 6089 | ALIAS (no_ospf_default_metric, |
| 6090 | no_ospf_default_metric_val_cmd, |
| 6091 | "no default-metric <0-16777214>", |
| 6092 | NO_STR |
| 6093 | "Set metric of redistributed routes\n" |
| 6094 | "Default metric\n") |
| 6095 | |
| 6096 | DEFUN (ospf_distance, |
| 6097 | ospf_distance_cmd, |
| 6098 | "distance <1-255>", |
| 6099 | "Define an administrative distance\n" |
| 6100 | "OSPF Administrative distance\n") |
| 6101 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6102 | struct ospf *ospf = vty->index; |
| 6103 | |
| 6104 | ospf->distance_all = atoi (argv[0]); |
| 6105 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6106 | return CMD_SUCCESS; |
| 6107 | } |
| 6108 | |
| 6109 | DEFUN (no_ospf_distance, |
| 6110 | no_ospf_distance_cmd, |
| 6111 | "no distance <1-255>", |
| 6112 | NO_STR |
| 6113 | "Define an administrative distance\n" |
| 6114 | "OSPF Administrative distance\n") |
| 6115 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6116 | struct ospf *ospf = vty->index; |
| 6117 | |
| 6118 | ospf->distance_all = 0; |
| 6119 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6120 | return CMD_SUCCESS; |
| 6121 | } |
| 6122 | |
| 6123 | DEFUN (no_ospf_distance_ospf, |
| 6124 | no_ospf_distance_ospf_cmd, |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6125 | "no distance ospf {intra-area|inter-area|external}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | NO_STR |
| 6127 | "Define an administrative distance\n" |
| 6128 | "OSPF Administrative distance\n" |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6129 | "OSPF Distance\n" |
| 6130 | "Intra-area routes\n" |
| 6131 | "Inter-area routes\n" |
| 6132 | "External routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6133 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6134 | struct ospf *ospf = vty->index; |
| 6135 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6136 | if (argc < 3) |
| 6137 | return CMD_WARNING; |
| 6138 | |
| 6139 | if (argv[0] != NULL) |
| 6140 | ospf->distance_intra = 0; |
| 6141 | |
| 6142 | if (argv[1] != NULL) |
| 6143 | ospf->distance_inter = 0; |
| 6144 | |
| 6145 | if (argv[2] != NULL) |
| 6146 | ospf->distance_external = 0; |
| 6147 | |
| 6148 | if (argv[0] || argv[1] || argv[2]) |
| 6149 | return CMD_SUCCESS; |
| 6150 | |
| 6151 | /* If no arguments are given, clear all distance information */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6152 | ospf->distance_intra = 0; |
| 6153 | ospf->distance_inter = 0; |
| 6154 | ospf->distance_external = 0; |
| 6155 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6156 | return CMD_SUCCESS; |
| 6157 | } |
| 6158 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6159 | DEFUN (ospf_distance_ospf, |
| 6160 | ospf_distance_ospf_cmd, |
| 6161 | "distance ospf " |
| 6162 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6163 | "Define an administrative distance\n" |
| 6164 | "OSPF Administrative distance\n" |
| 6165 | "Intra-area routes\n" |
| 6166 | "Distance for intra-area routes\n" |
| 6167 | "Inter-area routes\n" |
| 6168 | "Distance for inter-area routes\n" |
| 6169 | "External routes\n" |
| 6170 | "Distance for external routes\n") |
| 6171 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6172 | struct ospf *ospf = vty->index; |
| 6173 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6174 | if (argc < 3) /* should not happen */ |
| 6175 | return CMD_WARNING; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6176 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6177 | if (!argv[0] && !argv[1] && !argv[2]) |
| 6178 | { |
| 6179 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", |
| 6180 | VTY_NEWLINE); |
| 6181 | return CMD_WARNING; |
| 6182 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6183 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6184 | if (argv[0] != NULL) |
| 6185 | ospf->distance_intra = atoi(argv[0]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6186 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6187 | if (argv[1] != NULL) |
| 6188 | ospf->distance_inter = atoi(argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6189 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6190 | if (argv[2] != NULL) |
| 6191 | ospf->distance_external = atoi(argv[2]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6192 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6193 | return CMD_SUCCESS; |
| 6194 | } |
| 6195 | |
| 6196 | DEFUN (ospf_distance_source, |
| 6197 | ospf_distance_source_cmd, |
| 6198 | "distance <1-255> A.B.C.D/M", |
| 6199 | "Administrative distance\n" |
| 6200 | "Distance value\n" |
| 6201 | "IP source prefix\n") |
| 6202 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6203 | struct ospf *ospf = vty->index; |
| 6204 | |
| 6205 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6206 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6207 | return CMD_SUCCESS; |
| 6208 | } |
| 6209 | |
| 6210 | DEFUN (no_ospf_distance_source, |
| 6211 | no_ospf_distance_source_cmd, |
| 6212 | "no distance <1-255> A.B.C.D/M", |
| 6213 | NO_STR |
| 6214 | "Administrative distance\n" |
| 6215 | "Distance value\n" |
| 6216 | "IP source prefix\n") |
| 6217 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6218 | struct ospf *ospf = vty->index; |
| 6219 | |
| 6220 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6221 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6222 | return CMD_SUCCESS; |
| 6223 | } |
| 6224 | |
| 6225 | DEFUN (ospf_distance_source_access_list, |
| 6226 | ospf_distance_source_access_list_cmd, |
| 6227 | "distance <1-255> A.B.C.D/M WORD", |
| 6228 | "Administrative distance\n" |
| 6229 | "Distance value\n" |
| 6230 | "IP source prefix\n" |
| 6231 | "Access list name\n") |
| 6232 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6233 | struct ospf *ospf = vty->index; |
| 6234 | |
| 6235 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6236 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6237 | return CMD_SUCCESS; |
| 6238 | } |
| 6239 | |
| 6240 | DEFUN (no_ospf_distance_source_access_list, |
| 6241 | no_ospf_distance_source_access_list_cmd, |
| 6242 | "no distance <1-255> A.B.C.D/M WORD", |
| 6243 | NO_STR |
| 6244 | "Administrative distance\n" |
| 6245 | "Distance value\n" |
| 6246 | "IP source prefix\n" |
| 6247 | "Access list name\n") |
| 6248 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6249 | struct ospf *ospf = vty->index; |
| 6250 | |
| 6251 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6252 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6253 | return CMD_SUCCESS; |
| 6254 | } |
| 6255 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6256 | DEFUN (ip_ospf_mtu_ignore, |
| 6257 | ip_ospf_mtu_ignore_addr_cmd, |
| 6258 | "ip ospf mtu-ignore A.B.C.D", |
| 6259 | "IP Information\n" |
| 6260 | "OSPF interface commands\n" |
| 6261 | "Disable mtu mismatch detection\n" |
| 6262 | "Address of interface") |
| 6263 | { |
| 6264 | struct interface *ifp = vty->index; |
| 6265 | struct in_addr addr; |
| 6266 | int ret; |
| 6267 | |
| 6268 | struct ospf_if_params *params; |
| 6269 | params = IF_DEF_PARAMS (ifp); |
| 6270 | |
| 6271 | if (argc == 1) |
| 6272 | { |
| 6273 | ret = inet_aton(argv[0], &addr); |
| 6274 | if (!ret) |
| 6275 | { |
| 6276 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6277 | VTY_NEWLINE); |
| 6278 | return CMD_WARNING; |
| 6279 | } |
| 6280 | params = ospf_get_if_params (ifp, addr); |
| 6281 | ospf_if_update_params (ifp, addr); |
| 6282 | } |
| 6283 | params->mtu_ignore = 1; |
| 6284 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6285 | SET_IF_PARAM (params, mtu_ignore); |
| 6286 | else |
| 6287 | { |
| 6288 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6289 | if (params != IF_DEF_PARAMS (ifp)) |
| 6290 | { |
| 6291 | ospf_free_if_params (ifp, addr); |
| 6292 | ospf_if_update_params (ifp, addr); |
| 6293 | } |
| 6294 | } |
| 6295 | return CMD_SUCCESS; |
| 6296 | } |
| 6297 | |
| 6298 | ALIAS (ip_ospf_mtu_ignore, |
| 6299 | ip_ospf_mtu_ignore_cmd, |
| 6300 | "ip ospf mtu-ignore", |
| 6301 | "IP Information\n" |
| 6302 | "OSPF interface commands\n" |
| 6303 | "Disable mtu mismatch detection\n") |
| 6304 | |
| 6305 | |
| 6306 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6307 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6308 | "no ip ospf mtu-ignore A.B.C.D", |
| 6309 | "IP Information\n" |
| 6310 | "OSPF interface commands\n" |
| 6311 | "Disable mtu mismatch detection\n" |
| 6312 | "Address of interface") |
| 6313 | { |
| 6314 | struct interface *ifp = vty->index; |
| 6315 | struct in_addr addr; |
| 6316 | int ret; |
| 6317 | |
| 6318 | struct ospf_if_params *params; |
| 6319 | params = IF_DEF_PARAMS (ifp); |
| 6320 | |
| 6321 | if (argc == 1) |
| 6322 | { |
| 6323 | ret = inet_aton(argv[0], &addr); |
| 6324 | if (!ret) |
| 6325 | { |
| 6326 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6327 | VTY_NEWLINE); |
| 6328 | return CMD_WARNING; |
| 6329 | } |
| 6330 | params = ospf_get_if_params (ifp, addr); |
| 6331 | ospf_if_update_params (ifp, addr); |
| 6332 | } |
| 6333 | params->mtu_ignore = 0; |
| 6334 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6335 | SET_IF_PARAM (params, mtu_ignore); |
| 6336 | else |
| 6337 | { |
| 6338 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6339 | if (params != IF_DEF_PARAMS (ifp)) |
| 6340 | { |
| 6341 | ospf_free_if_params (ifp, addr); |
| 6342 | ospf_if_update_params (ifp, addr); |
| 6343 | } |
| 6344 | } |
| 6345 | return CMD_SUCCESS; |
| 6346 | } |
| 6347 | |
| 6348 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6349 | no_ip_ospf_mtu_ignore_cmd, |
| 6350 | "no ip ospf mtu-ignore", |
| 6351 | "IP Information\n" |
| 6352 | "OSPF interface commands\n" |
| 6353 | "Disable mtu mismatch detection\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6354 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6355 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6356 | ospf_max_metric_router_lsa_admin_cmd, |
| 6357 | "max-metric router-lsa administrative", |
| 6358 | "OSPF maximum / infinite-distance metric\n" |
| 6359 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6360 | "Administratively applied, for an indefinite period\n") |
| 6361 | { |
| 6362 | struct listnode *ln; |
| 6363 | struct ospf_area *area; |
| 6364 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6365 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6366 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6367 | { |
| 6368 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6369 | |
| 6370 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6371 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6372 | } |
Ayan Banerjee | 4ba4fc8 | 2012-12-03 11:17:24 -0800 | [diff] [blame] | 6373 | |
| 6374 | /* Allows for areas configured later to get the property */ |
| 6375 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; |
| 6376 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6377 | return CMD_SUCCESS; |
| 6378 | } |
| 6379 | |
| 6380 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6381 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6382 | "no max-metric router-lsa administrative", |
| 6383 | NO_STR |
| 6384 | "OSPF maximum / infinite-distance metric\n" |
| 6385 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6386 | "Administratively applied, for an indefinite period\n") |
| 6387 | { |
| 6388 | struct listnode *ln; |
| 6389 | struct ospf_area *area; |
| 6390 | struct ospf *ospf = vty->index; |
| 6391 | |
| 6392 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6393 | { |
| 6394 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6395 | |
| 6396 | /* Don't trample on the start-up stub timer */ |
| 6397 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6398 | && !area->t_stub_router) |
| 6399 | { |
| 6400 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6401 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6402 | } |
| 6403 | } |
Ayan Banerjee | 4ba4fc8 | 2012-12-03 11:17:24 -0800 | [diff] [blame] | 6404 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6405 | return CMD_SUCCESS; |
| 6406 | } |
| 6407 | |
| 6408 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6409 | ospf_max_metric_router_lsa_startup_cmd, |
| 6410 | "max-metric router-lsa on-startup <5-86400>", |
| 6411 | "OSPF maximum / infinite-distance metric\n" |
| 6412 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6413 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6414 | "Time (seconds) to advertise self as stub-router\n") |
| 6415 | { |
| 6416 | unsigned int seconds; |
| 6417 | struct ospf *ospf = vty->index; |
| 6418 | |
| 6419 | if (argc != 1) |
| 6420 | { |
| 6421 | vty_out (vty, "%% Must supply stub-router period"); |
| 6422 | return CMD_WARNING; |
| 6423 | } |
| 6424 | |
| 6425 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6426 | |
| 6427 | ospf->stub_router_startup_time = seconds; |
| 6428 | |
| 6429 | return CMD_SUCCESS; |
| 6430 | } |
| 6431 | |
| 6432 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6433 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6434 | "no max-metric router-lsa on-startup", |
| 6435 | NO_STR |
| 6436 | "OSPF maximum / infinite-distance metric\n" |
| 6437 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6438 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6439 | { |
| 6440 | struct listnode *ln; |
| 6441 | struct ospf_area *area; |
| 6442 | struct ospf *ospf = vty->index; |
| 6443 | |
| 6444 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6445 | |
| 6446 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6447 | { |
| 6448 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 6449 | OSPF_TIMER_OFF (area->t_stub_router); |
| 6450 | |
| 6451 | /* Don't trample on admin stub routed */ |
| 6452 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6453 | { |
| 6454 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6455 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6456 | } |
| 6457 | } |
| 6458 | return CMD_SUCCESS; |
| 6459 | } |
| 6460 | |
| 6461 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 6462 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 6463 | "max-metric router-lsa on-shutdown <5-86400>", |
| 6464 | "OSPF maximum / infinite-distance metric\n" |
| 6465 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6466 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 6467 | "Time (seconds) to wait till full shutdown\n") |
| 6468 | { |
| 6469 | unsigned int seconds; |
| 6470 | struct ospf *ospf = vty->index; |
| 6471 | |
| 6472 | if (argc != 1) |
| 6473 | { |
| 6474 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 6475 | return CMD_WARNING; |
| 6476 | } |
| 6477 | |
| 6478 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 6479 | |
| 6480 | ospf->stub_router_shutdown_time = seconds; |
| 6481 | |
| 6482 | return CMD_SUCCESS; |
| 6483 | } |
| 6484 | |
| 6485 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 6486 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 6487 | "no max-metric router-lsa on-shutdown", |
| 6488 | NO_STR |
| 6489 | "OSPF maximum / infinite-distance metric\n" |
| 6490 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6491 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 6492 | { |
| 6493 | struct ospf *ospf = vty->index; |
| 6494 | |
| 6495 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6496 | |
| 6497 | return CMD_SUCCESS; |
| 6498 | } |
| 6499 | |
| 6500 | static void |
| 6501 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 6502 | { |
| 6503 | struct listnode *ln; |
| 6504 | struct ospf_area *area; |
| 6505 | |
| 6506 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6507 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 6508 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 6509 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6510 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 6511 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 6512 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6513 | { |
| 6514 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6515 | { |
| 6516 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 6517 | VTY_NEWLINE); |
| 6518 | break; |
| 6519 | } |
| 6520 | } |
| 6521 | return; |
| 6522 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6523 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6524 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6525 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6526 | { |
| 6527 | struct route_node *rn; |
| 6528 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6529 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6530 | struct ospf_path *path; |
| 6531 | |
| 6532 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6533 | VTY_NEWLINE); |
| 6534 | |
| 6535 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6536 | if ((or = rn->info) != NULL) |
| 6537 | { |
| 6538 | char buf1[19]; |
| 6539 | snprintf (buf1, 19, "%s/%d", |
| 6540 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6541 | |
| 6542 | switch (or->path_type) |
| 6543 | { |
| 6544 | case OSPF_PATH_INTER_AREA: |
| 6545 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6546 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6547 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6548 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6549 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6550 | break; |
| 6551 | case OSPF_PATH_INTRA_AREA: |
| 6552 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6553 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6554 | break; |
| 6555 | default: |
| 6556 | break; |
| 6557 | } |
| 6558 | |
| 6559 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6560 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6561 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6562 | if (if_lookup_by_index(path->ifindex)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6563 | { |
| 6564 | if (path->nexthop.s_addr == 0) |
| 6565 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6566 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6567 | else |
| 6568 | vty_out (vty, "%24s via %s, %s%s", "", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6569 | inet_ntoa (path->nexthop), |
| 6570 | ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6571 | } |
| 6572 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6573 | } |
| 6574 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6575 | } |
| 6576 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6577 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6578 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6579 | { |
| 6580 | struct route_node *rn; |
| 6581 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6582 | struct listnode *pnode; |
| 6583 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6584 | struct ospf_path *path; |
| 6585 | |
| 6586 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6587 | VTY_NEWLINE); |
| 6588 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6589 | if (rn->info) |
| 6590 | { |
| 6591 | int flag = 0; |
| 6592 | |
| 6593 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6594 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6595 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 6596 | { |
| 6597 | if (flag++) |
| 6598 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6599 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6600 | /* Show path. */ |
| 6601 | vty_out (vty, "%s [%d] area: %s", |
| 6602 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6603 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6604 | /* Show flags. */ |
| 6605 | vty_out (vty, "%s%s%s", |
| 6606 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6607 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6608 | VTY_NEWLINE); |
| 6609 | |
| 6610 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 6611 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6612 | if (if_lookup_by_index(path->ifindex)) |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6613 | { |
| 6614 | if (path->nexthop.s_addr == 0) |
| 6615 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6616 | "", ifindex2ifname (path->ifindex), |
| 6617 | VTY_NEWLINE); |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6618 | else |
| 6619 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6620 | inet_ntoa (path->nexthop), |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6621 | ifindex2ifname (path->ifindex), |
| 6622 | VTY_NEWLINE); |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6623 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6624 | } |
| 6625 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6626 | } |
| 6627 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6628 | } |
| 6629 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6630 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6631 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6632 | { |
| 6633 | struct route_node *rn; |
| 6634 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6635 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6636 | struct ospf_path *path; |
| 6637 | |
| 6638 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6639 | VTY_NEWLINE); |
| 6640 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6641 | if ((er = rn->info) != NULL) |
| 6642 | { |
| 6643 | char buf1[19]; |
| 6644 | snprintf (buf1, 19, "%s/%d", |
| 6645 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6646 | |
| 6647 | switch (er->path_type) |
| 6648 | { |
| 6649 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6650 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6651 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6652 | break; |
| 6653 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6654 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6655 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6656 | break; |
| 6657 | } |
| 6658 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6659 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6660 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6661 | if (if_lookup_by_index(path->ifindex)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6662 | { |
| 6663 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6664 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6665 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6666 | else |
| 6667 | vty_out (vty, "%24s via %s, %s%s", "", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6668 | inet_ntoa (path->nexthop), |
| 6669 | ifindex2ifname (path->ifindex), |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6670 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6671 | } |
| 6672 | } |
| 6673 | } |
| 6674 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6675 | } |
| 6676 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6677 | DEFUN (show_ip_ospf_border_routers, |
| 6678 | show_ip_ospf_border_routers_cmd, |
| 6679 | "show ip ospf border-routers", |
| 6680 | SHOW_STR |
| 6681 | IP_STR |
| 6682 | "show all the ABR's and ASBR's\n" |
| 6683 | "for this area\n") |
| 6684 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6685 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6686 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6687 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6688 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6689 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6690 | return CMD_SUCCESS; |
| 6691 | } |
| 6692 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6693 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6694 | { |
| 6695 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6696 | return CMD_SUCCESS; |
| 6697 | } |
| 6698 | |
| 6699 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6700 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6701 | |
| 6702 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6703 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6704 | |
| 6705 | return CMD_SUCCESS; |
| 6706 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6707 | |
| 6708 | DEFUN (show_ip_ospf_route, |
| 6709 | show_ip_ospf_route_cmd, |
| 6710 | "show ip ospf route", |
| 6711 | SHOW_STR |
| 6712 | IP_STR |
| 6713 | "OSPF information\n" |
| 6714 | "OSPF routing table\n") |
| 6715 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6716 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6717 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6718 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6719 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6720 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6721 | return CMD_SUCCESS; |
| 6722 | } |
| 6723 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6724 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6725 | { |
| 6726 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6727 | return CMD_SUCCESS; |
| 6728 | } |
| 6729 | |
| 6730 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6731 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6732 | |
| 6733 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6734 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6735 | |
| 6736 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6737 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6738 | |
| 6739 | return CMD_SUCCESS; |
| 6740 | } |
| 6741 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6742 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6743 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6744 | { |
| 6745 | "unknown", |
| 6746 | "standard", |
| 6747 | "ibm", |
| 6748 | "cisco", |
| 6749 | "shortcut" |
| 6750 | }; |
| 6751 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6752 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6753 | { |
| 6754 | "default", |
| 6755 | "enable", |
| 6756 | "disable" |
| 6757 | }; |
| 6758 | |
| 6759 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6760 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6761 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6762 | { |
| 6763 | memset (buf, 0, length); |
| 6764 | |
| 6765 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6766 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6767 | else |
| 6768 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6769 | } |
| 6770 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6771 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6772 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6773 | { |
| 6774 | "unknown", /* should never be used. */ |
| 6775 | "point-to-point", |
| 6776 | "broadcast", |
| 6777 | "non-broadcast", |
| 6778 | "point-to-multipoint", |
| 6779 | "virtual-link", /* should never be used. */ |
| 6780 | "loopback" |
| 6781 | }; |
| 6782 | |
| 6783 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6784 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6785 | config_write_interface (struct vty *vty) |
| 6786 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6787 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6788 | struct interface *ifp; |
| 6789 | struct crypt_key *ck; |
| 6790 | int write = 0; |
| 6791 | struct route_node *rn = NULL; |
| 6792 | struct ospf_if_params *params; |
| 6793 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6794 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6795 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6796 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6797 | continue; |
| 6798 | |
| 6799 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6800 | vty_out (vty, "interface %s%s", ifp->name, |
| 6801 | VTY_NEWLINE); |
| 6802 | if (ifp->desc) |
| 6803 | vty_out (vty, " description %s%s", ifp->desc, |
| 6804 | VTY_NEWLINE); |
| 6805 | |
| 6806 | write++; |
| 6807 | |
| 6808 | params = IF_DEF_PARAMS (ifp); |
| 6809 | |
| 6810 | do { |
| 6811 | /* Interface Network print. */ |
| 6812 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6813 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6814 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 6815 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 6816 | { |
| 6817 | vty_out (vty, " ip ospf network %s", |
| 6818 | ospf_int_type_str[params->type]); |
| 6819 | if (params != IF_DEF_PARAMS (ifp)) |
| 6820 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6821 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6822 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6823 | } |
| 6824 | |
| 6825 | /* OSPF interface authentication print */ |
| 6826 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6827 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6828 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6829 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6830 | |
| 6831 | /* Translation tables are not that much help here due to syntax |
| 6832 | of the simple option */ |
| 6833 | switch (params->auth_type) |
| 6834 | { |
| 6835 | |
| 6836 | case OSPF_AUTH_NULL: |
| 6837 | auth_str = " null"; |
| 6838 | break; |
| 6839 | |
| 6840 | case OSPF_AUTH_SIMPLE: |
| 6841 | auth_str = ""; |
| 6842 | break; |
| 6843 | |
| 6844 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6845 | auth_str = " message-digest"; |
| 6846 | break; |
| 6847 | |
| 6848 | default: |
| 6849 | auth_str = ""; |
| 6850 | break; |
| 6851 | } |
| 6852 | |
| 6853 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6854 | if (params != IF_DEF_PARAMS (ifp)) |
| 6855 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6856 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6857 | } |
| 6858 | |
| 6859 | /* Simple Authentication Password print. */ |
| 6860 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6861 | params->auth_simple[0] != '\0') |
| 6862 | { |
| 6863 | vty_out (vty, " ip ospf authentication-key %s", |
| 6864 | params->auth_simple); |
| 6865 | if (params != IF_DEF_PARAMS (ifp)) |
| 6866 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6867 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6868 | } |
| 6869 | |
| 6870 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6871 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6872 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6873 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6874 | ck->key_id, ck->auth_key); |
| 6875 | if (params != IF_DEF_PARAMS (ifp)) |
| 6876 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6877 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6878 | } |
| 6879 | |
| 6880 | /* Interface Output Cost print. */ |
| 6881 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6882 | { |
| 6883 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6884 | if (params != IF_DEF_PARAMS (ifp)) |
| 6885 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6886 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6887 | } |
| 6888 | |
| 6889 | /* Hello Interval print. */ |
| 6890 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6891 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6892 | { |
| 6893 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6894 | if (params != IF_DEF_PARAMS (ifp)) |
| 6895 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6896 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6897 | } |
| 6898 | |
| 6899 | |
| 6900 | /* Router Dead Interval print. */ |
| 6901 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6902 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6903 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 6904 | vty_out (vty, " ip ospf dead-interval "); |
| 6905 | |
| 6906 | /* fast hello ? */ |
| 6907 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 6908 | vty_out (vty, "minimal hello-multiplier %d", |
| 6909 | params->fast_hello); |
| 6910 | else |
| 6911 | vty_out (vty, "%u", params->v_wait); |
| 6912 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6913 | if (params != IF_DEF_PARAMS (ifp)) |
| 6914 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6915 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6916 | } |
| 6917 | |
| 6918 | /* Router Priority print. */ |
| 6919 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 6920 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 6921 | { |
| 6922 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 6923 | if (params != IF_DEF_PARAMS (ifp)) |
| 6924 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6925 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6926 | } |
| 6927 | |
| 6928 | /* Retransmit Interval print. */ |
| 6929 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 6930 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 6931 | { |
| 6932 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 6933 | params->retransmit_interval); |
| 6934 | if (params != IF_DEF_PARAMS (ifp)) |
| 6935 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6936 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6937 | } |
| 6938 | |
| 6939 | /* Transmit Delay print. */ |
| 6940 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 6941 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 6942 | { |
| 6943 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 6944 | if (params != IF_DEF_PARAMS (ifp)) |
| 6945 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6946 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6947 | } |
| 6948 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6949 | /* MTU ignore print. */ |
| 6950 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 6951 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6952 | { |
| 6953 | if (params->mtu_ignore == 0) |
| 6954 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 6955 | else |
| 6956 | vty_out (vty, " ip ospf mtu-ignore"); |
| 6957 | if (params != IF_DEF_PARAMS (ifp)) |
| 6958 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6959 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6960 | } |
| 6961 | |
| 6962 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6963 | while (1) |
| 6964 | { |
| 6965 | if (rn == NULL) |
| 6966 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 6967 | else |
| 6968 | rn = route_next (rn); |
| 6969 | |
| 6970 | if (rn == NULL) |
| 6971 | break; |
| 6972 | params = rn->info; |
| 6973 | if (params != NULL) |
| 6974 | break; |
| 6975 | } |
| 6976 | } while (rn); |
| 6977 | |
| 6978 | #ifdef HAVE_OPAQUE_LSA |
| 6979 | ospf_opaque_config_write_if (vty, ifp); |
| 6980 | #endif /* HAVE_OPAQUE_LSA */ |
| 6981 | } |
| 6982 | |
| 6983 | return write; |
| 6984 | } |
| 6985 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6986 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6987 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6988 | { |
| 6989 | struct route_node *rn; |
| 6990 | u_char buf[INET_ADDRSTRLEN]; |
| 6991 | |
| 6992 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6993 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6994 | if (rn->info) |
| 6995 | { |
| 6996 | struct ospf_network *n = rn->info; |
| 6997 | |
| 6998 | memset (buf, 0, INET_ADDRSTRLEN); |
| 6999 | |
| 7000 | /* Create Area ID string by specified Area ID format. */ |
| 7001 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7002 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7003 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7004 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7005 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7006 | |
| 7007 | /* Network print. */ |
| 7008 | vty_out (vty, " network %s/%d area %s%s", |
| 7009 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7010 | buf, VTY_NEWLINE); |
| 7011 | } |
| 7012 | |
| 7013 | return 0; |
| 7014 | } |
| 7015 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7016 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7017 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7018 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7019 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7020 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7021 | u_char buf[INET_ADDRSTRLEN]; |
| 7022 | |
| 7023 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7024 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7025 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7026 | struct route_node *rn1; |
| 7027 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7028 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7029 | |
| 7030 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7031 | { |
| 7032 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7033 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7034 | else |
| 7035 | vty_out (vty, " area %s authentication message-digest%s", |
| 7036 | buf, VTY_NEWLINE); |
| 7037 | } |
| 7038 | |
| 7039 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7040 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7041 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7042 | VTY_NEWLINE); |
| 7043 | |
| 7044 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7045 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7046 | ) |
| 7047 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7048 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7049 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7050 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7051 | { |
| 7052 | vty_out (vty, " area %s nssa", buf); |
| 7053 | switch (area->NSSATranslatorRole) |
| 7054 | { |
| 7055 | case OSPF_NSSA_ROLE_NEVER: |
| 7056 | vty_out (vty, " translate-never"); |
| 7057 | break; |
| 7058 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7059 | vty_out (vty, " translate-always"); |
| 7060 | break; |
| 7061 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7062 | default: |
| 7063 | vty_out (vty, " translate-candidate"); |
| 7064 | } |
| 7065 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7066 | |
| 7067 | if (area->no_summary) |
| 7068 | vty_out (vty, " no-summary"); |
| 7069 | |
| 7070 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7071 | |
| 7072 | if (area->default_cost != 1) |
| 7073 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7074 | area->default_cost, VTY_NEWLINE); |
| 7075 | } |
| 7076 | |
| 7077 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7078 | if (rn1->info) |
| 7079 | { |
| 7080 | struct ospf_area_range *range = rn1->info; |
| 7081 | |
| 7082 | vty_out (vty, " area %s range %s/%d", buf, |
| 7083 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7084 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7085 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7086 | vty_out (vty, " cost %d", range->cost_config); |
| 7087 | |
| 7088 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7089 | vty_out (vty, " not-advertise"); |
| 7090 | |
| 7091 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7092 | vty_out (vty, " substitute %s/%d", |
| 7093 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7094 | |
| 7095 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7096 | } |
| 7097 | |
| 7098 | if (EXPORT_NAME (area)) |
| 7099 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7100 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7101 | |
| 7102 | if (IMPORT_NAME (area)) |
| 7103 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7104 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7105 | |
| 7106 | if (PREFIX_NAME_IN (area)) |
| 7107 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7108 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7109 | |
| 7110 | if (PREFIX_NAME_OUT (area)) |
| 7111 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7112 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7113 | } |
| 7114 | |
| 7115 | return 0; |
| 7116 | } |
| 7117 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7118 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7119 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7120 | { |
| 7121 | struct ospf_nbr_nbma *nbr_nbma; |
| 7122 | struct route_node *rn; |
| 7123 | |
| 7124 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7125 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7126 | if ((nbr_nbma = rn->info)) |
| 7127 | { |
| 7128 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7129 | |
| 7130 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7131 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7132 | |
| 7133 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7134 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 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_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7144 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7145 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7146 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7147 | u_char buf[INET_ADDRSTRLEN]; |
| 7148 | |
| 7149 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7150 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7151 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7152 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7153 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7154 | struct ospf_interface *oi; |
| 7155 | |
| 7156 | if (vl_data != NULL) |
| 7157 | { |
| 7158 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7159 | |
| 7160 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7161 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7162 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7163 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7164 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7165 | oi = vl_data->vl_oi; |
| 7166 | |
| 7167 | /* timers */ |
| 7168 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7169 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7170 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7171 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7172 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7173 | buf, |
| 7174 | inet_ntoa (vl_data->vl_peer), |
| 7175 | OSPF_IF_PARAM (oi, v_hello), |
| 7176 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7177 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7178 | OSPF_IF_PARAM (oi, v_wait), |
| 7179 | VTY_NEWLINE); |
| 7180 | else |
| 7181 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7182 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7183 | /* Auth key */ |
| 7184 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7185 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7186 | buf, |
| 7187 | inet_ntoa (vl_data->vl_peer), |
| 7188 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7189 | VTY_NEWLINE); |
| 7190 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7191 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7192 | n2, ck)) |
| 7193 | vty_out (vty, " area %s virtual-link %s" |
| 7194 | " message-digest-key %d md5 %s%s", |
| 7195 | buf, |
| 7196 | inet_ntoa (vl_data->vl_peer), |
| 7197 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7198 | |
| 7199 | } |
| 7200 | } |
| 7201 | |
| 7202 | return 0; |
| 7203 | } |
| 7204 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7205 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7206 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7207 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7208 | { |
| 7209 | int type; |
| 7210 | |
| 7211 | /* redistribute print. */ |
| 7212 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 7213 | if (type != zclient->redist_default && |
| 7214 | vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7215 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7216 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7217 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7218 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7219 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7220 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7221 | vty_out (vty, " metric-type 1"); |
| 7222 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7223 | if (ROUTEMAP_NAME (ospf, type)) |
| 7224 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7225 | |
| 7226 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7227 | } |
| 7228 | |
| 7229 | return 0; |
| 7230 | } |
| 7231 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7232 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7233 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7234 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7235 | if (ospf->default_metric != -1) |
| 7236 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7237 | VTY_NEWLINE); |
| 7238 | return 0; |
| 7239 | } |
| 7240 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7241 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7242 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7243 | { |
| 7244 | int type; |
| 7245 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7246 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7247 | { |
| 7248 | /* distribute-list print. */ |
| 7249 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
Denis Ovsienko | 171c9a9 | 2011-09-10 16:40:23 +0400 | [diff] [blame] | 7250 | if (DISTRIBUTE_NAME (ospf, type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7251 | vty_out (vty, " distribute-list %s out %s%s", |
Denis Ovsienko | 171c9a9 | 2011-09-10 16:40:23 +0400 | [diff] [blame] | 7252 | DISTRIBUTE_NAME (ospf, type), |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7253 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7254 | |
| 7255 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7256 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7257 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7258 | vty_out (vty, " default-information originate"); |
| 7259 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7260 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7261 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7262 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7263 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7264 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7265 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7266 | vty_out (vty, " metric-type 1"); |
| 7267 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7268 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7269 | vty_out (vty, " route-map %s", |
| 7270 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7271 | |
| 7272 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7273 | } |
| 7274 | |
| 7275 | } |
| 7276 | |
| 7277 | return 0; |
| 7278 | } |
| 7279 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7280 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7281 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7282 | { |
| 7283 | struct route_node *rn; |
| 7284 | struct ospf_distance *odistance; |
| 7285 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7286 | if (ospf->distance_all) |
| 7287 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7288 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7289 | if (ospf->distance_intra |
| 7290 | || ospf->distance_inter |
| 7291 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7292 | { |
| 7293 | vty_out (vty, " distance ospf"); |
| 7294 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7295 | if (ospf->distance_intra) |
| 7296 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7297 | if (ospf->distance_inter) |
| 7298 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7299 | if (ospf->distance_external) |
| 7300 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7301 | |
| 7302 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7303 | } |
| 7304 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7305 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7306 | if ((odistance = rn->info) != NULL) |
| 7307 | { |
| 7308 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7309 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7310 | odistance->access_list ? odistance->access_list : "", |
| 7311 | VTY_NEWLINE); |
| 7312 | } |
| 7313 | return 0; |
| 7314 | } |
| 7315 | |
| 7316 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7317 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7318 | ospf_config_write (struct vty *vty) |
| 7319 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7320 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7321 | struct interface *ifp; |
| 7322 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7323 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7324 | int write = 0; |
| 7325 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7326 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7327 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7328 | { |
| 7329 | /* `router ospf' print. */ |
| 7330 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7331 | |
| 7332 | write++; |
| 7333 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7334 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7335 | return write; |
| 7336 | |
| 7337 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7338 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7339 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7340 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7341 | |
| 7342 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7343 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7344 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7345 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7346 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7347 | /* log-adjacency-changes flag print. */ |
| 7348 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 7349 | { |
| 7350 | vty_out(vty, " log-adjacency-changes"); |
| 7351 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 7352 | vty_out(vty, " detail"); |
| 7353 | vty_out(vty, "%s", VTY_NEWLINE); |
| 7354 | } |
| 7355 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7356 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7357 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7358 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7359 | |
| 7360 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7361 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7362 | { |
| 7363 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7364 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7365 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7366 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7367 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7368 | |
Michael Rossberg | 2ef762e | 2015-07-27 07:56:25 +0200 | [diff] [blame] | 7369 | /* LSA timers */ |
| 7370 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
| 7371 | vty_out (vty, " timers throttle lsa all %d%s", |
| 7372 | ospf->min_ls_interval, VTY_NEWLINE); |
| 7373 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) |
| 7374 | vty_out (vty, " timers lsa arrival %d%s", |
| 7375 | ospf->min_ls_arrival, VTY_NEWLINE); |
| 7376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7377 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7378 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7379 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7380 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7381 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7382 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7383 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7384 | |
| 7385 | /* Max-metric router-lsa print */ |
| 7386 | config_write_stub_router (vty, ospf); |
| 7387 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7388 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7389 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7390 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7391 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7392 | |
| 7393 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7394 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7395 | |
| 7396 | /* passive-interface print. */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7397 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
| 7398 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); |
| 7399 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7400 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7401 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
| 7402 | && IF_DEF_PARAMS (ifp)->passive_interface != |
| 7403 | ospf->passive_interface_default) |
| 7404 | { |
| 7405 | vty_out (vty, " %spassive-interface %s%s", |
| 7406 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", |
| 7407 | ifp->name, VTY_NEWLINE); |
| 7408 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7409 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7410 | { |
| 7411 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) |
| 7412 | continue; |
| 7413 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), |
| 7414 | passive_interface)) |
| 7415 | { |
| 7416 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) |
| 7417 | continue; |
| 7418 | } |
| 7419 | else if (oi->params->passive_interface == ospf->passive_interface_default) |
| 7420 | continue; |
| 7421 | |
| 7422 | vty_out (vty, " %spassive-interface %s %s%s", |
| 7423 | oi->params->passive_interface ? "" : "no ", |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7424 | oi->ifp->name, |
| 7425 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7426 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7427 | |
| 7428 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7429 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7430 | |
| 7431 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7432 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7433 | |
| 7434 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7435 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7436 | |
| 7437 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7438 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7439 | |
| 7440 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7441 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7442 | |
| 7443 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7444 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7445 | |
| 7446 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7447 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7448 | |
| 7449 | #ifdef HAVE_OPAQUE_LSA |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7450 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7451 | #endif /* HAVE_OPAQUE_LSA */ |
| 7452 | } |
| 7453 | |
| 7454 | return write; |
| 7455 | } |
| 7456 | |
| 7457 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7458 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7459 | { |
| 7460 | /* "show ip ospf" commands. */ |
| 7461 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
| 7462 | install_element (ENABLE_NODE, &show_ip_ospf_cmd); |
| 7463 | |
| 7464 | /* "show ip ospf database" commands. */ |
| 7465 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7466 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7467 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7468 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7469 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7470 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7471 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
| 7472 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd); |
| 7473 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7474 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7475 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7476 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7477 | install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7478 | install_element (ENABLE_NODE, &show_ip_ospf_database_cmd); |
| 7479 | |
| 7480 | /* "show ip ospf interface" commands. */ |
| 7481 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
| 7482 | install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd); |
| 7483 | |
| 7484 | /* "show ip ospf neighbor" commands. */ |
| 7485 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7486 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7487 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7488 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7489 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7490 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7491 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7492 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7493 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7494 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7495 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7496 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7497 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd); |
| 7498 | install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd); |
| 7499 | |
| 7500 | /* "show ip ospf route" commands. */ |
| 7501 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
| 7502 | install_element (ENABLE_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7503 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
| 7504 | install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7505 | } |
| 7506 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7507 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7508 | /* ospfd's interface node. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 7509 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7510 | { |
| 7511 | INTERFACE_NODE, |
| 7512 | "%s(config-if)# ", |
| 7513 | 1 |
| 7514 | }; |
| 7515 | |
| 7516 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7517 | static void |
| 7518 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7519 | { |
| 7520 | /* Install interface node. */ |
| 7521 | install_node (&interface_node, config_write_interface); |
| 7522 | |
| 7523 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7524 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7525 | install_default (INTERFACE_NODE); |
| 7526 | |
| 7527 | /* "description" commands. */ |
| 7528 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7529 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7530 | |
| 7531 | /* "ip ospf authentication" commands. */ |
| 7532 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7533 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7534 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7535 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7536 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7537 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7538 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7539 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7540 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7541 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7542 | |
| 7543 | /* "ip ospf message-digest-key" commands. */ |
| 7544 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7545 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7546 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7547 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7548 | |
| 7549 | /* "ip ospf cost" commands. */ |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7550 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
| 7551 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 7552 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
| 7553 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7554 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7555 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7556 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7557 | /* "ip ospf mtu-ignore" commands. */ |
| 7558 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7559 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7560 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7561 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7562 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7563 | /* "ip ospf dead-interval" commands. */ |
| 7564 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7565 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7566 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 7567 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7568 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7569 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7570 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7571 | /* "ip ospf hello-interval" commands. */ |
| 7572 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7573 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7574 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7575 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
| 7576 | |
| 7577 | /* "ip ospf network" commands. */ |
| 7578 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7579 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7580 | |
| 7581 | /* "ip ospf priority" commands. */ |
| 7582 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7583 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7584 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7585 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7586 | |
| 7587 | /* "ip ospf retransmit-interval" commands. */ |
| 7588 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7589 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7590 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7591 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7592 | |
| 7593 | /* "ip ospf transmit-delay" commands. */ |
| 7594 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7595 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7596 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7597 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7598 | |
| 7599 | /* These commands are compatibitliy for previous version. */ |
| 7600 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7601 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7602 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7603 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7604 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
| 7605 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7606 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 7607 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
| 7608 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7609 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7610 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7611 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7612 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7613 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7614 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7615 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7616 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7617 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7618 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7619 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7620 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7621 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7622 | } |
| 7623 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7624 | static void |
| 7625 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7626 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7627 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7628 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7629 | |
| 7630 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7631 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7632 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7633 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7634 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7635 | |
| 7636 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7637 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7638 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7639 | |
| 7640 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7641 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7642 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 7643 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7644 | #if 0 |
| 7645 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7646 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7647 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7648 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7649 | #endif /* 0 */ |
| 7650 | } |
| 7651 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 7652 | static struct cmd_node ospf_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7653 | { |
| 7654 | OSPF_NODE, |
| 7655 | "%s(config-router)# ", |
| 7656 | 1 |
| 7657 | }; |
| 7658 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7660 | /* Install OSPF related vty commands. */ |
| 7661 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7662 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7663 | { |
| 7664 | /* Install ospf top node. */ |
| 7665 | install_node (&ospf_node, ospf_config_write); |
| 7666 | |
| 7667 | /* "router ospf" commands. */ |
| 7668 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7669 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7670 | |
| 7671 | install_default (OSPF_NODE); |
| 7672 | |
| 7673 | /* "ospf router-id" commands. */ |
| 7674 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7675 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7676 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7677 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7678 | |
| 7679 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7680 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7681 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7682 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7683 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7684 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7685 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7686 | |
| 7687 | /* "ospf abr-type" commands. */ |
| 7688 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7689 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7690 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7691 | /* "ospf log-adjacency-changes" commands. */ |
| 7692 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); |
| 7693 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); |
| 7694 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); |
| 7695 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); |
| 7696 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7697 | /* "ospf rfc1583-compatible" commands. */ |
| 7698 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7699 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7700 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7701 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7702 | |
| 7703 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7704 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7705 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7706 | |
| 7707 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7708 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7709 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7710 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7711 | |
| 7712 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7713 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7714 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7715 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7716 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7717 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7718 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7719 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7720 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7721 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7722 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7723 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7724 | |
| 7725 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7726 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7727 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7728 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7729 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7730 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7731 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7732 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7733 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7734 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7735 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7736 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7737 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7738 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7739 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7740 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7741 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7742 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7743 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7744 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7745 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7746 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7747 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7748 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7749 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7750 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7751 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7752 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7753 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7754 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7755 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7756 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7757 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7758 | |
| 7759 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7760 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7761 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7762 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7763 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7764 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7765 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7766 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7767 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7768 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7769 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7770 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7771 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7772 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7773 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7774 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7775 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7776 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7777 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7778 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7779 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 7780 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7781 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7782 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 7783 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7784 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7785 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 7786 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7787 | |
Michael Rossberg | 2ef762e | 2015-07-27 07:56:25 +0200 | [diff] [blame] | 7788 | /* LSA timer commands */ |
| 7789 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
| 7790 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); |
| 7791 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); |
| 7792 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); |
| 7793 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7794 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7795 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 7796 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 7797 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 7798 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 7799 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7800 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7801 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 7802 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7803 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7804 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7805 | /* max-metric commands */ |
| 7806 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 7807 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 7808 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 7809 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 7810 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 7811 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 7812 | |
| 7813 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7814 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 7815 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7816 | |
| 7817 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7818 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7819 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7820 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7821 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7822 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7823 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7824 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7825 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7826 | |
| 7827 | /* Init interface related vty commands. */ |
| 7828 | ospf_vty_if_init (); |
| 7829 | |
| 7830 | /* Init zebra related vty commands. */ |
| 7831 | ospf_vty_zebra_init (); |
| 7832 | } |