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. */ |
Olivier Dugeon | 29a1401 | 2016-04-19 18:42:40 +0200 | [diff] [blame] | 66 | 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 Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 295 | /* get the appropriate ospf parameters structure, checking if |
| 296 | * there's a valid interface address at the argi'th argv index |
| 297 | */ |
| 298 | enum { |
| 299 | VTY_SET = 0, |
| 300 | VTY_UNSET, |
| 301 | }; |
| 302 | #define OSPF_VTY_GET_IF_PARAMS(ifp,params,argi,addr,set) \ |
| 303 | (params) = IF_DEF_PARAMS ((ifp)); \ |
| 304 | \ |
| 305 | if (argc == (argi) + 1) \ |
| 306 | { \ |
| 307 | int ret = inet_aton(argv[(argi)], &(addr)); \ |
| 308 | if (!ret) \ |
| 309 | { \ |
| 310 | vty_out (vty, "Please specify interface address by A.B.C.D%s", \ |
| 311 | VTY_NEWLINE); \ |
| 312 | return CMD_WARNING; \ |
| 313 | } \ |
| 314 | (params) = ospf_get_if_params ((ifp), (addr)); \ |
| 315 | \ |
| 316 | if (set) \ |
| 317 | ospf_if_update_params ((ifp), (addr)); \ |
| 318 | else if ((params) == NULL) \ |
| 319 | return CMD_SUCCESS; \ |
| 320 | } |
| 321 | |
| 322 | #define OSPF_VTY_PARAM_UNSET(params,var,ifp,addr) \ |
| 323 | UNSET_IF_PARAM ((params), var); \ |
| 324 | if ((params) != IF_DEF_PARAMS ((ifp))) \ |
| 325 | { \ |
| 326 | ospf_free_if_params ((ifp), (addr)); \ |
| 327 | ospf_if_update_params ((ifp), (addr)); \ |
| 328 | } |
| 329 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 330 | DEFUN (ospf_passive_interface, |
| 331 | ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 332 | "passive-interface IFNAME A.B.C.D", |
| 333 | "Suppress routing updates on an interface\n" |
| 334 | "Interface's name\n") |
| 335 | { |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 336 | struct interface *ifp; |
| 337 | struct in_addr addr; |
| 338 | int ret; |
| 339 | struct ospf_if_params *params; |
| 340 | struct route_node *rn; |
| 341 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 342 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 343 | if (argc == 0) |
| 344 | { |
| 345 | ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE); |
| 346 | return CMD_SUCCESS; |
| 347 | } |
| 348 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 349 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | |
| 351 | params = IF_DEF_PARAMS (ifp); |
| 352 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 353 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 354 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 355 | ret = inet_aton(argv[1], &addr); |
| 356 | if (!ret) |
| 357 | { |
| 358 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 359 | VTY_NEWLINE); |
| 360 | return CMD_WARNING; |
| 361 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 362 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 363 | params = ospf_get_if_params (ifp, addr); |
| 364 | ospf_if_update_params (ifp, addr); |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 365 | ospf_passive_interface_update_addr (ospf, ifp, params, |
| 366 | OSPF_IF_PASSIVE, addr); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 367 | } |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 368 | |
| 369 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE); |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 370 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 371 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 372 | * interfaces for which the passive property changed. It is too much |
| 373 | * work to determine this set, so we do this for every interface. |
| 374 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 375 | * record of joined groups to avoid systems calls if the desired |
| 376 | * memberships match the current memership. |
| 377 | */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 378 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 379 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 380 | { |
| 381 | struct ospf_interface *oi = rn->info; |
| 382 | |
| 383 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE)) |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 384 | ospf_if_set_multicast(oi); |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 385 | } |
| 386 | /* |
| 387 | * XXX It is not clear what state transitions the interface needs to |
| 388 | * undergo when going from active to passive. Fixing this will |
| 389 | * require precise identification of interfaces having such a |
| 390 | * transition. |
| 391 | */ |
| 392 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 393 | return CMD_SUCCESS; |
| 394 | } |
| 395 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 396 | ALIAS (ospf_passive_interface, |
| 397 | ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 398 | "passive-interface IFNAME", |
| 399 | "Suppress routing updates on an interface\n" |
| 400 | "Interface's name\n") |
| 401 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 402 | ALIAS (ospf_passive_interface, |
| 403 | ospf_passive_interface_default_cmd, |
| 404 | "passive-interface default", |
| 405 | "Suppress routing updates on an interface\n" |
| 406 | "Suppress routing updates on interfaces by default\n") |
| 407 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 408 | DEFUN (no_ospf_passive_interface, |
| 409 | no_ospf_passive_interface_addr_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 410 | "no passive-interface IFNAME A.B.C.D", |
| 411 | NO_STR |
| 412 | "Allow routing updates on an interface\n" |
| 413 | "Interface's name\n") |
| 414 | { |
| 415 | struct interface *ifp; |
| 416 | struct in_addr addr; |
| 417 | struct ospf_if_params *params; |
| 418 | int ret; |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 419 | struct route_node *rn; |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 420 | struct ospf *ospf = vty->index; |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 421 | |
| 422 | if (argc == 0) |
| 423 | { |
| 424 | ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE); |
| 425 | return CMD_SUCCESS; |
| 426 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 427 | |
Andrew J. Schorr | 6e72cb6 | 2006-06-18 00:45:48 +0000 | [diff] [blame] | 428 | ifp = if_get_by_name (argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 429 | |
| 430 | params = IF_DEF_PARAMS (ifp); |
| 431 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 432 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 433 | { |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 434 | ret = inet_aton(argv[1], &addr); |
| 435 | if (!ret) |
| 436 | { |
| 437 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 438 | VTY_NEWLINE); |
| 439 | return CMD_WARNING; |
| 440 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 441 | |
Andrew J. Schorr | 4354088 | 2006-11-28 16:36:39 +0000 | [diff] [blame] | 442 | params = ospf_lookup_if_params (ifp, addr); |
| 443 | if (params == NULL) |
| 444 | return CMD_SUCCESS; |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 445 | ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE, |
| 446 | addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 447 | } |
Paul Jakma | e1bcd47 | 2014-09-19 16:41:10 +0100 | [diff] [blame] | 448 | ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE); |
| 449 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 450 | /* XXX We should call ospf_if_set_multicast on exactly those |
| 451 | * interfaces for which the passive property changed. It is too much |
| 452 | * work to determine this set, so we do this for every interface. |
| 453 | * This is safe and reasonable because ospf_if_set_multicast uses a |
| 454 | * record of joined groups to avoid systems calls if the desired |
| 455 | * memberships match the current memership. |
| 456 | */ |
| 457 | for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn)) |
| 458 | { |
| 459 | struct ospf_interface *oi = rn->info; |
| 460 | |
| 461 | if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE)) |
| 462 | ospf_if_set_multicast(oi); |
| 463 | } |
| 464 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 465 | return CMD_SUCCESS; |
| 466 | } |
| 467 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 468 | ALIAS (no_ospf_passive_interface, |
| 469 | no_ospf_passive_interface_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 470 | "no passive-interface IFNAME", |
| 471 | NO_STR |
| 472 | "Allow routing updates on an interface\n" |
| 473 | "Interface's name\n") |
| 474 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 475 | ALIAS (no_ospf_passive_interface, |
| 476 | no_ospf_passive_interface_default_cmd, |
| 477 | "no passive-interface default", |
| 478 | NO_STR |
| 479 | "Allow routing updates on an interface\n" |
| 480 | "Allow routing updates on interfaces by default\n") |
| 481 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 482 | DEFUN (ospf_network_area, |
| 483 | ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 484 | "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 485 | "Enable routing on an IP network\n" |
| 486 | "OSPF network prefix\n" |
| 487 | "Set the OSPF area ID\n" |
| 488 | "OSPF area ID in IP address format\n" |
| 489 | "OSPF area ID as a decimal value\n") |
| 490 | { |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 491 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 492 | struct prefix_ipv4 p; |
| 493 | struct in_addr area_id; |
| 494 | int ret, format; |
| 495 | |
| 496 | /* Get network prefix and Area ID. */ |
| 497 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 498 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 499 | |
| 500 | ret = ospf_network_set (ospf, &p, area_id); |
| 501 | if (ret == 0) |
| 502 | { |
| 503 | vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE); |
| 504 | return CMD_WARNING; |
| 505 | } |
| 506 | |
| 507 | return CMD_SUCCESS; |
| 508 | } |
| 509 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 510 | DEFUN (no_ospf_network_area, |
| 511 | no_ospf_network_area_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 512 | "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)", |
| 513 | NO_STR |
| 514 | "Enable routing on an IP network\n" |
| 515 | "OSPF network prefix\n" |
| 516 | "Set the OSPF area ID\n" |
| 517 | "OSPF area ID in IP address format\n" |
| 518 | "OSPF area ID as a decimal value\n") |
| 519 | { |
| 520 | struct ospf *ospf = (struct ospf *) vty->index; |
| 521 | struct prefix_ipv4 p; |
| 522 | struct in_addr area_id; |
| 523 | int ret, format; |
| 524 | |
| 525 | /* Get network prefix and Area ID. */ |
| 526 | VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]); |
| 527 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]); |
| 528 | |
| 529 | ret = ospf_network_unset (ospf, &p, area_id); |
| 530 | if (ret == 0) |
| 531 | { |
| 532 | vty_out (vty, "Can't find specified network area configuration.%s", |
| 533 | VTY_NEWLINE); |
| 534 | return CMD_WARNING; |
| 535 | } |
| 536 | |
| 537 | return CMD_SUCCESS; |
| 538 | } |
| 539 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 540 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 541 | DEFUN (ospf_area_range, |
| 542 | ospf_area_range_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 543 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M", |
| 544 | "OSPF area parameters\n" |
| 545 | "OSPF area ID in IP address format\n" |
| 546 | "OSPF area ID as a decimal value\n" |
| 547 | "Summarize routes matching address/mask (border routers only)\n" |
| 548 | "Area range prefix\n") |
| 549 | { |
| 550 | struct ospf *ospf = vty->index; |
| 551 | struct prefix_ipv4 p; |
| 552 | struct in_addr area_id; |
| 553 | int format; |
| 554 | u_int32_t cost; |
| 555 | |
| 556 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 557 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 558 | |
| 559 | ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE); |
| 560 | if (argc > 2) |
| 561 | { |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 562 | VTY_GET_INTEGER ("range cost", cost, argv[2]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | ospf_area_range_cost_set (ospf, area_id, &p, cost); |
| 564 | } |
| 565 | |
| 566 | return CMD_SUCCESS; |
| 567 | } |
| 568 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 569 | ALIAS (ospf_area_range, |
| 570 | ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 571 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise", |
| 572 | "OSPF area parameters\n" |
| 573 | "OSPF area ID in IP address format\n" |
| 574 | "OSPF area ID as a decimal value\n" |
| 575 | "OSPF area range for route advertise (default)\n" |
| 576 | "Area range prefix\n" |
| 577 | "Advertise this range (default)\n") |
| 578 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 579 | ALIAS (ospf_area_range, |
| 580 | ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 581 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 582 | "OSPF area parameters\n" |
| 583 | "OSPF area ID in IP address format\n" |
| 584 | "OSPF area ID as a decimal value\n" |
| 585 | "Summarize routes matching address/mask (border routers only)\n" |
| 586 | "Area range prefix\n" |
| 587 | "User specified metric for this range\n" |
| 588 | "Advertised metric for this range\n") |
| 589 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 590 | ALIAS (ospf_area_range, |
| 591 | ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 592 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 593 | "OSPF area parameters\n" |
| 594 | "OSPF area ID in IP address format\n" |
| 595 | "OSPF area ID as a decimal value\n" |
| 596 | "Summarize routes matching address/mask (border routers only)\n" |
| 597 | "Area range prefix\n" |
| 598 | "Advertise this range (default)\n" |
| 599 | "User specified metric for this range\n" |
| 600 | "Advertised metric for this range\n") |
| 601 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 602 | DEFUN (ospf_area_range_not_advertise, |
| 603 | ospf_area_range_not_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise", |
| 605 | "OSPF area parameters\n" |
| 606 | "OSPF area ID in IP address format\n" |
| 607 | "OSPF area ID as a decimal value\n" |
| 608 | "Summarize routes matching address/mask (border routers only)\n" |
| 609 | "Area range prefix\n" |
| 610 | "DoNotAdvertise this range\n") |
| 611 | { |
| 612 | struct ospf *ospf = vty->index; |
| 613 | struct prefix_ipv4 p; |
| 614 | struct in_addr area_id; |
| 615 | int format; |
| 616 | |
| 617 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 618 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 619 | |
| 620 | ospf_area_range_set (ospf, area_id, &p, 0); |
| 621 | |
| 622 | return CMD_SUCCESS; |
| 623 | } |
| 624 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 625 | DEFUN (no_ospf_area_range, |
| 626 | no_ospf_area_range_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", |
| 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 | { |
| 635 | struct ospf *ospf = vty->index; |
| 636 | struct prefix_ipv4 p; |
| 637 | struct in_addr area_id; |
| 638 | int format; |
| 639 | |
| 640 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 641 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 642 | |
| 643 | ospf_area_range_unset (ospf, area_id, &p); |
| 644 | |
| 645 | return CMD_SUCCESS; |
| 646 | } |
| 647 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 648 | ALIAS (no_ospf_area_range, |
| 649 | no_ospf_area_range_advertise_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 650 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)", |
| 651 | NO_STR |
| 652 | "OSPF area parameters\n" |
| 653 | "OSPF area ID in IP address format\n" |
| 654 | "OSPF area ID as a decimal value\n" |
| 655 | "Summarize routes matching address/mask (border routers only)\n" |
| 656 | "Area range prefix\n" |
| 657 | "Advertise this range (default)\n" |
| 658 | "DoNotAdvertise this range\n") |
| 659 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 660 | ALIAS (no_ospf_area_range, |
| 661 | no_ospf_area_range_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>", |
| 663 | NO_STR |
| 664 | "OSPF area parameters\n" |
| 665 | "OSPF area ID in IP address format\n" |
| 666 | "OSPF area ID as a decimal value\n" |
| 667 | "Summarize routes matching address/mask (border routers only)\n" |
| 668 | "Area range prefix\n" |
| 669 | "User specified metric for this range\n" |
| 670 | "Advertised metric for this range\n") |
| 671 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 672 | ALIAS (no_ospf_area_range, |
| 673 | no_ospf_area_range_advertise_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 674 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>", |
| 675 | NO_STR |
| 676 | "OSPF area parameters\n" |
| 677 | "OSPF area ID in IP address format\n" |
| 678 | "OSPF area ID as a decimal value\n" |
| 679 | "Summarize routes matching address/mask (border routers only)\n" |
| 680 | "Area range prefix\n" |
| 681 | "Advertise this range (default)\n" |
| 682 | "User specified metric for this range\n" |
| 683 | "Advertised metric for this range\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 684 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 685 | DEFUN (ospf_area_range_substitute, |
| 686 | ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 688 | "OSPF area parameters\n" |
| 689 | "OSPF area ID in IP address format\n" |
| 690 | "OSPF area ID as a decimal value\n" |
| 691 | "Summarize routes matching address/mask (border routers only)\n" |
| 692 | "Area range prefix\n" |
| 693 | "Announce area range as another prefix\n" |
| 694 | "Network prefix to be announced instead of range\n") |
| 695 | { |
| 696 | struct ospf *ospf = vty->index; |
| 697 | struct prefix_ipv4 p, s; |
| 698 | struct in_addr area_id; |
| 699 | int format; |
| 700 | |
| 701 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 702 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 703 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 704 | |
| 705 | ospf_area_range_substitute_set (ospf, area_id, &p, &s); |
| 706 | |
| 707 | return CMD_SUCCESS; |
| 708 | } |
| 709 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 710 | DEFUN (no_ospf_area_range_substitute, |
| 711 | no_ospf_area_range_substitute_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 712 | "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M", |
| 713 | NO_STR |
| 714 | "OSPF area parameters\n" |
| 715 | "OSPF area ID in IP address format\n" |
| 716 | "OSPF area ID as a decimal value\n" |
| 717 | "Summarize routes matching address/mask (border routers only)\n" |
| 718 | "Area range prefix\n" |
| 719 | "Announce area range as another prefix\n" |
| 720 | "Network prefix to be announced instead of range\n") |
| 721 | { |
| 722 | struct ospf *ospf = vty->index; |
| 723 | struct prefix_ipv4 p, s; |
| 724 | struct in_addr area_id; |
| 725 | int format; |
| 726 | |
| 727 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 728 | VTY_GET_IPV4_PREFIX ("area range", p, argv[1]); |
| 729 | VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]); |
| 730 | |
| 731 | ospf_area_range_substitute_unset (ospf, area_id, &p); |
| 732 | |
| 733 | return CMD_SUCCESS; |
| 734 | } |
| 735 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 736 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 737 | /* Command Handler Logic in VLink stuff is delicate!! |
| 738 | |
| 739 | ALTER AT YOUR OWN RISK!!!! |
| 740 | |
| 741 | Various dummy values are used to represent 'NoChange' state for |
| 742 | VLink configuration NOT being changed by a VLink command, and |
| 743 | special syntax is used within the command strings so that the |
| 744 | typed in command verbs can be seen in the configuration command |
| 745 | bacckend handler. This is to drastically reduce the verbeage |
| 746 | required to coe up with a reasonably compatible Cisco VLink command |
| 747 | |
| 748 | - Matthew Grant <grantma@anathoth.gen.nz> |
| 749 | Wed, 21 Feb 2001 15:13:52 +1300 |
| 750 | */ |
| 751 | |
| 752 | |
| 753 | /* Configuration data for virtual links |
| 754 | */ |
| 755 | struct ospf_vl_config_data { |
| 756 | struct vty *vty; /* vty stuff */ |
| 757 | struct in_addr area_id; /* area ID from command line */ |
| 758 | int format; /* command line area ID format */ |
| 759 | struct in_addr vl_peer; /* command line vl_peer */ |
| 760 | int auth_type; /* Authehntication type, if given */ |
| 761 | char *auth_key; /* simple password if present */ |
| 762 | int crypto_key_id; /* Cryptographic key ID */ |
| 763 | char *md5_key; /* MD5 authentication key */ |
| 764 | int hello_interval; /* Obvious what these are... */ |
| 765 | int retransmit_interval; |
| 766 | int transmit_delay; |
| 767 | int dead_interval; |
| 768 | }; |
| 769 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 770 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 771 | ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config, |
| 772 | struct vty *vty) |
| 773 | { |
| 774 | memset (vl_config, 0, sizeof (struct ospf_vl_config_data)); |
| 775 | vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN; |
| 776 | vl_config->vty = vty; |
| 777 | } |
| 778 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 779 | static struct ospf_vl_data * |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 780 | 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] | 781 | { |
| 782 | struct ospf_area *area; |
| 783 | struct ospf_vl_data *vl_data; |
| 784 | struct vty *vty; |
| 785 | struct in_addr area_id; |
| 786 | |
| 787 | vty = vl_config->vty; |
| 788 | area_id = vl_config->area_id; |
| 789 | |
| 790 | if (area_id.s_addr == OSPF_AREA_BACKBONE) |
| 791 | { |
| 792 | vty_out (vty, |
| 793 | "Configuring VLs over the backbone is not allowed%s", |
| 794 | VTY_NEWLINE); |
| 795 | return NULL; |
| 796 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 797 | area = ospf_area_get (ospf, area_id, vl_config->format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 798 | |
| 799 | if (area->external_routing != OSPF_AREA_DEFAULT) |
| 800 | { |
| 801 | if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 802 | vty_out (vty, "Area %s is %s%s", |
| 803 | inet_ntoa (area_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 804 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 805 | VTY_NEWLINE); |
| 806 | else |
| 807 | vty_out (vty, "Area %ld is %s%s", |
| 808 | (u_long)ntohl (area_id.s_addr), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 809 | area->external_routing == OSPF_AREA_NSSA?"nssa":"stub", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 810 | VTY_NEWLINE); |
| 811 | return NULL; |
| 812 | } |
| 813 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 814 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 815 | { |
| 816 | vl_data = ospf_vl_data_new (area, vl_config->vl_peer); |
| 817 | if (vl_data->vl_oi == NULL) |
| 818 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 819 | vl_data->vl_oi = ospf_vl_new (ospf, vl_data); |
| 820 | ospf_vl_add (ospf, vl_data); |
Paul Jakma | b6eef00 | 2014-10-09 14:19:51 +0100 | [diff] [blame] | 821 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | } |
| 823 | } |
| 824 | return vl_data; |
| 825 | } |
| 826 | |
| 827 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 828 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 829 | ospf_vl_set_security (struct ospf_vl_data *vl_data, |
| 830 | struct ospf_vl_config_data *vl_config) |
| 831 | { |
| 832 | struct crypt_key *ck; |
| 833 | struct vty *vty; |
| 834 | struct interface *ifp = vl_data->vl_oi->ifp; |
| 835 | |
| 836 | vty = vl_config->vty; |
| 837 | |
| 838 | if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN) |
| 839 | { |
| 840 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type); |
| 841 | IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type; |
| 842 | } |
| 843 | |
| 844 | if (vl_config->auth_key) |
| 845 | { |
| 846 | memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 847 | strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 848 | OSPF_AUTH_SIMPLE_SIZE); |
| 849 | } |
| 850 | else if (vl_config->md5_key) |
| 851 | { |
| 852 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id) |
| 853 | != NULL) |
| 854 | { |
| 855 | vty_out (vty, "OSPF: Key %d already exists%s", |
| 856 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 857 | return CMD_WARNING; |
| 858 | } |
| 859 | ck = ospf_crypt_key_new (); |
| 860 | ck->key_id = vl_config->crypto_key_id; |
| 861 | memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 862 | strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 863 | |
| 864 | ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck); |
| 865 | } |
| 866 | else if (vl_config->crypto_key_id != 0) |
| 867 | { |
| 868 | /* Delete a key */ |
| 869 | |
| 870 | if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, |
| 871 | vl_config->crypto_key_id) == NULL) |
| 872 | { |
| 873 | vty_out (vty, "OSPF: Key %d does not exist%s", |
| 874 | vl_config->crypto_key_id, VTY_NEWLINE); |
| 875 | return CMD_WARNING; |
| 876 | } |
| 877 | |
| 878 | ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id); |
| 879 | |
| 880 | } |
| 881 | |
| 882 | return CMD_SUCCESS; |
| 883 | } |
| 884 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 885 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 886 | ospf_vl_set_timers (struct ospf_vl_data *vl_data, |
| 887 | struct ospf_vl_config_data *vl_config) |
| 888 | { |
Christian Franke | 5bd78b9 | 2016-06-14 20:07:02 +0200 | [diff] [blame] | 889 | struct interface *ifp = vl_data->vl_oi->ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 890 | /* Virtual Link data initialised to defaults, so only set |
| 891 | if a value given */ |
| 892 | if (vl_config->hello_interval) |
| 893 | { |
| 894 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello); |
| 895 | IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval; |
| 896 | } |
| 897 | |
| 898 | if (vl_config->dead_interval) |
| 899 | { |
| 900 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait); |
| 901 | IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval; |
| 902 | } |
| 903 | |
| 904 | if (vl_config->retransmit_interval) |
| 905 | { |
| 906 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval); |
| 907 | IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval; |
| 908 | } |
| 909 | |
| 910 | if (vl_config->transmit_delay) |
| 911 | { |
| 912 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay); |
| 913 | IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay; |
| 914 | } |
| 915 | |
| 916 | return CMD_SUCCESS; |
| 917 | } |
| 918 | |
| 919 | |
| 920 | |
| 921 | /* The business end of all of the above */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 922 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 923 | ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 924 | { |
| 925 | struct ospf_vl_data *vl_data; |
| 926 | int ret; |
| 927 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 928 | vl_data = ospf_find_vl_data (ospf, vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 929 | if (!vl_data) |
| 930 | return CMD_WARNING; |
| 931 | |
| 932 | /* Process this one first as it can have a fatal result, which can |
| 933 | only logically occur if the virtual link exists already |
| 934 | Thus a command error does not result in a change to the |
| 935 | running configuration such as unexpectedly altered timer |
| 936 | values etc.*/ |
| 937 | ret = ospf_vl_set_security (vl_data, vl_config); |
| 938 | if (ret != CMD_SUCCESS) |
| 939 | return ret; |
| 940 | |
| 941 | /* Set any time based parameters, these area already range checked */ |
| 942 | |
| 943 | ret = ospf_vl_set_timers (vl_data, vl_config); |
| 944 | if (ret != CMD_SUCCESS) |
| 945 | return ret; |
| 946 | |
| 947 | return CMD_SUCCESS; |
| 948 | |
| 949 | } |
| 950 | |
| 951 | /* This stuff exists to make specifying all the alias commands A LOT simpler |
| 952 | */ |
| 953 | #define VLINK_HELPSTR_IPADDR \ |
| 954 | "OSPF area parameters\n" \ |
| 955 | "OSPF area ID in IP address format\n" \ |
| 956 | "OSPF area ID as a decimal value\n" \ |
| 957 | "Configure a virtual link\n" \ |
| 958 | "Router ID of the remote ABR\n" |
| 959 | |
| 960 | #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 961 | "Enable authentication on this virtual link\n" \ |
| 962 | "dummy string \n" |
| 963 | |
| 964 | #define VLINK_HELPSTR_AUTHTYPE_ALL \ |
| 965 | VLINK_HELPSTR_AUTHTYPE_SIMPLE \ |
| 966 | "Use null authentication\n" \ |
| 967 | "Use message-digest authentication\n" |
| 968 | |
| 969 | #define VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 970 | "Time between HELLO packets\n" \ |
| 971 | "Time between retransmitting lost link state advertisements\n" \ |
| 972 | "Link state transmit delay\n" \ |
| 973 | "Interval after which a neighbor is declared dead\n" |
| 974 | |
| 975 | #define VLINK_HELPSTR_TIME_PARAM \ |
| 976 | VLINK_HELPSTR_TIME_PARAM_NOSECS \ |
| 977 | "Seconds\n" |
| 978 | |
| 979 | #define VLINK_HELPSTR_AUTH_SIMPLE \ |
| 980 | "Authentication password (key)\n" \ |
| 981 | "The OSPF password (key)" |
| 982 | |
| 983 | #define VLINK_HELPSTR_AUTH_MD5 \ |
| 984 | "Message digest authentication password (key)\n" \ |
| 985 | "dummy string \n" \ |
| 986 | "Key ID\n" \ |
| 987 | "Use MD5 algorithm\n" \ |
| 988 | "The OSPF password (key)" |
| 989 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 990 | DEFUN (ospf_area_vlink, |
| 991 | ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 992 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 993 | VLINK_HELPSTR_IPADDR) |
| 994 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 995 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 996 | struct ospf_vl_config_data vl_config; |
| 997 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 998 | char md5_key[OSPF_AUTH_MD5_SIZE+1]; |
| 999 | int i; |
| 1000 | int ret; |
| 1001 | |
| 1002 | ospf_vl_config_data_init(&vl_config, vty); |
| 1003 | |
| 1004 | /* Read off first 2 parameters and check them */ |
| 1005 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format); |
| 1006 | if (ret < 0) |
| 1007 | { |
| 1008 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1009 | return CMD_WARNING; |
| 1010 | } |
| 1011 | |
| 1012 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1013 | if (! ret) |
| 1014 | { |
| 1015 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1016 | VTY_NEWLINE); |
| 1017 | return CMD_WARNING; |
| 1018 | } |
| 1019 | |
| 1020 | if (argc <=2) |
| 1021 | { |
| 1022 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
| 1023 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1024 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
| 1027 | /* Deal with other parameters */ |
| 1028 | for (i=2; i < argc; i++) |
| 1029 | { |
| 1030 | |
| 1031 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1032 | |
| 1033 | switch (argv[i][0]) |
| 1034 | { |
| 1035 | |
| 1036 | case 'a': |
| 1037 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1038 | { |
| 1039 | /* authentication-key - this option can occur anywhere on |
| 1040 | command line. At start of command line |
| 1041 | must check for authentication option. */ |
| 1042 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1043 | strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE); |
| 1044 | vl_config.auth_key = auth_key; |
| 1045 | i++; |
| 1046 | } |
| 1047 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1048 | { |
| 1049 | /* authentication - this option can only occur at start |
| 1050 | of command line */ |
| 1051 | vl_config.auth_type = OSPF_AUTH_SIMPLE; |
| 1052 | if ((i+1) < argc) |
| 1053 | { |
| 1054 | if (strncmp (argv[i+1], "n", 1) == 0) |
| 1055 | { |
| 1056 | /* "authentication null" */ |
| 1057 | vl_config.auth_type = OSPF_AUTH_NULL; |
| 1058 | i++; |
| 1059 | } |
| 1060 | else if (strncmp (argv[i+1], "m", 1) == 0 |
| 1061 | && strcmp (argv[i+1], "message-digest-") != 0) |
| 1062 | { |
| 1063 | /* "authentication message-digest" */ |
| 1064 | vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 1065 | i++; |
| 1066 | } |
| 1067 | } |
| 1068 | } |
| 1069 | break; |
| 1070 | |
| 1071 | case 'm': |
| 1072 | /* message-digest-key */ |
| 1073 | i++; |
| 1074 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1075 | if (vl_config.crypto_key_id < 0) |
| 1076 | return CMD_WARNING; |
| 1077 | i++; |
| 1078 | memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1); |
| 1079 | strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE); |
| 1080 | vl_config.md5_key = md5_key; |
| 1081 | break; |
| 1082 | |
| 1083 | case 'h': |
| 1084 | /* Hello interval */ |
| 1085 | i++; |
| 1086 | vl_config.hello_interval = strtol (argv[i], NULL, 10); |
| 1087 | if (vl_config.hello_interval < 0) |
| 1088 | return CMD_WARNING; |
| 1089 | break; |
| 1090 | |
| 1091 | case 'r': |
| 1092 | /* Retransmit Interval */ |
| 1093 | i++; |
| 1094 | vl_config.retransmit_interval = strtol (argv[i], NULL, 10); |
| 1095 | if (vl_config.retransmit_interval < 0) |
| 1096 | return CMD_WARNING; |
| 1097 | break; |
| 1098 | |
| 1099 | case 't': |
| 1100 | /* Transmit Delay */ |
| 1101 | i++; |
| 1102 | vl_config.transmit_delay = strtol (argv[i], NULL, 10); |
| 1103 | if (vl_config.transmit_delay < 0) |
| 1104 | return CMD_WARNING; |
| 1105 | break; |
| 1106 | |
| 1107 | case 'd': |
| 1108 | /* Dead Interval */ |
| 1109 | i++; |
| 1110 | vl_config.dead_interval = strtol (argv[i], NULL, 10); |
| 1111 | if (vl_config.dead_interval < 0) |
| 1112 | return CMD_WARNING; |
| 1113 | break; |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | |
| 1118 | /* Action configuration */ |
| 1119 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1120 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1121 | |
| 1122 | } |
| 1123 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1124 | DEFUN (no_ospf_area_vlink, |
| 1125 | no_ospf_area_vlink_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1126 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D", |
| 1127 | NO_STR |
| 1128 | VLINK_HELPSTR_IPADDR) |
| 1129 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1130 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1131 | struct ospf_area *area; |
| 1132 | struct ospf_vl_config_data vl_config; |
| 1133 | struct ospf_vl_data *vl_data = NULL; |
| 1134 | char auth_key[OSPF_AUTH_SIMPLE_SIZE+1]; |
| 1135 | int i; |
| 1136 | int ret, format; |
| 1137 | |
| 1138 | ospf_vl_config_data_init(&vl_config, vty); |
| 1139 | |
| 1140 | ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format); |
| 1141 | if (ret < 0) |
| 1142 | { |
| 1143 | vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE); |
| 1144 | return CMD_WARNING; |
| 1145 | } |
| 1146 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1147 | area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1148 | if (!area) |
| 1149 | { |
| 1150 | vty_out (vty, "Area does not exist%s", VTY_NEWLINE); |
| 1151 | return CMD_WARNING; |
| 1152 | } |
| 1153 | |
| 1154 | ret = inet_aton (argv[1], &vl_config.vl_peer); |
| 1155 | if (! ret) |
| 1156 | { |
| 1157 | vty_out (vty, "Please specify valid Router ID as a.b.c.d%s", |
| 1158 | VTY_NEWLINE); |
| 1159 | return CMD_WARNING; |
| 1160 | } |
| 1161 | |
| 1162 | if (argc <=2) |
| 1163 | { |
| 1164 | /* Basic VLink no command */ |
| 1165 | /* Thats all folks! - BUGS B. strikes again!!!*/ |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 1166 | if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer))) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1167 | ospf_vl_delete (ospf, vl_data); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1168 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1169 | ospf_area_check_free (ospf, vl_config.area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1170 | |
| 1171 | return CMD_SUCCESS; |
| 1172 | } |
| 1173 | |
| 1174 | /* If we are down here, we are reseting parameters */ |
| 1175 | |
| 1176 | /* Deal with other parameters */ |
| 1177 | for (i=2; i < argc; i++) |
| 1178 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1179 | /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */ |
| 1180 | |
| 1181 | switch (argv[i][0]) |
| 1182 | { |
| 1183 | |
| 1184 | case 'a': |
| 1185 | if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0) |
| 1186 | { |
| 1187 | /* authentication-key - this option can occur anywhere on |
| 1188 | command line. At start of command line |
| 1189 | must check for authentication option. */ |
| 1190 | memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
| 1191 | vl_config.auth_key = auth_key; |
| 1192 | } |
| 1193 | else if (strncmp (argv[i], "authentication", 14) == 0) |
| 1194 | { |
| 1195 | /* authentication - this option can only occur at start |
| 1196 | of command line */ |
| 1197 | vl_config.auth_type = OSPF_AUTH_NOTSET; |
| 1198 | } |
| 1199 | break; |
| 1200 | |
| 1201 | case 'm': |
| 1202 | /* message-digest-key */ |
| 1203 | /* Delete one key */ |
| 1204 | i++; |
| 1205 | vl_config.crypto_key_id = strtol (argv[i], NULL, 10); |
| 1206 | if (vl_config.crypto_key_id < 0) |
| 1207 | return CMD_WARNING; |
| 1208 | vl_config.md5_key = NULL; |
| 1209 | break; |
| 1210 | |
| 1211 | case 'h': |
| 1212 | /* Hello interval */ |
| 1213 | vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT; |
| 1214 | break; |
| 1215 | |
| 1216 | case 'r': |
| 1217 | /* Retransmit Interval */ |
| 1218 | vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 1219 | break; |
| 1220 | |
| 1221 | case 't': |
| 1222 | /* Transmit Delay */ |
| 1223 | vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 1224 | break; |
| 1225 | |
| 1226 | case 'd': |
| 1227 | /* Dead Interval */ |
| 1228 | i++; |
| 1229 | vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
| 1230 | break; |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | |
| 1235 | /* Action configuration */ |
| 1236 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1237 | return ospf_vl_set (ospf, &vl_config); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1240 | ALIAS (ospf_area_vlink, |
| 1241 | ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1242 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1243 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1244 | VLINK_HELPSTR_IPADDR |
| 1245 | VLINK_HELPSTR_TIME_PARAM) |
| 1246 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1247 | ALIAS (no_ospf_area_vlink, |
| 1248 | no_ospf_area_vlink_param1_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1249 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1250 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1251 | NO_STR |
| 1252 | VLINK_HELPSTR_IPADDR |
| 1253 | VLINK_HELPSTR_TIME_PARAM) |
| 1254 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1255 | ALIAS (ospf_area_vlink, |
| 1256 | ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1257 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1258 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1259 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1260 | VLINK_HELPSTR_IPADDR |
| 1261 | VLINK_HELPSTR_TIME_PARAM |
| 1262 | VLINK_HELPSTR_TIME_PARAM) |
| 1263 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1264 | ALIAS (no_ospf_area_vlink, |
| 1265 | no_ospf_area_vlink_param2_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1266 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1267 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1268 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1269 | NO_STR |
| 1270 | VLINK_HELPSTR_IPADDR |
| 1271 | VLINK_HELPSTR_TIME_PARAM |
| 1272 | VLINK_HELPSTR_TIME_PARAM) |
| 1273 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1274 | ALIAS (ospf_area_vlink, |
| 1275 | ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1276 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1277 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1278 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1279 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1280 | VLINK_HELPSTR_IPADDR |
| 1281 | VLINK_HELPSTR_TIME_PARAM |
| 1282 | VLINK_HELPSTR_TIME_PARAM |
| 1283 | VLINK_HELPSTR_TIME_PARAM) |
| 1284 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1285 | ALIAS (no_ospf_area_vlink, |
| 1286 | no_ospf_area_vlink_param3_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1287 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1288 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1289 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1290 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1291 | NO_STR |
| 1292 | VLINK_HELPSTR_IPADDR |
| 1293 | VLINK_HELPSTR_TIME_PARAM |
| 1294 | VLINK_HELPSTR_TIME_PARAM |
| 1295 | VLINK_HELPSTR_TIME_PARAM) |
| 1296 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1297 | ALIAS (ospf_area_vlink, |
| 1298 | ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1299 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1300 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1301 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1302 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> " |
| 1303 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>", |
| 1304 | VLINK_HELPSTR_IPADDR |
| 1305 | VLINK_HELPSTR_TIME_PARAM |
| 1306 | VLINK_HELPSTR_TIME_PARAM |
| 1307 | VLINK_HELPSTR_TIME_PARAM |
| 1308 | VLINK_HELPSTR_TIME_PARAM) |
| 1309 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1310 | ALIAS (no_ospf_area_vlink, |
| 1311 | no_ospf_area_vlink_param4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1312 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1313 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1314 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1315 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval) " |
| 1316 | "(hello-interval|retransmit-interval|transmit-delay|dead-interval)", |
| 1317 | NO_STR |
| 1318 | VLINK_HELPSTR_IPADDR |
| 1319 | VLINK_HELPSTR_TIME_PARAM |
| 1320 | VLINK_HELPSTR_TIME_PARAM |
| 1321 | VLINK_HELPSTR_TIME_PARAM |
| 1322 | VLINK_HELPSTR_TIME_PARAM) |
| 1323 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1324 | ALIAS (ospf_area_vlink, |
| 1325 | ospf_area_vlink_authtype_args_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1326 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1327 | "(authentication|) (message-digest|null)", |
| 1328 | VLINK_HELPSTR_IPADDR |
| 1329 | VLINK_HELPSTR_AUTHTYPE_ALL) |
| 1330 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1331 | ALIAS (ospf_area_vlink, |
| 1332 | ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1333 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1334 | "(authentication|)", |
| 1335 | VLINK_HELPSTR_IPADDR |
| 1336 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1337 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1338 | ALIAS (no_ospf_area_vlink, |
| 1339 | no_ospf_area_vlink_authtype_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1340 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1341 | "(authentication|)", |
| 1342 | NO_STR |
| 1343 | VLINK_HELPSTR_IPADDR |
| 1344 | VLINK_HELPSTR_AUTHTYPE_SIMPLE) |
| 1345 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1346 | ALIAS (ospf_area_vlink, |
| 1347 | ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1348 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1349 | "(message-digest-key|) <1-255> md5 KEY", |
| 1350 | VLINK_HELPSTR_IPADDR |
| 1351 | VLINK_HELPSTR_AUTH_MD5) |
| 1352 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1353 | ALIAS (no_ospf_area_vlink, |
| 1354 | no_ospf_area_vlink_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1355 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1356 | "(message-digest-key|) <1-255>", |
| 1357 | NO_STR |
| 1358 | VLINK_HELPSTR_IPADDR |
| 1359 | VLINK_HELPSTR_AUTH_MD5) |
| 1360 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1361 | ALIAS (ospf_area_vlink, |
| 1362 | ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1363 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1364 | "(authentication-key|) AUTH_KEY", |
| 1365 | VLINK_HELPSTR_IPADDR |
| 1366 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1367 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1368 | ALIAS (no_ospf_area_vlink, |
| 1369 | no_ospf_area_vlink_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1370 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1371 | "(authentication-key|)", |
| 1372 | NO_STR |
| 1373 | VLINK_HELPSTR_IPADDR |
| 1374 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1375 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1376 | ALIAS (ospf_area_vlink, |
| 1377 | ospf_area_vlink_authtype_args_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1378 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1379 | "(authentication|) (message-digest|null) " |
| 1380 | "(authentication-key|) AUTH_KEY", |
| 1381 | VLINK_HELPSTR_IPADDR |
| 1382 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1383 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1384 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1385 | ALIAS (ospf_area_vlink, |
| 1386 | ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1387 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1388 | "(authentication|) " |
| 1389 | "(authentication-key|) AUTH_KEY", |
| 1390 | VLINK_HELPSTR_IPADDR |
| 1391 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1392 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1393 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1394 | ALIAS (no_ospf_area_vlink, |
| 1395 | no_ospf_area_vlink_authtype_authkey_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1397 | "(authentication|) " |
| 1398 | "(authentication-key|)", |
| 1399 | NO_STR |
| 1400 | VLINK_HELPSTR_IPADDR |
| 1401 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1402 | VLINK_HELPSTR_AUTH_SIMPLE) |
| 1403 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1404 | ALIAS (ospf_area_vlink, |
| 1405 | ospf_area_vlink_authtype_args_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1406 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1407 | "(authentication|) (message-digest|null) " |
| 1408 | "(message-digest-key|) <1-255> md5 KEY", |
| 1409 | VLINK_HELPSTR_IPADDR |
| 1410 | VLINK_HELPSTR_AUTHTYPE_ALL |
| 1411 | VLINK_HELPSTR_AUTH_MD5) |
| 1412 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1413 | ALIAS (ospf_area_vlink, |
| 1414 | ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1415 | "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1416 | "(authentication|) " |
| 1417 | "(message-digest-key|) <1-255> md5 KEY", |
| 1418 | VLINK_HELPSTR_IPADDR |
| 1419 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1420 | VLINK_HELPSTR_AUTH_MD5) |
| 1421 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1422 | ALIAS (no_ospf_area_vlink, |
| 1423 | no_ospf_area_vlink_authtype_md5_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1424 | "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D " |
| 1425 | "(authentication|) " |
| 1426 | "(message-digest-key|)", |
| 1427 | NO_STR |
| 1428 | VLINK_HELPSTR_IPADDR |
| 1429 | VLINK_HELPSTR_AUTHTYPE_SIMPLE |
| 1430 | VLINK_HELPSTR_AUTH_MD5) |
| 1431 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1432 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1433 | DEFUN (ospf_area_shortcut, |
| 1434 | ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1435 | "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)", |
| 1436 | "OSPF area parameters\n" |
| 1437 | "OSPF area ID in IP address format\n" |
| 1438 | "OSPF area ID as a decimal value\n" |
| 1439 | "Configure the area's shortcutting mode\n" |
| 1440 | "Set default shortcutting behavior\n" |
| 1441 | "Enable shortcutting through the area\n" |
| 1442 | "Disable shortcutting through the area\n") |
| 1443 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1444 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1445 | struct ospf_area *area; |
| 1446 | struct in_addr area_id; |
| 1447 | int mode; |
| 1448 | int format; |
| 1449 | |
| 1450 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1451 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1452 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1453 | |
| 1454 | if (strncmp (argv[1], "de", 2) == 0) |
| 1455 | mode = OSPF_SHORTCUT_DEFAULT; |
| 1456 | else if (strncmp (argv[1], "di", 2) == 0) |
| 1457 | mode = OSPF_SHORTCUT_DISABLE; |
| 1458 | else if (strncmp (argv[1], "e", 1) == 0) |
| 1459 | mode = OSPF_SHORTCUT_ENABLE; |
| 1460 | else |
| 1461 | return CMD_WARNING; |
| 1462 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1463 | ospf_area_shortcut_set (ospf, area, mode); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1464 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1465 | if (ospf->abr_type != OSPF_ABR_SHORTCUT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1466 | vty_out (vty, "Shortcut area setting will take effect " |
| 1467 | "only when the router is configured as Shortcut ABR%s", |
| 1468 | VTY_NEWLINE); |
| 1469 | |
| 1470 | return CMD_SUCCESS; |
| 1471 | } |
| 1472 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1473 | DEFUN (no_ospf_area_shortcut, |
| 1474 | no_ospf_area_shortcut_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1475 | "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)", |
| 1476 | NO_STR |
| 1477 | "OSPF area parameters\n" |
| 1478 | "OSPF area ID in IP address format\n" |
| 1479 | "OSPF area ID as a decimal value\n" |
| 1480 | "Deconfigure the area's shortcutting mode\n" |
| 1481 | "Deconfigure enabled shortcutting through the area\n" |
| 1482 | "Deconfigure disabled shortcutting through the area\n") |
| 1483 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1484 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1485 | struct ospf_area *area; |
| 1486 | struct in_addr area_id; |
| 1487 | int format; |
| 1488 | |
| 1489 | VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]); |
| 1490 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1491 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1492 | if (!area) |
| 1493 | return CMD_SUCCESS; |
| 1494 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1495 | ospf_area_shortcut_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1496 | |
| 1497 | return CMD_SUCCESS; |
| 1498 | } |
| 1499 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1500 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1501 | DEFUN (ospf_area_stub, |
| 1502 | ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1503 | "area (A.B.C.D|<0-4294967295>) stub", |
| 1504 | "OSPF area parameters\n" |
| 1505 | "OSPF area ID in IP address format\n" |
| 1506 | "OSPF area ID as a decimal value\n" |
| 1507 | "Configure OSPF area as stub\n") |
| 1508 | { |
| 1509 | struct ospf *ospf = vty->index; |
| 1510 | struct in_addr area_id; |
| 1511 | int ret, format; |
| 1512 | |
| 1513 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1514 | |
| 1515 | ret = ospf_area_stub_set (ospf, area_id); |
| 1516 | if (ret == 0) |
| 1517 | { |
| 1518 | vty_out (vty, "First deconfigure all virtual link through this area%s", |
| 1519 | VTY_NEWLINE); |
| 1520 | return CMD_WARNING; |
| 1521 | } |
| 1522 | |
| 1523 | ospf_area_no_summary_unset (ospf, area_id); |
| 1524 | |
| 1525 | return CMD_SUCCESS; |
| 1526 | } |
| 1527 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1528 | DEFUN (ospf_area_stub_no_summary, |
| 1529 | ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1530 | "area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1531 | "OSPF stub parameters\n" |
| 1532 | "OSPF area ID in IP address format\n" |
| 1533 | "OSPF area ID as a decimal value\n" |
| 1534 | "Configure OSPF area as stub\n" |
| 1535 | "Do not inject inter-area routes into stub\n") |
| 1536 | { |
| 1537 | struct ospf *ospf = vty->index; |
| 1538 | struct in_addr area_id; |
| 1539 | int ret, format; |
| 1540 | |
| 1541 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1542 | |
| 1543 | ret = ospf_area_stub_set (ospf, area_id); |
| 1544 | if (ret == 0) |
| 1545 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1546 | 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] | 1547 | VTY_NEWLINE); |
| 1548 | return CMD_WARNING; |
| 1549 | } |
| 1550 | |
| 1551 | ospf_area_no_summary_set (ospf, area_id); |
| 1552 | |
| 1553 | return CMD_SUCCESS; |
| 1554 | } |
| 1555 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1556 | DEFUN (no_ospf_area_stub, |
| 1557 | no_ospf_area_stub_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1558 | "no area (A.B.C.D|<0-4294967295>) stub", |
| 1559 | NO_STR |
| 1560 | "OSPF area parameters\n" |
| 1561 | "OSPF area ID in IP address format\n" |
| 1562 | "OSPF area ID as a decimal value\n" |
| 1563 | "Configure OSPF area as stub\n") |
| 1564 | { |
| 1565 | struct ospf *ospf = vty->index; |
| 1566 | struct in_addr area_id; |
| 1567 | int format; |
| 1568 | |
| 1569 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1570 | |
| 1571 | ospf_area_stub_unset (ospf, area_id); |
| 1572 | ospf_area_no_summary_unset (ospf, area_id); |
| 1573 | |
| 1574 | return CMD_SUCCESS; |
| 1575 | } |
| 1576 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1577 | DEFUN (no_ospf_area_stub_no_summary, |
| 1578 | no_ospf_area_stub_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1579 | "no area (A.B.C.D|<0-4294967295>) stub no-summary", |
| 1580 | NO_STR |
| 1581 | "OSPF area parameters\n" |
| 1582 | "OSPF area ID in IP address format\n" |
| 1583 | "OSPF area ID as a decimal value\n" |
| 1584 | "Configure OSPF area as stub\n" |
| 1585 | "Do not inject inter-area routes into area\n") |
| 1586 | { |
| 1587 | struct ospf *ospf = vty->index; |
| 1588 | struct in_addr area_id; |
| 1589 | int format; |
| 1590 | |
| 1591 | VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]); |
| 1592 | ospf_area_no_summary_unset (ospf, area_id); |
| 1593 | |
| 1594 | return CMD_SUCCESS; |
| 1595 | } |
| 1596 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1597 | static int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1598 | ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[], |
| 1599 | int nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1600 | { |
| 1601 | struct ospf *ospf = vty->index; |
| 1602 | struct in_addr area_id; |
| 1603 | int ret, format; |
| 1604 | |
| 1605 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1606 | |
| 1607 | ret = ospf_area_nssa_set (ospf, area_id); |
| 1608 | if (ret == 0) |
| 1609 | { |
| 1610 | vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s", |
| 1611 | VTY_NEWLINE); |
| 1612 | return CMD_WARNING; |
| 1613 | } |
| 1614 | |
| 1615 | if (argc > 1) |
| 1616 | { |
| 1617 | if (strncmp (argv[1], "translate-c", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1618 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1619 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1620 | else if (strncmp (argv[1], "translate-n", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1621 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1622 | OSPF_NSSA_ROLE_NEVER); |
| 1623 | else if (strncmp (argv[1], "translate-a", 11) == 0) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1624 | ospf_area_nssa_translator_role_set (ospf, area_id, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1625 | OSPF_NSSA_ROLE_ALWAYS); |
| 1626 | } |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1627 | else |
| 1628 | { |
| 1629 | ospf_area_nssa_translator_role_set (ospf, area_id, |
| 1630 | OSPF_NSSA_ROLE_CANDIDATE); |
| 1631 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1632 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1633 | if (nosum) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1634 | ospf_area_no_summary_set (ospf, area_id); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1635 | else |
| 1636 | ospf_area_no_summary_unset (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1637 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1638 | ospf_schedule_abr_task (ospf); |
| 1639 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1640 | return CMD_SUCCESS; |
| 1641 | } |
| 1642 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1643 | DEFUN (ospf_area_nssa_translate_no_summary, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1644 | ospf_area_nssa_translate_no_summary_cmd, |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1645 | "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] | 1646 | "OSPF area parameters\n" |
| 1647 | "OSPF area ID in IP address format\n" |
| 1648 | "OSPF area ID as a decimal value\n" |
| 1649 | "Configure OSPF area as nssa\n" |
| 1650 | "Configure NSSA-ABR for translate election (default)\n" |
| 1651 | "Configure NSSA-ABR to never translate\n" |
| 1652 | "Configure NSSA-ABR to always translate\n" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1653 | "Do not inject inter-area routes into nssa\n") |
| 1654 | { |
| 1655 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
| 1656 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1657 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1658 | DEFUN (ospf_area_nssa_translate, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1659 | ospf_area_nssa_translate_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1660 | "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)", |
| 1661 | "OSPF area parameters\n" |
| 1662 | "OSPF area ID in IP address format\n" |
| 1663 | "OSPF area ID as a decimal value\n" |
| 1664 | "Configure OSPF area as nssa\n" |
| 1665 | "Configure NSSA-ABR for translate election (default)\n" |
| 1666 | "Configure NSSA-ABR to never translate\n" |
| 1667 | "Configure NSSA-ABR to always translate\n") |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1668 | { |
| 1669 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1670 | } |
| 1671 | |
| 1672 | DEFUN (ospf_area_nssa, |
| 1673 | ospf_area_nssa_cmd, |
| 1674 | "area (A.B.C.D|<0-4294967295>) nssa", |
| 1675 | "OSPF area parameters\n" |
| 1676 | "OSPF area ID in IP address format\n" |
| 1677 | "OSPF area ID as a decimal value\n" |
| 1678 | "Configure OSPF area as nssa\n") |
| 1679 | { |
| 1680 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 0); |
| 1681 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1682 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1683 | DEFUN (ospf_area_nssa_no_summary, |
| 1684 | ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1685 | "area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1686 | "OSPF area parameters\n" |
| 1687 | "OSPF area ID in IP address format\n" |
| 1688 | "OSPF area ID as a decimal value\n" |
| 1689 | "Configure OSPF area as nssa\n" |
| 1690 | "Do not inject inter-area routes into nssa\n") |
| 1691 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1692 | return ospf_area_nssa_cmd_handler (vty, argc, argv, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1693 | } |
| 1694 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1695 | DEFUN (no_ospf_area_nssa, |
| 1696 | no_ospf_area_nssa_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1697 | "no area (A.B.C.D|<0-4294967295>) nssa", |
| 1698 | NO_STR |
| 1699 | "OSPF area parameters\n" |
| 1700 | "OSPF area ID in IP address format\n" |
| 1701 | "OSPF area ID as a decimal value\n" |
| 1702 | "Configure OSPF area as nssa\n") |
| 1703 | { |
| 1704 | struct ospf *ospf = vty->index; |
| 1705 | struct in_addr area_id; |
| 1706 | int format; |
| 1707 | |
| 1708 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1709 | |
| 1710 | ospf_area_nssa_unset (ospf, area_id); |
| 1711 | ospf_area_no_summary_unset (ospf, area_id); |
| 1712 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 1713 | ospf_schedule_abr_task (ospf); |
| 1714 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1715 | return CMD_SUCCESS; |
| 1716 | } |
| 1717 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1718 | DEFUN (no_ospf_area_nssa_no_summary, |
| 1719 | no_ospf_area_nssa_no_summary_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1720 | "no area (A.B.C.D|<0-4294967295>) nssa no-summary", |
| 1721 | NO_STR |
| 1722 | "OSPF area parameters\n" |
| 1723 | "OSPF area ID in IP address format\n" |
| 1724 | "OSPF area ID as a decimal value\n" |
| 1725 | "Configure OSPF area as nssa\n" |
| 1726 | "Do not inject inter-area routes into nssa\n") |
| 1727 | { |
| 1728 | struct ospf *ospf = vty->index; |
| 1729 | struct in_addr area_id; |
| 1730 | int format; |
| 1731 | |
| 1732 | VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]); |
| 1733 | ospf_area_no_summary_unset (ospf, area_id); |
| 1734 | |
| 1735 | return CMD_SUCCESS; |
| 1736 | } |
| 1737 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1738 | DEFUN (ospf_area_default_cost, |
| 1739 | ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1740 | "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1741 | "OSPF area parameters\n" |
| 1742 | "OSPF area ID in IP address format\n" |
| 1743 | "OSPF area ID as a decimal value\n" |
| 1744 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1745 | "Stub's advertised default summary cost\n") |
| 1746 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1747 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1748 | struct ospf_area *area; |
| 1749 | struct in_addr area_id; |
| 1750 | u_int32_t cost; |
| 1751 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1752 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1753 | |
| 1754 | VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]); |
| 1755 | VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215); |
| 1756 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1757 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1758 | |
| 1759 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1760 | { |
| 1761 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1762 | return CMD_WARNING; |
| 1763 | } |
| 1764 | |
| 1765 | area->default_cost = cost; |
| 1766 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1767 | p.family = AF_INET; |
| 1768 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1769 | p.prefixlen = 0; |
| 1770 | if (IS_DEBUG_OSPF_EVENT) |
| 1771 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1772 | "announcing 0.0.0.0/0 to area %s", |
| 1773 | inet_ntoa (area->area_id)); |
| 1774 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1775 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1776 | return CMD_SUCCESS; |
| 1777 | } |
| 1778 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1779 | DEFUN (no_ospf_area_default_cost, |
| 1780 | no_ospf_area_default_cost_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1781 | "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>", |
| 1782 | NO_STR |
| 1783 | "OSPF area parameters\n" |
| 1784 | "OSPF area ID in IP address format\n" |
| 1785 | "OSPF area ID as a decimal value\n" |
| 1786 | "Set the summary-default cost of a NSSA or stub area\n" |
| 1787 | "Stub's advertised default summary cost\n") |
| 1788 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1789 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1790 | struct ospf_area *area; |
| 1791 | struct in_addr area_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | int format; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1793 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1794 | |
| 1795 | 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] | 1796 | VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1797 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1798 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1799 | if (area == NULL) |
| 1800 | return CMD_SUCCESS; |
| 1801 | |
| 1802 | if (area->external_routing == OSPF_AREA_DEFAULT) |
| 1803 | { |
| 1804 | vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE); |
| 1805 | return CMD_WARNING; |
| 1806 | } |
| 1807 | |
| 1808 | area->default_cost = 1; |
| 1809 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 1810 | p.family = AF_INET; |
| 1811 | p.prefix.s_addr = OSPF_DEFAULT_DESTINATION; |
| 1812 | p.prefixlen = 0; |
| 1813 | if (IS_DEBUG_OSPF_EVENT) |
| 1814 | zlog_debug ("ospf_abr_announce_stub_defaults(): " |
| 1815 | "announcing 0.0.0.0/0 to area %s", |
| 1816 | inet_ntoa (area->area_id)); |
| 1817 | ospf_abr_announce_network_to_area (&p, area->default_cost, area); |
| 1818 | |
| 1819 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1820 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1821 | |
| 1822 | return CMD_SUCCESS; |
| 1823 | } |
| 1824 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1825 | DEFUN (ospf_area_export_list, |
| 1826 | ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1827 | "area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1828 | "OSPF area parameters\n" |
| 1829 | "OSPF area ID in IP address format\n" |
| 1830 | "OSPF area ID as a decimal value\n" |
| 1831 | "Set the filter for networks announced to other areas\n" |
| 1832 | "Name of the access-list\n") |
| 1833 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1834 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1835 | struct ospf_area *area; |
| 1836 | struct in_addr area_id; |
| 1837 | int format; |
| 1838 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1839 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1840 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1841 | area = ospf_area_get (ospf, area_id, format); |
| 1842 | ospf_area_export_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1843 | |
| 1844 | return CMD_SUCCESS; |
| 1845 | } |
| 1846 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1847 | DEFUN (no_ospf_area_export_list, |
| 1848 | no_ospf_area_export_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1849 | "no area (A.B.C.D|<0-4294967295>) export-list NAME", |
| 1850 | NO_STR |
| 1851 | "OSPF area parameters\n" |
| 1852 | "OSPF area ID in IP address format\n" |
| 1853 | "OSPF area ID as a decimal value\n" |
| 1854 | "Unset the filter for networks announced to other areas\n" |
| 1855 | "Name of the access-list\n") |
| 1856 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1857 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1858 | struct ospf_area *area; |
| 1859 | struct in_addr area_id; |
| 1860 | int format; |
| 1861 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1862 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1863 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1864 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1865 | if (area == NULL) |
| 1866 | return CMD_SUCCESS; |
| 1867 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1868 | ospf_area_export_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1869 | |
| 1870 | return CMD_SUCCESS; |
| 1871 | } |
| 1872 | |
| 1873 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1874 | DEFUN (ospf_area_import_list, |
| 1875 | ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1876 | "area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1877 | "OSPF area parameters\n" |
| 1878 | "OSPF area ID in IP address format\n" |
| 1879 | "OSPF area ID as a decimal value\n" |
| 1880 | "Set the filter for networks from other areas announced to the specified one\n" |
| 1881 | "Name of the access-list\n") |
| 1882 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1883 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1884 | struct ospf_area *area; |
| 1885 | struct in_addr area_id; |
| 1886 | int format; |
| 1887 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1888 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1889 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1890 | area = ospf_area_get (ospf, area_id, format); |
| 1891 | ospf_area_import_list_set (ospf, area, argv[1]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1892 | |
| 1893 | return CMD_SUCCESS; |
| 1894 | } |
| 1895 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1896 | DEFUN (no_ospf_area_import_list, |
| 1897 | no_ospf_area_import_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1898 | "no area (A.B.C.D|<0-4294967295>) import-list NAME", |
| 1899 | NO_STR |
| 1900 | "OSPF area parameters\n" |
| 1901 | "OSPF area ID in IP address format\n" |
| 1902 | "OSPF area ID as a decimal value\n" |
| 1903 | "Unset the filter for networks announced to other areas\n" |
| 1904 | "Name of the access-list\n") |
| 1905 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1906 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1907 | struct ospf_area *area; |
| 1908 | struct in_addr area_id; |
| 1909 | int format; |
| 1910 | |
hasso | 5293076 | 2004-04-19 18:26:53 +0000 | [diff] [blame] | 1911 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1912 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1913 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1914 | if (area == NULL) |
| 1915 | return CMD_SUCCESS; |
| 1916 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1917 | ospf_area_import_list_unset (ospf, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1918 | |
| 1919 | return CMD_SUCCESS; |
| 1920 | } |
| 1921 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1922 | DEFUN (ospf_area_filter_list, |
| 1923 | ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1924 | "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1925 | "OSPF area parameters\n" |
| 1926 | "OSPF area ID in IP address format\n" |
| 1927 | "OSPF area ID as a decimal value\n" |
| 1928 | "Filter networks between OSPF areas\n" |
| 1929 | "Filter prefixes between OSPF areas\n" |
| 1930 | "Name of an IP prefix-list\n" |
| 1931 | "Filter networks sent to this area\n" |
| 1932 | "Filter networks sent from this area\n") |
| 1933 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1934 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1935 | struct ospf_area *area; |
| 1936 | struct in_addr area_id; |
| 1937 | struct prefix_list *plist; |
| 1938 | int format; |
| 1939 | |
| 1940 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1941 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1942 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1943 | plist = prefix_list_lookup (AFI_IP, argv[1]); |
| 1944 | if (strncmp (argv[2], "in", 2) == 0) |
| 1945 | { |
| 1946 | PREFIX_LIST_IN (area) = plist; |
| 1947 | if (PREFIX_NAME_IN (area)) |
| 1948 | free (PREFIX_NAME_IN (area)); |
| 1949 | |
| 1950 | PREFIX_NAME_IN (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1951 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1952 | } |
| 1953 | else |
| 1954 | { |
| 1955 | PREFIX_LIST_OUT (area) = plist; |
| 1956 | if (PREFIX_NAME_OUT (area)) |
| 1957 | free (PREFIX_NAME_OUT (area)); |
| 1958 | |
| 1959 | PREFIX_NAME_OUT (area) = strdup (argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1960 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1961 | } |
| 1962 | |
| 1963 | return CMD_SUCCESS; |
| 1964 | } |
| 1965 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 1966 | DEFUN (no_ospf_area_filter_list, |
| 1967 | no_ospf_area_filter_list_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1968 | "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)", |
| 1969 | NO_STR |
| 1970 | "OSPF area parameters\n" |
| 1971 | "OSPF area ID in IP address format\n" |
| 1972 | "OSPF area ID as a decimal value\n" |
| 1973 | "Filter networks between OSPF areas\n" |
| 1974 | "Filter prefixes between OSPF areas\n" |
| 1975 | "Name of an IP prefix-list\n" |
| 1976 | "Filter networks sent to this area\n" |
| 1977 | "Filter networks sent from this area\n") |
| 1978 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1979 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1980 | struct ospf_area *area; |
| 1981 | struct in_addr area_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1982 | int format; |
| 1983 | |
| 1984 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 1985 | |
Paul Jakma | 1a8ec2b | 2006-05-11 13:34:08 +0000 | [diff] [blame] | 1986 | if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL) |
| 1987 | return CMD_SUCCESS; |
| 1988 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1989 | if (strncmp (argv[2], "in", 2) == 0) |
| 1990 | { |
| 1991 | if (PREFIX_NAME_IN (area)) |
| 1992 | if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0) |
| 1993 | return CMD_SUCCESS; |
| 1994 | |
| 1995 | PREFIX_LIST_IN (area) = NULL; |
| 1996 | if (PREFIX_NAME_IN (area)) |
| 1997 | free (PREFIX_NAME_IN (area)); |
| 1998 | |
| 1999 | PREFIX_NAME_IN (area) = NULL; |
| 2000 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2001 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2002 | } |
| 2003 | else |
| 2004 | { |
| 2005 | if (PREFIX_NAME_OUT (area)) |
| 2006 | if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0) |
| 2007 | return CMD_SUCCESS; |
| 2008 | |
| 2009 | PREFIX_LIST_OUT (area) = NULL; |
| 2010 | if (PREFIX_NAME_OUT (area)) |
| 2011 | free (PREFIX_NAME_OUT (area)); |
| 2012 | |
| 2013 | PREFIX_NAME_OUT (area) = NULL; |
| 2014 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2015 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2016 | } |
| 2017 | |
| 2018 | return CMD_SUCCESS; |
| 2019 | } |
| 2020 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2021 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2022 | DEFUN (ospf_area_authentication_message_digest, |
| 2023 | ospf_area_authentication_message_digest_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2024 | "area (A.B.C.D|<0-4294967295>) authentication message-digest", |
| 2025 | "OSPF area parameters\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 2026 | "OSPF area ID in IP address format\n" |
| 2027 | "OSPF area ID as a decimal value\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2028 | "Enable authentication\n" |
| 2029 | "Use message-digest authentication\n") |
| 2030 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2031 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2032 | struct ospf_area *area; |
| 2033 | struct in_addr area_id; |
| 2034 | int format; |
| 2035 | |
| 2036 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2037 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2038 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2039 | area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 2040 | |
| 2041 | return CMD_SUCCESS; |
| 2042 | } |
| 2043 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2044 | DEFUN (ospf_area_authentication, |
| 2045 | ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2046 | "area (A.B.C.D|<0-4294967295>) authentication", |
| 2047 | "OSPF area parameters\n" |
| 2048 | "OSPF area ID in IP address format\n" |
| 2049 | "OSPF area ID as a decimal value\n" |
| 2050 | "Enable authentication\n") |
| 2051 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2052 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2053 | struct ospf_area *area; |
| 2054 | struct in_addr area_id; |
| 2055 | int format; |
| 2056 | |
| 2057 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2058 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2059 | area = ospf_area_get (ospf, area_id, format); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2060 | area->auth_type = OSPF_AUTH_SIMPLE; |
| 2061 | |
| 2062 | return CMD_SUCCESS; |
| 2063 | } |
| 2064 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2065 | DEFUN (no_ospf_area_authentication, |
| 2066 | no_ospf_area_authentication_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2067 | "no area (A.B.C.D|<0-4294967295>) authentication", |
| 2068 | NO_STR |
| 2069 | "OSPF area parameters\n" |
| 2070 | "OSPF area ID in IP address format\n" |
| 2071 | "OSPF area ID as a decimal value\n" |
| 2072 | "Enable authentication\n") |
| 2073 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2074 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2075 | struct ospf_area *area; |
| 2076 | struct in_addr area_id; |
| 2077 | int format; |
| 2078 | |
| 2079 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
| 2080 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2081 | area = ospf_area_lookup_by_area_id (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2082 | if (area == NULL) |
| 2083 | return CMD_SUCCESS; |
| 2084 | |
| 2085 | area->auth_type = OSPF_AUTH_NULL; |
| 2086 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2087 | ospf_area_check_free (ospf, area_id); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2088 | |
| 2089 | return CMD_SUCCESS; |
| 2090 | } |
| 2091 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2092 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2093 | DEFUN (ospf_abr_type, |
| 2094 | ospf_abr_type_cmd, |
| 2095 | "ospf abr-type (cisco|ibm|shortcut|standard)", |
| 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 | "Standard behavior (RFC2328)\n") |
| 2102 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2103 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2104 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2105 | |
| 2106 | if (strncmp (argv[0], "c", 1) == 0) |
| 2107 | abr_type = OSPF_ABR_CISCO; |
| 2108 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2109 | abr_type = OSPF_ABR_IBM; |
| 2110 | else if (strncmp (argv[0], "sh", 2) == 0) |
| 2111 | abr_type = OSPF_ABR_SHORTCUT; |
| 2112 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2113 | abr_type = OSPF_ABR_STAND; |
| 2114 | else |
| 2115 | return CMD_WARNING; |
| 2116 | |
| 2117 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2118 | if (ospf->abr_type != abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2119 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2120 | ospf->abr_type = abr_type; |
| 2121 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2122 | } |
| 2123 | |
| 2124 | return CMD_SUCCESS; |
| 2125 | } |
| 2126 | |
| 2127 | DEFUN (no_ospf_abr_type, |
| 2128 | no_ospf_abr_type_cmd, |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2129 | "no ospf abr-type (cisco|ibm|shortcut|standard)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2130 | NO_STR |
| 2131 | "OSPF specific commands\n" |
| 2132 | "Set OSPF ABR type\n" |
| 2133 | "Alternative ABR, cisco implementation\n" |
| 2134 | "Alternative ABR, IBM implementation\n" |
| 2135 | "Shortcut ABR\n") |
| 2136 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2137 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2138 | u_char abr_type = OSPF_ABR_UNKNOWN; |
| 2139 | |
| 2140 | if (strncmp (argv[0], "c", 1) == 0) |
| 2141 | abr_type = OSPF_ABR_CISCO; |
| 2142 | else if (strncmp (argv[0], "i", 1) == 0) |
| 2143 | abr_type = OSPF_ABR_IBM; |
Francesco Dolcini | 04d2331 | 2009-06-02 18:20:09 +0100 | [diff] [blame] | 2144 | else if (strncmp (argv[0], "sh", 2) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2145 | abr_type = OSPF_ABR_SHORTCUT; |
Francesco Dolcini | 04d2331 | 2009-06-02 18:20:09 +0100 | [diff] [blame] | 2146 | else if (strncmp (argv[0], "st", 2) == 0) |
| 2147 | abr_type = OSPF_ABR_STAND; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2148 | else |
| 2149 | return CMD_WARNING; |
| 2150 | |
| 2151 | /* If ABR type value is changed, schedule ABR task. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2152 | if (ospf->abr_type == abr_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2153 | { |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 2154 | ospf->abr_type = OSPF_ABR_DEFAULT; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2155 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2156 | } |
| 2157 | |
| 2158 | return CMD_SUCCESS; |
| 2159 | } |
| 2160 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2161 | DEFUN (ospf_log_adjacency_changes, |
| 2162 | ospf_log_adjacency_changes_cmd, |
| 2163 | "log-adjacency-changes", |
| 2164 | "Log changes in adjacency state\n") |
| 2165 | { |
| 2166 | struct ospf *ospf = vty->index; |
| 2167 | |
| 2168 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2169 | return CMD_SUCCESS; |
| 2170 | } |
| 2171 | |
| 2172 | DEFUN (ospf_log_adjacency_changes_detail, |
| 2173 | ospf_log_adjacency_changes_detail_cmd, |
| 2174 | "log-adjacency-changes detail", |
| 2175 | "Log changes in adjacency state\n" |
| 2176 | "Log all state changes\n") |
| 2177 | { |
| 2178 | struct ospf *ospf = vty->index; |
| 2179 | |
| 2180 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2181 | SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2182 | return CMD_SUCCESS; |
| 2183 | } |
| 2184 | |
| 2185 | DEFUN (no_ospf_log_adjacency_changes, |
| 2186 | no_ospf_log_adjacency_changes_cmd, |
| 2187 | "no log-adjacency-changes", |
| 2188 | NO_STR |
| 2189 | "Log changes in adjacency state\n") |
| 2190 | { |
| 2191 | struct ospf *ospf = vty->index; |
| 2192 | |
| 2193 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2194 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES); |
| 2195 | return CMD_SUCCESS; |
| 2196 | } |
| 2197 | |
| 2198 | DEFUN (no_ospf_log_adjacency_changes_detail, |
| 2199 | no_ospf_log_adjacency_changes_detail_cmd, |
| 2200 | "no log-adjacency-changes detail", |
| 2201 | NO_STR |
| 2202 | "Log changes in adjacency state\n" |
| 2203 | "Log all state changes\n") |
| 2204 | { |
| 2205 | struct ospf *ospf = vty->index; |
| 2206 | |
| 2207 | UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL); |
| 2208 | return CMD_SUCCESS; |
| 2209 | } |
| 2210 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2211 | DEFUN (ospf_compatible_rfc1583, |
| 2212 | ospf_compatible_rfc1583_cmd, |
| 2213 | "compatible rfc1583", |
| 2214 | "OSPF compatibility list\n" |
| 2215 | "compatible with RFC 1583\n") |
| 2216 | { |
| 2217 | struct ospf *ospf = vty->index; |
| 2218 | |
| 2219 | if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2220 | { |
| 2221 | SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
Paul Jakma | b6eef00 | 2014-10-09 14:19:51 +0100 | [diff] [blame] | 2222 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2223 | } |
| 2224 | return CMD_SUCCESS; |
| 2225 | } |
| 2226 | |
| 2227 | DEFUN (no_ospf_compatible_rfc1583, |
| 2228 | no_ospf_compatible_rfc1583_cmd, |
| 2229 | "no compatible rfc1583", |
| 2230 | NO_STR |
| 2231 | "OSPF compatibility list\n" |
| 2232 | "compatible with RFC 1583\n") |
| 2233 | { |
| 2234 | struct ospf *ospf = vty->index; |
| 2235 | |
| 2236 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
| 2237 | { |
| 2238 | UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE); |
Paul Jakma | b6eef00 | 2014-10-09 14:19:51 +0100 | [diff] [blame] | 2239 | ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | } |
| 2241 | return CMD_SUCCESS; |
| 2242 | } |
| 2243 | |
| 2244 | ALIAS (ospf_compatible_rfc1583, |
| 2245 | ospf_rfc1583_flag_cmd, |
| 2246 | "ospf rfc1583compatibility", |
| 2247 | "OSPF specific commands\n" |
| 2248 | "Enable the RFC1583Compatibility flag\n") |
| 2249 | |
| 2250 | ALIAS (no_ospf_compatible_rfc1583, |
| 2251 | no_ospf_rfc1583_flag_cmd, |
| 2252 | "no ospf rfc1583compatibility", |
| 2253 | NO_STR |
| 2254 | "OSPF specific commands\n" |
| 2255 | "Disable the RFC1583Compatibility flag\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2256 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2257 | static int |
| 2258 | ospf_timers_spf_set (struct vty *vty, unsigned int delay, |
| 2259 | unsigned int hold, |
| 2260 | unsigned int max) |
| 2261 | { |
| 2262 | struct ospf *ospf = vty->index; |
| 2263 | |
| 2264 | ospf->spf_delay = delay; |
| 2265 | ospf->spf_holdtime = hold; |
| 2266 | ospf->spf_max_holdtime = max; |
| 2267 | |
| 2268 | return CMD_SUCCESS; |
| 2269 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2270 | |
Michael Rossberg | 2ef762e | 2015-07-27 07:56:25 +0200 | [diff] [blame] | 2271 | DEFUN (ospf_timers_min_ls_interval, |
| 2272 | ospf_timers_min_ls_interval_cmd, |
| 2273 | "timers throttle lsa all <0-5000>", |
| 2274 | "Adjust routing timers\n" |
| 2275 | "Throttling adaptive timer\n" |
| 2276 | "LSA delay between transmissions\n" |
| 2277 | NO_STR |
| 2278 | "Delay (msec) between sending LSAs\n") |
| 2279 | { |
| 2280 | struct ospf *ospf = vty->index; |
| 2281 | unsigned int interval; |
| 2282 | |
| 2283 | if (argc != 1) |
| 2284 | { |
| 2285 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2286 | return CMD_WARNING; |
| 2287 | } |
| 2288 | |
| 2289 | VTY_GET_INTEGER ("LSA interval", interval, argv[0]); |
| 2290 | |
| 2291 | ospf->min_ls_interval = interval; |
| 2292 | |
| 2293 | return CMD_SUCCESS; |
| 2294 | } |
| 2295 | |
| 2296 | DEFUN (no_ospf_timers_min_ls_interval, |
| 2297 | no_ospf_timers_min_ls_interval_cmd, |
| 2298 | "no timers throttle lsa all", |
| 2299 | NO_STR |
| 2300 | "Adjust routing timers\n" |
| 2301 | "Throttling adaptive timer\n" |
| 2302 | "LSA delay between transmissions\n") |
| 2303 | { |
| 2304 | struct ospf *ospf = vty->index; |
| 2305 | ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL; |
| 2306 | |
| 2307 | return CMD_SUCCESS; |
| 2308 | } |
| 2309 | |
| 2310 | DEFUN (ospf_timers_min_ls_arrival, |
| 2311 | ospf_timers_min_ls_arrival_cmd, |
| 2312 | "timers lsa arrival <0-1000>", |
| 2313 | "Adjust routing timers\n" |
| 2314 | "Throttling link state advertisement delays\n" |
| 2315 | "OSPF minimum arrival interval delay\n" |
| 2316 | "Delay (msec) between accepted LSAs\n") |
| 2317 | { |
| 2318 | struct ospf *ospf = vty->index; |
| 2319 | unsigned int arrival; |
| 2320 | |
| 2321 | if (argc != 1) |
| 2322 | { |
| 2323 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2324 | return CMD_WARNING; |
| 2325 | } |
| 2326 | |
| 2327 | VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000); |
| 2328 | |
| 2329 | ospf->min_ls_arrival = arrival; |
| 2330 | |
| 2331 | return CMD_SUCCESS; |
| 2332 | } |
| 2333 | |
| 2334 | DEFUN (no_ospf_timers_min_ls_arrival, |
| 2335 | no_ospf_timers_min_ls_arrival_cmd, |
| 2336 | "no timers lsa arrival", |
| 2337 | NO_STR |
| 2338 | "Adjust routing timers\n" |
| 2339 | "Throttling link state advertisement delays\n" |
| 2340 | "OSPF minimum arrival interval delay\n") |
| 2341 | { |
| 2342 | struct ospf *ospf = vty->index; |
| 2343 | ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL; |
| 2344 | |
| 2345 | return CMD_SUCCESS; |
| 2346 | } |
| 2347 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2348 | DEFUN (ospf_timers_throttle_spf, |
| 2349 | ospf_timers_throttle_spf_cmd, |
| 2350 | "timers throttle spf <0-600000> <0-600000> <0-600000>", |
| 2351 | "Adjust routing timers\n" |
| 2352 | "Throttling adaptive timer\n" |
| 2353 | "OSPF SPF timers\n" |
| 2354 | "Delay (msec) from first change received till SPF calculation\n" |
| 2355 | "Initial hold time (msec) between consecutive SPF calculations\n" |
| 2356 | "Maximum hold time (msec)\n") |
| 2357 | { |
| 2358 | unsigned int delay, hold, max; |
| 2359 | |
| 2360 | if (argc != 3) |
| 2361 | { |
| 2362 | vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE); |
| 2363 | return CMD_WARNING; |
| 2364 | } |
| 2365 | |
| 2366 | VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000); |
| 2367 | VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000); |
| 2368 | VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000); |
| 2369 | |
| 2370 | return ospf_timers_spf_set (vty, delay, hold, max); |
| 2371 | } |
| 2372 | |
| 2373 | DEFUN_DEPRECATED (ospf_timers_spf, |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2374 | ospf_timers_spf_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2375 | "timers spf <0-4294967295> <0-4294967295>", |
| 2376 | "Adjust routing timers\n" |
| 2377 | "OSPF SPF timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2378 | "Delay (s) between receiving a change to SPF calculation\n" |
| 2379 | "Hold time (s) between consecutive SPF calculations\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2380 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2381 | unsigned int delay, hold; |
| 2382 | |
| 2383 | if (argc != 2) |
| 2384 | { |
| 2385 | vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE); |
| 2386 | return CMD_WARNING; |
| 2387 | } |
| 2388 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2389 | VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]); |
| 2390 | VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2391 | |
| 2392 | /* truncate down the second values if they're greater than 600000ms */ |
| 2393 | if (delay > (600000 / 1000)) |
| 2394 | delay = 600000; |
| 2395 | else if (delay == 0) |
| 2396 | /* 0s delay was probably specified because of lack of ms resolution */ |
| 2397 | delay = OSPF_SPF_DELAY_DEFAULT; |
| 2398 | if (hold > (600000 / 1000)) |
| 2399 | hold = 600000; |
| 2400 | |
| 2401 | return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2402 | } |
| 2403 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2404 | DEFUN (no_ospf_timers_throttle_spf, |
| 2405 | no_ospf_timers_throttle_spf_cmd, |
| 2406 | "no timers throttle spf", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2407 | NO_STR |
| 2408 | "Adjust routing timers\n" |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2409 | "Throttling adaptive timer\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2410 | "OSPF SPF timers\n") |
| 2411 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2412 | return ospf_timers_spf_set (vty, |
| 2413 | OSPF_SPF_DELAY_DEFAULT, |
| 2414 | OSPF_SPF_HOLDTIME_DEFAULT, |
| 2415 | OSPF_SPF_MAX_HOLDTIME_DEFAULT); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2416 | } |
| 2417 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2418 | ALIAS_DEPRECATED (no_ospf_timers_throttle_spf, |
| 2419 | no_ospf_timers_spf_cmd, |
| 2420 | "no timers spf", |
| 2421 | NO_STR |
| 2422 | "Adjust routing timers\n" |
| 2423 | "OSPF SPF timers\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2424 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2425 | DEFUN (ospf_neighbor, |
| 2426 | ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2427 | "neighbor A.B.C.D", |
| 2428 | NEIGHBOR_STR |
| 2429 | "Neighbor IP address\n") |
| 2430 | { |
| 2431 | struct ospf *ospf = vty->index; |
| 2432 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2433 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2434 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2435 | |
| 2436 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2437 | |
| 2438 | if (argc > 1) |
| 2439 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255); |
| 2440 | |
| 2441 | if (argc > 2) |
| 2442 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535); |
| 2443 | |
| 2444 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2445 | if (argc > 1) |
| 2446 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2447 | if (argc > 2) |
Andrew Certain | 1a61ad1 | 2012-12-04 12:50:23 -0800 | [diff] [blame] | 2448 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2449 | |
| 2450 | return CMD_SUCCESS; |
| 2451 | } |
| 2452 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2453 | ALIAS (ospf_neighbor, |
| 2454 | ospf_neighbor_priority_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2455 | "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2456 | NEIGHBOR_STR |
| 2457 | "Neighbor IP address\n" |
| 2458 | "Neighbor Priority\n" |
| 2459 | "Priority\n" |
| 2460 | "Dead Neighbor Polling interval\n" |
| 2461 | "Seconds\n") |
| 2462 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2463 | ALIAS (ospf_neighbor, |
| 2464 | ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2465 | "neighbor A.B.C.D priority <0-255>", |
| 2466 | NEIGHBOR_STR |
| 2467 | "Neighbor IP address\n" |
| 2468 | "Neighbor Priority\n" |
| 2469 | "Seconds\n") |
| 2470 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2471 | DEFUN (ospf_neighbor_poll_interval, |
| 2472 | ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2473 | "neighbor A.B.C.D poll-interval <1-65535>", |
| 2474 | NEIGHBOR_STR |
| 2475 | "Neighbor IP address\n" |
| 2476 | "Dead Neighbor Polling interval\n" |
| 2477 | "Seconds\n") |
| 2478 | { |
| 2479 | struct ospf *ospf = vty->index; |
| 2480 | struct in_addr nbr_addr; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2481 | unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; |
| 2482 | unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2483 | |
| 2484 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2485 | |
| 2486 | if (argc > 1) |
| 2487 | VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535); |
| 2488 | |
| 2489 | if (argc > 2) |
| 2490 | VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255); |
| 2491 | |
| 2492 | ospf_nbr_nbma_set (ospf, nbr_addr); |
| 2493 | if (argc > 1) |
| 2494 | ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval); |
| 2495 | if (argc > 2) |
| 2496 | ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority); |
| 2497 | |
| 2498 | return CMD_SUCCESS; |
| 2499 | } |
| 2500 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2501 | ALIAS (ospf_neighbor_poll_interval, |
| 2502 | ospf_neighbor_poll_interval_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2503 | "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>", |
| 2504 | NEIGHBOR_STR |
| 2505 | "Neighbor address\n" |
| 2506 | "OSPF dead-router polling interval\n" |
| 2507 | "Seconds\n" |
| 2508 | "OSPF priority of non-broadcast neighbor\n" |
| 2509 | "Priority\n") |
| 2510 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2511 | DEFUN (no_ospf_neighbor, |
| 2512 | no_ospf_neighbor_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2513 | "no neighbor A.B.C.D", |
| 2514 | NO_STR |
| 2515 | NEIGHBOR_STR |
| 2516 | "Neighbor IP address\n") |
| 2517 | { |
| 2518 | struct ospf *ospf = vty->index; |
| 2519 | struct in_addr nbr_addr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2520 | |
| 2521 | VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); |
| 2522 | |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 2523 | (void)ospf_nbr_nbma_unset (ospf, nbr_addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2524 | |
| 2525 | return CMD_SUCCESS; |
| 2526 | } |
| 2527 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2528 | ALIAS (no_ospf_neighbor, |
| 2529 | no_ospf_neighbor_priority_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2530 | "no neighbor A.B.C.D priority <0-255>", |
| 2531 | NO_STR |
| 2532 | NEIGHBOR_STR |
| 2533 | "Neighbor IP address\n" |
| 2534 | "Neighbor Priority\n" |
| 2535 | "Priority\n") |
| 2536 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2537 | ALIAS (no_ospf_neighbor, |
| 2538 | no_ospf_neighbor_poll_interval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2539 | "no neighbor A.B.C.D poll-interval <1-65535>", |
| 2540 | NO_STR |
| 2541 | NEIGHBOR_STR |
| 2542 | "Neighbor IP address\n" |
| 2543 | "Dead Neighbor Polling interval\n" |
| 2544 | "Seconds\n") |
| 2545 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2546 | ALIAS (no_ospf_neighbor, |
| 2547 | no_ospf_neighbor_priority_pollinterval_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2548 | "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>", |
| 2549 | NO_STR |
| 2550 | NEIGHBOR_STR |
| 2551 | "Neighbor IP address\n" |
| 2552 | "Neighbor Priority\n" |
| 2553 | "Priority\n" |
| 2554 | "Dead Neighbor Polling interval\n" |
| 2555 | "Seconds\n") |
| 2556 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2557 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2558 | DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2559 | "refresh timer <10-1800>", |
| 2560 | "Adjust refresh parameters\n" |
| 2561 | "Set refresh timer\n" |
| 2562 | "Timer value in seconds\n") |
| 2563 | { |
| 2564 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2565 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2566 | |
| 2567 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2568 | interval = (interval / 10) * 10; |
| 2569 | |
| 2570 | ospf_timers_refresh_set (ospf, interval); |
| 2571 | |
| 2572 | return CMD_SUCCESS; |
| 2573 | } |
| 2574 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2575 | DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2576 | "no refresh timer <10-1800>", |
| 2577 | "Adjust refresh parameters\n" |
| 2578 | "Unset refresh timer\n" |
| 2579 | "Timer value in seconds\n") |
| 2580 | { |
| 2581 | struct ospf *ospf = vty->index; |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2582 | unsigned int interval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2583 | |
| 2584 | if (argc == 1) |
| 2585 | { |
| 2586 | VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); |
| 2587 | |
| 2588 | if (ospf->lsa_refresh_interval != interval || |
| 2589 | interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
| 2590 | return CMD_SUCCESS; |
| 2591 | } |
| 2592 | |
| 2593 | ospf_timers_refresh_unset (ospf); |
| 2594 | |
| 2595 | return CMD_SUCCESS; |
| 2596 | } |
| 2597 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2598 | ALIAS (no_ospf_refresh_timer, |
| 2599 | no_ospf_refresh_timer_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2600 | "no refresh timer", |
| 2601 | "Adjust refresh parameters\n" |
| 2602 | "Unset refresh timer\n") |
| 2603 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2604 | DEFUN (ospf_auto_cost_reference_bandwidth, |
| 2605 | ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2606 | "auto-cost reference-bandwidth <1-4294967>", |
| 2607 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2608 | "Use reference bandwidth method to assign OSPF cost\n" |
| 2609 | "The reference bandwidth in terms of Mbits per second\n") |
| 2610 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2611 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2612 | u_int32_t refbw; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 2613 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2614 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2615 | |
| 2616 | refbw = strtol (argv[0], NULL, 10); |
| 2617 | if (refbw < 1 || refbw > 4294967) |
| 2618 | { |
| 2619 | vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE); |
| 2620 | return CMD_WARNING; |
| 2621 | } |
| 2622 | |
| 2623 | /* If reference bandwidth is changed. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2624 | if ((refbw * 1000) == ospf->ref_bandwidth) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2625 | return CMD_SUCCESS; |
| 2626 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2627 | ospf->ref_bandwidth = refbw * 1000; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2628 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
| 2629 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2630 | |
| 2631 | return CMD_SUCCESS; |
| 2632 | } |
| 2633 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 2634 | DEFUN (no_ospf_auto_cost_reference_bandwidth, |
| 2635 | no_ospf_auto_cost_reference_bandwidth_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2636 | "no auto-cost reference-bandwidth", |
| 2637 | NO_STR |
| 2638 | "Calculate OSPF interface cost according to bandwidth\n" |
| 2639 | "Use reference bandwidth method to assign OSPF cost\n") |
| 2640 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2641 | struct ospf *ospf = vty->index; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2642 | struct listnode *node, *nnode; |
| 2643 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2644 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2645 | if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2646 | return CMD_SUCCESS; |
| 2647 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2648 | ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2649 | vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE); |
| 2650 | vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE); |
| 2651 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2652 | for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp)) |
| 2653 | ospf_if_recalculate_output_cost (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2654 | |
| 2655 | return CMD_SUCCESS; |
| 2656 | } |
| 2657 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2658 | const char *ospf_abr_type_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2659 | { |
| 2660 | "Unknown", |
| 2661 | "Standard (RFC2328)", |
| 2662 | "Alternative IBM", |
| 2663 | "Alternative Cisco", |
| 2664 | "Alternative Shortcut" |
| 2665 | }; |
| 2666 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 2667 | const char *ospf_shortcut_mode_descr_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2668 | { |
| 2669 | "Default", |
| 2670 | "Enabled", |
| 2671 | "Disabled" |
| 2672 | }; |
| 2673 | |
| 2674 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2675 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 2676 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2677 | show_ip_ospf_area (struct vty *vty, struct ospf_area *area) |
| 2678 | { |
| 2679 | /* Show Area ID. */ |
| 2680 | vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id)); |
| 2681 | |
| 2682 | /* Show Area type/mode. */ |
| 2683 | if (OSPF_IS_AREA_BACKBONE (area)) |
| 2684 | vty_out (vty, " (Backbone)%s", VTY_NEWLINE); |
| 2685 | else |
| 2686 | { |
| 2687 | if (area->external_routing == OSPF_AREA_STUB) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2688 | vty_out (vty, " (Stub%s%s)", |
| 2689 | area->no_summary ? ", no summary" : "", |
| 2690 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2691 | |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2692 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 2693 | vty_out (vty, " (NSSA%s%s)", |
| 2694 | area->no_summary ? ", no summary" : "", |
| 2695 | area->shortcut_configured ? "; " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2696 | |
| 2697 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2698 | vty_out (vty, " Shortcutting mode: %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2699 | ospf_shortcut_mode_descr_str[area->shortcut_configured]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2700 | vty_out (vty, ", S-bit consensus: %s%s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2701 | area->shortcut_capability ? "ok" : "no", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2702 | } |
| 2703 | |
| 2704 | /* Show number of interfaces. */ |
| 2705 | vty_out (vty, " Number of interfaces in this area: Total: %d, " |
| 2706 | "Active: %d%s", listcount (area->oiflist), |
| 2707 | area->act_ints, VTY_NEWLINE); |
| 2708 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2709 | if (area->external_routing == OSPF_AREA_NSSA) |
| 2710 | { |
| 2711 | 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] | 2712 | if (! IS_OSPF_ABR (area->ospf)) |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2713 | vty_out (vty, " It is not ABR, therefore not Translator. %s", |
| 2714 | VTY_NEWLINE); |
| 2715 | else if (area->NSSATranslatorState) |
| 2716 | { |
| 2717 | vty_out (vty, " We are an ABR and "); |
| 2718 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2719 | vty_out (vty, "the NSSA Elected Translator. %s", |
| 2720 | VTY_NEWLINE); |
| 2721 | else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS) |
| 2722 | vty_out (vty, "always an NSSA Translator. %s", |
| 2723 | VTY_NEWLINE); |
| 2724 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2725 | else |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2726 | { |
| 2727 | vty_out (vty, " We are an ABR, but "); |
| 2728 | if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE) |
| 2729 | vty_out (vty, "not the NSSA Elected Translator. %s", |
| 2730 | VTY_NEWLINE); |
| 2731 | else |
hasso | c6b8781 | 2004-12-22 13:09:59 +0000 | [diff] [blame] | 2732 | vty_out (vty, "never an NSSA Translator. %s", |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2733 | VTY_NEWLINE); |
| 2734 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2735 | } |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2736 | /* Stub-router state for this area */ |
| 2737 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
| 2738 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2739 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2740 | vty_out (vty, " Originating stub / maximum-distance Router-LSA%s", |
| 2741 | VTY_NEWLINE); |
| 2742 | if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 2743 | vty_out (vty, " Administratively activated (indefinitely)%s", |
| 2744 | VTY_NEWLINE); |
| 2745 | if (area->t_stub_router) |
| 2746 | vty_out (vty, " Active from startup, %s remaining%s", |
| 2747 | ospf_timer_dump (area->t_stub_router, timebuf, |
| 2748 | sizeof(timebuf)), VTY_NEWLINE); |
| 2749 | } |
| 2750 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2751 | /* Show number of fully adjacent neighbors. */ |
| 2752 | vty_out (vty, " Number of fully adjacent neighbors in this area:" |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 2753 | " %d%s", area->full_nbrs, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2754 | |
| 2755 | /* Show authentication type. */ |
| 2756 | vty_out (vty, " Area has "); |
| 2757 | if (area->auth_type == OSPF_AUTH_NULL) |
| 2758 | vty_out (vty, "no authentication%s", VTY_NEWLINE); |
| 2759 | else if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 2760 | vty_out (vty, "simple password authentication%s", VTY_NEWLINE); |
| 2761 | else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) |
| 2762 | vty_out (vty, "message digest authentication%s", VTY_NEWLINE); |
| 2763 | |
| 2764 | if (!OSPF_IS_AREA_BACKBONE (area)) |
| 2765 | vty_out (vty, " Number of full virtual adjacencies going through" |
| 2766 | " this area: %d%s", area->full_vls, VTY_NEWLINE); |
| 2767 | |
| 2768 | /* Show SPF calculation times. */ |
| 2769 | vty_out (vty, " SPF algorithm executed %d times%s", |
| 2770 | area->spf_calculation, VTY_NEWLINE); |
| 2771 | |
| 2772 | /* Show number of LSA. */ |
| 2773 | vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2774 | vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s", |
| 2775 | ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA), |
| 2776 | ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE); |
| 2777 | vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s", |
| 2778 | ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA), |
| 2779 | ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE); |
| 2780 | vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2781 | ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA), |
| 2782 | ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE); |
| 2783 | vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s", |
| 2784 | ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA), |
| 2785 | ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE); |
| 2786 | vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s", |
| 2787 | ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA), |
| 2788 | ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2789 | vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s", |
| 2790 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA), |
| 2791 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE); |
| 2792 | vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s", |
| 2793 | ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA), |
| 2794 | ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2795 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2796 | } |
| 2797 | |
| 2798 | DEFUN (show_ip_ospf, |
| 2799 | show_ip_ospf_cmd, |
| 2800 | "show ip ospf", |
| 2801 | SHOW_STR |
| 2802 | IP_STR |
| 2803 | "OSPF information\n") |
| 2804 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2805 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2806 | struct ospf_area * area; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2807 | struct ospf *ospf; |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2808 | struct timeval result; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 2809 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2810 | |
| 2811 | /* Check OSPF is enable. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 2812 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2813 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2814 | { |
| 2815 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 2816 | return CMD_SUCCESS; |
| 2817 | } |
| 2818 | |
| 2819 | /* Show Router ID. */ |
| 2820 | vty_out (vty, " OSPF Routing Process, Router ID: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2821 | inet_ntoa (ospf->router_id), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2822 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2823 | |
| 2824 | /* Graceful shutdown */ |
paul | c9c93d5 | 2005-11-26 13:31:11 +0000 | [diff] [blame] | 2825 | if (ospf->t_deferred_shutdown) |
| 2826 | vty_out (vty, " Deferred shutdown in progress, %s remaining%s", |
| 2827 | ospf_timer_dump (ospf->t_deferred_shutdown, |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2828 | timebuf, sizeof (timebuf)), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2829 | /* Show capability. */ |
| 2830 | vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE); |
| 2831 | vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE); |
| 2832 | vty_out (vty, " RFC1583Compatibility flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2833 | CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2834 | "enabled" : "disabled", VTY_NEWLINE); |
Paul Jakma | e30677a | 2015-01-20 15:45:36 +0000 | [diff] [blame] | 2835 | vty_out (vty, " OpaqueCapability flag is %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2836 | CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2837 | "enabled" : "disabled", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2838 | VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 2839 | |
| 2840 | /* Show stub-router configuration */ |
| 2841 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED |
| 2842 | || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2843 | { |
| 2844 | vty_out (vty, " Stub router advertisement is configured%s", |
| 2845 | VTY_NEWLINE); |
| 2846 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2847 | vty_out (vty, " Enabled for %us after start-up%s", |
| 2848 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 2849 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 2850 | vty_out (vty, " Enabled for %us prior to full shutdown%s", |
| 2851 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 2852 | } |
| 2853 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2854 | /* Show SPF timers. */ |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2855 | vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s" |
| 2856 | " Minimum hold time between consecutive SPFs %d millisec(s)%s" |
| 2857 | " Maximum hold time between consecutive SPFs %d millisec(s)%s" |
| 2858 | " Hold time multiplier is currently %d%s", |
| 2859 | ospf->spf_delay, VTY_NEWLINE, |
| 2860 | ospf->spf_holdtime, VTY_NEWLINE, |
| 2861 | ospf->spf_max_holdtime, VTY_NEWLINE, |
| 2862 | ospf->spf_hold_multiplier, VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2863 | vty_out (vty, " SPF algorithm "); |
| 2864 | if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec) |
| 2865 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 2866 | result = tv_sub (recent_relative_time (), ospf->ts_spf); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2867 | vty_out (vty, "last executed %s ago%s", |
| 2868 | ospf_timeval_dump (&result, timebuf, sizeof (timebuf)), |
| 2869 | VTY_NEWLINE); |
Dinesh G Dutt | 50f38b3 | 2014-09-30 12:53:28 -0700 | [diff] [blame] | 2870 | vty_out (vty, " Last SPF duration %s%s", |
| 2871 | ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)), |
| 2872 | VTY_NEWLINE); |
paul | b8ad39d | 2005-10-23 15:23:05 +0000 | [diff] [blame] | 2873 | } |
| 2874 | else |
| 2875 | vty_out (vty, "has not been run%s", VTY_NEWLINE); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 2876 | vty_out (vty, " SPF timer %s%s%s", |
| 2877 | (ospf->t_spf_calc ? "due in " : "is "), |
| 2878 | ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)), |
| 2879 | VTY_NEWLINE); |
| 2880 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2881 | /* Show refresh parameters. */ |
| 2882 | vty_out (vty, " Refresh timer %d secs%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2883 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2884 | |
| 2885 | /* Show ABR/ASBR flags. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2886 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2887 | vty_out (vty, " This router is an ABR, ABR type is: %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2888 | ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2889 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2890 | if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2891 | vty_out (vty, " This router is an ASBR " |
| 2892 | "(injecting external routing information)%s", VTY_NEWLINE); |
| 2893 | |
| 2894 | /* Show Number of AS-external-LSAs. */ |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2895 | vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s", |
| 2896 | ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), |
| 2897 | ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE); |
hasso | fe71a97 | 2004-12-22 16:16:02 +0000 | [diff] [blame] | 2898 | vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s", |
| 2899 | ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA), |
| 2900 | ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2901 | /* Show number of areas attached. */ |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 2902 | vty_out (vty, " Number of areas attached to this router: %d%s", |
| 2903 | listcount (ospf->areas), VTY_NEWLINE); |
| 2904 | |
| 2905 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 2906 | { |
| 2907 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 2908 | vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE); |
| 2909 | else |
| 2910 | vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE); |
| 2911 | } |
| 2912 | |
| 2913 | vty_out (vty, "%s",VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2914 | |
| 2915 | /* Show each area status. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2916 | for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area)) |
| 2917 | show_ip_ospf_area (vty, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2918 | |
| 2919 | return CMD_SUCCESS; |
| 2920 | } |
| 2921 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 2922 | |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2923 | static void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2924 | show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, |
| 2925 | struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2926 | { |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2927 | int is_up; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2928 | struct ospf_neighbor *nbr; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2929 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2930 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2931 | /* Is interface up? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2932 | vty_out (vty, "%s is %s%s", ifp->name, |
| 2933 | ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 2934 | vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s", |
| 2935 | ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags), |
| 2936 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2937 | |
| 2938 | /* Is interface OSPF enabled? */ |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2939 | if (ospf_oi_count(ifp) == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2940 | { |
| 2941 | vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE); |
| 2942 | return; |
| 2943 | } |
ajs | fd651fa | 2005-03-29 16:08:16 +0000 | [diff] [blame] | 2944 | else if (!is_up) |
| 2945 | { |
| 2946 | vty_out (vty, " OSPF is enabled, but not running on this interface%s", |
| 2947 | VTY_NEWLINE); |
| 2948 | return; |
| 2949 | } |
| 2950 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2951 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 2952 | { |
| 2953 | struct ospf_interface *oi = rn->info; |
| 2954 | |
| 2955 | if (oi == NULL) |
| 2956 | continue; |
| 2957 | |
| 2958 | /* Show OSPF interface information. */ |
| 2959 | vty_out (vty, " Internet Address %s/%d,", |
| 2960 | inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen); |
| 2961 | |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2962 | if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2963 | { |
| 2964 | struct in_addr *dest; |
| 2965 | const char *dstr; |
| 2966 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 2967 | if (CONNECTED_PEER(oi->connected) |
| 2968 | || oi->type == OSPF_IFTYPE_VIRTUALLINK) |
Paul Jakma | 9c27ef9 | 2006-05-04 07:32:57 +0000 | [diff] [blame] | 2969 | dstr = "Peer"; |
| 2970 | else |
| 2971 | dstr = "Broadcast"; |
| 2972 | |
| 2973 | /* For Vlinks, showing the peer address is probably more |
| 2974 | * informative than the local interface that is being used |
| 2975 | */ |
| 2976 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 2977 | dest = &oi->vl_data->peer_addr; |
| 2978 | else |
| 2979 | dest = &oi->connected->destination->u.prefix4; |
| 2980 | |
| 2981 | vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest)); |
| 2982 | } |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 2983 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2984 | vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area), |
| 2985 | VTY_NEWLINE); |
| 2986 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 2987 | vty_out (vty, " MTU mismatch detection:%s%s", |
| 2988 | OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE); |
| 2989 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2990 | vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 2991 | inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type], |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2992 | oi->output_cost, VTY_NEWLINE); |
| 2993 | |
| 2994 | vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s", |
| 2995 | OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state), |
| 2996 | PRIORITY (oi), VTY_NEWLINE); |
| 2997 | |
| 2998 | /* Show DR information. */ |
| 2999 | if (DR (oi).s_addr == 0) |
| 3000 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 3001 | else |
| 3002 | { |
| 3003 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi)); |
| 3004 | if (nbr == NULL) |
| 3005 | vty_out (vty, " No designated router on this network%s", VTY_NEWLINE); |
| 3006 | else |
| 3007 | { |
| 3008 | vty_out (vty, " Designated Router (ID) %s,", |
| 3009 | inet_ntoa (nbr->router_id)); |
| 3010 | vty_out (vty, " Interface Address %s%s", |
| 3011 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3012 | } |
| 3013 | } |
| 3014 | |
| 3015 | /* Show BDR information. */ |
| 3016 | if (BDR (oi).s_addr == 0) |
| 3017 | vty_out (vty, " No backup designated router on this network%s", |
| 3018 | VTY_NEWLINE); |
| 3019 | else |
| 3020 | { |
| 3021 | nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi)); |
| 3022 | if (nbr == NULL) |
| 3023 | vty_out (vty, " No backup designated router on this network%s", |
| 3024 | VTY_NEWLINE); |
| 3025 | else |
| 3026 | { |
| 3027 | vty_out (vty, " Backup Designated Router (ID) %s,", |
| 3028 | inet_ntoa (nbr->router_id)); |
| 3029 | vty_out (vty, " Interface Address %s%s", |
| 3030 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3031 | } |
| 3032 | } |
Paul Jakma | 7eb5b47 | 2009-10-13 16:13:13 +0100 | [diff] [blame] | 3033 | |
| 3034 | /* Next network-LSA sequence number we'll use, if we're elected DR */ |
| 3035 | if (oi->params && ntohl (oi->params->network_lsa_seqnum) |
| 3036 | != OSPF_INITIAL_SEQUENCE_NUMBER) |
| 3037 | vty_out (vty, " Saved Network-LSA sequence number 0x%x%s", |
| 3038 | ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE); |
| 3039 | |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 3040 | vty_out (vty, " Multicast group memberships:"); |
Paul Jakma | 429ac78 | 2006-06-15 18:40:49 +0000 | [diff] [blame] | 3041 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS) |
| 3042 | || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 3043 | { |
| 3044 | if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)) |
| 3045 | vty_out (vty, " OSPFAllRouters"); |
| 3046 | if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS)) |
| 3047 | vty_out (vty, " OSPFDesignatedRouters"); |
| 3048 | } |
| 3049 | else |
ajs | ba6454e | 2005-02-08 15:37:30 +0000 | [diff] [blame] | 3050 | vty_out (vty, " <None>"); |
| 3051 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3052 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3053 | vty_out (vty, " Timer intervals configured,"); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3054 | vty_out (vty, " Hello "); |
| 3055 | if (OSPF_IF_PARAM (oi, fast_hello) == 0) |
| 3056 | vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello)); |
| 3057 | else |
| 3058 | vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello)); |
| 3059 | vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s", |
| 3060 | OSPF_IF_PARAM (oi, v_wait), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3061 | OSPF_IF_PARAM (oi, v_wait), |
| 3062 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 3063 | VTY_NEWLINE); |
| 3064 | |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 3065 | if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3066 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3067 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3068 | vty_out (vty, " Hello due in %s%s", |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3069 | ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)), |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 3070 | VTY_NEWLINE); |
| 3071 | } |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 3072 | else /* passive-interface is set */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3073 | vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE); |
| 3074 | |
| 3075 | vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3076 | ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3077 | VTY_NEWLINE); |
| 3078 | } |
| 3079 | } |
| 3080 | |
| 3081 | DEFUN (show_ip_ospf_interface, |
| 3082 | show_ip_ospf_interface_cmd, |
| 3083 | "show ip ospf interface [INTERFACE]", |
| 3084 | SHOW_STR |
| 3085 | IP_STR |
| 3086 | "OSPF information\n" |
| 3087 | "Interface information\n" |
| 3088 | "Interface name\n") |
| 3089 | { |
| 3090 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3091 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3092 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3093 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3094 | ospf = ospf_lookup (); |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 3095 | if (ospf == NULL) |
| 3096 | { |
| 3097 | vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3098 | return CMD_SUCCESS; |
| 3099 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3100 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3101 | /* Show All Interfaces. */ |
| 3102 | if (argc == 0) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3103 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 3104 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3105 | /* Interface name is specified. */ |
| 3106 | else |
| 3107 | { |
| 3108 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 3109 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 3110 | else |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3111 | show_ip_ospf_interface_sub (vty, ospf, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3112 | } |
| 3113 | |
| 3114 | return CMD_SUCCESS; |
| 3115 | } |
| 3116 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3117 | static void |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3118 | show_ip_ospf_neighbour_header (struct vty *vty) |
| 3119 | { |
Daniel Walton | 743219e | 2015-05-19 18:03:57 -0700 | [diff] [blame] | 3120 | vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3121 | VTY_NEWLINE, |
| 3122 | "Neighbor ID", "Pri", "State", "Dead Time", |
| 3123 | "Address", "Interface", "RXmtL", "RqstL", "DBsmL", |
| 3124 | VTY_NEWLINE); |
| 3125 | } |
| 3126 | |
| 3127 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3128 | show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi) |
| 3129 | { |
| 3130 | struct route_node *rn; |
| 3131 | struct ospf_neighbor *nbr; |
| 3132 | char msgbuf[16]; |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3133 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3134 | |
| 3135 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3136 | if ((nbr = rn->info)) |
| 3137 | /* Do not show myself. */ |
| 3138 | if (nbr != oi->nbr_self) |
| 3139 | /* Down state is not shown. */ |
| 3140 | if (nbr->state != NSM_Down) |
| 3141 | { |
| 3142 | ospf_nbr_state_message (nbr, msgbuf, 16); |
| 3143 | |
| 3144 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3145 | vty_out (vty, "%-15s %3d %-15s ", |
| 3146 | "-", nbr->priority, |
| 3147 | msgbuf); |
| 3148 | else |
| 3149 | vty_out (vty, "%-15s %3d %-15s ", |
| 3150 | inet_ntoa (nbr->router_id), nbr->priority, |
| 3151 | msgbuf); |
| 3152 | |
| 3153 | vty_out (vty, "%9s ", |
| 3154 | ospf_timer_dump (nbr->t_inactivity, timebuf, |
| 3155 | sizeof(timebuf))); |
| 3156 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3157 | vty_out (vty, "%-15s ", inet_ntoa (nbr->src)); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3158 | vty_out (vty, "%-20s %5ld %5ld %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3159 | IF_NAME (oi), ospf_ls_retransmit_count (nbr), |
| 3160 | ospf_ls_request_count (nbr), ospf_db_summary_count (nbr), |
| 3161 | VTY_NEWLINE); |
| 3162 | } |
| 3163 | } |
| 3164 | |
| 3165 | DEFUN (show_ip_ospf_neighbor, |
| 3166 | show_ip_ospf_neighbor_cmd, |
| 3167 | "show ip ospf neighbor", |
| 3168 | SHOW_STR |
| 3169 | IP_STR |
| 3170 | "OSPF information\n" |
| 3171 | "Neighbor list\n") |
| 3172 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3173 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3174 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3175 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3176 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3177 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3178 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3179 | { |
| 3180 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3181 | return CMD_SUCCESS; |
| 3182 | } |
| 3183 | |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3184 | show_ip_ospf_neighbour_header (vty); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3185 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3186 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3187 | show_ip_ospf_neighbor_sub (vty, oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3188 | |
| 3189 | return CMD_SUCCESS; |
| 3190 | } |
| 3191 | |
| 3192 | DEFUN (show_ip_ospf_neighbor_all, |
| 3193 | show_ip_ospf_neighbor_all_cmd, |
| 3194 | "show ip ospf neighbor all", |
| 3195 | SHOW_STR |
| 3196 | IP_STR |
| 3197 | "OSPF information\n" |
| 3198 | "Neighbor list\n" |
| 3199 | "include down status neighbor\n") |
| 3200 | { |
Joakim Tjernlund | 35f8914 | 2008-07-01 16:54:07 +0200 | [diff] [blame] | 3201 | struct ospf *ospf = ospf_lookup (); |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3202 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3203 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3204 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3205 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3206 | { |
| 3207 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3208 | return CMD_SUCCESS; |
| 3209 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3210 | |
| 3211 | show_ip_ospf_neighbour_header (vty); |
| 3212 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3213 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3214 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3215 | struct listnode *nbr_node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3216 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3217 | |
| 3218 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3219 | |
| 3220 | /* print Down neighbor status */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3221 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3222 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3223 | if (nbr_nbma->nbr == NULL |
| 3224 | || nbr_nbma->nbr->state == NSM_Down) |
| 3225 | { |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3226 | vty_out (vty, "%-15s %3d %-15s %9s ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3227 | "-", nbr_nbma->priority, "Down", "-"); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3228 | vty_out (vty, "%-15s %-20s %5d %5d %5d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3229 | inet_ntoa (nbr_nbma->addr), IF_NAME (oi), |
| 3230 | 0, 0, 0, VTY_NEWLINE); |
| 3231 | } |
| 3232 | } |
| 3233 | } |
| 3234 | |
| 3235 | return CMD_SUCCESS; |
| 3236 | } |
| 3237 | |
| 3238 | DEFUN (show_ip_ospf_neighbor_int, |
| 3239 | show_ip_ospf_neighbor_int_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3240 | "show ip ospf neighbor IFNAME", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3241 | SHOW_STR |
| 3242 | IP_STR |
| 3243 | "OSPF information\n" |
| 3244 | "Neighbor list\n" |
| 3245 | "Interface name\n") |
| 3246 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3247 | struct ospf *ospf; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3248 | struct interface *ifp; |
| 3249 | struct route_node *rn; |
| 3250 | |
| 3251 | ifp = if_lookup_by_name (argv[0]); |
| 3252 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3253 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3254 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3255 | return CMD_WARNING; |
| 3256 | } |
| 3257 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3258 | ospf = ospf_lookup (); |
| 3259 | if (ospf == NULL) |
| 3260 | { |
| 3261 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3262 | return CMD_SUCCESS; |
| 3263 | } |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3264 | |
| 3265 | show_ip_ospf_neighbour_header (vty); |
| 3266 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3267 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3268 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3269 | struct ospf_interface *oi = rn->info; |
| 3270 | |
| 3271 | if (oi == NULL) |
| 3272 | continue; |
| 3273 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3274 | show_ip_ospf_neighbor_sub (vty, oi); |
| 3275 | } |
| 3276 | |
| 3277 | return CMD_SUCCESS; |
| 3278 | } |
| 3279 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3280 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3281 | show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3282 | struct ospf_nbr_nbma *nbr_nbma) |
| 3283 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3284 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3285 | |
| 3286 | /* Show neighbor ID. */ |
| 3287 | vty_out (vty, " Neighbor %s,", "-"); |
| 3288 | |
| 3289 | /* Show interface address. */ |
| 3290 | vty_out (vty, " interface address %s%s", |
| 3291 | inet_ntoa (nbr_nbma->addr), VTY_NEWLINE); |
| 3292 | /* Show Area ID. */ |
| 3293 | vty_out (vty, " In the area %s via interface %s%s", |
| 3294 | ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE); |
| 3295 | /* Show neighbor priority and state. */ |
| 3296 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3297 | nbr_nbma->priority, "Down"); |
| 3298 | /* Show state changes. */ |
| 3299 | vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE); |
| 3300 | |
| 3301 | /* Show PollInterval */ |
| 3302 | vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE); |
| 3303 | |
| 3304 | /* Show poll-interval timer. */ |
| 3305 | vty_out (vty, " Poll timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3306 | ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)), |
| 3307 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3308 | |
| 3309 | /* Show poll-interval timer thread. */ |
| 3310 | vty_out (vty, " Thread Poll Timer %s%s", |
| 3311 | nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE); |
| 3312 | } |
| 3313 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3314 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3315 | show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi, |
| 3316 | struct ospf_neighbor *nbr) |
| 3317 | { |
ajs | 649654a | 2005-11-16 20:17:52 +0000 | [diff] [blame] | 3318 | char timebuf[OSPF_TIME_DUMP_SIZE]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3319 | |
| 3320 | /* Show neighbor ID. */ |
| 3321 | if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0) |
| 3322 | vty_out (vty, " Neighbor %s,", "-"); |
| 3323 | else |
| 3324 | vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id)); |
| 3325 | |
| 3326 | /* Show interface address. */ |
| 3327 | vty_out (vty, " interface address %s%s", |
| 3328 | inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE); |
| 3329 | /* Show Area ID. */ |
| 3330 | vty_out (vty, " In the area %s via interface %s%s", |
| 3331 | ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE); |
| 3332 | /* Show neighbor priority and state. */ |
| 3333 | vty_out (vty, " Neighbor priority is %d, State is %s,", |
| 3334 | nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state)); |
| 3335 | /* Show state changes. */ |
| 3336 | vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3337 | 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] | 3338 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3339 | struct timeval res |
| 3340 | = tv_sub (recent_relative_time (), nbr->ts_last_progress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3341 | vty_out (vty, " Most recent state change statistics:%s", |
| 3342 | VTY_NEWLINE); |
| 3343 | vty_out (vty, " Progressive change %s ago%s", |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3344 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3345 | VTY_NEWLINE); |
| 3346 | } |
| 3347 | if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec) |
| 3348 | { |
Paul Jakma | 2518efd | 2006-08-27 06:49:29 +0000 | [diff] [blame] | 3349 | struct timeval res |
| 3350 | = tv_sub (recent_relative_time (), nbr->ts_last_regress); |
Paul Jakma | 3fed416 | 2006-07-25 20:44:12 +0000 | [diff] [blame] | 3351 | vty_out (vty, " Regressive change %s ago, due to %s%s", |
| 3352 | ospf_timeval_dump (&res, timebuf, sizeof(timebuf)), |
| 3353 | (nbr->last_regress_str ? nbr->last_regress_str : "??"), |
Paul Jakma | 90c3317 | 2006-07-11 17:57:25 +0000 | [diff] [blame] | 3354 | VTY_NEWLINE); |
| 3355 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3356 | /* Show Designated Rotuer ID. */ |
| 3357 | vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router)); |
| 3358 | /* Show Backup Designated Rotuer ID. */ |
| 3359 | vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE); |
| 3360 | /* Show options. */ |
| 3361 | vty_out (vty, " Options %d %s%s", nbr->options, |
| 3362 | ospf_options_dump (nbr->options), VTY_NEWLINE); |
| 3363 | /* Show Router Dead interval timer. */ |
| 3364 | vty_out (vty, " Dead timer due in %s%s", |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 3365 | ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)), |
| 3366 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3367 | /* Show Database Summary list. */ |
| 3368 | vty_out (vty, " Database Summary List %d%s", |
| 3369 | ospf_db_summary_count (nbr), VTY_NEWLINE); |
| 3370 | /* Show Link State Request list. */ |
| 3371 | vty_out (vty, " Link State Request List %ld%s", |
| 3372 | ospf_ls_request_count (nbr), VTY_NEWLINE); |
| 3373 | /* Show Link State Retransmission list. */ |
| 3374 | vty_out (vty, " Link State Retransmission List %ld%s", |
| 3375 | ospf_ls_retransmit_count (nbr), VTY_NEWLINE); |
| 3376 | /* Show inactivity timer thread. */ |
| 3377 | vty_out (vty, " Thread Inactivity Timer %s%s", |
| 3378 | nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE); |
| 3379 | /* Show Database Description retransmission thread. */ |
| 3380 | vty_out (vty, " Thread Database Description Retransmision %s%s", |
| 3381 | nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE); |
| 3382 | /* Show Link State Request Retransmission thread. */ |
| 3383 | vty_out (vty, " Thread Link State Request Retransmission %s%s", |
| 3384 | nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE); |
| 3385 | /* Show Link State Update Retransmission thread. */ |
| 3386 | vty_out (vty, " Thread Link State Update Retransmission %s%s%s", |
| 3387 | nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE); |
| 3388 | } |
| 3389 | |
| 3390 | DEFUN (show_ip_ospf_neighbor_id, |
| 3391 | show_ip_ospf_neighbor_id_cmd, |
| 3392 | "show ip ospf neighbor A.B.C.D", |
| 3393 | SHOW_STR |
| 3394 | IP_STR |
| 3395 | "OSPF information\n" |
| 3396 | "Neighbor list\n" |
| 3397 | "Neighbor ID\n") |
| 3398 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3399 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3400 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3401 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3402 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3403 | struct in_addr router_id; |
| 3404 | int ret; |
| 3405 | |
| 3406 | ret = inet_aton (argv[0], &router_id); |
| 3407 | if (!ret) |
| 3408 | { |
| 3409 | vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE); |
| 3410 | return CMD_WARNING; |
| 3411 | } |
| 3412 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3413 | ospf = ospf_lookup (); |
| 3414 | if (ospf == NULL) |
| 3415 | { |
| 3416 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3417 | return CMD_SUCCESS; |
| 3418 | } |
| 3419 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3420 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
| 3421 | if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id))) |
Andrew J. Schorr | 1c066bf | 2006-06-30 16:53:47 +0000 | [diff] [blame] | 3422 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3423 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3424 | return CMD_SUCCESS; |
| 3425 | } |
| 3426 | |
| 3427 | DEFUN (show_ip_ospf_neighbor_detail, |
| 3428 | show_ip_ospf_neighbor_detail_cmd, |
| 3429 | "show ip ospf neighbor detail", |
| 3430 | SHOW_STR |
| 3431 | IP_STR |
| 3432 | "OSPF information\n" |
| 3433 | "Neighbor list\n" |
| 3434 | "detail of all neighbors\n") |
| 3435 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3436 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3437 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3438 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3439 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3440 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3441 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3442 | { |
| 3443 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3444 | return CMD_SUCCESS; |
| 3445 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3446 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3447 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3448 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3449 | struct route_node *rn; |
| 3450 | struct ospf_neighbor *nbr; |
| 3451 | |
| 3452 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3453 | if ((nbr = rn->info)) |
| 3454 | if (nbr != oi->nbr_self) |
| 3455 | if (nbr->state != NSM_Down) |
| 3456 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
| 3457 | } |
| 3458 | |
| 3459 | return CMD_SUCCESS; |
| 3460 | } |
| 3461 | |
| 3462 | DEFUN (show_ip_ospf_neighbor_detail_all, |
| 3463 | show_ip_ospf_neighbor_detail_all_cmd, |
| 3464 | "show ip ospf neighbor detail all", |
| 3465 | SHOW_STR |
| 3466 | IP_STR |
| 3467 | "OSPF information\n" |
| 3468 | "Neighbor list\n" |
| 3469 | "detail of all neighbors\n" |
| 3470 | "include down status neighbor\n") |
| 3471 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3472 | struct ospf *ospf; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3473 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3474 | struct ospf_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3475 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3476 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3477 | if (ospf == NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3478 | { |
| 3479 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3480 | return CMD_SUCCESS; |
| 3481 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3482 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3483 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3484 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3485 | struct route_node *rn; |
| 3486 | struct ospf_neighbor *nbr; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3487 | struct ospf_nbr_nbma *nbr_nbma; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3488 | |
| 3489 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 3490 | if ((nbr = rn->info)) |
| 3491 | if (nbr != oi->nbr_self) |
| 3492 | if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down) |
| 3493 | show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info); |
| 3494 | |
| 3495 | if (oi->type == OSPF_IFTYPE_NBMA) |
| 3496 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3497 | struct listnode *nd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3498 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3499 | for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma)) |
| 3500 | if (nbr_nbma->nbr == NULL |
| 3501 | || nbr_nbma->nbr->state == NSM_Down) |
| 3502 | show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | return CMD_SUCCESS; |
| 3507 | } |
| 3508 | |
| 3509 | DEFUN (show_ip_ospf_neighbor_int_detail, |
| 3510 | show_ip_ospf_neighbor_int_detail_cmd, |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3511 | "show ip ospf neighbor IFNAME detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3512 | SHOW_STR |
| 3513 | IP_STR |
| 3514 | "OSPF information\n" |
| 3515 | "Neighbor list\n" |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3516 | "Interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3517 | "detail of all neighbors") |
| 3518 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3519 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3520 | struct ospf_interface *oi; |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3521 | struct interface *ifp; |
| 3522 | struct route_node *rn, *nrn; |
| 3523 | struct ospf_neighbor *nbr; |
| 3524 | |
| 3525 | ifp = if_lookup_by_name (argv[0]); |
| 3526 | if (!ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3527 | { |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3528 | vty_out (vty, "No such interface.%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3529 | return CMD_WARNING; |
| 3530 | } |
| 3531 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3532 | ospf = ospf_lookup (); |
| 3533 | if (ospf == NULL) |
| 3534 | { |
| 3535 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 3536 | return CMD_SUCCESS; |
| 3537 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3538 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3539 | |
hasso | bb5b755 | 2005-08-21 20:01:15 +0000 | [diff] [blame] | 3540 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 3541 | if ((oi = rn->info)) |
| 3542 | for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn)) |
| 3543 | if ((nbr = nrn->info)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3544 | if (nbr != oi->nbr_self) |
| 3545 | if (nbr->state != NSM_Down) |
| 3546 | show_ip_ospf_neighbor_detail_sub (vty, oi, nbr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3547 | |
| 3548 | return CMD_SUCCESS; |
| 3549 | } |
| 3550 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 3551 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3552 | /* Show functions */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3553 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3554 | show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3555 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3556 | struct router_lsa *rl; |
| 3557 | struct summary_lsa *sl; |
| 3558 | struct as_external_lsa *asel; |
| 3559 | struct prefix_ipv4 p; |
| 3560 | |
| 3561 | if (lsa != NULL) |
| 3562 | /* If self option is set, check LSA self flag. */ |
| 3563 | if (self == 0 || IS_LSA_SELF (lsa)) |
| 3564 | { |
| 3565 | /* LSA common part show. */ |
| 3566 | vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id)); |
| 3567 | vty_out (vty, "%-15s %4d 0x%08lx 0x%04x", |
| 3568 | inet_ntoa (lsa->data->adv_router), LS_AGE (lsa), |
| 3569 | (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum)); |
| 3570 | /* LSA specific part show. */ |
| 3571 | switch (lsa->data->type) |
| 3572 | { |
| 3573 | case OSPF_ROUTER_LSA: |
| 3574 | rl = (struct router_lsa *) lsa->data; |
| 3575 | vty_out (vty, " %-d", ntohs (rl->links)); |
| 3576 | break; |
| 3577 | case OSPF_SUMMARY_LSA: |
| 3578 | sl = (struct summary_lsa *) lsa->data; |
| 3579 | |
| 3580 | p.family = AF_INET; |
| 3581 | p.prefix = sl->header.id; |
| 3582 | p.prefixlen = ip_masklen (sl->mask); |
| 3583 | apply_mask_ipv4 (&p); |
| 3584 | |
| 3585 | vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen); |
| 3586 | break; |
| 3587 | case OSPF_AS_EXTERNAL_LSA: |
paul | 551a897 | 2003-05-18 15:22:55 +0000 | [diff] [blame] | 3588 | case OSPF_AS_NSSA_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3589 | asel = (struct as_external_lsa *) lsa->data; |
| 3590 | |
| 3591 | p.family = AF_INET; |
| 3592 | p.prefix = asel->header.id; |
| 3593 | p.prefixlen = ip_masklen (asel->mask); |
| 3594 | apply_mask_ipv4 (&p); |
| 3595 | |
| 3596 | vty_out (vty, " %s %s/%d [0x%lx]", |
| 3597 | IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1", |
| 3598 | inet_ntoa (p.prefix), p.prefixlen, |
| 3599 | (u_long)ntohl (asel->e[0].route_tag)); |
| 3600 | break; |
| 3601 | case OSPF_NETWORK_LSA: |
| 3602 | case OSPF_ASBR_SUMMARY_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3603 | case OSPF_OPAQUE_LINK_LSA: |
| 3604 | case OSPF_OPAQUE_AREA_LSA: |
| 3605 | case OSPF_OPAQUE_AS_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3606 | default: |
| 3607 | break; |
| 3608 | } |
| 3609 | vty_out (vty, VTY_NEWLINE); |
| 3610 | } |
| 3611 | |
| 3612 | return 0; |
| 3613 | } |
| 3614 | |
Stephen Hemminger | 8b6a15b | 2009-12-03 19:25:04 +0300 | [diff] [blame] | 3615 | static const char *show_database_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3616 | { |
| 3617 | "unknown", |
| 3618 | "Router Link States", |
| 3619 | "Net Link States", |
| 3620 | "Summary Link States", |
| 3621 | "ASBR-Summary Link States", |
| 3622 | "AS External Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3623 | "Group Membership LSA", |
| 3624 | "NSSA-external Link States", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3625 | "Type-8 LSA", |
| 3626 | "Link-Local Opaque-LSA", |
| 3627 | "Area-Local Opaque-LSA", |
| 3628 | "AS-external Opaque-LSA", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3629 | }; |
| 3630 | |
Stephen Hemminger | 8b6a15b | 2009-12-03 19:25:04 +0300 | [diff] [blame] | 3631 | static const char *show_database_header[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3632 | { |
| 3633 | "", |
| 3634 | "Link ID ADV Router Age Seq# CkSum Link count", |
| 3635 | "Link ID ADV Router Age Seq# CkSum", |
| 3636 | "Link ID ADV Router Age Seq# CkSum Route", |
| 3637 | "Link ID ADV Router Age Seq# CkSum", |
| 3638 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3639 | " --- header for Group Member ----", |
| 3640 | "Link ID ADV Router Age Seq# CkSum Route", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3641 | " --- type-8 ---", |
| 3642 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3643 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
| 3644 | "Opaque-Type/Id ADV Router Age Seq# CkSum", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3645 | }; |
| 3646 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3647 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3648 | show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa) |
| 3649 | { |
| 3650 | struct router_lsa *rlsa = (struct router_lsa*) lsa->data; |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3651 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3652 | vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE); |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3653 | vty_out (vty, " Options: 0x%-2x : %s%s", |
| 3654 | lsa->data->options, |
| 3655 | ospf_options_dump(lsa->data->options), |
| 3656 | VTY_NEWLINE); |
| 3657 | vty_out (vty, " LS Flags: 0x%-2x %s%s", |
paul | 9d52603 | 2003-06-30 22:46:14 +0000 | [diff] [blame] | 3658 | lsa->flags, |
paul | 4957f49 | 2003-06-27 01:28:45 +0000 | [diff] [blame] | 3659 | ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""), |
| 3660 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3661 | |
| 3662 | if (lsa->data->type == OSPF_ROUTER_LSA) |
| 3663 | { |
| 3664 | vty_out (vty, " Flags: 0x%x" , rlsa->flags); |
| 3665 | |
| 3666 | if (rlsa->flags) |
| 3667 | vty_out (vty, " :%s%s%s%s", |
| 3668 | IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "", |
| 3669 | IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "", |
| 3670 | IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "", |
| 3671 | IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : ""); |
| 3672 | |
| 3673 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3674 | } |
| 3675 | vty_out (vty, " LS Type: %s%s", |
| 3676 | LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3677 | vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id), |
| 3678 | LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE); |
| 3679 | vty_out (vty, " Advertising Router: %s%s", |
| 3680 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 3681 | vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum), |
| 3682 | VTY_NEWLINE); |
| 3683 | vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum), |
| 3684 | VTY_NEWLINE); |
| 3685 | vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); |
| 3686 | } |
| 3687 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3688 | const char *link_type_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3689 | { |
| 3690 | "(null)", |
| 3691 | "another Router (point-to-point)", |
| 3692 | "a Transit Network", |
| 3693 | "Stub Network", |
| 3694 | "a Virtual Link", |
| 3695 | }; |
| 3696 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3697 | const char *link_id_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3698 | { |
| 3699 | "(null)", |
| 3700 | "Neighboring Router ID", |
| 3701 | "Designated Router address", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 3702 | "Net", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3703 | "Neighboring Router ID", |
| 3704 | }; |
| 3705 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 3706 | const char *link_data_desc[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3707 | { |
| 3708 | "(null)", |
| 3709 | "Router Interface address", |
| 3710 | "Router Interface address", |
| 3711 | "Network Mask", |
| 3712 | "Router Interface address", |
| 3713 | }; |
| 3714 | |
| 3715 | /* Show router-LSA each Link information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3716 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3717 | show_ip_ospf_database_router_links (struct vty *vty, |
| 3718 | struct router_lsa *rl) |
| 3719 | { |
Donald Sharp | 0bc874b | 2015-07-29 19:16:13 -0400 | [diff] [blame] | 3720 | int len, type; |
| 3721 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3722 | |
| 3723 | len = ntohs (rl->header.length) - 4; |
| 3724 | for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++) |
| 3725 | { |
| 3726 | type = rl->link[i].type; |
| 3727 | |
| 3728 | vty_out (vty, " Link connected to: %s%s", |
| 3729 | link_type_desc[type], VTY_NEWLINE); |
| 3730 | vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type], |
| 3731 | inet_ntoa (rl->link[i].link_id), VTY_NEWLINE); |
| 3732 | vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type], |
| 3733 | inet_ntoa (rl->link[i].link_data), VTY_NEWLINE); |
| 3734 | vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE); |
| 3735 | vty_out (vty, " TOS 0 Metric: %d%s", |
| 3736 | ntohs (rl->link[i].metric), VTY_NEWLINE); |
| 3737 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3738 | } |
| 3739 | } |
| 3740 | |
| 3741 | /* Show router-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3742 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3743 | show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3744 | { |
| 3745 | if (lsa != NULL) |
| 3746 | { |
| 3747 | struct router_lsa *rl = (struct router_lsa *) lsa->data; |
| 3748 | |
| 3749 | show_ip_ospf_database_header (vty, lsa); |
| 3750 | |
| 3751 | vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links), |
| 3752 | VTY_NEWLINE, VTY_NEWLINE); |
| 3753 | |
| 3754 | show_ip_ospf_database_router_links (vty, rl); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3755 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3756 | } |
| 3757 | |
| 3758 | return 0; |
| 3759 | } |
| 3760 | |
| 3761 | /* Show network-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3762 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3763 | show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3764 | { |
| 3765 | int length, i; |
| 3766 | |
| 3767 | if (lsa != NULL) |
| 3768 | { |
| 3769 | struct network_lsa *nl = (struct network_lsa *) lsa->data; |
| 3770 | |
| 3771 | show_ip_ospf_database_header (vty, lsa); |
| 3772 | |
| 3773 | vty_out (vty, " Network Mask: /%d%s", |
| 3774 | ip_masklen (nl->mask), VTY_NEWLINE); |
| 3775 | |
| 3776 | length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4; |
| 3777 | |
| 3778 | for (i = 0; length > 0; i++, length -= 4) |
| 3779 | vty_out (vty, " Attached Router: %s%s", |
| 3780 | inet_ntoa (nl->routers[i]), VTY_NEWLINE); |
| 3781 | |
| 3782 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3783 | } |
| 3784 | |
| 3785 | return 0; |
| 3786 | } |
| 3787 | |
| 3788 | /* Show summary-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3789 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3790 | show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3791 | { |
| 3792 | if (lsa != NULL) |
| 3793 | { |
| 3794 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3795 | |
| 3796 | show_ip_ospf_database_header (vty, lsa); |
| 3797 | |
| 3798 | vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask), |
| 3799 | VTY_NEWLINE); |
| 3800 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3801 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3802 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | return 0; |
| 3806 | } |
| 3807 | |
| 3808 | /* Show summary-ASBR-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3809 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3810 | show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3811 | { |
| 3812 | if (lsa != NULL) |
| 3813 | { |
| 3814 | struct summary_lsa *sl = (struct summary_lsa *) lsa->data; |
| 3815 | |
| 3816 | show_ip_ospf_database_header (vty, lsa); |
| 3817 | |
| 3818 | vty_out (vty, " Network Mask: /%d%s", |
| 3819 | ip_masklen (sl->mask), VTY_NEWLINE); |
| 3820 | vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric), |
| 3821 | VTY_NEWLINE); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 3822 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3823 | } |
| 3824 | |
| 3825 | return 0; |
| 3826 | } |
| 3827 | |
| 3828 | /* Show AS-external-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3829 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3830 | show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3831 | { |
| 3832 | if (lsa != NULL) |
| 3833 | { |
| 3834 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3835 | |
| 3836 | show_ip_ospf_database_header (vty, lsa); |
| 3837 | |
| 3838 | vty_out (vty, " Network Mask: /%d%s", |
| 3839 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3840 | vty_out (vty, " Metric Type: %s%s", |
| 3841 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3842 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3843 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3844 | vty_out (vty, " Metric: %d%s", |
| 3845 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3846 | vty_out (vty, " Forward Address: %s%s", |
| 3847 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3848 | |
| 3849 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3850 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
| 3851 | } |
| 3852 | |
| 3853 | return 0; |
| 3854 | } |
| 3855 | |
Stephen Hemminger | 075e12f | 2011-12-06 23:54:17 +0400 | [diff] [blame] | 3856 | #if 0 |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3857 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3858 | show_as_external_lsa_stdvty (struct ospf_lsa *lsa) |
| 3859 | { |
| 3860 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3861 | |
| 3862 | /* show_ip_ospf_database_header (vty, lsa); */ |
| 3863 | |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3864 | zlog_debug( " Network Mask: /%d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3865 | ip_masklen (al->mask), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3866 | zlog_debug( " Metric Type: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3867 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3868 | "2 (Larger than any link state path)" : "1", "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3869 | zlog_debug( " TOS: 0%s", "\n"); |
| 3870 | zlog_debug( " Metric: %d%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3871 | GET_METRIC (al->e[0].metric), "\n"); |
ajs | 2a42e28 | 2004-12-08 18:43:03 +0000 | [diff] [blame] | 3872 | zlog_debug( " Forward Address: %s%s", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3873 | inet_ntoa (al->e[0].fwd_addr), "\n"); |
| 3874 | |
Christian Franke | ddc160c | 2016-10-01 20:42:34 +0200 | [diff] [blame] | 3875 | zlog_debug( " External Route Tag: %lu%s%s", |
| 3876 | (u_long)ntohl (al->e[0].route_tag), "\n", "\n"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3877 | |
| 3878 | return 0; |
| 3879 | } |
Stephen Hemminger | 075e12f | 2011-12-06 23:54:17 +0400 | [diff] [blame] | 3880 | #endif |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3881 | |
| 3882 | /* Show AS-NSSA-LSA detail information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3883 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3884 | show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3885 | { |
| 3886 | if (lsa != NULL) |
| 3887 | { |
| 3888 | struct as_external_lsa *al = (struct as_external_lsa *) lsa->data; |
| 3889 | |
| 3890 | show_ip_ospf_database_header (vty, lsa); |
| 3891 | |
| 3892 | vty_out (vty, " Network Mask: /%d%s", |
| 3893 | ip_masklen (al->mask), VTY_NEWLINE); |
| 3894 | vty_out (vty, " Metric Type: %s%s", |
| 3895 | IS_EXTERNAL_METRIC (al->e[0].tos) ? |
| 3896 | "2 (Larger than any link state path)" : "1", VTY_NEWLINE); |
| 3897 | vty_out (vty, " TOS: 0%s", VTY_NEWLINE); |
| 3898 | vty_out (vty, " Metric: %d%s", |
| 3899 | GET_METRIC (al->e[0].metric), VTY_NEWLINE); |
| 3900 | vty_out (vty, " NSSA: Forward Address: %s%s", |
| 3901 | inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE); |
| 3902 | |
Christian Franke | ddc160c | 2016-10-01 20:42:34 +0200 | [diff] [blame] | 3903 | vty_out (vty, " External Route Tag: %lu%s%s", |
| 3904 | (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3905 | } |
| 3906 | |
| 3907 | return 0; |
| 3908 | } |
| 3909 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3910 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3911 | show_func_dummy (struct vty *vty, struct ospf_lsa *lsa) |
| 3912 | { |
| 3913 | return 0; |
| 3914 | } |
| 3915 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3916 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3917 | show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa) |
| 3918 | { |
| 3919 | if (lsa != NULL) |
| 3920 | { |
| 3921 | show_ip_ospf_database_header (vty, lsa); |
| 3922 | show_opaque_info_detail (vty, lsa); |
| 3923 | |
| 3924 | vty_out (vty, "%s", VTY_NEWLINE); |
| 3925 | } |
| 3926 | return 0; |
| 3927 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3928 | |
| 3929 | int (*show_function[])(struct vty *, struct ospf_lsa *) = |
| 3930 | { |
| 3931 | NULL, |
| 3932 | show_router_lsa_detail, |
| 3933 | show_network_lsa_detail, |
| 3934 | show_summary_lsa_detail, |
| 3935 | show_summary_asbr_lsa_detail, |
| 3936 | show_as_external_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3937 | show_func_dummy, |
| 3938 | show_as_nssa_lsa_detail, /* almost same as external */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3939 | NULL, /* type-8 */ |
| 3940 | show_opaque_lsa_detail, |
| 3941 | show_opaque_lsa_detail, |
| 3942 | show_opaque_lsa_detail, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3943 | }; |
| 3944 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3945 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3946 | show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id, |
| 3947 | struct in_addr *adv_router) |
| 3948 | { |
| 3949 | memset (lp, 0, sizeof (struct prefix_ls)); |
| 3950 | lp->family = 0; |
| 3951 | if (id == NULL) |
| 3952 | lp->prefixlen = 0; |
| 3953 | else if (adv_router == NULL) |
| 3954 | { |
| 3955 | lp->prefixlen = 32; |
| 3956 | lp->id = *id; |
| 3957 | } |
| 3958 | else |
| 3959 | { |
| 3960 | lp->prefixlen = 64; |
| 3961 | lp->id = *id; |
| 3962 | lp->adv_router = *adv_router; |
| 3963 | } |
| 3964 | } |
| 3965 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3966 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3967 | show_lsa_detail_proc (struct vty *vty, struct route_table *rt, |
| 3968 | struct in_addr *id, struct in_addr *adv_router) |
| 3969 | { |
| 3970 | struct prefix_ls lp; |
| 3971 | struct route_node *rn, *start; |
| 3972 | struct ospf_lsa *lsa; |
| 3973 | |
| 3974 | show_lsa_prefix_set (vty, &lp, id, adv_router); |
| 3975 | start = route_node_get (rt, (struct prefix *) &lp); |
| 3976 | if (start) |
| 3977 | { |
| 3978 | route_lock_node (start); |
| 3979 | for (rn = start; rn; rn = route_next_until (rn, start)) |
| 3980 | if ((lsa = rn->info)) |
| 3981 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3982 | if (show_function[lsa->data->type] != NULL) |
| 3983 | show_function[lsa->data->type] (vty, lsa); |
| 3984 | } |
| 3985 | route_unlock_node (start); |
| 3986 | } |
| 3987 | } |
| 3988 | |
| 3989 | /* Show detail LSA information |
| 3990 | -- if id is NULL then show all LSAs. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 3991 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 3992 | show_lsa_detail (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3993 | struct in_addr *id, struct in_addr *adv_router) |
| 3994 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 3995 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 3996 | struct ospf_area *area; |
| 3997 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3998 | switch (type) |
| 3999 | { |
| 4000 | case OSPF_AS_EXTERNAL_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4001 | case OSPF_OPAQUE_AS_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4002 | vty_out (vty, " %s %s%s", |
| 4003 | show_database_desc[type], |
| 4004 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4005 | show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4006 | break; |
| 4007 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4008 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4009 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4010 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 4011 | VTY_NEWLINE, show_database_desc[type], |
| 4012 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 4013 | show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router); |
| 4014 | } |
| 4015 | break; |
| 4016 | } |
| 4017 | } |
| 4018 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4019 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4020 | show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt, |
| 4021 | struct in_addr *adv_router) |
| 4022 | { |
| 4023 | struct route_node *rn; |
| 4024 | struct ospf_lsa *lsa; |
| 4025 | |
| 4026 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 4027 | if ((lsa = rn->info)) |
| 4028 | if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router)) |
| 4029 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4030 | if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)) |
| 4031 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4032 | if (show_function[lsa->data->type] != NULL) |
| 4033 | show_function[lsa->data->type] (vty, lsa); |
| 4034 | } |
| 4035 | } |
| 4036 | |
| 4037 | /* Show detail LSA information. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4038 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4039 | show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4040 | struct in_addr *adv_router) |
| 4041 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 4042 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4043 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4044 | |
| 4045 | switch (type) |
| 4046 | { |
| 4047 | case OSPF_AS_EXTERNAL_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4048 | case OSPF_OPAQUE_AS_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4049 | vty_out (vty, " %s %s%s", |
| 4050 | show_database_desc[type], |
| 4051 | VTY_NEWLINE, VTY_NEWLINE); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4052 | show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4053 | adv_router); |
| 4054 | break; |
| 4055 | default: |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4056 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4057 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4058 | vty_out (vty, "%s %s (Area %s)%s%s", |
| 4059 | VTY_NEWLINE, show_database_desc[type], |
| 4060 | ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE); |
| 4061 | show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type), |
| 4062 | adv_router); |
| 4063 | } |
| 4064 | break; |
| 4065 | } |
| 4066 | } |
| 4067 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4068 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4069 | show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4070 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4071 | struct ospf_lsa *lsa; |
| 4072 | struct route_node *rn; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4073 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 4074 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4075 | int type; |
| 4076 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4077 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4078 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4079 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4080 | { |
| 4081 | switch (type) |
| 4082 | { |
| 4083 | case OSPF_AS_EXTERNAL_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4084 | case OSPF_OPAQUE_AS_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4085 | continue; |
| 4086 | default: |
| 4087 | break; |
| 4088 | } |
| 4089 | if (ospf_lsdb_count_self (area->lsdb, type) > 0 || |
| 4090 | (!self && ospf_lsdb_count (area->lsdb, type) > 0)) |
| 4091 | { |
| 4092 | vty_out (vty, " %s (Area %s)%s%s", |
| 4093 | show_database_desc[type], |
| 4094 | ospf_area_desc_string (area), |
| 4095 | VTY_NEWLINE, VTY_NEWLINE); |
| 4096 | vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE); |
| 4097 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4098 | LSDB_LOOP (AREA_LSDB (area, type), rn, lsa) |
| 4099 | show_lsa_summary (vty, lsa, self); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4100 | |
| 4101 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4102 | } |
| 4103 | } |
| 4104 | } |
| 4105 | |
| 4106 | for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++) |
| 4107 | { |
| 4108 | switch (type) |
| 4109 | { |
| 4110 | case OSPF_AS_EXTERNAL_LSA: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4111 | case OSPF_OPAQUE_AS_LSA: |
paul | e8e1946 | 2006-01-19 20:16:55 +0000 | [diff] [blame] | 4112 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4113 | default: |
| 4114 | continue; |
| 4115 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4116 | if (ospf_lsdb_count_self (ospf->lsdb, type) || |
| 4117 | (!self && ospf_lsdb_count (ospf->lsdb, type))) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4118 | { |
| 4119 | vty_out (vty, " %s%s%s", |
| 4120 | show_database_desc[type], |
| 4121 | VTY_NEWLINE, VTY_NEWLINE); |
| 4122 | vty_out (vty, "%s%s", show_database_header[type], |
| 4123 | VTY_NEWLINE); |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4124 | |
| 4125 | LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa) |
| 4126 | show_lsa_summary (vty, lsa, self); |
| 4127 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4128 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4129 | } |
| 4130 | } |
| 4131 | |
| 4132 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4133 | } |
| 4134 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 4135 | static void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4136 | show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4137 | { |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4138 | struct route_node *rn; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4139 | |
| 4140 | vty_out (vty, "%s MaxAge Link States:%s%s", |
| 4141 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 4142 | |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4143 | for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4144 | { |
Dinesh Dutt | 91e6a0e | 2012-12-04 10:46:37 -0800 | [diff] [blame] | 4145 | struct ospf_lsa *lsa; |
| 4146 | |
| 4147 | if ((lsa = rn->info) != NULL) |
| 4148 | { |
| 4149 | vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE); |
| 4150 | vty_out (vty, "Link State ID: %s%s", |
| 4151 | inet_ntoa (lsa->data->id), VTY_NEWLINE); |
| 4152 | vty_out (vty, "Advertising Router: %s%s", |
| 4153 | inet_ntoa (lsa->data->adv_router), VTY_NEWLINE); |
| 4154 | vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE); |
| 4155 | vty_out (vty, "%s", VTY_NEWLINE); |
| 4156 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 4157 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4158 | } |
| 4159 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4160 | #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n" |
| 4161 | #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4162 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4163 | #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n" |
| 4164 | #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n" |
| 4165 | #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n" |
| 4166 | #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4167 | |
| 4168 | #define OSPF_LSA_TYPES_CMD_STR \ |
| 4169 | "asbr-summary|external|network|router|summary" \ |
| 4170 | OSPF_LSA_TYPE_NSSA_CMD_STR \ |
| 4171 | OSPF_LSA_TYPE_OPAQUE_CMD_STR |
| 4172 | |
| 4173 | #define OSPF_LSA_TYPES_DESC \ |
| 4174 | "ASBR summary link states\n" \ |
| 4175 | "External link states\n" \ |
| 4176 | "Network link states\n" \ |
| 4177 | "Router link states\n" \ |
| 4178 | "Network summary link states\n" \ |
| 4179 | OSPF_LSA_TYPE_NSSA_DESC \ |
| 4180 | OSPF_LSA_TYPE_OPAQUE_LINK_DESC \ |
| 4181 | OSPF_LSA_TYPE_OPAQUE_AREA_DESC \ |
| 4182 | OSPF_LSA_TYPE_OPAQUE_AS_DESC |
| 4183 | |
| 4184 | DEFUN (show_ip_ospf_database, |
| 4185 | show_ip_ospf_database_cmd, |
| 4186 | "show ip ospf database", |
| 4187 | SHOW_STR |
| 4188 | IP_STR |
| 4189 | "OSPF information\n" |
| 4190 | "Database summary\n") |
| 4191 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4192 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4193 | int type, ret; |
| 4194 | struct in_addr id, adv_router; |
| 4195 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4196 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4197 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4198 | { |
| 4199 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4200 | return CMD_SUCCESS; |
| 4201 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4202 | |
| 4203 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4204 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4205 | |
| 4206 | /* Show all LSA. */ |
| 4207 | if (argc == 0) |
| 4208 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4209 | show_ip_ospf_database_summary (vty, ospf, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4210 | return CMD_SUCCESS; |
| 4211 | } |
| 4212 | |
| 4213 | /* Set database type to show. */ |
| 4214 | if (strncmp (argv[0], "r", 1) == 0) |
| 4215 | type = OSPF_ROUTER_LSA; |
| 4216 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4217 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4218 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4219 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4220 | else if (strncmp (argv[0], "su", 2) == 0) |
| 4221 | type = OSPF_SUMMARY_LSA; |
| 4222 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4223 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4224 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4225 | type = OSPF_AS_EXTERNAL_LSA; |
| 4226 | else if (strncmp (argv[0], "se", 2) == 0) |
| 4227 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4228 | show_ip_ospf_database_summary (vty, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4229 | return CMD_SUCCESS; |
| 4230 | } |
| 4231 | else if (strncmp (argv[0], "m", 1) == 0) |
| 4232 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4233 | show_ip_ospf_database_maxage (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4234 | return CMD_SUCCESS; |
| 4235 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4236 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4237 | type = OSPF_OPAQUE_LINK_LSA; |
| 4238 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4239 | type = OSPF_OPAQUE_AREA_LSA; |
| 4240 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4241 | type = OSPF_OPAQUE_AS_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4242 | else |
| 4243 | return CMD_WARNING; |
| 4244 | |
| 4245 | /* `show ip ospf database LSA'. */ |
| 4246 | if (argc == 1) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4247 | show_lsa_detail (vty, ospf, type, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4248 | else if (argc >= 2) |
| 4249 | { |
| 4250 | ret = inet_aton (argv[1], &id); |
| 4251 | if (!ret) |
| 4252 | return CMD_WARNING; |
| 4253 | |
| 4254 | /* `show ip ospf database LSA ID'. */ |
| 4255 | if (argc == 2) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4256 | show_lsa_detail (vty, ospf, type, &id, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4257 | /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */ |
| 4258 | else if (argc == 3) |
| 4259 | { |
| 4260 | if (strncmp (argv[2], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4261 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4262 | else |
| 4263 | { |
| 4264 | ret = inet_aton (argv[2], &adv_router); |
| 4265 | if (!ret) |
| 4266 | return CMD_WARNING; |
| 4267 | } |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4268 | show_lsa_detail (vty, ospf, type, &id, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4269 | } |
| 4270 | } |
| 4271 | |
| 4272 | return CMD_SUCCESS; |
| 4273 | } |
| 4274 | |
| 4275 | ALIAS (show_ip_ospf_database, |
| 4276 | show_ip_ospf_database_type_cmd, |
| 4277 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)", |
| 4278 | SHOW_STR |
| 4279 | IP_STR |
| 4280 | "OSPF information\n" |
| 4281 | "Database summary\n" |
| 4282 | OSPF_LSA_TYPES_DESC |
| 4283 | "LSAs in MaxAge list\n" |
| 4284 | "Self-originated link states\n") |
| 4285 | |
| 4286 | ALIAS (show_ip_ospf_database, |
| 4287 | show_ip_ospf_database_type_id_cmd, |
| 4288 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D", |
| 4289 | SHOW_STR |
| 4290 | IP_STR |
| 4291 | "OSPF information\n" |
| 4292 | "Database summary\n" |
| 4293 | OSPF_LSA_TYPES_DESC |
| 4294 | "Link State ID (as an IP address)\n") |
| 4295 | |
| 4296 | ALIAS (show_ip_ospf_database, |
| 4297 | show_ip_ospf_database_type_id_adv_router_cmd, |
| 4298 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D", |
| 4299 | SHOW_STR |
| 4300 | IP_STR |
| 4301 | "OSPF information\n" |
| 4302 | "Database summary\n" |
| 4303 | OSPF_LSA_TYPES_DESC |
| 4304 | "Link State ID (as an IP address)\n" |
| 4305 | "Advertising Router link states\n" |
| 4306 | "Advertising Router (as an IP address)\n") |
| 4307 | |
| 4308 | ALIAS (show_ip_ospf_database, |
| 4309 | show_ip_ospf_database_type_id_self_cmd, |
| 4310 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)", |
| 4311 | SHOW_STR |
| 4312 | IP_STR |
| 4313 | "OSPF information\n" |
| 4314 | "Database summary\n" |
| 4315 | OSPF_LSA_TYPES_DESC |
| 4316 | "Link State ID (as an IP address)\n" |
| 4317 | "Self-originated link states\n" |
| 4318 | "\n") |
| 4319 | |
| 4320 | DEFUN (show_ip_ospf_database_type_adv_router, |
| 4321 | show_ip_ospf_database_type_adv_router_cmd, |
| 4322 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D", |
| 4323 | SHOW_STR |
| 4324 | IP_STR |
| 4325 | "OSPF information\n" |
| 4326 | "Database summary\n" |
| 4327 | OSPF_LSA_TYPES_DESC |
| 4328 | "Advertising Router link states\n" |
| 4329 | "Advertising Router (as an IP address)\n") |
| 4330 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4331 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4332 | int type, ret; |
| 4333 | struct in_addr adv_router; |
| 4334 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4335 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4336 | if (ospf == NULL) |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 4337 | { |
| 4338 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
| 4339 | return CMD_SUCCESS; |
| 4340 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4341 | |
| 4342 | vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE, |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4343 | inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4344 | |
| 4345 | if (argc != 2) |
| 4346 | return CMD_WARNING; |
| 4347 | |
| 4348 | /* Set database type to show. */ |
| 4349 | if (strncmp (argv[0], "r", 1) == 0) |
| 4350 | type = OSPF_ROUTER_LSA; |
| 4351 | else if (strncmp (argv[0], "ne", 2) == 0) |
| 4352 | type = OSPF_NETWORK_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4353 | else if (strncmp (argv[0], "ns", 2) == 0) |
| 4354 | type = OSPF_AS_NSSA_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4355 | else if (strncmp (argv[0], "s", 1) == 0) |
| 4356 | type = OSPF_SUMMARY_LSA; |
| 4357 | else if (strncmp (argv[0], "a", 1) == 0) |
| 4358 | type = OSPF_ASBR_SUMMARY_LSA; |
| 4359 | else if (strncmp (argv[0], "e", 1) == 0) |
| 4360 | type = OSPF_AS_EXTERNAL_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4361 | else if (strncmp (argv[0], "opaque-l", 8) == 0) |
| 4362 | type = OSPF_OPAQUE_LINK_LSA; |
| 4363 | else if (strncmp (argv[0], "opaque-ar", 9) == 0) |
| 4364 | type = OSPF_OPAQUE_AREA_LSA; |
| 4365 | else if (strncmp (argv[0], "opaque-as", 9) == 0) |
| 4366 | type = OSPF_OPAQUE_AS_LSA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4367 | else |
| 4368 | return CMD_WARNING; |
| 4369 | |
| 4370 | /* `show ip ospf database LSA adv-router ADV_ROUTER'. */ |
| 4371 | if (strncmp (argv[1], "s", 1) == 0) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 4372 | adv_router = ospf->router_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4373 | else |
| 4374 | { |
| 4375 | ret = inet_aton (argv[1], &adv_router); |
| 4376 | if (!ret) |
| 4377 | return CMD_WARNING; |
| 4378 | } |
| 4379 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 4380 | show_lsa_detail_adv_router (vty, ospf, type, &adv_router); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4381 | |
| 4382 | return CMD_SUCCESS; |
| 4383 | } |
| 4384 | |
| 4385 | ALIAS (show_ip_ospf_database_type_adv_router, |
| 4386 | show_ip_ospf_database_type_self_cmd, |
| 4387 | "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)", |
| 4388 | SHOW_STR |
| 4389 | IP_STR |
| 4390 | "OSPF information\n" |
| 4391 | "Database summary\n" |
| 4392 | OSPF_LSA_TYPES_DESC |
| 4393 | "Self-originated link states\n") |
| 4394 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 4395 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4396 | DEFUN (ip_ospf_authentication_args, |
| 4397 | ip_ospf_authentication_args_addr_cmd, |
| 4398 | "ip ospf authentication (null|message-digest) A.B.C.D", |
| 4399 | "IP Information\n" |
| 4400 | "OSPF interface commands\n" |
| 4401 | "Enable authentication on this interface\n" |
| 4402 | "Use null authentication\n" |
| 4403 | "Use message-digest authentication\n" |
| 4404 | "Address of interface") |
| 4405 | { |
| 4406 | struct interface *ifp; |
| 4407 | struct in_addr addr; |
| 4408 | int ret; |
| 4409 | struct ospf_if_params *params; |
| 4410 | |
| 4411 | ifp = vty->index; |
| 4412 | params = IF_DEF_PARAMS (ifp); |
| 4413 | |
| 4414 | if (argc == 2) |
| 4415 | { |
| 4416 | ret = inet_aton(argv[1], &addr); |
| 4417 | if (!ret) |
| 4418 | { |
| 4419 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4420 | VTY_NEWLINE); |
| 4421 | return CMD_WARNING; |
| 4422 | } |
| 4423 | |
| 4424 | params = ospf_get_if_params (ifp, addr); |
| 4425 | ospf_if_update_params (ifp, addr); |
| 4426 | } |
| 4427 | |
| 4428 | /* Handle null authentication */ |
| 4429 | if ( argv[0][0] == 'n' ) |
| 4430 | { |
| 4431 | SET_IF_PARAM (params, auth_type); |
| 4432 | params->auth_type = OSPF_AUTH_NULL; |
| 4433 | return CMD_SUCCESS; |
| 4434 | } |
| 4435 | |
| 4436 | /* Handle message-digest authentication */ |
| 4437 | if ( argv[0][0] == 'm' ) |
| 4438 | { |
| 4439 | SET_IF_PARAM (params, auth_type); |
| 4440 | params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC; |
| 4441 | return CMD_SUCCESS; |
| 4442 | } |
| 4443 | |
| 4444 | vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE); |
| 4445 | return CMD_WARNING; |
| 4446 | } |
| 4447 | |
| 4448 | ALIAS (ip_ospf_authentication_args, |
| 4449 | ip_ospf_authentication_args_cmd, |
| 4450 | "ip ospf authentication (null|message-digest)", |
| 4451 | "IP Information\n" |
| 4452 | "OSPF interface commands\n" |
| 4453 | "Enable authentication on this interface\n" |
| 4454 | "Use null authentication\n" |
| 4455 | "Use message-digest authentication\n") |
| 4456 | |
| 4457 | DEFUN (ip_ospf_authentication, |
| 4458 | ip_ospf_authentication_addr_cmd, |
| 4459 | "ip ospf authentication A.B.C.D", |
| 4460 | "IP Information\n" |
| 4461 | "OSPF interface commands\n" |
| 4462 | "Enable authentication on this interface\n" |
| 4463 | "Address of interface") |
| 4464 | { |
| 4465 | struct interface *ifp; |
| 4466 | struct in_addr addr; |
| 4467 | int ret; |
| 4468 | struct ospf_if_params *params; |
| 4469 | |
| 4470 | ifp = vty->index; |
| 4471 | params = IF_DEF_PARAMS (ifp); |
| 4472 | |
| 4473 | if (argc == 1) |
| 4474 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4475 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4476 | if (!ret) |
| 4477 | { |
| 4478 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4479 | VTY_NEWLINE); |
| 4480 | return CMD_WARNING; |
| 4481 | } |
| 4482 | |
| 4483 | params = ospf_get_if_params (ifp, addr); |
| 4484 | ospf_if_update_params (ifp, addr); |
| 4485 | } |
| 4486 | |
| 4487 | SET_IF_PARAM (params, auth_type); |
| 4488 | params->auth_type = OSPF_AUTH_SIMPLE; |
| 4489 | |
| 4490 | return CMD_SUCCESS; |
| 4491 | } |
| 4492 | |
| 4493 | ALIAS (ip_ospf_authentication, |
| 4494 | ip_ospf_authentication_cmd, |
| 4495 | "ip ospf authentication", |
| 4496 | "IP Information\n" |
| 4497 | "OSPF interface commands\n" |
| 4498 | "Enable authentication on this interface\n") |
| 4499 | |
| 4500 | DEFUN (no_ip_ospf_authentication, |
| 4501 | no_ip_ospf_authentication_addr_cmd, |
| 4502 | "no ip ospf authentication A.B.C.D", |
| 4503 | NO_STR |
| 4504 | "IP Information\n" |
| 4505 | "OSPF interface commands\n" |
| 4506 | "Enable authentication on this interface\n" |
| 4507 | "Address of interface") |
| 4508 | { |
| 4509 | struct interface *ifp; |
| 4510 | struct in_addr addr; |
| 4511 | int ret; |
| 4512 | struct ospf_if_params *params; |
| 4513 | |
| 4514 | ifp = vty->index; |
| 4515 | params = IF_DEF_PARAMS (ifp); |
| 4516 | |
| 4517 | if (argc == 1) |
| 4518 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4519 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4520 | if (!ret) |
| 4521 | { |
| 4522 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4523 | VTY_NEWLINE); |
| 4524 | return CMD_WARNING; |
| 4525 | } |
| 4526 | |
| 4527 | params = ospf_lookup_if_params (ifp, addr); |
| 4528 | if (params == NULL) |
| 4529 | return CMD_SUCCESS; |
| 4530 | } |
| 4531 | |
| 4532 | params->auth_type = OSPF_AUTH_NOTSET; |
| 4533 | UNSET_IF_PARAM (params, auth_type); |
| 4534 | |
| 4535 | if (params != IF_DEF_PARAMS (ifp)) |
| 4536 | { |
| 4537 | ospf_free_if_params (ifp, addr); |
| 4538 | ospf_if_update_params (ifp, addr); |
| 4539 | } |
| 4540 | |
| 4541 | return CMD_SUCCESS; |
| 4542 | } |
| 4543 | |
| 4544 | ALIAS (no_ip_ospf_authentication, |
| 4545 | no_ip_ospf_authentication_cmd, |
| 4546 | "no ip ospf authentication", |
| 4547 | NO_STR |
| 4548 | "IP Information\n" |
| 4549 | "OSPF interface commands\n" |
| 4550 | "Enable authentication on this interface\n") |
| 4551 | |
| 4552 | DEFUN (ip_ospf_authentication_key, |
| 4553 | ip_ospf_authentication_key_addr_cmd, |
| 4554 | "ip ospf authentication-key AUTH_KEY A.B.C.D", |
| 4555 | "IP Information\n" |
| 4556 | "OSPF interface commands\n" |
| 4557 | "Authentication password (key)\n" |
| 4558 | "The OSPF password (key)\n" |
| 4559 | "Address of interface") |
| 4560 | { |
| 4561 | struct interface *ifp; |
| 4562 | struct in_addr addr; |
| 4563 | int ret; |
| 4564 | struct ospf_if_params *params; |
| 4565 | |
| 4566 | ifp = vty->index; |
| 4567 | params = IF_DEF_PARAMS (ifp); |
| 4568 | |
| 4569 | if (argc == 2) |
| 4570 | { |
| 4571 | ret = inet_aton(argv[1], &addr); |
| 4572 | if (!ret) |
| 4573 | { |
| 4574 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4575 | VTY_NEWLINE); |
| 4576 | return CMD_WARNING; |
| 4577 | } |
| 4578 | |
| 4579 | params = ospf_get_if_params (ifp, addr); |
| 4580 | ospf_if_update_params (ifp, addr); |
| 4581 | } |
| 4582 | |
| 4583 | |
| 4584 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4585 | strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4586 | SET_IF_PARAM (params, auth_simple); |
| 4587 | |
| 4588 | return CMD_SUCCESS; |
| 4589 | } |
| 4590 | |
| 4591 | ALIAS (ip_ospf_authentication_key, |
| 4592 | ip_ospf_authentication_key_cmd, |
| 4593 | "ip ospf authentication-key AUTH_KEY", |
| 4594 | "IP Information\n" |
| 4595 | "OSPF interface commands\n" |
| 4596 | "Authentication password (key)\n" |
| 4597 | "The OSPF password (key)") |
| 4598 | |
| 4599 | ALIAS (ip_ospf_authentication_key, |
| 4600 | ospf_authentication_key_cmd, |
| 4601 | "ospf authentication-key AUTH_KEY", |
| 4602 | "OSPF interface commands\n" |
| 4603 | "Authentication password (key)\n" |
| 4604 | "The OSPF password (key)") |
| 4605 | |
| 4606 | DEFUN (no_ip_ospf_authentication_key, |
| 4607 | no_ip_ospf_authentication_key_addr_cmd, |
| 4608 | "no ip ospf authentication-key A.B.C.D", |
| 4609 | NO_STR |
| 4610 | "IP Information\n" |
| 4611 | "OSPF interface commands\n" |
| 4612 | "Authentication password (key)\n" |
| 4613 | "Address of interface") |
| 4614 | { |
| 4615 | struct interface *ifp; |
| 4616 | struct in_addr addr; |
| 4617 | int ret; |
| 4618 | struct ospf_if_params *params; |
| 4619 | |
| 4620 | ifp = vty->index; |
| 4621 | params = IF_DEF_PARAMS (ifp); |
| 4622 | |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4623 | if (argc == 1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4624 | { |
Paul Jakma | 5dcf71d | 2007-05-10 03:00:09 +0000 | [diff] [blame] | 4625 | ret = inet_aton(argv[0], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4626 | if (!ret) |
| 4627 | { |
| 4628 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4629 | VTY_NEWLINE); |
| 4630 | return CMD_WARNING; |
| 4631 | } |
| 4632 | |
| 4633 | params = ospf_lookup_if_params (ifp, addr); |
| 4634 | if (params == NULL) |
| 4635 | return CMD_SUCCESS; |
| 4636 | } |
| 4637 | |
| 4638 | memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE); |
| 4639 | UNSET_IF_PARAM (params, auth_simple); |
| 4640 | |
| 4641 | if (params != IF_DEF_PARAMS (ifp)) |
| 4642 | { |
| 4643 | ospf_free_if_params (ifp, addr); |
| 4644 | ospf_if_update_params (ifp, addr); |
| 4645 | } |
| 4646 | |
| 4647 | return CMD_SUCCESS; |
| 4648 | } |
| 4649 | |
| 4650 | ALIAS (no_ip_ospf_authentication_key, |
| 4651 | no_ip_ospf_authentication_key_cmd, |
| 4652 | "no ip ospf authentication-key", |
| 4653 | NO_STR |
| 4654 | "IP Information\n" |
| 4655 | "OSPF interface commands\n" |
| 4656 | "Authentication password (key)\n") |
| 4657 | |
| 4658 | ALIAS (no_ip_ospf_authentication_key, |
| 4659 | no_ospf_authentication_key_cmd, |
| 4660 | "no ospf authentication-key", |
| 4661 | NO_STR |
| 4662 | "OSPF interface commands\n" |
| 4663 | "Authentication password (key)\n") |
| 4664 | |
| 4665 | DEFUN (ip_ospf_message_digest_key, |
| 4666 | ip_ospf_message_digest_key_addr_cmd, |
| 4667 | "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D", |
| 4668 | "IP Information\n" |
| 4669 | "OSPF interface commands\n" |
| 4670 | "Message digest authentication password (key)\n" |
| 4671 | "Key ID\n" |
| 4672 | "Use MD5 algorithm\n" |
| 4673 | "The OSPF password (key)" |
| 4674 | "Address of interface") |
| 4675 | { |
| 4676 | struct interface *ifp; |
| 4677 | struct crypt_key *ck; |
| 4678 | u_char key_id; |
| 4679 | struct in_addr addr; |
| 4680 | int ret; |
| 4681 | struct ospf_if_params *params; |
| 4682 | |
| 4683 | ifp = vty->index; |
| 4684 | params = IF_DEF_PARAMS (ifp); |
| 4685 | |
| 4686 | if (argc == 3) |
| 4687 | { |
| 4688 | ret = inet_aton(argv[2], &addr); |
| 4689 | if (!ret) |
| 4690 | { |
| 4691 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4692 | VTY_NEWLINE); |
| 4693 | return CMD_WARNING; |
| 4694 | } |
| 4695 | |
| 4696 | params = ospf_get_if_params (ifp, addr); |
| 4697 | ospf_if_update_params (ifp, addr); |
| 4698 | } |
| 4699 | |
| 4700 | key_id = strtol (argv[0], NULL, 10); |
| 4701 | if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL) |
| 4702 | { |
| 4703 | vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE); |
| 4704 | return CMD_WARNING; |
| 4705 | } |
| 4706 | |
| 4707 | ck = ospf_crypt_key_new (); |
| 4708 | ck->key_id = (u_char) key_id; |
| 4709 | memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 4710 | strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4711 | |
| 4712 | ospf_crypt_key_add (params->auth_crypt, ck); |
| 4713 | SET_IF_PARAM (params, auth_crypt); |
| 4714 | |
| 4715 | return CMD_SUCCESS; |
| 4716 | } |
| 4717 | |
| 4718 | ALIAS (ip_ospf_message_digest_key, |
| 4719 | ip_ospf_message_digest_key_cmd, |
| 4720 | "ip ospf message-digest-key <1-255> md5 KEY", |
| 4721 | "IP Information\n" |
| 4722 | "OSPF interface commands\n" |
| 4723 | "Message digest authentication password (key)\n" |
| 4724 | "Key ID\n" |
| 4725 | "Use MD5 algorithm\n" |
| 4726 | "The OSPF password (key)") |
| 4727 | |
| 4728 | ALIAS (ip_ospf_message_digest_key, |
| 4729 | ospf_message_digest_key_cmd, |
| 4730 | "ospf message-digest-key <1-255> md5 KEY", |
| 4731 | "OSPF interface commands\n" |
| 4732 | "Message digest authentication password (key)\n" |
| 4733 | "Key ID\n" |
| 4734 | "Use MD5 algorithm\n" |
| 4735 | "The OSPF password (key)") |
| 4736 | |
| 4737 | DEFUN (no_ip_ospf_message_digest_key, |
| 4738 | no_ip_ospf_message_digest_key_addr_cmd, |
| 4739 | "no ip ospf message-digest-key <1-255> A.B.C.D", |
| 4740 | NO_STR |
| 4741 | "IP Information\n" |
| 4742 | "OSPF interface commands\n" |
| 4743 | "Message digest authentication password (key)\n" |
| 4744 | "Key ID\n" |
| 4745 | "Address of interface") |
| 4746 | { |
| 4747 | struct interface *ifp; |
| 4748 | struct crypt_key *ck; |
| 4749 | int key_id; |
| 4750 | struct in_addr addr; |
| 4751 | int ret; |
| 4752 | struct ospf_if_params *params; |
| 4753 | |
| 4754 | ifp = vty->index; |
| 4755 | params = IF_DEF_PARAMS (ifp); |
| 4756 | |
| 4757 | if (argc == 2) |
| 4758 | { |
| 4759 | ret = inet_aton(argv[1], &addr); |
| 4760 | if (!ret) |
| 4761 | { |
| 4762 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4763 | VTY_NEWLINE); |
| 4764 | return CMD_WARNING; |
| 4765 | } |
| 4766 | |
| 4767 | params = ospf_lookup_if_params (ifp, addr); |
| 4768 | if (params == NULL) |
| 4769 | return CMD_SUCCESS; |
| 4770 | } |
| 4771 | |
| 4772 | key_id = strtol (argv[0], NULL, 10); |
| 4773 | ck = ospf_crypt_key_lookup (params->auth_crypt, key_id); |
| 4774 | if (ck == NULL) |
| 4775 | { |
| 4776 | vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE); |
| 4777 | return CMD_WARNING; |
| 4778 | } |
| 4779 | |
| 4780 | ospf_crypt_key_delete (params->auth_crypt, key_id); |
| 4781 | |
| 4782 | if (params != IF_DEF_PARAMS (ifp)) |
| 4783 | { |
| 4784 | ospf_free_if_params (ifp, addr); |
| 4785 | ospf_if_update_params (ifp, addr); |
| 4786 | } |
| 4787 | |
| 4788 | return CMD_SUCCESS; |
| 4789 | } |
| 4790 | |
| 4791 | ALIAS (no_ip_ospf_message_digest_key, |
| 4792 | no_ip_ospf_message_digest_key_cmd, |
| 4793 | "no ip ospf message-digest-key <1-255>", |
| 4794 | NO_STR |
| 4795 | "IP Information\n" |
| 4796 | "OSPF interface commands\n" |
| 4797 | "Message digest authentication password (key)\n" |
| 4798 | "Key ID\n") |
| 4799 | |
| 4800 | ALIAS (no_ip_ospf_message_digest_key, |
| 4801 | no_ospf_message_digest_key_cmd, |
| 4802 | "no ospf message-digest-key <1-255>", |
| 4803 | NO_STR |
| 4804 | "OSPF interface commands\n" |
| 4805 | "Message digest authentication password (key)\n" |
| 4806 | "Key ID\n") |
| 4807 | |
| 4808 | DEFUN (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4809 | ip_ospf_cost_u32_inet4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4810 | "ip ospf cost <1-65535> A.B.C.D", |
| 4811 | "IP Information\n" |
| 4812 | "OSPF interface commands\n" |
| 4813 | "Interface cost\n" |
| 4814 | "Cost\n" |
| 4815 | "Address of interface") |
| 4816 | { |
| 4817 | struct interface *ifp = vty->index; |
| 4818 | u_int32_t cost; |
| 4819 | struct in_addr addr; |
| 4820 | int ret; |
| 4821 | struct ospf_if_params *params; |
| 4822 | |
| 4823 | params = IF_DEF_PARAMS (ifp); |
| 4824 | |
| 4825 | cost = strtol (argv[0], NULL, 10); |
| 4826 | |
| 4827 | /* cost range is <1-65535>. */ |
| 4828 | if (cost < 1 || cost > 65535) |
| 4829 | { |
| 4830 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4831 | return CMD_WARNING; |
| 4832 | } |
| 4833 | |
| 4834 | if (argc == 2) |
| 4835 | { |
| 4836 | ret = inet_aton(argv[1], &addr); |
| 4837 | if (!ret) |
| 4838 | { |
| 4839 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4840 | VTY_NEWLINE); |
| 4841 | return CMD_WARNING; |
| 4842 | } |
| 4843 | |
| 4844 | params = ospf_get_if_params (ifp, addr); |
| 4845 | ospf_if_update_params (ifp, addr); |
| 4846 | } |
| 4847 | |
| 4848 | SET_IF_PARAM (params, output_cost_cmd); |
| 4849 | params->output_cost_cmd = cost; |
| 4850 | |
| 4851 | ospf_if_recalculate_output_cost (ifp); |
| 4852 | |
| 4853 | return CMD_SUCCESS; |
| 4854 | } |
| 4855 | |
| 4856 | ALIAS (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4857 | ip_ospf_cost_u32_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4858 | "ip ospf cost <1-65535>", |
| 4859 | "IP Information\n" |
| 4860 | "OSPF interface commands\n" |
| 4861 | "Interface cost\n" |
| 4862 | "Cost") |
| 4863 | |
| 4864 | ALIAS (ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4865 | ospf_cost_u32_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4866 | "ospf cost <1-65535>", |
| 4867 | "OSPF interface commands\n" |
| 4868 | "Interface cost\n" |
| 4869 | "Cost") |
| 4870 | |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4871 | ALIAS (ip_ospf_cost, |
| 4872 | ospf_cost_u32_inet4_cmd, |
| 4873 | "ospf cost <1-65535> A.B.C.D", |
| 4874 | "OSPF interface commands\n" |
| 4875 | "Interface cost\n" |
| 4876 | "Cost\n" |
| 4877 | "Address of interface") |
| 4878 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4879 | DEFUN (no_ip_ospf_cost, |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4880 | no_ip_ospf_cost_inet4_cmd, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 4881 | "no ip ospf cost A.B.C.D", |
| 4882 | NO_STR |
| 4883 | "IP Information\n" |
| 4884 | "OSPF interface commands\n" |
| 4885 | "Interface cost\n" |
| 4886 | "Address of interface") |
| 4887 | { |
| 4888 | struct interface *ifp = vty->index; |
| 4889 | struct in_addr addr; |
| 4890 | int ret; |
| 4891 | struct ospf_if_params *params; |
| 4892 | |
| 4893 | ifp = vty->index; |
| 4894 | params = IF_DEF_PARAMS (ifp); |
| 4895 | |
| 4896 | if (argc == 1) |
| 4897 | { |
| 4898 | ret = inet_aton(argv[0], &addr); |
| 4899 | if (!ret) |
| 4900 | { |
| 4901 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4902 | VTY_NEWLINE); |
| 4903 | return CMD_WARNING; |
| 4904 | } |
| 4905 | |
| 4906 | params = ospf_lookup_if_params (ifp, addr); |
| 4907 | if (params == NULL) |
| 4908 | return CMD_SUCCESS; |
| 4909 | } |
| 4910 | |
| 4911 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4912 | |
| 4913 | if (params != IF_DEF_PARAMS (ifp)) |
| 4914 | { |
| 4915 | ospf_free_if_params (ifp, addr); |
| 4916 | ospf_if_update_params (ifp, addr); |
| 4917 | } |
| 4918 | |
| 4919 | ospf_if_recalculate_output_cost (ifp); |
| 4920 | |
| 4921 | return CMD_SUCCESS; |
| 4922 | } |
| 4923 | |
| 4924 | ALIAS (no_ip_ospf_cost, |
| 4925 | no_ip_ospf_cost_cmd, |
| 4926 | "no ip ospf cost", |
| 4927 | NO_STR |
| 4928 | "IP Information\n" |
| 4929 | "OSPF interface commands\n" |
| 4930 | "Interface cost\n") |
| 4931 | |
| 4932 | ALIAS (no_ip_ospf_cost, |
| 4933 | no_ospf_cost_cmd, |
| 4934 | "no ospf cost", |
| 4935 | NO_STR |
| 4936 | "OSPF interface commands\n" |
| 4937 | "Interface cost\n") |
| 4938 | |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 4939 | ALIAS (no_ip_ospf_cost, |
| 4940 | no_ospf_cost_inet4_cmd, |
| 4941 | "no ospf cost A.B.C.D", |
| 4942 | NO_STR |
| 4943 | "OSPF interface commands\n" |
| 4944 | "Interface cost\n" |
| 4945 | "Address of interface") |
| 4946 | |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 4947 | DEFUN (no_ip_ospf_cost2, |
| 4948 | no_ip_ospf_cost_u32_cmd, |
| 4949 | "no ip ospf cost <1-65535>", |
| 4950 | NO_STR |
| 4951 | "IP Information\n" |
| 4952 | "OSPF interface commands\n" |
| 4953 | "Interface cost\n" |
| 4954 | "Cost") |
| 4955 | { |
| 4956 | struct interface *ifp = vty->index; |
| 4957 | struct in_addr addr; |
| 4958 | u_int32_t cost; |
| 4959 | int ret; |
| 4960 | struct ospf_if_params *params; |
| 4961 | |
| 4962 | ifp = vty->index; |
| 4963 | params = IF_DEF_PARAMS (ifp); |
| 4964 | |
| 4965 | /* According to the semantics we are mimicking "no ip ospf cost N" is |
| 4966 | * always treated as "no ip ospf cost" regardless of the actual value |
| 4967 | * of N already configured for the interface. Thus the first argument |
| 4968 | * is always checked to be a number, but is ignored after that. |
| 4969 | */ |
| 4970 | cost = strtol (argv[0], NULL, 10); |
| 4971 | if (cost < 1 || cost > 65535) |
| 4972 | { |
| 4973 | vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE); |
| 4974 | return CMD_WARNING; |
| 4975 | } |
| 4976 | |
| 4977 | if (argc == 2) |
| 4978 | { |
| 4979 | ret = inet_aton(argv[1], &addr); |
| 4980 | if (!ret) |
| 4981 | { |
| 4982 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 4983 | VTY_NEWLINE); |
| 4984 | return CMD_WARNING; |
| 4985 | } |
| 4986 | |
| 4987 | params = ospf_lookup_if_params (ifp, addr); |
| 4988 | if (params == NULL) |
| 4989 | return CMD_SUCCESS; |
| 4990 | } |
| 4991 | |
| 4992 | UNSET_IF_PARAM (params, output_cost_cmd); |
| 4993 | |
| 4994 | if (params != IF_DEF_PARAMS (ifp)) |
| 4995 | { |
| 4996 | ospf_free_if_params (ifp, addr); |
| 4997 | ospf_if_update_params (ifp, addr); |
| 4998 | } |
| 4999 | |
| 5000 | ospf_if_recalculate_output_cost (ifp); |
| 5001 | |
| 5002 | return CMD_SUCCESS; |
| 5003 | } |
| 5004 | |
| 5005 | ALIAS (no_ip_ospf_cost2, |
| 5006 | no_ospf_cost_u32_cmd, |
| 5007 | "no ospf cost <1-65535>", |
| 5008 | NO_STR |
| 5009 | "OSPF interface commands\n" |
| 5010 | "Interface cost\n" |
| 5011 | "Cost") |
| 5012 | |
| 5013 | ALIAS (no_ip_ospf_cost2, |
| 5014 | no_ip_ospf_cost_u32_inet4_cmd, |
| 5015 | "no ip ospf cost <1-65535> A.B.C.D", |
| 5016 | NO_STR |
| 5017 | "IP Information\n" |
| 5018 | "OSPF interface commands\n" |
| 5019 | "Interface cost\n" |
| 5020 | "Cost\n" |
| 5021 | "Address of interface") |
| 5022 | |
| 5023 | ALIAS (no_ip_ospf_cost2, |
| 5024 | no_ospf_cost_u32_inet4_cmd, |
| 5025 | "no ospf cost <1-65535> A.B.C.D", |
| 5026 | NO_STR |
| 5027 | "OSPF interface commands\n" |
| 5028 | "Interface cost\n" |
| 5029 | "Cost\n" |
| 5030 | "Address of interface") |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 5031 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 5032 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5033 | ospf_nbr_timer_update (struct ospf_interface *oi) |
| 5034 | { |
| 5035 | struct route_node *rn; |
| 5036 | struct ospf_neighbor *nbr; |
| 5037 | |
| 5038 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) |
| 5039 | if ((nbr = rn->info)) |
| 5040 | { |
| 5041 | nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait); |
| 5042 | nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval); |
| 5043 | nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval); |
| 5044 | nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval); |
| 5045 | } |
| 5046 | } |
| 5047 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5048 | static int |
| 5049 | ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str, |
| 5050 | const char *nbr_str, |
| 5051 | const char *fast_hello_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5052 | { |
| 5053 | struct interface *ifp = vty->index; |
| 5054 | u_int32_t seconds; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5055 | u_char hellomult; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5056 | struct in_addr addr; |
| 5057 | int ret; |
| 5058 | struct ospf_if_params *params; |
| 5059 | struct ospf_interface *oi; |
| 5060 | struct route_node *rn; |
| 5061 | |
| 5062 | params = IF_DEF_PARAMS (ifp); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5063 | |
| 5064 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5065 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5066 | ret = inet_aton(nbr_str, &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5067 | if (!ret) |
| 5068 | { |
| 5069 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5070 | VTY_NEWLINE); |
| 5071 | return CMD_WARNING; |
| 5072 | } |
| 5073 | |
| 5074 | params = ospf_get_if_params (ifp, addr); |
| 5075 | ospf_if_update_params (ifp, addr); |
| 5076 | } |
| 5077 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5078 | if (interval_str) |
| 5079 | { |
| 5080 | VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str, |
| 5081 | 1, 65535); |
| 5082 | |
| 5083 | /* reset fast_hello too, just to be sure */ |
| 5084 | UNSET_IF_PARAM (params, fast_hello); |
| 5085 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 5086 | } |
| 5087 | else if (fast_hello_str) |
| 5088 | { |
| 5089 | VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str, |
| 5090 | 1, 10); |
| 5091 | /* 1s dead-interval with sub-second hellos desired */ |
| 5092 | seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL; |
| 5093 | SET_IF_PARAM (params, fast_hello); |
| 5094 | params->fast_hello = hellomult; |
| 5095 | } |
| 5096 | else |
| 5097 | { |
| 5098 | vty_out (vty, "Please specify dead-interval or hello-multiplier%s", |
| 5099 | VTY_NEWLINE); |
| 5100 | return CMD_WARNING; |
| 5101 | } |
| 5102 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5103 | SET_IF_PARAM (params, v_wait); |
| 5104 | params->v_wait = seconds; |
| 5105 | |
| 5106 | /* Update timer values in neighbor structure. */ |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5107 | if (nbr_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5108 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5109 | struct ospf *ospf; |
| 5110 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5111 | { |
| 5112 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5113 | if (oi) |
| 5114 | ospf_nbr_timer_update (oi); |
| 5115 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5116 | } |
| 5117 | else |
| 5118 | { |
| 5119 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5120 | if ((oi = rn->info)) |
| 5121 | ospf_nbr_timer_update (oi); |
| 5122 | } |
| 5123 | |
| 5124 | return CMD_SUCCESS; |
| 5125 | } |
| 5126 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5127 | |
| 5128 | DEFUN (ip_ospf_dead_interval, |
| 5129 | ip_ospf_dead_interval_addr_cmd, |
| 5130 | "ip ospf dead-interval <1-65535> A.B.C.D", |
| 5131 | "IP Information\n" |
| 5132 | "OSPF interface commands\n" |
| 5133 | "Interval after which a neighbor is declared dead\n" |
| 5134 | "Seconds\n" |
| 5135 | "Address of interface\n") |
| 5136 | { |
| 5137 | if (argc == 2) |
| 5138 | return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL); |
| 5139 | else |
| 5140 | return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL); |
| 5141 | } |
| 5142 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5143 | ALIAS (ip_ospf_dead_interval, |
| 5144 | ip_ospf_dead_interval_cmd, |
| 5145 | "ip ospf dead-interval <1-65535>", |
| 5146 | "IP Information\n" |
| 5147 | "OSPF interface commands\n" |
| 5148 | "Interval after which a neighbor is declared dead\n" |
| 5149 | "Seconds\n") |
| 5150 | |
| 5151 | ALIAS (ip_ospf_dead_interval, |
| 5152 | ospf_dead_interval_cmd, |
| 5153 | "ospf dead-interval <1-65535>", |
| 5154 | "OSPF interface commands\n" |
| 5155 | "Interval after which a neighbor is declared dead\n" |
| 5156 | "Seconds\n") |
| 5157 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5158 | DEFUN (ip_ospf_dead_interval_minimal, |
| 5159 | ip_ospf_dead_interval_minimal_addr_cmd, |
| 5160 | "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D", |
| 5161 | "IP Information\n" |
| 5162 | "OSPF interface commands\n" |
| 5163 | "Interval after which a neighbor is declared dead\n" |
| 5164 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5165 | "Hello multiplier factor\n" |
| 5166 | "Number of Hellos to send each second\n" |
| 5167 | "Address of interface\n") |
| 5168 | { |
| 5169 | if (argc == 2) |
| 5170 | return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]); |
| 5171 | else |
| 5172 | return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]); |
| 5173 | } |
| 5174 | |
| 5175 | ALIAS (ip_ospf_dead_interval_minimal, |
| 5176 | ip_ospf_dead_interval_minimal_cmd, |
| 5177 | "ip ospf dead-interval minimal hello-multiplier <1-10>", |
| 5178 | "IP Information\n" |
| 5179 | "OSPF interface commands\n" |
| 5180 | "Interval after which a neighbor is declared dead\n" |
| 5181 | "Minimal 1s dead-interval with fast sub-second hellos\n" |
| 5182 | "Hello multiplier factor\n" |
| 5183 | "Number of Hellos to send each second\n") |
| 5184 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5185 | DEFUN (no_ip_ospf_dead_interval, |
| 5186 | no_ip_ospf_dead_interval_addr_cmd, |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5187 | "no ip ospf dead-interval <1-65535> A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5188 | NO_STR |
| 5189 | "IP Information\n" |
| 5190 | "OSPF interface commands\n" |
| 5191 | "Interval after which a neighbor is declared dead\n" |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5192 | "Seconds\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5193 | "Address of interface") |
| 5194 | { |
| 5195 | struct interface *ifp = vty->index; |
| 5196 | struct in_addr addr; |
| 5197 | int ret; |
| 5198 | struct ospf_if_params *params; |
| 5199 | struct ospf_interface *oi; |
| 5200 | struct route_node *rn; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5201 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5202 | ifp = vty->index; |
| 5203 | params = IF_DEF_PARAMS (ifp); |
| 5204 | |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5205 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5206 | { |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5207 | ret = inet_aton(argv[1], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5208 | if (!ret) |
| 5209 | { |
| 5210 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5211 | VTY_NEWLINE); |
| 5212 | return CMD_WARNING; |
| 5213 | } |
| 5214 | |
| 5215 | params = ospf_lookup_if_params (ifp, addr); |
| 5216 | if (params == NULL) |
| 5217 | return CMD_SUCCESS; |
| 5218 | } |
| 5219 | |
| 5220 | UNSET_IF_PARAM (params, v_wait); |
| 5221 | params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT; |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5222 | |
| 5223 | UNSET_IF_PARAM (params, fast_hello); |
| 5224 | params->fast_hello = OSPF_FAST_HELLO_DEFAULT; |
| 5225 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5226 | if (params != IF_DEF_PARAMS (ifp)) |
| 5227 | { |
| 5228 | ospf_free_if_params (ifp, addr); |
| 5229 | ospf_if_update_params (ifp, addr); |
| 5230 | } |
| 5231 | |
| 5232 | /* Update timer values in neighbor structure. */ |
| 5233 | if (argc == 1) |
| 5234 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 5235 | struct ospf *ospf; |
| 5236 | |
| 5237 | if ((ospf = ospf_lookup())) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 5238 | { |
| 5239 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr); |
| 5240 | if (oi) |
| 5241 | ospf_nbr_timer_update (oi); |
| 5242 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5243 | } |
| 5244 | else |
| 5245 | { |
| 5246 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5247 | if ((oi = rn->info)) |
| 5248 | ospf_nbr_timer_update (oi); |
| 5249 | } |
| 5250 | |
| 5251 | return CMD_SUCCESS; |
| 5252 | } |
| 5253 | |
| 5254 | ALIAS (no_ip_ospf_dead_interval, |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5255 | no_ip_ospf_dead_interval_seconds_cmd, |
| 5256 | "no ip ospf dead-interval <1-65535>", |
| 5257 | NO_STR |
| 5258 | "IP Information\n" |
| 5259 | "OSPF interface commands\n" |
| 5260 | "Interval after which a neighbor is declared dead\n" |
| 5261 | "Seconds\n") |
| 5262 | |
| 5263 | ALIAS (no_ip_ospf_dead_interval, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5264 | no_ip_ospf_dead_interval_cmd, |
| 5265 | "no ip ospf dead-interval", |
| 5266 | NO_STR |
| 5267 | "IP Information\n" |
| 5268 | "OSPF interface commands\n" |
| 5269 | "Interval after which a neighbor is declared dead\n") |
| 5270 | |
| 5271 | ALIAS (no_ip_ospf_dead_interval, |
| 5272 | no_ospf_dead_interval_cmd, |
| 5273 | "no ospf dead-interval", |
| 5274 | NO_STR |
| 5275 | "OSPF interface commands\n" |
| 5276 | "Interval after which a neighbor is declared dead\n") |
| 5277 | |
| 5278 | DEFUN (ip_ospf_hello_interval, |
| 5279 | ip_ospf_hello_interval_addr_cmd, |
| 5280 | "ip ospf hello-interval <1-65535> A.B.C.D", |
| 5281 | "IP Information\n" |
| 5282 | "OSPF interface commands\n" |
| 5283 | "Time between HELLO packets\n" |
| 5284 | "Seconds\n" |
| 5285 | "Address of interface") |
| 5286 | { |
| 5287 | struct interface *ifp = vty->index; |
| 5288 | u_int32_t seconds; |
| 5289 | struct in_addr addr; |
| 5290 | int ret; |
| 5291 | struct ospf_if_params *params; |
| 5292 | |
| 5293 | params = IF_DEF_PARAMS (ifp); |
| 5294 | |
| 5295 | seconds = strtol (argv[0], NULL, 10); |
| 5296 | |
| 5297 | /* HelloInterval range is <1-65535>. */ |
| 5298 | if (seconds < 1 || seconds > 65535) |
| 5299 | { |
| 5300 | vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE); |
| 5301 | return CMD_WARNING; |
| 5302 | } |
| 5303 | |
| 5304 | if (argc == 2) |
| 5305 | { |
| 5306 | ret = inet_aton(argv[1], &addr); |
| 5307 | if (!ret) |
| 5308 | { |
| 5309 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5310 | VTY_NEWLINE); |
| 5311 | return CMD_WARNING; |
| 5312 | } |
| 5313 | |
| 5314 | params = ospf_get_if_params (ifp, addr); |
| 5315 | ospf_if_update_params (ifp, addr); |
| 5316 | } |
| 5317 | |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5318 | SET_IF_PARAM (params, v_hello); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5319 | params->v_hello = seconds; |
| 5320 | |
| 5321 | return CMD_SUCCESS; |
| 5322 | } |
| 5323 | |
| 5324 | ALIAS (ip_ospf_hello_interval, |
| 5325 | ip_ospf_hello_interval_cmd, |
| 5326 | "ip ospf hello-interval <1-65535>", |
| 5327 | "IP Information\n" |
| 5328 | "OSPF interface commands\n" |
| 5329 | "Time between HELLO packets\n" |
| 5330 | "Seconds\n") |
| 5331 | |
| 5332 | ALIAS (ip_ospf_hello_interval, |
| 5333 | ospf_hello_interval_cmd, |
| 5334 | "ospf hello-interval <1-65535>", |
| 5335 | "OSPF interface commands\n" |
| 5336 | "Time between HELLO packets\n" |
| 5337 | "Seconds\n") |
| 5338 | |
| 5339 | DEFUN (no_ip_ospf_hello_interval, |
| 5340 | no_ip_ospf_hello_interval_addr_cmd, |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5341 | "no ip ospf hello-interval <1-65535> A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5342 | NO_STR |
| 5343 | "IP Information\n" |
| 5344 | "OSPF interface commands\n" |
| 5345 | "Time between HELLO packets\n" |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5346 | "Seconds\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5347 | "Address of interface") |
| 5348 | { |
| 5349 | struct interface *ifp = vty->index; |
| 5350 | struct in_addr addr; |
| 5351 | int ret; |
| 5352 | struct ospf_if_params *params; |
| 5353 | |
| 5354 | ifp = vty->index; |
| 5355 | params = IF_DEF_PARAMS (ifp); |
| 5356 | |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5357 | if (argc == 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5358 | { |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5359 | ret = inet_aton(argv[1], &addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5360 | if (!ret) |
| 5361 | { |
| 5362 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5363 | VTY_NEWLINE); |
| 5364 | return CMD_WARNING; |
| 5365 | } |
| 5366 | |
| 5367 | params = ospf_lookup_if_params (ifp, addr); |
| 5368 | if (params == NULL) |
| 5369 | return CMD_SUCCESS; |
| 5370 | } |
| 5371 | |
| 5372 | UNSET_IF_PARAM (params, v_hello); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 5373 | params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5374 | |
| 5375 | if (params != IF_DEF_PARAMS (ifp)) |
| 5376 | { |
| 5377 | ospf_free_if_params (ifp, addr); |
| 5378 | ospf_if_update_params (ifp, addr); |
| 5379 | } |
| 5380 | |
| 5381 | return CMD_SUCCESS; |
| 5382 | } |
| 5383 | |
| 5384 | ALIAS (no_ip_ospf_hello_interval, |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 5385 | no_ip_ospf_hello_interval_seconds_cmd, |
| 5386 | "no ip ospf hello-interval <1-65535>", |
| 5387 | NO_STR |
| 5388 | "IP Information\n" |
| 5389 | "OSPF interface commands\n" |
| 5390 | "Time between HELLO packets\n" |
| 5391 | "Seconds\n") |
| 5392 | |
| 5393 | ALIAS (no_ip_ospf_hello_interval, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5394 | no_ip_ospf_hello_interval_cmd, |
| 5395 | "no ip ospf hello-interval", |
| 5396 | NO_STR |
| 5397 | "IP Information\n" |
| 5398 | "OSPF interface commands\n" |
| 5399 | "Time between HELLO packets\n") |
| 5400 | |
| 5401 | ALIAS (no_ip_ospf_hello_interval, |
| 5402 | no_ospf_hello_interval_cmd, |
| 5403 | "no ospf hello-interval", |
| 5404 | NO_STR |
| 5405 | "OSPF interface commands\n" |
| 5406 | "Time between HELLO packets\n") |
| 5407 | |
| 5408 | DEFUN (ip_ospf_network, |
| 5409 | ip_ospf_network_cmd, |
| 5410 | "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5411 | "IP Information\n" |
| 5412 | "OSPF interface commands\n" |
| 5413 | "Network type\n" |
| 5414 | "Specify OSPF broadcast multi-access network\n" |
| 5415 | "Specify OSPF NBMA network\n" |
| 5416 | "Specify OSPF point-to-multipoint network\n" |
| 5417 | "Specify OSPF point-to-point network\n") |
| 5418 | { |
| 5419 | struct interface *ifp = vty->index; |
| 5420 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5421 | struct route_node *rn; |
Christian Franke | 4b4bda9 | 2013-07-11 07:56:29 +0000 | [diff] [blame] | 5422 | |
| 5423 | if (old_type == OSPF_IFTYPE_LOOPBACK) |
| 5424 | { |
| 5425 | vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE); |
| 5426 | return CMD_WARNING; |
| 5427 | } |
| 5428 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5429 | if (strncmp (argv[0], "b", 1) == 0) |
| 5430 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST; |
| 5431 | else if (strncmp (argv[0], "n", 1) == 0) |
| 5432 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA; |
| 5433 | else if (strncmp (argv[0], "point-to-m", 10) == 0) |
| 5434 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT; |
| 5435 | else if (strncmp (argv[0], "point-to-p", 10) == 0) |
| 5436 | IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT; |
| 5437 | |
| 5438 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5439 | return CMD_SUCCESS; |
| 5440 | |
| 5441 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
| 5442 | |
| 5443 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5444 | { |
| 5445 | struct ospf_interface *oi = rn->info; |
| 5446 | |
| 5447 | if (!oi) |
| 5448 | continue; |
| 5449 | |
| 5450 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5451 | |
| 5452 | if (oi->state > ISM_Down) |
| 5453 | { |
| 5454 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5455 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5456 | } |
| 5457 | } |
| 5458 | |
| 5459 | return CMD_SUCCESS; |
| 5460 | } |
| 5461 | |
| 5462 | ALIAS (ip_ospf_network, |
| 5463 | ospf_network_cmd, |
| 5464 | "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)", |
| 5465 | "OSPF interface commands\n" |
| 5466 | "Network type\n" |
| 5467 | "Specify OSPF broadcast multi-access network\n" |
| 5468 | "Specify OSPF NBMA network\n" |
| 5469 | "Specify OSPF point-to-multipoint network\n" |
| 5470 | "Specify OSPF point-to-point network\n") |
| 5471 | |
| 5472 | DEFUN (no_ip_ospf_network, |
| 5473 | no_ip_ospf_network_cmd, |
| 5474 | "no ip ospf network", |
| 5475 | NO_STR |
| 5476 | "IP Information\n" |
| 5477 | "OSPF interface commands\n" |
| 5478 | "Network type\n") |
| 5479 | { |
| 5480 | struct interface *ifp = vty->index; |
| 5481 | int old_type = IF_DEF_PARAMS (ifp)->type; |
| 5482 | struct route_node *rn; |
| 5483 | |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 5484 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5485 | |
| 5486 | if (IF_DEF_PARAMS (ifp)->type == old_type) |
| 5487 | return CMD_SUCCESS; |
| 5488 | |
| 5489 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5490 | { |
| 5491 | struct ospf_interface *oi = rn->info; |
| 5492 | |
| 5493 | if (!oi) |
| 5494 | continue; |
| 5495 | |
| 5496 | oi->type = IF_DEF_PARAMS (ifp)->type; |
| 5497 | |
| 5498 | if (oi->state > ISM_Down) |
| 5499 | { |
| 5500 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown); |
| 5501 | OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp); |
| 5502 | } |
| 5503 | } |
| 5504 | |
| 5505 | return CMD_SUCCESS; |
| 5506 | } |
| 5507 | |
| 5508 | ALIAS (no_ip_ospf_network, |
| 5509 | no_ospf_network_cmd, |
| 5510 | "no ospf network", |
| 5511 | NO_STR |
| 5512 | "OSPF interface commands\n" |
| 5513 | "Network type\n") |
| 5514 | |
| 5515 | DEFUN (ip_ospf_priority, |
| 5516 | ip_ospf_priority_addr_cmd, |
| 5517 | "ip ospf priority <0-255> A.B.C.D", |
| 5518 | "IP Information\n" |
| 5519 | "OSPF interface commands\n" |
| 5520 | "Router priority\n" |
| 5521 | "Priority\n" |
| 5522 | "Address of interface") |
| 5523 | { |
| 5524 | struct interface *ifp = vty->index; |
Andrew Certain | 0798cee | 2012-12-04 13:43:42 -0800 | [diff] [blame] | 5525 | long priority; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5526 | struct route_node *rn; |
| 5527 | struct in_addr addr; |
| 5528 | int ret; |
| 5529 | struct ospf_if_params *params; |
| 5530 | |
| 5531 | params = IF_DEF_PARAMS (ifp); |
| 5532 | |
| 5533 | priority = strtol (argv[0], NULL, 10); |
| 5534 | |
| 5535 | /* Router Priority range is <0-255>. */ |
| 5536 | if (priority < 0 || priority > 255) |
| 5537 | { |
| 5538 | vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE); |
| 5539 | return CMD_WARNING; |
| 5540 | } |
| 5541 | |
| 5542 | if (argc == 2) |
| 5543 | { |
| 5544 | ret = inet_aton(argv[1], &addr); |
| 5545 | if (!ret) |
| 5546 | { |
| 5547 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5548 | VTY_NEWLINE); |
| 5549 | return CMD_WARNING; |
| 5550 | } |
| 5551 | |
| 5552 | params = ospf_get_if_params (ifp, addr); |
| 5553 | ospf_if_update_params (ifp, addr); |
| 5554 | } |
| 5555 | |
| 5556 | SET_IF_PARAM (params, priority); |
| 5557 | params->priority = priority; |
| 5558 | |
| 5559 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5560 | { |
| 5561 | struct ospf_interface *oi = rn->info; |
| 5562 | |
| 5563 | if (!oi) |
| 5564 | continue; |
| 5565 | |
| 5566 | |
| 5567 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5568 | { |
| 5569 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5570 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5571 | } |
| 5572 | } |
| 5573 | |
| 5574 | return CMD_SUCCESS; |
| 5575 | } |
| 5576 | |
| 5577 | ALIAS (ip_ospf_priority, |
| 5578 | ip_ospf_priority_cmd, |
| 5579 | "ip ospf priority <0-255>", |
| 5580 | "IP Information\n" |
| 5581 | "OSPF interface commands\n" |
| 5582 | "Router priority\n" |
| 5583 | "Priority\n") |
| 5584 | |
| 5585 | ALIAS (ip_ospf_priority, |
| 5586 | ospf_priority_cmd, |
| 5587 | "ospf priority <0-255>", |
| 5588 | "OSPF interface commands\n" |
| 5589 | "Router priority\n" |
| 5590 | "Priority\n") |
| 5591 | |
| 5592 | DEFUN (no_ip_ospf_priority, |
| 5593 | no_ip_ospf_priority_addr_cmd, |
| 5594 | "no ip ospf priority A.B.C.D", |
| 5595 | NO_STR |
| 5596 | "IP Information\n" |
| 5597 | "OSPF interface commands\n" |
| 5598 | "Router priority\n" |
| 5599 | "Address of interface") |
| 5600 | { |
| 5601 | struct interface *ifp = vty->index; |
| 5602 | struct route_node *rn; |
| 5603 | struct in_addr addr; |
| 5604 | int ret; |
| 5605 | struct ospf_if_params *params; |
| 5606 | |
| 5607 | ifp = vty->index; |
| 5608 | params = IF_DEF_PARAMS (ifp); |
| 5609 | |
| 5610 | if (argc == 1) |
| 5611 | { |
| 5612 | ret = inet_aton(argv[0], &addr); |
| 5613 | if (!ret) |
| 5614 | { |
| 5615 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5616 | VTY_NEWLINE); |
| 5617 | return CMD_WARNING; |
| 5618 | } |
| 5619 | |
| 5620 | params = ospf_lookup_if_params (ifp, addr); |
| 5621 | if (params == NULL) |
| 5622 | return CMD_SUCCESS; |
| 5623 | } |
| 5624 | |
| 5625 | UNSET_IF_PARAM (params, priority); |
| 5626 | params->priority = OSPF_ROUTER_PRIORITY_DEFAULT; |
| 5627 | |
| 5628 | if (params != IF_DEF_PARAMS (ifp)) |
| 5629 | { |
| 5630 | ospf_free_if_params (ifp, addr); |
| 5631 | ospf_if_update_params (ifp, addr); |
| 5632 | } |
| 5633 | |
| 5634 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 5635 | { |
| 5636 | struct ospf_interface *oi = rn->info; |
| 5637 | |
| 5638 | if (!oi) |
| 5639 | continue; |
| 5640 | |
| 5641 | |
| 5642 | if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority)) |
| 5643 | { |
| 5644 | PRIORITY (oi) = OSPF_IF_PARAM (oi, priority); |
| 5645 | OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange); |
| 5646 | } |
| 5647 | } |
| 5648 | |
| 5649 | return CMD_SUCCESS; |
| 5650 | } |
| 5651 | |
| 5652 | ALIAS (no_ip_ospf_priority, |
| 5653 | no_ip_ospf_priority_cmd, |
| 5654 | "no ip ospf priority", |
| 5655 | NO_STR |
| 5656 | "IP Information\n" |
| 5657 | "OSPF interface commands\n" |
| 5658 | "Router priority\n") |
| 5659 | |
| 5660 | ALIAS (no_ip_ospf_priority, |
| 5661 | no_ospf_priority_cmd, |
| 5662 | "no ospf priority", |
| 5663 | NO_STR |
| 5664 | "OSPF interface commands\n" |
| 5665 | "Router priority\n") |
| 5666 | |
| 5667 | DEFUN (ip_ospf_retransmit_interval, |
| 5668 | ip_ospf_retransmit_interval_addr_cmd, |
| 5669 | "ip ospf retransmit-interval <3-65535> A.B.C.D", |
| 5670 | "IP Information\n" |
| 5671 | "OSPF interface commands\n" |
| 5672 | "Time between retransmitting lost link state advertisements\n" |
| 5673 | "Seconds\n" |
| 5674 | "Address of interface") |
| 5675 | { |
| 5676 | struct interface *ifp = vty->index; |
| 5677 | u_int32_t seconds; |
| 5678 | struct in_addr addr; |
| 5679 | int ret; |
| 5680 | struct ospf_if_params *params; |
| 5681 | |
| 5682 | params = IF_DEF_PARAMS (ifp); |
| 5683 | seconds = strtol (argv[0], NULL, 10); |
| 5684 | |
| 5685 | /* Retransmit Interval range is <3-65535>. */ |
| 5686 | if (seconds < 3 || seconds > 65535) |
| 5687 | { |
| 5688 | vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE); |
| 5689 | return CMD_WARNING; |
| 5690 | } |
| 5691 | |
| 5692 | |
| 5693 | if (argc == 2) |
| 5694 | { |
| 5695 | ret = inet_aton(argv[1], &addr); |
| 5696 | if (!ret) |
| 5697 | { |
| 5698 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5699 | VTY_NEWLINE); |
| 5700 | return CMD_WARNING; |
| 5701 | } |
| 5702 | |
| 5703 | params = ospf_get_if_params (ifp, addr); |
| 5704 | ospf_if_update_params (ifp, addr); |
| 5705 | } |
| 5706 | |
| 5707 | SET_IF_PARAM (params, retransmit_interval); |
| 5708 | params->retransmit_interval = seconds; |
| 5709 | |
| 5710 | return CMD_SUCCESS; |
| 5711 | } |
| 5712 | |
| 5713 | ALIAS (ip_ospf_retransmit_interval, |
| 5714 | ip_ospf_retransmit_interval_cmd, |
| 5715 | "ip ospf retransmit-interval <3-65535>", |
| 5716 | "IP Information\n" |
| 5717 | "OSPF interface commands\n" |
| 5718 | "Time between retransmitting lost link state advertisements\n" |
| 5719 | "Seconds\n") |
| 5720 | |
| 5721 | ALIAS (ip_ospf_retransmit_interval, |
| 5722 | ospf_retransmit_interval_cmd, |
| 5723 | "ospf retransmit-interval <3-65535>", |
| 5724 | "OSPF interface commands\n" |
| 5725 | "Time between retransmitting lost link state advertisements\n" |
| 5726 | "Seconds\n") |
| 5727 | |
| 5728 | DEFUN (no_ip_ospf_retransmit_interval, |
| 5729 | no_ip_ospf_retransmit_interval_addr_cmd, |
| 5730 | "no ip ospf retransmit-interval A.B.C.D", |
| 5731 | NO_STR |
| 5732 | "IP Information\n" |
| 5733 | "OSPF interface commands\n" |
| 5734 | "Time between retransmitting lost link state advertisements\n" |
| 5735 | "Address of interface") |
| 5736 | { |
| 5737 | struct interface *ifp = vty->index; |
| 5738 | struct in_addr addr; |
| 5739 | int ret; |
| 5740 | struct ospf_if_params *params; |
| 5741 | |
| 5742 | ifp = vty->index; |
| 5743 | params = IF_DEF_PARAMS (ifp); |
| 5744 | |
| 5745 | if (argc == 1) |
| 5746 | { |
| 5747 | ret = inet_aton(argv[0], &addr); |
| 5748 | if (!ret) |
| 5749 | { |
| 5750 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5751 | VTY_NEWLINE); |
| 5752 | return CMD_WARNING; |
| 5753 | } |
| 5754 | |
| 5755 | params = ospf_lookup_if_params (ifp, addr); |
| 5756 | if (params == NULL) |
| 5757 | return CMD_SUCCESS; |
| 5758 | } |
| 5759 | |
| 5760 | UNSET_IF_PARAM (params, retransmit_interval); |
| 5761 | params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT; |
| 5762 | |
| 5763 | if (params != IF_DEF_PARAMS (ifp)) |
| 5764 | { |
| 5765 | ospf_free_if_params (ifp, addr); |
| 5766 | ospf_if_update_params (ifp, addr); |
| 5767 | } |
| 5768 | |
| 5769 | return CMD_SUCCESS; |
| 5770 | } |
| 5771 | |
| 5772 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5773 | no_ip_ospf_retransmit_interval_cmd, |
| 5774 | "no ip ospf retransmit-interval", |
| 5775 | NO_STR |
| 5776 | "IP Information\n" |
| 5777 | "OSPF interface commands\n" |
| 5778 | "Time between retransmitting lost link state advertisements\n") |
| 5779 | |
| 5780 | ALIAS (no_ip_ospf_retransmit_interval, |
| 5781 | no_ospf_retransmit_interval_cmd, |
| 5782 | "no ospf retransmit-interval", |
| 5783 | NO_STR |
| 5784 | "OSPF interface commands\n" |
| 5785 | "Time between retransmitting lost link state advertisements\n") |
| 5786 | |
| 5787 | DEFUN (ip_ospf_transmit_delay, |
| 5788 | ip_ospf_transmit_delay_addr_cmd, |
| 5789 | "ip ospf transmit-delay <1-65535> A.B.C.D", |
| 5790 | "IP Information\n" |
| 5791 | "OSPF interface commands\n" |
| 5792 | "Link state transmit delay\n" |
| 5793 | "Seconds\n" |
| 5794 | "Address of interface") |
| 5795 | { |
| 5796 | struct interface *ifp = vty->index; |
| 5797 | u_int32_t seconds; |
| 5798 | struct in_addr addr; |
| 5799 | int ret; |
| 5800 | struct ospf_if_params *params; |
| 5801 | |
| 5802 | params = IF_DEF_PARAMS (ifp); |
| 5803 | seconds = strtol (argv[0], NULL, 10); |
| 5804 | |
| 5805 | /* Transmit Delay range is <1-65535>. */ |
| 5806 | if (seconds < 1 || seconds > 65535) |
| 5807 | { |
| 5808 | vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE); |
| 5809 | return CMD_WARNING; |
| 5810 | } |
| 5811 | |
| 5812 | if (argc == 2) |
| 5813 | { |
| 5814 | ret = inet_aton(argv[1], &addr); |
| 5815 | if (!ret) |
| 5816 | { |
| 5817 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5818 | VTY_NEWLINE); |
| 5819 | return CMD_WARNING; |
| 5820 | } |
| 5821 | |
| 5822 | params = ospf_get_if_params (ifp, addr); |
| 5823 | ospf_if_update_params (ifp, addr); |
| 5824 | } |
| 5825 | |
| 5826 | SET_IF_PARAM (params, transmit_delay); |
| 5827 | params->transmit_delay = seconds; |
| 5828 | |
| 5829 | return CMD_SUCCESS; |
| 5830 | } |
| 5831 | |
| 5832 | ALIAS (ip_ospf_transmit_delay, |
| 5833 | ip_ospf_transmit_delay_cmd, |
| 5834 | "ip ospf transmit-delay <1-65535>", |
| 5835 | "IP Information\n" |
| 5836 | "OSPF interface commands\n" |
| 5837 | "Link state transmit delay\n" |
| 5838 | "Seconds\n") |
| 5839 | |
| 5840 | ALIAS (ip_ospf_transmit_delay, |
| 5841 | ospf_transmit_delay_cmd, |
| 5842 | "ospf transmit-delay <1-65535>", |
| 5843 | "OSPF interface commands\n" |
| 5844 | "Link state transmit delay\n" |
| 5845 | "Seconds\n") |
| 5846 | |
| 5847 | DEFUN (no_ip_ospf_transmit_delay, |
| 5848 | no_ip_ospf_transmit_delay_addr_cmd, |
| 5849 | "no ip ospf transmit-delay A.B.C.D", |
| 5850 | NO_STR |
| 5851 | "IP Information\n" |
| 5852 | "OSPF interface commands\n" |
| 5853 | "Link state transmit delay\n" |
| 5854 | "Address of interface") |
| 5855 | { |
| 5856 | struct interface *ifp = vty->index; |
| 5857 | struct in_addr addr; |
| 5858 | int ret; |
| 5859 | struct ospf_if_params *params; |
| 5860 | |
| 5861 | ifp = vty->index; |
| 5862 | params = IF_DEF_PARAMS (ifp); |
| 5863 | |
| 5864 | if (argc == 1) |
| 5865 | { |
| 5866 | ret = inet_aton(argv[0], &addr); |
| 5867 | if (!ret) |
| 5868 | { |
| 5869 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 5870 | VTY_NEWLINE); |
| 5871 | return CMD_WARNING; |
| 5872 | } |
| 5873 | |
| 5874 | params = ospf_lookup_if_params (ifp, addr); |
| 5875 | if (params == NULL) |
| 5876 | return CMD_SUCCESS; |
| 5877 | } |
| 5878 | |
| 5879 | UNSET_IF_PARAM (params, transmit_delay); |
| 5880 | params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT; |
| 5881 | |
| 5882 | if (params != IF_DEF_PARAMS (ifp)) |
| 5883 | { |
| 5884 | ospf_free_if_params (ifp, addr); |
| 5885 | ospf_if_update_params (ifp, addr); |
| 5886 | } |
| 5887 | |
| 5888 | return CMD_SUCCESS; |
| 5889 | } |
| 5890 | |
| 5891 | ALIAS (no_ip_ospf_transmit_delay, |
| 5892 | no_ip_ospf_transmit_delay_cmd, |
| 5893 | "no ip ospf transmit-delay", |
| 5894 | NO_STR |
| 5895 | "IP Information\n" |
| 5896 | "OSPF interface commands\n" |
| 5897 | "Link state transmit delay\n") |
| 5898 | |
| 5899 | ALIAS (no_ip_ospf_transmit_delay, |
| 5900 | no_ospf_transmit_delay_cmd, |
| 5901 | "no ospf transmit-delay", |
| 5902 | NO_STR |
| 5903 | "OSPF interface commands\n" |
| 5904 | "Link state transmit delay\n") |
| 5905 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5906 | DEFUN (ip_ospf_area, |
| 5907 | ip_ospf_area_cmd, |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5908 | "ip ospf area (A.B.C.D|<0-4294967295>) [A.B.C.D]", |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5909 | "IP Information\n" |
| 5910 | "OSPF interface commands\n" |
| 5911 | "Enable OSPF on this interface\n" |
| 5912 | "OSPF area ID in IP address format\n" |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5913 | "OSPF area ID as a decimal value\n" |
| 5914 | "Address of interface\n") |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5915 | { |
| 5916 | struct interface *ifp = vty->index; |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5917 | struct in_addr area_id; |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5918 | struct in_addr addr; |
| 5919 | int format; |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5920 | struct ospf_if_params *params; |
| 5921 | |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5922 | VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]); |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5923 | |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5924 | OSPF_VTY_GET_IF_PARAMS(ifp, params, 1, addr, VTY_SET); |
| 5925 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5926 | if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) |
| 5927 | { |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5928 | vty_out (vty, "There is already an interface area statement.%s", |
| 5929 | VTY_NEWLINE); |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5930 | return CMD_WARNING; |
| 5931 | } |
| 5932 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 5933 | { |
| 5934 | vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE); |
| 5935 | return CMD_WARNING; |
| 5936 | } |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5937 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5938 | SET_IF_PARAM (params, if_area); |
| 5939 | params->if_area = area_id; |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5940 | ospf_interface_area_set (ifp); |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5941 | |
| 5942 | return CMD_SUCCESS; |
| 5943 | } |
| 5944 | |
| 5945 | DEFUN (no_ip_ospf_area, |
| 5946 | no_ip_ospf_area_cmd, |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5947 | "no ip ospf area [A.B.C.D]", |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5948 | NO_STR |
| 5949 | "IP Information\n" |
| 5950 | "OSPF interface commands\n" |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5951 | "Disable OSPF on this interface\n" |
| 5952 | "Address of interface\n") |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5953 | { |
| 5954 | struct interface *ifp = vty->index; |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5955 | struct ospf_if_params *params; |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5956 | struct in_addr addr; |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5957 | |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5958 | OSPF_VTY_GET_IF_PARAMS(ifp, params, 0, addr, VTY_UNSET); |
| 5959 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5960 | if (!OSPF_IF_PARAM_CONFIGURED(params, if_area)) |
| 5961 | return CMD_SUCCESS; |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 5962 | |
| 5963 | OSPF_VTY_PARAM_UNSET(params, if_area, ifp, addr); |
| 5964 | |
| 5965 | ospf_interface_area_unset (ifp); |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5966 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 5967 | return CMD_SUCCESS; |
| 5968 | } |
| 5969 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5970 | DEFUN (ospf_redistribute_source, |
| 5971 | ospf_redistribute_source_cmd, |
| 5972 | "redistribute " QUAGGA_REDIST_STR_OSPFD |
| 5973 | " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 5974 | REDIST_STR |
| 5975 | QUAGGA_REDIST_HELP_STR_OSPFD |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5976 | "Metric for redistributed routes\n" |
| 5977 | "OSPF default metric\n" |
| 5978 | "OSPF exterior metric type for redistributed routes\n" |
| 5979 | "Set OSPF External Type 1 metrics\n" |
| 5980 | "Set OSPF External Type 2 metrics\n" |
| 5981 | "Route map reference\n" |
| 5982 | "Pointer to route-map entries\n") |
| 5983 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 5984 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5985 | int source; |
| 5986 | int type = -1; |
| 5987 | int metric = -1; |
| 5988 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5989 | if (argc < 4) |
| 5990 | return CMD_WARNING; /* should not happen */ |
| 5991 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5992 | /* Get distribute source. */ |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 5993 | source = proto_redistnum(AFI_IP, argv[0]); |
| 5994 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5995 | return CMD_WARNING; |
| 5996 | |
| 5997 | /* Get metric value. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 5998 | if (argv[1] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 5999 | if (!str2metric (argv[1], &metric)) |
| 6000 | return CMD_WARNING; |
| 6001 | |
| 6002 | /* Get metric type. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6003 | if (argv[2] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6004 | if (!str2metric_type (argv[2], &type)) |
| 6005 | return CMD_WARNING; |
| 6006 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6007 | if (argv[3] != NULL) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6008 | ospf_routemap_set (ospf, source, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6009 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6010 | ospf_routemap_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6011 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6012 | return ospf_redistribute_set (ospf, source, type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6013 | } |
| 6014 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6015 | DEFUN (no_ospf_redistribute_source, |
| 6016 | no_ospf_redistribute_source_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 6017 | "no redistribute " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6018 | NO_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 6019 | REDIST_STR |
| 6020 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6021 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6022 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6023 | int source; |
| 6024 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 6025 | source = proto_redistnum(AFI_IP, argv[0]); |
| 6026 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6027 | return CMD_WARNING; |
| 6028 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6029 | ospf_routemap_unset (ospf, source); |
| 6030 | return ospf_redistribute_unset (ospf, source); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6031 | } |
| 6032 | |
| 6033 | DEFUN (ospf_distribute_list_out, |
| 6034 | ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 6035 | "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6036 | "Filter networks in routing updates\n" |
| 6037 | "Access-list name\n" |
| 6038 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 6039 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6040 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6041 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6042 | int source; |
| 6043 | |
| 6044 | /* Get distribute source. */ |
Christian Franke | bda3c32 | 2012-12-04 11:31:16 -0800 | [diff] [blame] | 6045 | source = proto_redistnum(AFI_IP, argv[1]); |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 6046 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6047 | return CMD_WARNING; |
| 6048 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6049 | return ospf_distribute_list_out_set (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6050 | } |
| 6051 | |
| 6052 | DEFUN (no_ospf_distribute_list_out, |
| 6053 | no_ospf_distribute_list_out_cmd, |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 6054 | "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6055 | NO_STR |
| 6056 | "Filter networks in routing updates\n" |
| 6057 | "Access-list name\n" |
| 6058 | OUT_STR |
Paul Jakma | d1c65c2 | 2006-06-27 08:01:43 +0000 | [diff] [blame] | 6059 | QUAGGA_REDIST_HELP_STR_OSPFD) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6060 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6061 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6062 | int source; |
| 6063 | |
Christian Franke | bda3c32 | 2012-12-04 11:31:16 -0800 | [diff] [blame] | 6064 | source = proto_redistnum(AFI_IP, argv[1]); |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 6065 | if (source < 0 || source == ZEBRA_ROUTE_OSPF) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6066 | return CMD_WARNING; |
| 6067 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6068 | return ospf_distribute_list_out_unset (ospf, source, argv[0]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6069 | } |
| 6070 | |
| 6071 | /* Default information originate. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6072 | DEFUN (ospf_default_information_originate, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6073 | ospf_default_information_originate_cmd, |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6074 | "default-information originate " |
| 6075 | "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6076 | "Control distribution of default information\n" |
| 6077 | "Distribute a default route\n" |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6078 | "Always advertise default route\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6079 | "OSPF default metric\n" |
| 6080 | "OSPF metric\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6081 | "OSPF metric type for default routes\n" |
| 6082 | "Set OSPF External Type 1 metrics\n" |
| 6083 | "Set OSPF External Type 2 metrics\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6084 | "Route map reference\n" |
| 6085 | "Pointer to route-map entries\n") |
| 6086 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6087 | struct ospf *ospf = vty->index; |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6088 | int default_originate = DEFAULT_ORIGINATE_ZEBRA; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6089 | int type = -1; |
| 6090 | int metric = -1; |
| 6091 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6092 | if (argc < 4) |
| 6093 | return CMD_WARNING; /* this should not happen */ |
| 6094 | |
| 6095 | /* Check whether "always" was specified */ |
| 6096 | if (argv[0] != NULL) |
| 6097 | default_originate = DEFAULT_ORIGINATE_ALWAYS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6098 | |
| 6099 | /* Get metric value. */ |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6100 | if (argv[1] != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6101 | if (!str2metric (argv[1], &metric)) |
| 6102 | return CMD_WARNING; |
| 6103 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6104 | /* Get metric type. */ |
| 6105 | if (argv[2] != NULL) |
| 6106 | if (!str2metric_type (argv[2], &type)) |
| 6107 | return CMD_WARNING; |
| 6108 | |
| 6109 | if (argv[3] != NULL) |
| 6110 | ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6111 | else |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6112 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6113 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6114 | return ospf_redistribute_default_set (ospf, default_originate, |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6115 | type, metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6116 | } |
| 6117 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6118 | DEFUN (no_ospf_default_information_originate, |
| 6119 | no_ospf_default_information_originate_cmd, |
| 6120 | "no default-information originate", |
| 6121 | NO_STR |
| 6122 | "Control distribution of default information\n" |
| 6123 | "Distribute a default route\n") |
| 6124 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6125 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6126 | struct prefix_ipv4 p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6127 | |
| 6128 | p.family = AF_INET; |
| 6129 | p.prefix.s_addr = 0; |
| 6130 | p.prefixlen = 0; |
| 6131 | |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 6132 | ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6133 | |
| 6134 | if (EXTERNAL_INFO (DEFAULT_ROUTE)) { |
| 6135 | ospf_external_info_delete (DEFAULT_ROUTE, p); |
| 6136 | route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE)); |
| 6137 | EXTERNAL_INFO (DEFAULT_ROUTE) = NULL; |
| 6138 | } |
| 6139 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6140 | ospf_routemap_unset (ospf, DEFAULT_ROUTE); |
| 6141 | return ospf_redistribute_default_unset (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6142 | } |
| 6143 | |
| 6144 | DEFUN (ospf_default_metric, |
| 6145 | ospf_default_metric_cmd, |
| 6146 | "default-metric <0-16777214>", |
| 6147 | "Set metric of redistributed routes\n" |
| 6148 | "Default metric\n") |
| 6149 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6150 | struct ospf *ospf = vty->index; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6151 | int metric = -1; |
| 6152 | |
| 6153 | if (!str2metric (argv[0], &metric)) |
| 6154 | return CMD_WARNING; |
| 6155 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6156 | ospf->default_metric = metric; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6157 | |
| 6158 | return CMD_SUCCESS; |
| 6159 | } |
| 6160 | |
| 6161 | DEFUN (no_ospf_default_metric, |
| 6162 | no_ospf_default_metric_cmd, |
| 6163 | "no default-metric", |
| 6164 | NO_STR |
| 6165 | "Set metric of redistributed routes\n") |
| 6166 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6167 | struct ospf *ospf = vty->index; |
| 6168 | |
| 6169 | ospf->default_metric = -1; |
| 6170 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6171 | return CMD_SUCCESS; |
| 6172 | } |
| 6173 | |
| 6174 | ALIAS (no_ospf_default_metric, |
| 6175 | no_ospf_default_metric_val_cmd, |
| 6176 | "no default-metric <0-16777214>", |
| 6177 | NO_STR |
| 6178 | "Set metric of redistributed routes\n" |
| 6179 | "Default metric\n") |
| 6180 | |
| 6181 | DEFUN (ospf_distance, |
| 6182 | ospf_distance_cmd, |
| 6183 | "distance <1-255>", |
| 6184 | "Define an administrative distance\n" |
| 6185 | "OSPF Administrative distance\n") |
| 6186 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6187 | struct ospf *ospf = vty->index; |
| 6188 | |
| 6189 | ospf->distance_all = atoi (argv[0]); |
| 6190 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6191 | return CMD_SUCCESS; |
| 6192 | } |
| 6193 | |
| 6194 | DEFUN (no_ospf_distance, |
| 6195 | no_ospf_distance_cmd, |
| 6196 | "no distance <1-255>", |
| 6197 | NO_STR |
| 6198 | "Define an administrative distance\n" |
| 6199 | "OSPF Administrative distance\n") |
| 6200 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6201 | struct ospf *ospf = vty->index; |
| 6202 | |
| 6203 | ospf->distance_all = 0; |
| 6204 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6205 | return CMD_SUCCESS; |
| 6206 | } |
| 6207 | |
| 6208 | DEFUN (no_ospf_distance_ospf, |
| 6209 | no_ospf_distance_ospf_cmd, |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6210 | "no distance ospf {intra-area|inter-area|external}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6211 | NO_STR |
| 6212 | "Define an administrative distance\n" |
| 6213 | "OSPF Administrative distance\n" |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6214 | "OSPF Distance\n" |
| 6215 | "Intra-area routes\n" |
| 6216 | "Inter-area routes\n" |
| 6217 | "External routes\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6218 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6219 | struct ospf *ospf = vty->index; |
| 6220 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6221 | if (argc < 3) |
| 6222 | return CMD_WARNING; |
| 6223 | |
| 6224 | if (argv[0] != NULL) |
| 6225 | ospf->distance_intra = 0; |
| 6226 | |
| 6227 | if (argv[1] != NULL) |
| 6228 | ospf->distance_inter = 0; |
| 6229 | |
| 6230 | if (argv[2] != NULL) |
| 6231 | ospf->distance_external = 0; |
| 6232 | |
| 6233 | if (argv[0] || argv[1] || argv[2]) |
| 6234 | return CMD_SUCCESS; |
| 6235 | |
| 6236 | /* If no arguments are given, clear all distance information */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6237 | ospf->distance_intra = 0; |
| 6238 | ospf->distance_inter = 0; |
| 6239 | ospf->distance_external = 0; |
| 6240 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6241 | return CMD_SUCCESS; |
| 6242 | } |
| 6243 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6244 | DEFUN (ospf_distance_ospf, |
| 6245 | ospf_distance_ospf_cmd, |
| 6246 | "distance ospf " |
| 6247 | "{intra-area <1-255>|inter-area <1-255>|external <1-255>}", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6248 | "Define an administrative distance\n" |
| 6249 | "OSPF Administrative distance\n" |
| 6250 | "Intra-area routes\n" |
| 6251 | "Distance for intra-area routes\n" |
| 6252 | "Inter-area routes\n" |
| 6253 | "Distance for inter-area routes\n" |
| 6254 | "External routes\n" |
| 6255 | "Distance for external routes\n") |
| 6256 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6257 | struct ospf *ospf = vty->index; |
| 6258 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6259 | if (argc < 3) /* should not happen */ |
| 6260 | return CMD_WARNING; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6261 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6262 | if (!argv[0] && !argv[1] && !argv[2]) |
| 6263 | { |
| 6264 | vty_out(vty, "%% Command incomplete. (Arguments required)%s", |
| 6265 | VTY_NEWLINE); |
| 6266 | return CMD_WARNING; |
| 6267 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6268 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6269 | if (argv[0] != NULL) |
| 6270 | ospf->distance_intra = atoi(argv[0]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6271 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6272 | if (argv[1] != NULL) |
| 6273 | ospf->distance_inter = atoi(argv[1]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6274 | |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 6275 | if (argv[2] != NULL) |
| 6276 | ospf->distance_external = atoi(argv[2]); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6277 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6278 | return CMD_SUCCESS; |
| 6279 | } |
| 6280 | |
| 6281 | DEFUN (ospf_distance_source, |
| 6282 | ospf_distance_source_cmd, |
| 6283 | "distance <1-255> A.B.C.D/M", |
| 6284 | "Administrative distance\n" |
| 6285 | "Distance value\n" |
| 6286 | "IP source prefix\n") |
| 6287 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6288 | struct ospf *ospf = vty->index; |
| 6289 | |
| 6290 | ospf_distance_set (vty, ospf, argv[0], argv[1], NULL); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6291 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6292 | return CMD_SUCCESS; |
| 6293 | } |
| 6294 | |
| 6295 | DEFUN (no_ospf_distance_source, |
| 6296 | no_ospf_distance_source_cmd, |
| 6297 | "no distance <1-255> A.B.C.D/M", |
| 6298 | NO_STR |
| 6299 | "Administrative distance\n" |
| 6300 | "Distance value\n" |
| 6301 | "IP source prefix\n") |
| 6302 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6303 | struct ospf *ospf = vty->index; |
| 6304 | |
| 6305 | ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL); |
| 6306 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6307 | return CMD_SUCCESS; |
| 6308 | } |
| 6309 | |
| 6310 | DEFUN (ospf_distance_source_access_list, |
| 6311 | ospf_distance_source_access_list_cmd, |
| 6312 | "distance <1-255> A.B.C.D/M WORD", |
| 6313 | "Administrative distance\n" |
| 6314 | "Distance value\n" |
| 6315 | "IP source prefix\n" |
| 6316 | "Access list name\n") |
| 6317 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6318 | struct ospf *ospf = vty->index; |
| 6319 | |
| 6320 | ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]); |
| 6321 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6322 | return CMD_SUCCESS; |
| 6323 | } |
| 6324 | |
| 6325 | DEFUN (no_ospf_distance_source_access_list, |
| 6326 | no_ospf_distance_source_access_list_cmd, |
| 6327 | "no distance <1-255> A.B.C.D/M WORD", |
| 6328 | NO_STR |
| 6329 | "Administrative distance\n" |
| 6330 | "Distance value\n" |
| 6331 | "IP source prefix\n" |
| 6332 | "Access list name\n") |
| 6333 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6334 | struct ospf *ospf = vty->index; |
| 6335 | |
| 6336 | ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]); |
| 6337 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6338 | return CMD_SUCCESS; |
| 6339 | } |
| 6340 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6341 | DEFUN (ip_ospf_mtu_ignore, |
| 6342 | ip_ospf_mtu_ignore_addr_cmd, |
| 6343 | "ip ospf mtu-ignore A.B.C.D", |
| 6344 | "IP Information\n" |
| 6345 | "OSPF interface commands\n" |
| 6346 | "Disable mtu mismatch detection\n" |
| 6347 | "Address of interface") |
| 6348 | { |
| 6349 | struct interface *ifp = vty->index; |
| 6350 | struct in_addr addr; |
| 6351 | int ret; |
| 6352 | |
| 6353 | struct ospf_if_params *params; |
| 6354 | params = IF_DEF_PARAMS (ifp); |
| 6355 | |
| 6356 | if (argc == 1) |
| 6357 | { |
| 6358 | ret = inet_aton(argv[0], &addr); |
| 6359 | if (!ret) |
| 6360 | { |
| 6361 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6362 | VTY_NEWLINE); |
| 6363 | return CMD_WARNING; |
| 6364 | } |
| 6365 | params = ospf_get_if_params (ifp, addr); |
| 6366 | ospf_if_update_params (ifp, addr); |
| 6367 | } |
| 6368 | params->mtu_ignore = 1; |
| 6369 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6370 | SET_IF_PARAM (params, mtu_ignore); |
| 6371 | else |
| 6372 | { |
| 6373 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6374 | if (params != IF_DEF_PARAMS (ifp)) |
| 6375 | { |
| 6376 | ospf_free_if_params (ifp, addr); |
| 6377 | ospf_if_update_params (ifp, addr); |
| 6378 | } |
| 6379 | } |
| 6380 | return CMD_SUCCESS; |
| 6381 | } |
| 6382 | |
| 6383 | ALIAS (ip_ospf_mtu_ignore, |
| 6384 | ip_ospf_mtu_ignore_cmd, |
| 6385 | "ip ospf mtu-ignore", |
| 6386 | "IP Information\n" |
| 6387 | "OSPF interface commands\n" |
| 6388 | "Disable mtu mismatch detection\n") |
| 6389 | |
| 6390 | |
| 6391 | DEFUN (no_ip_ospf_mtu_ignore, |
| 6392 | no_ip_ospf_mtu_ignore_addr_cmd, |
| 6393 | "no ip ospf mtu-ignore A.B.C.D", |
| 6394 | "IP Information\n" |
| 6395 | "OSPF interface commands\n" |
| 6396 | "Disable mtu mismatch detection\n" |
| 6397 | "Address of interface") |
| 6398 | { |
| 6399 | struct interface *ifp = vty->index; |
| 6400 | struct in_addr addr; |
| 6401 | int ret; |
| 6402 | |
| 6403 | struct ospf_if_params *params; |
| 6404 | params = IF_DEF_PARAMS (ifp); |
| 6405 | |
| 6406 | if (argc == 1) |
| 6407 | { |
| 6408 | ret = inet_aton(argv[0], &addr); |
| 6409 | if (!ret) |
| 6410 | { |
| 6411 | vty_out (vty, "Please specify interface address by A.B.C.D%s", |
| 6412 | VTY_NEWLINE); |
| 6413 | return CMD_WARNING; |
| 6414 | } |
| 6415 | params = ospf_get_if_params (ifp, addr); |
| 6416 | ospf_if_update_params (ifp, addr); |
| 6417 | } |
| 6418 | params->mtu_ignore = 0; |
| 6419 | if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 6420 | SET_IF_PARAM (params, mtu_ignore); |
| 6421 | else |
| 6422 | { |
| 6423 | UNSET_IF_PARAM (params, mtu_ignore); |
| 6424 | if (params != IF_DEF_PARAMS (ifp)) |
| 6425 | { |
| 6426 | ospf_free_if_params (ifp, addr); |
| 6427 | ospf_if_update_params (ifp, addr); |
| 6428 | } |
| 6429 | } |
| 6430 | return CMD_SUCCESS; |
| 6431 | } |
| 6432 | |
| 6433 | ALIAS (no_ip_ospf_mtu_ignore, |
| 6434 | no_ip_ospf_mtu_ignore_cmd, |
| 6435 | "no ip ospf mtu-ignore", |
| 6436 | "IP Information\n" |
| 6437 | "OSPF interface commands\n" |
| 6438 | "Disable mtu mismatch detection\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6439 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6440 | DEFUN (ospf_max_metric_router_lsa_admin, |
| 6441 | ospf_max_metric_router_lsa_admin_cmd, |
| 6442 | "max-metric router-lsa administrative", |
| 6443 | "OSPF maximum / infinite-distance metric\n" |
| 6444 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6445 | "Administratively applied, for an indefinite period\n") |
| 6446 | { |
| 6447 | struct listnode *ln; |
| 6448 | struct ospf_area *area; |
| 6449 | struct ospf *ospf = vty->index; |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 6450 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6451 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6452 | { |
| 6453 | SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6454 | |
| 6455 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)) |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6456 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6457 | } |
Ayan Banerjee | 4ba4fc8 | 2012-12-03 11:17:24 -0800 | [diff] [blame] | 6458 | |
| 6459 | /* Allows for areas configured later to get the property */ |
| 6460 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET; |
| 6461 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6462 | return CMD_SUCCESS; |
| 6463 | } |
| 6464 | |
| 6465 | DEFUN (no_ospf_max_metric_router_lsa_admin, |
| 6466 | no_ospf_max_metric_router_lsa_admin_cmd, |
| 6467 | "no max-metric router-lsa administrative", |
| 6468 | NO_STR |
| 6469 | "OSPF maximum / infinite-distance metric\n" |
| 6470 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6471 | "Administratively applied, for an indefinite period\n") |
| 6472 | { |
| 6473 | struct listnode *ln; |
| 6474 | struct ospf_area *area; |
| 6475 | struct ospf *ospf = vty->index; |
| 6476 | |
| 6477 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6478 | { |
| 6479 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED); |
| 6480 | |
| 6481 | /* Don't trample on the start-up stub timer */ |
| 6482 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED) |
| 6483 | && !area->t_stub_router) |
| 6484 | { |
| 6485 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6486 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6487 | } |
| 6488 | } |
Ayan Banerjee | 4ba4fc8 | 2012-12-03 11:17:24 -0800 | [diff] [blame] | 6489 | ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET; |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6490 | return CMD_SUCCESS; |
| 6491 | } |
| 6492 | |
| 6493 | DEFUN (ospf_max_metric_router_lsa_startup, |
| 6494 | ospf_max_metric_router_lsa_startup_cmd, |
| 6495 | "max-metric router-lsa on-startup <5-86400>", |
| 6496 | "OSPF maximum / infinite-distance metric\n" |
| 6497 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6498 | "Automatically advertise stub Router-LSA on startup of OSPF\n" |
| 6499 | "Time (seconds) to advertise self as stub-router\n") |
| 6500 | { |
| 6501 | unsigned int seconds; |
| 6502 | struct ospf *ospf = vty->index; |
| 6503 | |
| 6504 | if (argc != 1) |
| 6505 | { |
| 6506 | vty_out (vty, "%% Must supply stub-router period"); |
| 6507 | return CMD_WARNING; |
| 6508 | } |
| 6509 | |
| 6510 | VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]); |
| 6511 | |
| 6512 | ospf->stub_router_startup_time = seconds; |
| 6513 | |
| 6514 | return CMD_SUCCESS; |
| 6515 | } |
| 6516 | |
| 6517 | DEFUN (no_ospf_max_metric_router_lsa_startup, |
| 6518 | no_ospf_max_metric_router_lsa_startup_cmd, |
| 6519 | "no max-metric router-lsa on-startup", |
| 6520 | NO_STR |
| 6521 | "OSPF maximum / infinite-distance metric\n" |
| 6522 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6523 | "Automatically advertise stub Router-LSA on startup of OSPF\n") |
| 6524 | { |
| 6525 | struct listnode *ln; |
| 6526 | struct ospf_area *area; |
| 6527 | struct ospf *ospf = vty->index; |
| 6528 | |
| 6529 | ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6530 | |
| 6531 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6532 | { |
| 6533 | SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED); |
| 6534 | OSPF_TIMER_OFF (area->t_stub_router); |
| 6535 | |
| 6536 | /* Don't trample on admin stub routed */ |
| 6537 | if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6538 | { |
| 6539 | UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED); |
Paul Jakma | c363d38 | 2010-01-24 22:42:13 +0000 | [diff] [blame] | 6540 | ospf_router_lsa_update_area (area); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 6541 | } |
| 6542 | } |
| 6543 | return CMD_SUCCESS; |
| 6544 | } |
| 6545 | |
| 6546 | DEFUN (ospf_max_metric_router_lsa_shutdown, |
| 6547 | ospf_max_metric_router_lsa_shutdown_cmd, |
| 6548 | "max-metric router-lsa on-shutdown <5-86400>", |
| 6549 | "OSPF maximum / infinite-distance metric\n" |
| 6550 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6551 | "Advertise stub-router prior to full shutdown of OSPF\n" |
| 6552 | "Time (seconds) to wait till full shutdown\n") |
| 6553 | { |
| 6554 | unsigned int seconds; |
| 6555 | struct ospf *ospf = vty->index; |
| 6556 | |
| 6557 | if (argc != 1) |
| 6558 | { |
| 6559 | vty_out (vty, "%% Must supply stub-router shutdown period"); |
| 6560 | return CMD_WARNING; |
| 6561 | } |
| 6562 | |
| 6563 | VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]); |
| 6564 | |
| 6565 | ospf->stub_router_shutdown_time = seconds; |
| 6566 | |
| 6567 | return CMD_SUCCESS; |
| 6568 | } |
| 6569 | |
| 6570 | DEFUN (no_ospf_max_metric_router_lsa_shutdown, |
| 6571 | no_ospf_max_metric_router_lsa_shutdown_cmd, |
| 6572 | "no max-metric router-lsa on-shutdown", |
| 6573 | NO_STR |
| 6574 | "OSPF maximum / infinite-distance metric\n" |
| 6575 | "Advertise own Router-LSA with infinite distance (stub router)\n" |
| 6576 | "Advertise stub-router prior to full shutdown of OSPF\n") |
| 6577 | { |
| 6578 | struct ospf *ospf = vty->index; |
| 6579 | |
| 6580 | ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED; |
| 6581 | |
| 6582 | return CMD_SUCCESS; |
| 6583 | } |
| 6584 | |
| 6585 | static void |
| 6586 | config_write_stub_router (struct vty *vty, struct ospf *ospf) |
| 6587 | { |
| 6588 | struct listnode *ln; |
| 6589 | struct ospf_area *area; |
| 6590 | |
| 6591 | if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6592 | vty_out (vty, " max-metric router-lsa on-startup %u%s", |
| 6593 | ospf->stub_router_startup_time, VTY_NEWLINE); |
| 6594 | if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED) |
| 6595 | vty_out (vty, " max-metric router-lsa on-shutdown %u%s", |
| 6596 | ospf->stub_router_shutdown_time, VTY_NEWLINE); |
| 6597 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area)) |
| 6598 | { |
| 6599 | if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED)) |
| 6600 | { |
| 6601 | vty_out (vty, " max-metric router-lsa administrative%s", |
| 6602 | VTY_NEWLINE); |
| 6603 | break; |
| 6604 | } |
| 6605 | } |
| 6606 | return; |
| 6607 | } |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6608 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6609 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6610 | show_ip_ospf_route_network (struct vty *vty, struct route_table *rt) |
| 6611 | { |
| 6612 | struct route_node *rn; |
| 6613 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6614 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6615 | struct ospf_path *path; |
| 6616 | |
| 6617 | vty_out (vty, "============ OSPF network routing table ============%s", |
| 6618 | VTY_NEWLINE); |
| 6619 | |
| 6620 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6621 | if ((or = rn->info) != NULL) |
| 6622 | { |
| 6623 | char buf1[19]; |
| 6624 | snprintf (buf1, 19, "%s/%d", |
| 6625 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6626 | |
| 6627 | switch (or->path_type) |
| 6628 | { |
| 6629 | case OSPF_PATH_INTER_AREA: |
| 6630 | if (or->type == OSPF_DESTINATION_NETWORK) |
| 6631 | vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost, |
| 6632 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6633 | else if (or->type == OSPF_DESTINATION_DISCARD) |
| 6634 | vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE); |
| 6635 | break; |
| 6636 | case OSPF_PATH_INTRA_AREA: |
| 6637 | vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost, |
| 6638 | inet_ntoa (or->u.std.area_id), VTY_NEWLINE); |
| 6639 | break; |
| 6640 | default: |
| 6641 | break; |
| 6642 | } |
| 6643 | |
| 6644 | if (or->type == OSPF_DESTINATION_NETWORK) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6645 | for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6646 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6647 | if (if_lookup_by_index(path->ifindex)) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6648 | { |
| 6649 | if (path->nexthop.s_addr == 0) |
| 6650 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6651 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6652 | else |
| 6653 | vty_out (vty, "%24s via %s, %s%s", "", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6654 | inet_ntoa (path->nexthop), |
| 6655 | ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6656 | } |
| 6657 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6658 | } |
| 6659 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6660 | } |
| 6661 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6662 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6663 | show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs) |
| 6664 | { |
| 6665 | struct route_node *rn; |
| 6666 | struct ospf_route *or; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6667 | struct listnode *pnode; |
| 6668 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6669 | struct ospf_path *path; |
| 6670 | |
| 6671 | vty_out (vty, "============ OSPF router routing table =============%s", |
| 6672 | VTY_NEWLINE); |
| 6673 | for (rn = route_top (rtrs); rn; rn = route_next (rn)) |
| 6674 | if (rn->info) |
| 6675 | { |
| 6676 | int flag = 0; |
| 6677 | |
| 6678 | vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4)); |
| 6679 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6680 | for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or)) |
| 6681 | { |
| 6682 | if (flag++) |
| 6683 | vty_out (vty, "%24s", ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6684 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6685 | /* Show path. */ |
| 6686 | vty_out (vty, "%s [%d] area: %s", |
| 6687 | (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "), |
| 6688 | or->cost, inet_ntoa (or->u.std.area_id)); |
| 6689 | /* Show flags. */ |
| 6690 | vty_out (vty, "%s%s%s", |
| 6691 | (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""), |
| 6692 | (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""), |
| 6693 | VTY_NEWLINE); |
| 6694 | |
| 6695 | for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path)) |
| 6696 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6697 | if (if_lookup_by_index(path->ifindex)) |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6698 | { |
| 6699 | if (path->nexthop.s_addr == 0) |
| 6700 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6701 | "", ifindex2ifname (path->ifindex), |
| 6702 | VTY_NEWLINE); |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6703 | else |
| 6704 | vty_out (vty, "%24s via %s, %s%s", "", |
| 6705 | inet_ntoa (path->nexthop), |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6706 | ifindex2ifname (path->ifindex), |
| 6707 | VTY_NEWLINE); |
hasso | 54bedb5 | 2005-08-17 13:31:47 +0000 | [diff] [blame] | 6708 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6709 | } |
| 6710 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6711 | } |
| 6712 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6713 | } |
| 6714 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6715 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6716 | show_ip_ospf_route_external (struct vty *vty, struct route_table *rt) |
| 6717 | { |
| 6718 | struct route_node *rn; |
| 6719 | struct ospf_route *er; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6720 | struct listnode *pnode, *pnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6721 | struct ospf_path *path; |
| 6722 | |
| 6723 | vty_out (vty, "============ OSPF external routing table ===========%s", |
| 6724 | VTY_NEWLINE); |
| 6725 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 6726 | if ((er = rn->info) != NULL) |
| 6727 | { |
| 6728 | char buf1[19]; |
| 6729 | snprintf (buf1, 19, "%s/%d", |
| 6730 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen); |
| 6731 | |
| 6732 | switch (er->path_type) |
| 6733 | { |
| 6734 | case OSPF_PATH_TYPE1_EXTERNAL: |
| 6735 | vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1, |
| 6736 | er->cost, er->u.ext.tag, VTY_NEWLINE); |
| 6737 | break; |
| 6738 | case OSPF_PATH_TYPE2_EXTERNAL: |
| 6739 | vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost, |
| 6740 | er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE); |
| 6741 | break; |
| 6742 | } |
| 6743 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6744 | for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6745 | { |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6746 | if (if_lookup_by_index(path->ifindex)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6747 | { |
| 6748 | if (path->nexthop.s_addr == 0) |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6749 | vty_out (vty, "%24s directly attached to %s%s", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6750 | "", ifindex2ifname (path->ifindex), VTY_NEWLINE); |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6751 | else |
| 6752 | vty_out (vty, "%24s via %s, %s%s", "", |
Joakim Tjernlund | a8ba847 | 2009-07-27 12:42:34 +0200 | [diff] [blame] | 6753 | inet_ntoa (path->nexthop), |
| 6754 | ifindex2ifname (path->ifindex), |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 6755 | VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6756 | } |
| 6757 | } |
| 6758 | } |
| 6759 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6760 | } |
| 6761 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6762 | DEFUN (show_ip_ospf_border_routers, |
| 6763 | show_ip_ospf_border_routers_cmd, |
| 6764 | "show ip ospf border-routers", |
| 6765 | SHOW_STR |
| 6766 | IP_STR |
| 6767 | "show all the ABR's and ASBR's\n" |
| 6768 | "for this area\n") |
| 6769 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6770 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6771 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6772 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6773 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6774 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6775 | return CMD_SUCCESS; |
| 6776 | } |
| 6777 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6778 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6779 | { |
| 6780 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6781 | return CMD_SUCCESS; |
| 6782 | } |
| 6783 | |
| 6784 | /* Show Network routes. |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6785 | show_ip_ospf_route_network (vty, ospf->new_table); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6786 | |
| 6787 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6788 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6789 | |
| 6790 | return CMD_SUCCESS; |
| 6791 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6792 | |
| 6793 | DEFUN (show_ip_ospf_route, |
| 6794 | show_ip_ospf_route_cmd, |
| 6795 | "show ip ospf route", |
| 6796 | SHOW_STR |
| 6797 | IP_STR |
| 6798 | "OSPF information\n" |
| 6799 | "OSPF routing table\n") |
| 6800 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 6801 | struct ospf *ospf; |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6802 | |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6803 | if ((ospf = ospf_lookup ()) == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6804 | { |
Paul Jakma | cac3b5c | 2006-05-11 13:31:11 +0000 | [diff] [blame] | 6805 | vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6806 | return CMD_SUCCESS; |
| 6807 | } |
| 6808 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6809 | if (ospf->new_table == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6810 | { |
| 6811 | vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE); |
| 6812 | return CMD_SUCCESS; |
| 6813 | } |
| 6814 | |
| 6815 | /* Show Network routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6816 | show_ip_ospf_route_network (vty, ospf->new_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6817 | |
| 6818 | /* Show Router routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6819 | show_ip_ospf_route_router (vty, ospf->new_rtrs); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6820 | |
| 6821 | /* Show AS External routes. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 6822 | show_ip_ospf_route_external (vty, ospf->old_external_route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6823 | |
| 6824 | return CMD_SUCCESS; |
| 6825 | } |
| 6826 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6827 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6828 | const char *ospf_abr_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6829 | { |
| 6830 | "unknown", |
| 6831 | "standard", |
| 6832 | "ibm", |
| 6833 | "cisco", |
| 6834 | "shortcut" |
| 6835 | }; |
| 6836 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6837 | const char *ospf_shortcut_mode_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6838 | { |
| 6839 | "default", |
| 6840 | "enable", |
| 6841 | "disable" |
| 6842 | }; |
| 6843 | |
| 6844 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6845 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6846 | area_id2str (char *buf, int length, struct ospf_area *area) |
| 6847 | { |
| 6848 | memset (buf, 0, length); |
| 6849 | |
| 6850 | if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
| 6851 | strncpy (buf, inet_ntoa (area->area_id), length); |
| 6852 | else |
| 6853 | sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr)); |
| 6854 | } |
| 6855 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 6856 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6857 | const char *ospf_int_type_str[] = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6858 | { |
| 6859 | "unknown", /* should never be used. */ |
| 6860 | "point-to-point", |
| 6861 | "broadcast", |
| 6862 | "non-broadcast", |
| 6863 | "point-to-multipoint", |
| 6864 | "virtual-link", /* should never be used. */ |
| 6865 | "loopback" |
| 6866 | }; |
| 6867 | |
| 6868 | /* Configuration write function for ospfd. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 6869 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6870 | config_write_interface (struct vty *vty) |
| 6871 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 6872 | struct listnode *n1, *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6873 | struct interface *ifp; |
| 6874 | struct crypt_key *ck; |
| 6875 | int write = 0; |
| 6876 | struct route_node *rn = NULL; |
| 6877 | struct ospf_if_params *params; |
| 6878 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6879 | for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6880 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6881 | if (memcmp (ifp->name, "VLINK", 5) == 0) |
| 6882 | continue; |
| 6883 | |
| 6884 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 6885 | vty_out (vty, "interface %s%s", ifp->name, |
| 6886 | VTY_NEWLINE); |
| 6887 | if (ifp->desc) |
| 6888 | vty_out (vty, " description %s%s", ifp->desc, |
| 6889 | VTY_NEWLINE); |
| 6890 | |
| 6891 | write++; |
| 6892 | |
| 6893 | params = IF_DEF_PARAMS (ifp); |
| 6894 | |
| 6895 | do { |
| 6896 | /* Interface Network print. */ |
| 6897 | if (OSPF_IF_PARAM_CONFIGURED (params, type) && |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6898 | params->type != OSPF_IFTYPE_LOOPBACK) |
| 6899 | { |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 6900 | if (params->type != ospf_default_iftype(ifp)) |
hasso | 7b90143 | 2004-08-31 13:37:42 +0000 | [diff] [blame] | 6901 | { |
| 6902 | vty_out (vty, " ip ospf network %s", |
| 6903 | ospf_int_type_str[params->type]); |
| 6904 | if (params != IF_DEF_PARAMS (ifp)) |
| 6905 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6906 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6907 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6908 | } |
| 6909 | |
| 6910 | /* OSPF interface authentication print */ |
| 6911 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && |
| 6912 | params->auth_type != OSPF_AUTH_NOTSET) |
| 6913 | { |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 6914 | const char *auth_str; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6915 | |
| 6916 | /* Translation tables are not that much help here due to syntax |
| 6917 | of the simple option */ |
| 6918 | switch (params->auth_type) |
| 6919 | { |
| 6920 | |
| 6921 | case OSPF_AUTH_NULL: |
| 6922 | auth_str = " null"; |
| 6923 | break; |
| 6924 | |
| 6925 | case OSPF_AUTH_SIMPLE: |
| 6926 | auth_str = ""; |
| 6927 | break; |
| 6928 | |
| 6929 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 6930 | auth_str = " message-digest"; |
| 6931 | break; |
| 6932 | |
| 6933 | default: |
| 6934 | auth_str = ""; |
| 6935 | break; |
| 6936 | } |
| 6937 | |
| 6938 | vty_out (vty, " ip ospf authentication%s", auth_str); |
| 6939 | if (params != IF_DEF_PARAMS (ifp)) |
| 6940 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6941 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6942 | } |
| 6943 | |
| 6944 | /* Simple Authentication Password print. */ |
| 6945 | if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) && |
| 6946 | params->auth_simple[0] != '\0') |
| 6947 | { |
| 6948 | vty_out (vty, " ip ospf authentication-key %s", |
| 6949 | params->auth_simple); |
| 6950 | if (params != IF_DEF_PARAMS (ifp)) |
| 6951 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6952 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6953 | } |
| 6954 | |
| 6955 | /* Cryptographic Authentication Key print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 6956 | for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6957 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6958 | vty_out (vty, " ip ospf message-digest-key %d md5 %s", |
| 6959 | ck->key_id, ck->auth_key); |
| 6960 | if (params != IF_DEF_PARAMS (ifp)) |
| 6961 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6962 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6963 | } |
| 6964 | |
| 6965 | /* Interface Output Cost print. */ |
| 6966 | if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd)) |
| 6967 | { |
| 6968 | vty_out (vty, " ip ospf cost %u", params->output_cost_cmd); |
| 6969 | if (params != IF_DEF_PARAMS (ifp)) |
| 6970 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6971 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6972 | } |
| 6973 | |
| 6974 | /* Hello Interval print. */ |
| 6975 | if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) && |
| 6976 | params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT) |
| 6977 | { |
| 6978 | vty_out (vty, " ip ospf hello-interval %u", params->v_hello); |
| 6979 | if (params != IF_DEF_PARAMS (ifp)) |
| 6980 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 6981 | vty_out (vty, "%s", VTY_NEWLINE); |
| 6982 | } |
| 6983 | |
| 6984 | |
| 6985 | /* Router Dead Interval print. */ |
| 6986 | if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) && |
| 6987 | params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT) |
| 6988 | { |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 6989 | vty_out (vty, " ip ospf dead-interval "); |
| 6990 | |
| 6991 | /* fast hello ? */ |
| 6992 | if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello)) |
| 6993 | vty_out (vty, "minimal hello-multiplier %d", |
| 6994 | params->fast_hello); |
| 6995 | else |
| 6996 | vty_out (vty, "%u", params->v_wait); |
| 6997 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 6998 | if (params != IF_DEF_PARAMS (ifp)) |
| 6999 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7000 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7001 | } |
| 7002 | |
| 7003 | /* Router Priority print. */ |
| 7004 | if (OSPF_IF_PARAM_CONFIGURED (params, priority) && |
| 7005 | params->priority != OSPF_ROUTER_PRIORITY_DEFAULT) |
| 7006 | { |
| 7007 | vty_out (vty, " ip ospf priority %u", params->priority); |
| 7008 | if (params != IF_DEF_PARAMS (ifp)) |
| 7009 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7010 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7011 | } |
| 7012 | |
| 7013 | /* Retransmit Interval print. */ |
| 7014 | if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) && |
| 7015 | params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT) |
| 7016 | { |
| 7017 | vty_out (vty, " ip ospf retransmit-interval %u", |
| 7018 | params->retransmit_interval); |
| 7019 | if (params != IF_DEF_PARAMS (ifp)) |
| 7020 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7021 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7022 | } |
| 7023 | |
| 7024 | /* Transmit Delay print. */ |
| 7025 | if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) && |
| 7026 | params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7027 | { |
| 7028 | vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay); |
| 7029 | if (params != IF_DEF_PARAMS (ifp)) |
| 7030 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7031 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7032 | } |
| 7033 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 7034 | /* Area print. */ |
| 7035 | if (OSPF_IF_PARAM_CONFIGURED (params, if_area)) |
| 7036 | { |
Paul Jakma | 8a667cf | 2009-08-27 16:51:42 +0100 | [diff] [blame] | 7037 | vty_out (vty, " ip ospf area %s", inet_ntoa (params->if_area)); |
| 7038 | if (params != IF_DEF_PARAMS (ifp)) |
| 7039 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7040 | vty_out (vty, "%s", VTY_NEWLINE); |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 7041 | } |
| 7042 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7043 | /* MTU ignore print. */ |
| 7044 | if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) && |
| 7045 | params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT) |
| 7046 | { |
| 7047 | if (params->mtu_ignore == 0) |
| 7048 | vty_out (vty, " no ip ospf mtu-ignore"); |
| 7049 | else |
| 7050 | vty_out (vty, " ip ospf mtu-ignore"); |
| 7051 | if (params != IF_DEF_PARAMS (ifp)) |
| 7052 | vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4)); |
| 7053 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7054 | } |
| 7055 | |
| 7056 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7057 | while (1) |
| 7058 | { |
| 7059 | if (rn == NULL) |
| 7060 | rn = route_top (IF_OIFS_PARAMS (ifp)); |
| 7061 | else |
| 7062 | rn = route_next (rn); |
| 7063 | |
| 7064 | if (rn == NULL) |
| 7065 | break; |
| 7066 | params = rn->info; |
| 7067 | if (params != NULL) |
| 7068 | break; |
| 7069 | } |
| 7070 | } while (rn); |
| 7071 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7072 | ospf_opaque_config_write_if (vty, ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7073 | } |
| 7074 | |
| 7075 | return write; |
| 7076 | } |
| 7077 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7078 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7079 | config_write_network_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7080 | { |
| 7081 | struct route_node *rn; |
| 7082 | u_char buf[INET_ADDRSTRLEN]; |
| 7083 | |
| 7084 | /* `network area' print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7085 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7086 | if (rn->info) |
| 7087 | { |
| 7088 | struct ospf_network *n = rn->info; |
| 7089 | |
| 7090 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7091 | |
| 7092 | /* Create Area ID string by specified Area ID format. */ |
| 7093 | if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7094 | strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7095 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7096 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7097 | (unsigned long int) ntohl (n->area_id.s_addr)); |
| 7098 | |
| 7099 | /* Network print. */ |
| 7100 | vty_out (vty, " network %s/%d area %s%s", |
| 7101 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7102 | buf, VTY_NEWLINE); |
| 7103 | } |
| 7104 | |
| 7105 | return 0; |
| 7106 | } |
| 7107 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7108 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7109 | config_write_ospf_area (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7110 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7111 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7112 | struct ospf_area *area; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7113 | u_char buf[INET_ADDRSTRLEN]; |
| 7114 | |
| 7115 | /* Area configuration print. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7116 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7117 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7118 | struct route_node *rn1; |
| 7119 | |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7120 | area_id2str ((char *) buf, INET_ADDRSTRLEN, area); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7121 | |
| 7122 | if (area->auth_type != OSPF_AUTH_NULL) |
| 7123 | { |
| 7124 | if (area->auth_type == OSPF_AUTH_SIMPLE) |
| 7125 | vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE); |
| 7126 | else |
| 7127 | vty_out (vty, " area %s authentication message-digest%s", |
| 7128 | buf, VTY_NEWLINE); |
| 7129 | } |
| 7130 | |
| 7131 | if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT) |
| 7132 | vty_out (vty, " area %s shortcut %s%s", buf, |
| 7133 | ospf_shortcut_mode_str[area->shortcut_configured], |
| 7134 | VTY_NEWLINE); |
| 7135 | |
| 7136 | if ((area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7137 | || (area->external_routing == OSPF_AREA_NSSA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7138 | ) |
| 7139 | { |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7140 | if (area->external_routing == OSPF_AREA_STUB) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7141 | vty_out (vty, " area %s stub", buf); |
paul | b0a053b | 2003-06-22 09:04:47 +0000 | [diff] [blame] | 7142 | else if (area->external_routing == OSPF_AREA_NSSA) |
| 7143 | { |
| 7144 | vty_out (vty, " area %s nssa", buf); |
| 7145 | switch (area->NSSATranslatorRole) |
| 7146 | { |
| 7147 | case OSPF_NSSA_ROLE_NEVER: |
| 7148 | vty_out (vty, " translate-never"); |
| 7149 | break; |
| 7150 | case OSPF_NSSA_ROLE_ALWAYS: |
| 7151 | vty_out (vty, " translate-always"); |
| 7152 | break; |
| 7153 | case OSPF_NSSA_ROLE_CANDIDATE: |
| 7154 | default: |
| 7155 | vty_out (vty, " translate-candidate"); |
| 7156 | } |
| 7157 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7158 | |
| 7159 | if (area->no_summary) |
| 7160 | vty_out (vty, " no-summary"); |
| 7161 | |
| 7162 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7163 | |
| 7164 | if (area->default_cost != 1) |
| 7165 | vty_out (vty, " area %s default-cost %d%s", buf, |
| 7166 | area->default_cost, VTY_NEWLINE); |
| 7167 | } |
| 7168 | |
| 7169 | for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1)) |
| 7170 | if (rn1->info) |
| 7171 | { |
| 7172 | struct ospf_area_range *range = rn1->info; |
| 7173 | |
| 7174 | vty_out (vty, " area %s range %s/%d", buf, |
| 7175 | inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen); |
| 7176 | |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 7177 | if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7178 | vty_out (vty, " cost %d", range->cost_config); |
| 7179 | |
| 7180 | if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE)) |
| 7181 | vty_out (vty, " not-advertise"); |
| 7182 | |
| 7183 | if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE)) |
| 7184 | vty_out (vty, " substitute %s/%d", |
| 7185 | inet_ntoa (range->subst_addr), range->subst_masklen); |
| 7186 | |
| 7187 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7188 | } |
| 7189 | |
| 7190 | if (EXPORT_NAME (area)) |
| 7191 | vty_out (vty, " area %s export-list %s%s", buf, |
| 7192 | EXPORT_NAME (area), VTY_NEWLINE); |
| 7193 | |
| 7194 | if (IMPORT_NAME (area)) |
| 7195 | vty_out (vty, " area %s import-list %s%s", buf, |
| 7196 | IMPORT_NAME (area), VTY_NEWLINE); |
| 7197 | |
| 7198 | if (PREFIX_NAME_IN (area)) |
| 7199 | vty_out (vty, " area %s filter-list prefix %s in%s", buf, |
| 7200 | PREFIX_NAME_IN (area), VTY_NEWLINE); |
| 7201 | |
| 7202 | if (PREFIX_NAME_OUT (area)) |
| 7203 | vty_out (vty, " area %s filter-list prefix %s out%s", buf, |
| 7204 | PREFIX_NAME_OUT (area), VTY_NEWLINE); |
| 7205 | } |
| 7206 | |
| 7207 | return 0; |
| 7208 | } |
| 7209 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7210 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7211 | config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7212 | { |
| 7213 | struct ospf_nbr_nbma *nbr_nbma; |
| 7214 | struct route_node *rn; |
| 7215 | |
| 7216 | /* Static Neighbor configuration print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7217 | for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7218 | if ((nbr_nbma = rn->info)) |
| 7219 | { |
| 7220 | vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr)); |
| 7221 | |
| 7222 | if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT) |
| 7223 | vty_out (vty, " priority %d", nbr_nbma->priority); |
| 7224 | |
| 7225 | if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT) |
| 7226 | vty_out (vty, " poll-interval %d", nbr_nbma->v_poll); |
| 7227 | |
| 7228 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7229 | } |
| 7230 | |
| 7231 | return 0; |
| 7232 | } |
| 7233 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7234 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7235 | config_write_virtual_link (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7236 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7237 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7238 | struct ospf_vl_data *vl_data; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7239 | u_char buf[INET_ADDRSTRLEN]; |
| 7240 | |
| 7241 | /* Virtual-Link print */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7242 | for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7243 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7244 | struct listnode *n2; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7245 | struct crypt_key *ck; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7246 | struct ospf_interface *oi; |
| 7247 | |
| 7248 | if (vl_data != NULL) |
| 7249 | { |
| 7250 | memset (buf, 0, INET_ADDRSTRLEN); |
| 7251 | |
| 7252 | if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS) |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7253 | strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7254 | else |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 7255 | sprintf ((char *) buf, "%lu", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7256 | (unsigned long int) ntohl (vl_data->vl_area_id.s_addr)); |
| 7257 | oi = vl_data->vl_oi; |
| 7258 | |
| 7259 | /* timers */ |
| 7260 | if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT || |
| 7261 | OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT || |
| 7262 | OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT || |
| 7263 | OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT) |
| 7264 | vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s", |
| 7265 | buf, |
| 7266 | inet_ntoa (vl_data->vl_peer), |
| 7267 | OSPF_IF_PARAM (oi, v_hello), |
| 7268 | OSPF_IF_PARAM (oi, retransmit_interval), |
| 7269 | OSPF_IF_PARAM (oi, transmit_delay), |
| 7270 | OSPF_IF_PARAM (oi, v_wait), |
| 7271 | VTY_NEWLINE); |
| 7272 | else |
| 7273 | vty_out (vty, " area %s virtual-link %s%s", buf, |
| 7274 | inet_ntoa (vl_data->vl_peer), VTY_NEWLINE); |
| 7275 | /* Auth key */ |
| 7276 | if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0') |
| 7277 | vty_out (vty, " area %s virtual-link %s authentication-key %s%s", |
| 7278 | buf, |
| 7279 | inet_ntoa (vl_data->vl_peer), |
| 7280 | IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple, |
| 7281 | VTY_NEWLINE); |
| 7282 | /* md5 keys */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7283 | for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt, |
| 7284 | n2, ck)) |
| 7285 | vty_out (vty, " area %s virtual-link %s" |
| 7286 | " message-digest-key %d md5 %s%s", |
| 7287 | buf, |
| 7288 | inet_ntoa (vl_data->vl_peer), |
| 7289 | ck->key_id, ck->auth_key, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7290 | |
| 7291 | } |
| 7292 | } |
| 7293 | |
| 7294 | return 0; |
| 7295 | } |
| 7296 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7297 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7298 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7299 | config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7300 | { |
| 7301 | int type; |
| 7302 | |
| 7303 | /* redistribute print. */ |
| 7304 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 7305 | if (type != zclient->redist_default && |
| 7306 | vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7307 | { |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7308 | vty_out (vty, " redistribute %s", zebra_route_string(type)); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7309 | if (ospf->dmetric[type].value >= 0) |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7310 | vty_out (vty, " metric %d", ospf->dmetric[type].value); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7311 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7312 | if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7313 | vty_out (vty, " metric-type 1"); |
| 7314 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7315 | if (ROUTEMAP_NAME (ospf, type)) |
| 7316 | vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7317 | |
| 7318 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7319 | } |
| 7320 | |
| 7321 | return 0; |
| 7322 | } |
| 7323 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7324 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7325 | config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7326 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7327 | if (ospf->default_metric != -1) |
| 7328 | vty_out (vty, " default-metric %d%s", ospf->default_metric, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7329 | VTY_NEWLINE); |
| 7330 | return 0; |
| 7331 | } |
| 7332 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7333 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7334 | config_write_ospf_distribute (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7335 | { |
| 7336 | int type; |
| 7337 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7338 | if (ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7339 | { |
| 7340 | /* distribute-list print. */ |
| 7341 | for (type = 0; type < ZEBRA_ROUTE_MAX; type++) |
Denis Ovsienko | 171c9a9 | 2011-09-10 16:40:23 +0400 | [diff] [blame] | 7342 | if (DISTRIBUTE_NAME (ospf, type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7343 | vty_out (vty, " distribute-list %s out %s%s", |
Denis Ovsienko | 171c9a9 | 2011-09-10 16:40:23 +0400 | [diff] [blame] | 7344 | DISTRIBUTE_NAME (ospf, type), |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 7345 | zebra_route_string(type), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7346 | |
| 7347 | /* default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7348 | if (ospf->default_originate != DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7349 | { |
paul | c42c177 | 2006-01-10 20:36:49 +0000 | [diff] [blame] | 7350 | vty_out (vty, " default-information originate"); |
| 7351 | if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS) |
| 7352 | vty_out (vty, " always"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7353 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7354 | if (ospf->dmetric[DEFAULT_ROUTE].value >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7355 | vty_out (vty, " metric %d", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7356 | ospf->dmetric[DEFAULT_ROUTE].value); |
| 7357 | if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7358 | vty_out (vty, " metric-type 1"); |
| 7359 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7360 | if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)) |
| 7361 | vty_out (vty, " route-map %s", |
| 7362 | ROUTEMAP_NAME (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7363 | |
| 7364 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7365 | } |
| 7366 | |
| 7367 | } |
| 7368 | |
| 7369 | return 0; |
| 7370 | } |
| 7371 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7372 | static int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7373 | config_write_ospf_distance (struct vty *vty, struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7374 | { |
| 7375 | struct route_node *rn; |
| 7376 | struct ospf_distance *odistance; |
| 7377 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7378 | if (ospf->distance_all) |
| 7379 | vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7380 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7381 | if (ospf->distance_intra |
| 7382 | || ospf->distance_inter |
| 7383 | || ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7384 | { |
| 7385 | vty_out (vty, " distance ospf"); |
| 7386 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7387 | if (ospf->distance_intra) |
| 7388 | vty_out (vty, " intra-area %d", ospf->distance_intra); |
| 7389 | if (ospf->distance_inter) |
| 7390 | vty_out (vty, " inter-area %d", ospf->distance_inter); |
| 7391 | if (ospf->distance_external) |
| 7392 | vty_out (vty, " external %d", ospf->distance_external); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7393 | |
| 7394 | vty_out (vty, "%s", VTY_NEWLINE); |
| 7395 | } |
| 7396 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7397 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7398 | if ((odistance = rn->info) != NULL) |
| 7399 | { |
| 7400 | vty_out (vty, " distance %d %s/%d %s%s", odistance->distance, |
| 7401 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 7402 | odistance->access_list ? odistance->access_list : "", |
| 7403 | VTY_NEWLINE); |
| 7404 | } |
| 7405 | return 0; |
| 7406 | } |
| 7407 | |
| 7408 | /* OSPF configuration write function. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7409 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7410 | ospf_config_write (struct vty *vty) |
| 7411 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7412 | struct ospf *ospf; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7413 | struct interface *ifp; |
| 7414 | struct ospf_interface *oi; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 7415 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7416 | int write = 0; |
| 7417 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 7418 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7419 | if (ospf != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7420 | { |
| 7421 | /* `router ospf' print. */ |
| 7422 | vty_out (vty, "router ospf%s", VTY_NEWLINE); |
| 7423 | |
| 7424 | write++; |
| 7425 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7426 | if (!ospf->networks) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7427 | return write; |
| 7428 | |
| 7429 | /* Router ID print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7430 | if (ospf->router_id_static.s_addr != 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7431 | vty_out (vty, " ospf router-id %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7432 | inet_ntoa (ospf->router_id_static), VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7433 | |
| 7434 | /* ABR type print. */ |
paul | d57834f | 2005-07-12 20:04:22 +0000 | [diff] [blame] | 7435 | if (ospf->abr_type != OSPF_ABR_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7436 | vty_out (vty, " ospf abr-type %s%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7437 | ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7438 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7439 | /* log-adjacency-changes flag print. */ |
| 7440 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES)) |
| 7441 | { |
| 7442 | vty_out(vty, " log-adjacency-changes"); |
| 7443 | if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL)) |
| 7444 | vty_out(vty, " detail"); |
| 7445 | vty_out(vty, "%s", VTY_NEWLINE); |
| 7446 | } |
| 7447 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7448 | /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7449 | if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7450 | vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE); |
| 7451 | |
| 7452 | /* auto-cost reference-bandwidth configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7453 | if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH) |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7454 | { |
| 7455 | vty_out (vty, "! Important: ensure reference bandwidth " |
| 7456 | "is consistent across all routers%s", VTY_NEWLINE); |
| 7457 | vty_out (vty, " auto-cost reference-bandwidth %d%s", |
| 7458 | ospf->ref_bandwidth / 1000, VTY_NEWLINE); |
| 7459 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7460 | |
Michael Rossberg | 2ef762e | 2015-07-27 07:56:25 +0200 | [diff] [blame] | 7461 | /* LSA timers */ |
| 7462 | if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL) |
| 7463 | vty_out (vty, " timers throttle lsa all %d%s", |
| 7464 | ospf->min_ls_interval, VTY_NEWLINE); |
| 7465 | if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL) |
| 7466 | vty_out (vty, " timers lsa arrival %d%s", |
| 7467 | ospf->min_ls_arrival, VTY_NEWLINE); |
| 7468 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7469 | /* SPF timers print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7470 | if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT || |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7471 | ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT || |
| 7472 | ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT) |
| 7473 | vty_out (vty, " timers throttle spf %d %d %d%s", |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7474 | ospf->spf_delay, ospf->spf_holdtime, |
paul | ea4ffc9 | 2005-10-21 20:04:41 +0000 | [diff] [blame] | 7475 | ospf->spf_max_holdtime, VTY_NEWLINE); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7476 | |
| 7477 | /* Max-metric router-lsa print */ |
| 7478 | config_write_stub_router (vty, ospf); |
| 7479 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7480 | /* SPF refresh parameters print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7481 | if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7482 | vty_out (vty, " refresh timer %d%s", |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7483 | ospf->lsa_refresh_interval, VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7484 | |
| 7485 | /* Redistribute information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7486 | config_write_ospf_redistribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7487 | |
| 7488 | /* passive-interface print. */ |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7489 | if (ospf->passive_interface_default == OSPF_IF_PASSIVE) |
| 7490 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); |
| 7491 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7492 | for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7493 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface) |
| 7494 | && IF_DEF_PARAMS (ifp)->passive_interface != |
| 7495 | ospf->passive_interface_default) |
| 7496 | { |
| 7497 | vty_out (vty, " %spassive-interface %s%s", |
| 7498 | IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ", |
| 7499 | ifp->name, VTY_NEWLINE); |
| 7500 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7501 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7502 | { |
| 7503 | if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface)) |
| 7504 | continue; |
| 7505 | if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp), |
| 7506 | passive_interface)) |
| 7507 | { |
| 7508 | if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface) |
| 7509 | continue; |
| 7510 | } |
| 7511 | else if (oi->params->passive_interface == ospf->passive_interface_default) |
| 7512 | continue; |
| 7513 | |
| 7514 | vty_out (vty, " %spassive-interface %s %s%s", |
| 7515 | oi->params->passive_interface ? "" : "no ", |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 7516 | oi->ifp->name, |
| 7517 | inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7518 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7519 | |
| 7520 | /* Network area print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7521 | config_write_network_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7522 | |
| 7523 | /* Area config print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7524 | config_write_ospf_area (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7525 | |
| 7526 | /* static neighbor print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7527 | config_write_ospf_nbr_nbma (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7528 | |
| 7529 | /* Virtual-Link print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7530 | config_write_virtual_link (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7531 | |
| 7532 | /* Default metric configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7533 | config_write_ospf_default_metric (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7534 | |
| 7535 | /* Distribute-list and default-information print. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7536 | config_write_ospf_distribute (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7537 | |
| 7538 | /* Distance configuration. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7539 | config_write_ospf_distance (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7540 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 7541 | ospf_opaque_config_write_router (vty, ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7542 | } |
| 7543 | |
| 7544 | return write; |
| 7545 | } |
| 7546 | |
| 7547 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7548 | ospf_vty_show_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7549 | { |
| 7550 | /* "show ip ospf" commands. */ |
| 7551 | install_element (VIEW_NODE, &show_ip_ospf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7552 | |
| 7553 | /* "show ip ospf database" commands. */ |
| 7554 | install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd); |
| 7555 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd); |
| 7556 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd); |
| 7557 | install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); |
| 7558 | install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd); |
| 7559 | install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd); |
| 7560 | install_element (VIEW_NODE, &show_ip_ospf_database_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7561 | |
| 7562 | /* "show ip ospf interface" commands. */ |
| 7563 | install_element (VIEW_NODE, &show_ip_ospf_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7564 | |
| 7565 | /* "show ip ospf neighbor" commands. */ |
| 7566 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd); |
| 7567 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd); |
| 7568 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd); |
| 7569 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd); |
| 7570 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd); |
| 7571 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd); |
| 7572 | install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7573 | |
| 7574 | /* "show ip ospf route" commands. */ |
| 7575 | install_element (VIEW_NODE, &show_ip_ospf_route_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7576 | install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7577 | } |
| 7578 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7579 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7580 | /* ospfd's interface node. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 7581 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7582 | { |
| 7583 | INTERFACE_NODE, |
| 7584 | "%s(config-if)# ", |
| 7585 | 1 |
| 7586 | }; |
| 7587 | |
| 7588 | /* Initialization of OSPF interface. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7589 | static void |
| 7590 | ospf_vty_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7591 | { |
| 7592 | /* Install interface node. */ |
| 7593 | install_node (&interface_node, config_write_interface); |
| 7594 | |
| 7595 | install_element (CONFIG_NODE, &interface_cmd); |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 7596 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7597 | install_default (INTERFACE_NODE); |
| 7598 | |
| 7599 | /* "description" commands. */ |
| 7600 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 7601 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 7602 | |
| 7603 | /* "ip ospf authentication" commands. */ |
| 7604 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd); |
| 7605 | install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd); |
| 7606 | install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd); |
| 7607 | install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd); |
| 7608 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd); |
| 7609 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd); |
| 7610 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd); |
| 7611 | install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd); |
| 7612 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd); |
| 7613 | install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd); |
| 7614 | |
| 7615 | /* "ip ospf message-digest-key" commands. */ |
| 7616 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd); |
| 7617 | install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd); |
| 7618 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd); |
| 7619 | install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd); |
| 7620 | |
| 7621 | /* "ip ospf cost" commands. */ |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7622 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd); |
| 7623 | install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd); |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 7624 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd); |
| 7625 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7626 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7627 | install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd); |
| 7628 | |
vincent | ba68253 | 2005-09-29 13:52:57 +0000 | [diff] [blame] | 7629 | /* "ip ospf mtu-ignore" commands. */ |
| 7630 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd); |
| 7631 | install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd); |
| 7632 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd); |
| 7633 | install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd); |
| 7634 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7635 | /* "ip ospf dead-interval" commands. */ |
| 7636 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd); |
| 7637 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7638 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd); |
| 7639 | install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7640 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd); |
| 7641 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd); |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 7642 | install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd); |
paul | f9ad937 | 2005-10-21 00:45:17 +0000 | [diff] [blame] | 7643 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7644 | /* "ip ospf hello-interval" commands. */ |
| 7645 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd); |
| 7646 | install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd); |
| 7647 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd); |
| 7648 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd); |
Daniel Walton | 24521e2 | 2015-05-19 18:03:48 -0700 | [diff] [blame] | 7649 | install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7650 | |
| 7651 | /* "ip ospf network" commands. */ |
| 7652 | install_element (INTERFACE_NODE, &ip_ospf_network_cmd); |
| 7653 | install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd); |
| 7654 | |
| 7655 | /* "ip ospf priority" commands. */ |
| 7656 | install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd); |
| 7657 | install_element (INTERFACE_NODE, &ip_ospf_priority_cmd); |
| 7658 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd); |
| 7659 | install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd); |
| 7660 | |
| 7661 | /* "ip ospf retransmit-interval" commands. */ |
| 7662 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd); |
| 7663 | install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd); |
| 7664 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd); |
| 7665 | install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd); |
| 7666 | |
| 7667 | /* "ip ospf transmit-delay" commands. */ |
| 7668 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd); |
| 7669 | install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd); |
| 7670 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd); |
| 7671 | install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd); |
| 7672 | |
Joakim Tjernlund | 738bce7 | 2009-08-07 13:48:15 +0200 | [diff] [blame] | 7673 | /* "ip ospf area" commands. */ |
| 7674 | install_element (INTERFACE_NODE, &ip_ospf_area_cmd); |
| 7675 | install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd); |
| 7676 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7677 | /* These commands are compatibitliy for previous version. */ |
| 7678 | install_element (INTERFACE_NODE, &ospf_authentication_key_cmd); |
| 7679 | install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd); |
| 7680 | install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd); |
| 7681 | install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7682 | install_element (INTERFACE_NODE, &ospf_cost_u32_cmd); |
| 7683 | install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7684 | install_element (INTERFACE_NODE, &no_ospf_cost_cmd); |
Denis Ovsienko | 827341b | 2009-09-28 19:34:59 +0400 | [diff] [blame] | 7685 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd); |
| 7686 | install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd); |
Denis Ovsienko | 9eff36b | 2009-04-10 18:51:24 +0400 | [diff] [blame] | 7687 | install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7688 | install_element (INTERFACE_NODE, &ospf_dead_interval_cmd); |
| 7689 | install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd); |
| 7690 | install_element (INTERFACE_NODE, &ospf_hello_interval_cmd); |
| 7691 | install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd); |
| 7692 | install_element (INTERFACE_NODE, &ospf_network_cmd); |
| 7693 | install_element (INTERFACE_NODE, &no_ospf_network_cmd); |
| 7694 | install_element (INTERFACE_NODE, &ospf_priority_cmd); |
| 7695 | install_element (INTERFACE_NODE, &no_ospf_priority_cmd); |
| 7696 | install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd); |
| 7697 | install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd); |
| 7698 | install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd); |
| 7699 | install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd); |
| 7700 | } |
| 7701 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7702 | static void |
| 7703 | ospf_vty_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7704 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7705 | install_element (OSPF_NODE, &ospf_redistribute_source_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7706 | install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd); |
| 7707 | |
| 7708 | install_element (OSPF_NODE, &ospf_distribute_list_out_cmd); |
| 7709 | install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd); |
| 7710 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7711 | install_element (OSPF_NODE, &ospf_default_information_originate_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7712 | install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd); |
| 7713 | |
| 7714 | install_element (OSPF_NODE, &ospf_default_metric_cmd); |
| 7715 | install_element (OSPF_NODE, &no_ospf_default_metric_cmd); |
| 7716 | install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd); |
| 7717 | |
| 7718 | install_element (OSPF_NODE, &ospf_distance_cmd); |
| 7719 | install_element (OSPF_NODE, &no_ospf_distance_cmd); |
| 7720 | install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd); |
Christian Franke | 6f2a670 | 2013-09-30 12:27:52 +0000 | [diff] [blame] | 7721 | install_element (OSPF_NODE, &ospf_distance_ospf_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7722 | #if 0 |
| 7723 | install_element (OSPF_NODE, &ospf_distance_source_cmd); |
| 7724 | install_element (OSPF_NODE, &no_ospf_distance_source_cmd); |
| 7725 | install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd); |
| 7726 | install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd); |
| 7727 | #endif /* 0 */ |
| 7728 | } |
| 7729 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 7730 | static struct cmd_node ospf_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7731 | { |
| 7732 | OSPF_NODE, |
| 7733 | "%s(config-router)# ", |
| 7734 | 1 |
| 7735 | }; |
| 7736 | |
Vipin Kumar | a90dc87 | 2015-05-19 17:58:13 -0700 | [diff] [blame] | 7737 | static void |
| 7738 | ospf_interface_clear (struct interface *ifp) |
| 7739 | { |
| 7740 | if (!if_is_operative (ifp)) return; |
| 7741 | |
| 7742 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) |
| 7743 | zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name); |
| 7744 | |
| 7745 | ospf_if_reset(ifp); |
| 7746 | } |
| 7747 | |
| 7748 | DEFUN (clear_ip_ospf_interface, |
| 7749 | clear_ip_ospf_interface_cmd, |
| 7750 | "clear ip ospf interface [IFNAME]", |
| 7751 | CLEAR_STR |
| 7752 | IP_STR |
| 7753 | "OSPF information\n" |
| 7754 | "Interface information\n" |
| 7755 | "Interface name\n") |
| 7756 | { |
| 7757 | struct interface *ifp; |
| 7758 | struct listnode *node; |
| 7759 | |
| 7760 | if (argc == 0) /* Clear all the ospfv2 interfaces. */ |
| 7761 | { |
| 7762 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
| 7763 | ospf_interface_clear(ifp); |
| 7764 | } |
| 7765 | else /* Interface name is specified. */ |
| 7766 | { |
| 7767 | if ((ifp = if_lookup_by_name (argv[0])) == NULL) |
| 7768 | vty_out (vty, "No such interface name%s", VTY_NEWLINE); |
| 7769 | else |
| 7770 | ospf_interface_clear(ifp); |
| 7771 | } |
| 7772 | |
| 7773 | return CMD_SUCCESS; |
| 7774 | } |
| 7775 | |
| 7776 | void |
| 7777 | ospf_vty_clear_init (void) |
| 7778 | { |
| 7779 | install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd); |
| 7780 | } |
| 7781 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 7782 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7783 | /* Install OSPF related vty commands. */ |
| 7784 | void |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 7785 | ospf_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7786 | { |
| 7787 | /* Install ospf top node. */ |
| 7788 | install_node (&ospf_node, ospf_config_write); |
| 7789 | |
| 7790 | /* "router ospf" commands. */ |
| 7791 | install_element (CONFIG_NODE, &router_ospf_cmd); |
| 7792 | install_element (CONFIG_NODE, &no_router_ospf_cmd); |
| 7793 | |
| 7794 | install_default (OSPF_NODE); |
| 7795 | |
| 7796 | /* "ospf router-id" commands. */ |
| 7797 | install_element (OSPF_NODE, &ospf_router_id_cmd); |
| 7798 | install_element (OSPF_NODE, &no_ospf_router_id_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7799 | install_element (OSPF_NODE, &router_ospf_id_cmd); |
| 7800 | install_element (OSPF_NODE, &no_router_ospf_id_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7801 | |
| 7802 | /* "passive-interface" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7803 | install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd); |
| 7804 | install_element (OSPF_NODE, &ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7805 | install_element (OSPF_NODE, &ospf_passive_interface_default_cmd); |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7806 | install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd); |
| 7807 | install_element (OSPF_NODE, &no_ospf_passive_interface_cmd); |
Paul Jakma | 7ffa8fa | 2006-10-22 20:07:53 +0000 | [diff] [blame] | 7808 | install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7809 | |
| 7810 | /* "ospf abr-type" commands. */ |
| 7811 | install_element (OSPF_NODE, &ospf_abr_type_cmd); |
| 7812 | install_element (OSPF_NODE, &no_ospf_abr_type_cmd); |
| 7813 | |
Andrew J. Schorr | d7e60dd | 2006-06-29 20:20:52 +0000 | [diff] [blame] | 7814 | /* "ospf log-adjacency-changes" commands. */ |
| 7815 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd); |
| 7816 | install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd); |
| 7817 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd); |
| 7818 | install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd); |
| 7819 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7820 | /* "ospf rfc1583-compatible" commands. */ |
| 7821 | install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd); |
| 7822 | install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd); |
| 7823 | install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd); |
| 7824 | install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd); |
| 7825 | |
| 7826 | /* "network area" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7827 | install_element (OSPF_NODE, &ospf_network_area_cmd); |
| 7828 | install_element (OSPF_NODE, &no_ospf_network_area_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7829 | |
| 7830 | /* "area authentication" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7831 | install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd); |
| 7832 | install_element (OSPF_NODE, &ospf_area_authentication_cmd); |
| 7833 | install_element (OSPF_NODE, &no_ospf_area_authentication_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7834 | |
| 7835 | /* "area range" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7836 | install_element (OSPF_NODE, &ospf_area_range_cmd); |
| 7837 | install_element (OSPF_NODE, &ospf_area_range_advertise_cmd); |
| 7838 | install_element (OSPF_NODE, &ospf_area_range_cost_cmd); |
| 7839 | install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd); |
| 7840 | install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd); |
| 7841 | install_element (OSPF_NODE, &no_ospf_area_range_cmd); |
| 7842 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd); |
| 7843 | install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd); |
| 7844 | install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd); |
| 7845 | install_element (OSPF_NODE, &ospf_area_range_substitute_cmd); |
| 7846 | install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7847 | |
| 7848 | /* "area virtual-link" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7849 | install_element (OSPF_NODE, &ospf_area_vlink_cmd); |
| 7850 | install_element (OSPF_NODE, &no_ospf_area_vlink_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7851 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7852 | install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd); |
| 7853 | install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7854 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7855 | install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd); |
| 7856 | install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7857 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7858 | install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd); |
| 7859 | install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7860 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7861 | install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd); |
| 7862 | install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7863 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7864 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd); |
| 7865 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd); |
| 7866 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7867 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7868 | install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd); |
| 7869 | install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7870 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7871 | install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd); |
| 7872 | install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7873 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7874 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd); |
| 7875 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd); |
| 7876 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7877 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7878 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd); |
| 7879 | install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd); |
| 7880 | install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7881 | |
| 7882 | /* "area stub" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7883 | install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd); |
| 7884 | install_element (OSPF_NODE, &ospf_area_stub_cmd); |
| 7885 | install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd); |
| 7886 | install_element (OSPF_NODE, &no_ospf_area_stub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7887 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7888 | /* "area nssa" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7889 | install_element (OSPF_NODE, &ospf_area_nssa_cmd); |
| 7890 | install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd); |
| 7891 | install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd); |
| 7892 | install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd); |
| 7893 | install_element (OSPF_NODE, &no_ospf_area_nssa_cmd); |
| 7894 | install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7895 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7896 | install_element (OSPF_NODE, &ospf_area_default_cost_cmd); |
| 7897 | install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7898 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7899 | install_element (OSPF_NODE, &ospf_area_shortcut_cmd); |
| 7900 | install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7901 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7902 | install_element (OSPF_NODE, &ospf_area_export_list_cmd); |
| 7903 | install_element (OSPF_NODE, &no_ospf_area_export_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7904 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7905 | install_element (OSPF_NODE, &ospf_area_filter_list_cmd); |
| 7906 | install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7907 | |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7908 | install_element (OSPF_NODE, &ospf_area_import_list_cmd); |
| 7909 | install_element (OSPF_NODE, &no_ospf_area_import_list_cmd); |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7910 | |
Michael Rossberg | 2ef762e | 2015-07-27 07:56:25 +0200 | [diff] [blame] | 7911 | /* LSA timer commands */ |
| 7912 | install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd); |
| 7913 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd); |
| 7914 | install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd); |
| 7915 | install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd); |
| 7916 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7917 | /* SPF timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7918 | install_element (OSPF_NODE, &ospf_timers_spf_cmd); |
| 7919 | install_element (OSPF_NODE, &no_ospf_timers_spf_cmd); |
paul | d24f6e2 | 2005-10-21 09:23:12 +0000 | [diff] [blame] | 7920 | install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd); |
| 7921 | install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd); |
| 7922 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7923 | /* refresh timer commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7924 | install_element (OSPF_NODE, &ospf_refresh_timer_cmd); |
| 7925 | install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd); |
| 7926 | install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7927 | |
paul | 88d6cf3 | 2005-10-29 12:50:09 +0000 | [diff] [blame] | 7928 | /* max-metric commands */ |
| 7929 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd); |
| 7930 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd); |
| 7931 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd); |
| 7932 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd); |
| 7933 | install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd); |
| 7934 | install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd); |
| 7935 | |
| 7936 | /* reference bandwidth commands */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7937 | install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd); |
| 7938 | install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7939 | |
| 7940 | /* "neighbor" commands. */ |
paul | a2c6283 | 2003-04-23 17:01:31 +0000 | [diff] [blame] | 7941 | install_element (OSPF_NODE, &ospf_neighbor_cmd); |
| 7942 | install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd); |
| 7943 | install_element (OSPF_NODE, &ospf_neighbor_priority_cmd); |
| 7944 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd); |
| 7945 | install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd); |
| 7946 | install_element (OSPF_NODE, &no_ospf_neighbor_cmd); |
| 7947 | install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd); |
| 7948 | install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 7949 | |
| 7950 | /* Init interface related vty commands. */ |
| 7951 | ospf_vty_if_init (); |
| 7952 | |
| 7953 | /* Init zebra related vty commands. */ |
| 7954 | ospf_vty_zebra_init (); |
| 7955 | } |