jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_circuit.h |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public Licenseas published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
hasso | 37da8c0 | 2004-05-19 11:38:40 +0000 | [diff] [blame] | 23 | #ifdef GNU_LINUX |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 24 | #include <net/ethernet.h> |
hasso | 37da8c0 | 2004-05-19 11:38:40 +0000 | [diff] [blame] | 25 | #else |
| 26 | #include <netinet/if_ether.h> |
| 27 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 28 | |
Paul Jakma | 238497f | 2007-08-07 18:49:18 +0000 | [diff] [blame] | 29 | #ifndef ETHER_ADDR_LEN |
| 30 | #define ETHER_ADDR_LEN ETHERADDRL |
| 31 | #endif |
| 32 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 33 | #include "log.h" |
| 34 | #include "memory.h" |
| 35 | #include "if.h" |
| 36 | #include "linklist.h" |
| 37 | #include "command.h" |
| 38 | #include "thread.h" |
| 39 | #include "hash.h" |
| 40 | #include "prefix.h" |
| 41 | #include "stream.h" |
| 42 | |
| 43 | #include "isisd/dict.h" |
| 44 | #include "isisd/include-netbsd/iso.h" |
| 45 | #include "isisd/isis_constants.h" |
| 46 | #include "isisd/isis_common.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 47 | #include "isisd/isis_flags.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 48 | #include "isisd/isis_circuit.h" |
| 49 | #include "isisd/isis_tlv.h" |
| 50 | #include "isisd/isis_lsp.h" |
| 51 | #include "isisd/isis_pdu.h" |
| 52 | #include "isisd/isis_network.h" |
| 53 | #include "isisd/isis_misc.h" |
| 54 | #include "isisd/isis_constants.h" |
| 55 | #include "isisd/isis_adjacency.h" |
| 56 | #include "isisd/isis_dr.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 57 | #include "isisd/isisd.h" |
| 58 | #include "isisd/isis_csm.h" |
| 59 | #include "isisd/isis_events.h" |
| 60 | |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 61 | /* |
| 62 | * Prototypes. |
| 63 | */ |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 64 | int isis_interface_config_write(struct vty *); |
| 65 | int isis_if_new_hook(struct interface *); |
| 66 | int isis_if_delete_hook(struct interface *); |
| 67 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 68 | struct isis_circuit * |
| 69 | isis_circuit_new () |
| 70 | { |
| 71 | struct isis_circuit *circuit; |
| 72 | int i; |
| 73 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 74 | circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit)); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 75 | if (circuit == NULL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 76 | { |
| 77 | zlog_err ("Can't malloc isis circuit"); |
| 78 | return NULL; |
| 79 | } |
| 80 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 81 | /* |
| 82 | * Default values |
| 83 | */ |
| 84 | circuit->is_type = IS_LEVEL_1_AND_2; |
| 85 | circuit->flags = 0; |
| 86 | circuit->pad_hellos = 1; |
| 87 | for (i = 0; i < 2; i++) |
| 88 | { |
| 89 | circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL; |
| 90 | circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER; |
| 91 | circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL; |
| 92 | circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL; |
| 93 | circuit->priority[i] = DEFAULT_PRIORITY; |
| 94 | circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRIC; |
| 95 | circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED; |
| 96 | circuit->metrics[i].metric_error = METRICS_UNSUPPORTED; |
| 97 | circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED; |
| 98 | circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC; |
| 99 | } |
| 100 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 101 | return circuit; |
| 102 | } |
| 103 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 104 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 105 | isis_circuit_del (struct isis_circuit *circuit) |
| 106 | { |
| 107 | if (!circuit) |
| 108 | return; |
| 109 | |
| 110 | isis_circuit_if_unbind (circuit, circuit->interface); |
| 111 | |
| 112 | /* and lastly the circuit itself */ |
| 113 | XFREE (MTYPE_ISIS_CIRCUIT, circuit); |
| 114 | |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 119 | isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area) |
| 120 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 121 | assert (area); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 122 | circuit->area = area; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 123 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 124 | /* |
Christian Franke | 7324ae1 | 2015-11-10 18:04:48 +0100 | [diff] [blame] | 125 | * Whenever the is-type of an area is changed, the is-type of each circuit |
| 126 | * in that area is updated to a non-empty subset of the area is-type. |
| 127 | * Inversely, when configuring a new circuit, this property should be |
| 128 | * ensured as well. |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 129 | */ |
Christian Franke | 7324ae1 | 2015-11-10 18:04:48 +0100 | [diff] [blame] | 130 | if (area->is_type != IS_LEVEL_1_AND_2) |
| 131 | circuit->is_type = area->is_type; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 132 | |
| 133 | /* |
| 134 | * Add the circuit into area |
| 135 | */ |
| 136 | listnode_add (area->circuit_list, circuit); |
| 137 | |
| 138 | circuit->idx = flags_get_index (&area->flags); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 139 | |
| 140 | return; |
| 141 | } |
| 142 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 143 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 144 | isis_circuit_deconfigure (struct isis_circuit *circuit, struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 145 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 146 | /* Free the index of SRM and SSN flags */ |
| 147 | flags_free_index (&area->flags, circuit->idx); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 148 | circuit->idx = 0; |
| 149 | /* Remove circuit from area */ |
| 150 | assert (circuit->area == area); |
| 151 | listnode_delete (area->circuit_list, circuit); |
| 152 | circuit->area = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 153 | |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | struct isis_circuit * |
| 158 | circuit_lookup_by_ifp (struct interface *ifp, struct list *list) |
| 159 | { |
| 160 | struct isis_circuit *circuit = NULL; |
| 161 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 162 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 163 | if (!list) |
| 164 | return NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 165 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 166 | for (ALL_LIST_ELEMENTS_RO (list, node, circuit)) |
| 167 | if (circuit->interface == ifp) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 168 | { |
| 169 | assert (ifp->info == circuit); |
| 170 | return circuit; |
| 171 | } |
| 172 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 173 | return NULL; |
| 174 | } |
| 175 | |
| 176 | struct isis_circuit * |
| 177 | circuit_scan_by_ifp (struct interface *ifp) |
| 178 | { |
| 179 | struct isis_area *area; |
| 180 | struct listnode *node; |
| 181 | struct isis_circuit *circuit; |
| 182 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 183 | if (ifp->info) |
| 184 | return (struct isis_circuit *)ifp->info; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 185 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 186 | if (isis->area_list) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 187 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 188 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
| 189 | { |
| 190 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 191 | if (circuit) |
| 192 | return circuit; |
| 193 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 194 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 195 | return circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 196 | } |
| 197 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 198 | static struct isis_circuit * |
| 199 | isis_circuit_lookup (struct vty *vty) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 200 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 201 | struct interface *ifp; |
| 202 | struct isis_circuit *circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 203 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 204 | ifp = (struct interface *) vty->index; |
| 205 | if (!ifp) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 206 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 207 | vty_out (vty, "Invalid interface %s", VTY_NEWLINE); |
| 208 | return NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 209 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 210 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 211 | circuit = circuit_scan_by_ifp (ifp); |
| 212 | if (!circuit) |
| 213 | { |
| 214 | vty_out (vty, "ISIS is not enabled on circuit %s%s", |
| 215 | ifp->name, VTY_NEWLINE); |
| 216 | return NULL; |
| 217 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 218 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 219 | return circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | void |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 223 | isis_circuit_add_addr (struct isis_circuit *circuit, |
| 224 | struct connected *connected) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 225 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 226 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 227 | struct prefix_ipv4 *ipv4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 228 | u_char buf[BUFSIZ]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 229 | #ifdef HAVE_IPV6 |
| 230 | struct prefix_ipv6 *ipv6; |
| 231 | #endif /* HAVE_IPV6 */ |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 232 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 233 | memset (&buf, 0, BUFSIZ); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 234 | if (connected->address->family == AF_INET) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 235 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 236 | u_int32_t addr = connected->address->u.prefix4.s_addr; |
| 237 | addr = ntohl (addr); |
| 238 | if (IPV4_NET0(addr) || |
| 239 | IPV4_NET127(addr) || |
| 240 | IN_CLASSD(addr) || |
| 241 | IPV4_LINKLOCAL(addr)) |
| 242 | return; |
| 243 | |
| 244 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ipv4)) |
| 245 | if (prefix_same ((struct prefix *) ipv4, connected->address)) |
| 246 | return; |
| 247 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 248 | ipv4 = prefix_ipv4_new (); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 249 | ipv4->prefixlen = connected->address->prefixlen; |
| 250 | ipv4->prefix = connected->address->u.prefix4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 251 | listnode_add (circuit->ip_addrs, ipv4); |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 252 | if (circuit->area) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 253 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 254 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 255 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 256 | prefix2str (connected->address, buf, BUFSIZ); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 257 | zlog_debug ("Added IP address %s to circuit %d", buf, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 258 | circuit->circuit_id); |
| 259 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 260 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 261 | #ifdef HAVE_IPV6 |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 262 | if (connected->address->family == AF_INET6) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 263 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 264 | if (IN6_IS_ADDR_LOOPBACK(&connected->address->u.prefix6)) |
| 265 | return; |
| 266 | |
| 267 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ipv6)) |
| 268 | if (prefix_same ((struct prefix *) ipv6, connected->address)) |
| 269 | return; |
| 270 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ipv6)) |
| 271 | if (prefix_same ((struct prefix *) ipv6, connected->address)) |
| 272 | return; |
| 273 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 274 | ipv6 = prefix_ipv6_new (); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 275 | ipv6->prefixlen = connected->address->prefixlen; |
| 276 | ipv6->prefix = connected->address->u.prefix6; |
| 277 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 278 | if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 279 | listnode_add (circuit->ipv6_link, ipv6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 280 | else |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 281 | listnode_add (circuit->ipv6_non_link, ipv6); |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 282 | if (circuit->area) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 283 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 284 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 285 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 286 | prefix2str (connected->address, buf, BUFSIZ); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 287 | zlog_debug ("Added IPv6 address %s to circuit %d", buf, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 288 | circuit->circuit_id); |
| 289 | #endif /* EXTREME_DEBUG */ |
| 290 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 291 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 292 | return; |
| 293 | } |
| 294 | |
| 295 | void |
| 296 | isis_circuit_del_addr (struct isis_circuit *circuit, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 297 | struct connected *connected) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 298 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 299 | struct prefix_ipv4 *ipv4, *ip = NULL; |
| 300 | struct listnode *node; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 301 | u_char buf[BUFSIZ]; |
| 302 | #ifdef HAVE_IPV6 |
| 303 | struct prefix_ipv6 *ipv6, *ip6 = NULL; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 304 | int found = 0; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 305 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 306 | |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 307 | memset (&buf, 0, BUFSIZ); |
| 308 | if (connected->address->family == AF_INET) |
| 309 | { |
| 310 | ipv4 = prefix_ipv4_new (); |
| 311 | ipv4->prefixlen = connected->address->prefixlen; |
| 312 | ipv4->prefix = connected->address->u.prefix4; |
| 313 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 314 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 315 | if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 316 | break; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 317 | |
| 318 | if (ip) |
| 319 | { |
| 320 | listnode_delete (circuit->ip_addrs, ip); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 321 | if (circuit->area) |
| 322 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 323 | } |
| 324 | else |
| 325 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 326 | prefix2str (connected->address, (char *)buf, BUFSIZ); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 327 | zlog_warn ("Nonexitant ip address %s removal attempt from \ |
| 328 | circuit %d", buf, circuit->circuit_id); |
Christian Franke | ec87416 | 2015-11-10 18:33:12 +0100 | [diff] [blame] | 329 | zlog_warn ("Current ip addresses on %s:", circuit->interface->name); |
| 330 | for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, ip)) |
| 331 | { |
| 332 | prefix2str((struct prefix*)ip, (char *)buf, BUFSIZ); |
| 333 | zlog_warn(" %s", buf); |
| 334 | } |
| 335 | zlog_warn("End of addresses"); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 336 | } |
David Lamparter | e8aca32 | 2012-11-27 01:10:30 +0000 | [diff] [blame] | 337 | |
| 338 | prefix_ipv4_free (ipv4); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 339 | } |
| 340 | #ifdef HAVE_IPV6 |
| 341 | if (connected->address->family == AF_INET6) |
| 342 | { |
| 343 | ipv6 = prefix_ipv6_new (); |
| 344 | ipv6->prefixlen = connected->address->prefixlen; |
| 345 | ipv6->prefix = connected->address->u.prefix6; |
| 346 | |
| 347 | if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix)) |
| 348 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 349 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 350 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 351 | if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6)) |
| 352 | break; |
| 353 | } |
| 354 | if (ip6) |
| 355 | { |
| 356 | listnode_delete (circuit->ipv6_link, ip6); |
| 357 | found = 1; |
| 358 | } |
| 359 | } |
| 360 | else |
| 361 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 362 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 363 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 364 | if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6)) |
| 365 | break; |
| 366 | } |
| 367 | if (ip6) |
| 368 | { |
| 369 | listnode_delete (circuit->ipv6_non_link, ip6); |
| 370 | found = 1; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | if (!found) |
| 375 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 376 | prefix2str (connected->address, (char *)buf, BUFSIZ); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 377 | zlog_warn ("Nonexitant ip address %s removal attempt from \ |
| 378 | circuit %d", buf, circuit->circuit_id); |
Christian Franke | ec87416 | 2015-11-10 18:33:12 +0100 | [diff] [blame] | 379 | zlog_warn ("Current ip addresses on %s:", circuit->interface->name); |
| 380 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip6)) |
| 381 | { |
| 382 | prefix2str((struct prefix*)ip6, (char *)buf, BUFSIZ); |
| 383 | zlog_warn(" %s", buf); |
| 384 | } |
| 385 | zlog_warn(" -----"); |
| 386 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip6)) |
| 387 | { |
| 388 | prefix2str((struct prefix*)ip6, (char *)buf, BUFSIZ); |
| 389 | zlog_warn(" %s", buf); |
| 390 | } |
| 391 | zlog_warn("End of addresses"); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 392 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 393 | else if (circuit->area) |
| 394 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
David Lamparter | e8aca32 | 2012-11-27 01:10:30 +0000 | [diff] [blame] | 395 | |
| 396 | prefix_ipv6_free (ipv6); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 397 | } |
| 398 | #endif /* HAVE_IPV6 */ |
| 399 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 400 | } |
| 401 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 402 | static u_char |
| 403 | isis_circuit_id_gen (struct interface *ifp) |
| 404 | { |
| 405 | u_char id = 0; |
| 406 | char ifname[16]; |
| 407 | unsigned int i; |
| 408 | int start = -1, end = -1; |
| 409 | |
| 410 | /* |
| 411 | * Get a stable circuit id from ifname. This makes |
| 412 | * the ifindex from flapping when netdevs are created |
| 413 | * and deleted on the fly. Note that this circuit id |
| 414 | * is used in pseudo lsps so it is better to be stable. |
| 415 | * The following code works on any reasonanle ifname |
| 416 | * like: eth1 or trk-1.1 etc. |
| 417 | */ |
| 418 | for (i = 0; i < strlen (ifp->name); i++) |
| 419 | { |
David Lamparter | 52f02b4 | 2015-04-10 09:14:30 +0200 | [diff] [blame] | 420 | if (isdigit((unsigned char)ifp->name[i])) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 421 | { |
| 422 | if (start < 0) |
| 423 | { |
| 424 | start = i; |
| 425 | end = i + 1; |
| 426 | } |
| 427 | else |
| 428 | { |
| 429 | end = i + 1; |
| 430 | } |
| 431 | } |
| 432 | else if (start >= 0) |
| 433 | break; |
| 434 | } |
| 435 | |
| 436 | if ((start >= 0) && (end >= start) && (end - start) < 16) |
| 437 | { |
| 438 | memset (ifname, 0, 16); |
| 439 | strncpy (ifname, &ifp->name[start], end - start); |
| 440 | id = (u_char)atoi(ifname); |
| 441 | } |
| 442 | |
| 443 | /* Try to be unique. */ |
| 444 | if (!id) |
| 445 | id = (u_char)((ifp->ifindex & 0xff) | 0x80); |
| 446 | |
| 447 | return id; |
| 448 | } |
| 449 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 450 | void |
| 451 | isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp) |
| 452 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 453 | struct listnode *node, *nnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 454 | struct connected *conn; |
| 455 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 456 | circuit->circuit_id = isis_circuit_id_gen (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 457 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 458 | isis_circuit_if_bind (circuit, ifp); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 459 | /* isis_circuit_update_addrs (circuit, ifp); */ |
| 460 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 461 | if (if_is_broadcast (ifp)) |
| 462 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 463 | if (circuit->circ_type_config == CIRCUIT_T_P2P) |
| 464 | circuit->circ_type = CIRCUIT_T_P2P; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 465 | else |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 466 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 467 | } |
| 468 | else if (if_is_pointopoint (ifp)) |
| 469 | { |
| 470 | circuit->circ_type = CIRCUIT_T_P2P; |
| 471 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 472 | else if (if_is_loopback (ifp)) |
| 473 | { |
| 474 | circuit->circ_type = CIRCUIT_T_LOOPBACK; |
| 475 | circuit->is_passive = 1; |
| 476 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 477 | else |
| 478 | { |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 479 | /* It's normal in case of loopback etc. */ |
| 480 | if (isis->debugs & DEBUG_EVENTS) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 481 | zlog_debug ("isis_circuit_if_add: unsupported media"); |
| 482 | circuit->circ_type = CIRCUIT_T_UNKNOWN; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 483 | } |
| 484 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 485 | circuit->ip_addrs = list_new (); |
| 486 | #ifdef HAVE_IPV6 |
| 487 | circuit->ipv6_link = list_new (); |
| 488 | circuit->ipv6_non_link = list_new (); |
| 489 | #endif /* HAVE_IPV6 */ |
| 490 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 491 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn)) |
| 492 | isis_circuit_add_addr (circuit, conn); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 493 | |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 498 | isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 499 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 500 | struct listnode *node, *nnode; |
| 501 | struct connected *conn; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 502 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 503 | assert (circuit->interface == ifp); |
| 504 | |
| 505 | /* destroy addresses */ |
| 506 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn)) |
| 507 | isis_circuit_del_addr (circuit, conn); |
| 508 | |
| 509 | if (circuit->ip_addrs) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 510 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 511 | assert (listcount(circuit->ip_addrs) == 0); |
| 512 | list_delete (circuit->ip_addrs); |
| 513 | circuit->ip_addrs = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 514 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 515 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 516 | #ifdef HAVE_IPV6 |
| 517 | if (circuit->ipv6_link) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 518 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 519 | assert (listcount(circuit->ipv6_link) == 0); |
| 520 | list_delete (circuit->ipv6_link); |
| 521 | circuit->ipv6_link = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 522 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 523 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 524 | if (circuit->ipv6_non_link) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 525 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 526 | assert (listcount(circuit->ipv6_non_link) == 0); |
| 527 | list_delete (circuit->ipv6_non_link); |
| 528 | circuit->ipv6_non_link = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 529 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 530 | #endif /* HAVE_IPV6 */ |
| 531 | |
| 532 | circuit->circ_type = CIRCUIT_T_UNKNOWN; |
| 533 | circuit->circuit_id = 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 534 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 535 | return; |
| 536 | } |
| 537 | |
| 538 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 539 | isis_circuit_if_bind (struct isis_circuit *circuit, struct interface *ifp) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 540 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 541 | assert (circuit != NULL); |
| 542 | assert (ifp != NULL); |
| 543 | if (circuit->interface) |
| 544 | assert (circuit->interface == ifp); |
| 545 | else |
| 546 | circuit->interface = ifp; |
| 547 | if (ifp->info) |
| 548 | assert (ifp->info == circuit); |
| 549 | else |
| 550 | ifp->info = circuit; |
| 551 | } |
| 552 | |
| 553 | void |
| 554 | isis_circuit_if_unbind (struct isis_circuit *circuit, struct interface *ifp) |
| 555 | { |
| 556 | assert (circuit != NULL); |
| 557 | assert (ifp != NULL); |
| 558 | assert (circuit->interface == ifp); |
| 559 | assert (ifp->info == circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 560 | circuit->interface = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 561 | ifp->info = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 564 | static void |
| 565 | isis_circuit_update_all_srmflags (struct isis_circuit *circuit, int is_set) |
| 566 | { |
| 567 | struct isis_area *area; |
| 568 | struct isis_lsp *lsp; |
| 569 | dnode_t *dnode, *dnode_next; |
| 570 | int level; |
| 571 | |
| 572 | assert (circuit); |
| 573 | area = circuit->area; |
| 574 | assert (area); |
| 575 | for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) |
| 576 | { |
| 577 | if (level & circuit->is_type) |
| 578 | { |
| 579 | if (area->lspdb[level - 1] && |
| 580 | dict_count (area->lspdb[level - 1]) > 0) |
| 581 | { |
| 582 | for (dnode = dict_first (area->lspdb[level - 1]); |
| 583 | dnode != NULL; dnode = dnode_next) |
| 584 | { |
| 585 | dnode_next = dict_next (area->lspdb[level - 1], dnode); |
| 586 | lsp = dnode_get (dnode); |
| 587 | if (is_set) |
| 588 | { |
| 589 | ISIS_SET_FLAG (lsp->SRMflags, circuit); |
| 590 | } |
| 591 | else |
| 592 | { |
| 593 | ISIS_CLEAR_FLAG (lsp->SRMflags, circuit); |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | } |
| 599 | } |
| 600 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 601 | size_t |
| 602 | isis_circuit_pdu_size(struct isis_circuit *circuit) |
| 603 | { |
| 604 | return ISO_MTU(circuit); |
| 605 | } |
| 606 | |
| 607 | void |
| 608 | isis_circuit_stream(struct isis_circuit *circuit, struct stream **stream) |
| 609 | { |
| 610 | size_t stream_size = isis_circuit_pdu_size(circuit); |
| 611 | |
| 612 | if (!*stream) |
| 613 | { |
| 614 | *stream = stream_new(stream_size); |
| 615 | } |
| 616 | else |
| 617 | { |
| 618 | if (STREAM_SIZE(*stream) != stream_size) |
| 619 | stream_resize(*stream, stream_size); |
| 620 | stream_reset(*stream); |
| 621 | } |
| 622 | } |
| 623 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 624 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 625 | isis_circuit_up (struct isis_circuit *circuit) |
| 626 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 627 | int retv; |
| 628 | |
| 629 | /* Set the flags for all the lsps of the circuit. */ |
| 630 | isis_circuit_update_all_srmflags (circuit, 1); |
| 631 | |
| 632 | if (circuit->state == C_STATE_UP) |
| 633 | return ISIS_OK; |
| 634 | |
| 635 | if (circuit->is_passive) |
| 636 | return ISIS_OK; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 637 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 638 | if (circuit->area->lsp_mtu > isis_circuit_pdu_size(circuit)) |
| 639 | { |
| 640 | zlog_err("Interface MTU %zu on %s is too low to support area lsp mtu %u!", |
| 641 | isis_circuit_pdu_size(circuit), circuit->interface->name, |
| 642 | circuit->area->lsp_mtu); |
| 643 | isis_circuit_down(circuit); |
| 644 | return ISIS_ERROR; |
| 645 | } |
| 646 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 647 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 648 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 649 | /* |
| 650 | * Get the Hardware Address |
| 651 | */ |
| 652 | #ifdef HAVE_STRUCT_SOCKADDR_DL |
| 653 | #ifndef SUNOS_5 |
| 654 | if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN) |
| 655 | zlog_warn ("unsupported link layer"); |
| 656 | else |
| 657 | memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), |
| 658 | ETH_ALEN); |
| 659 | #endif |
| 660 | #else |
| 661 | if (circuit->interface->hw_addr_len != ETH_ALEN) |
| 662 | { |
| 663 | zlog_warn ("unsupported link layer"); |
| 664 | } |
| 665 | else |
| 666 | { |
| 667 | memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN); |
| 668 | } |
| 669 | #ifdef EXTREME_DEGUG |
| 670 | zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s", |
| 671 | circuit->interface->ifindex, ISO_MTU (circuit), |
| 672 | snpa_print (circuit->u.bc.snpa)); |
| 673 | #endif /* EXTREME_DEBUG */ |
| 674 | #endif /* HAVE_STRUCT_SOCKADDR_DL */ |
| 675 | |
| 676 | circuit->u.bc.adjdb[0] = list_new (); |
| 677 | circuit->u.bc.adjdb[1] = list_new (); |
| 678 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 679 | /* |
| 680 | * ISO 10589 - 8.4.1 Enabling of broadcast circuits |
| 681 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 682 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 683 | /* initilizing the hello sending threads |
| 684 | * for a broadcast IF |
| 685 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 686 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 687 | /* 8.4.1 a) commence sending of IIH PDUs */ |
| 688 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 689 | if (circuit->is_type & IS_LEVEL_1) |
| 690 | { |
| 691 | thread_add_event (master, send_lan_l1_hello, circuit, 0); |
| 692 | circuit->u.bc.lan_neighs[0] = list_new (); |
| 693 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 694 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 695 | if (circuit->is_type & IS_LEVEL_2) |
| 696 | { |
| 697 | thread_add_event (master, send_lan_l2_hello, circuit, 0); |
| 698 | circuit->u.bc.lan_neighs[1] = list_new (); |
| 699 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 700 | |
| 701 | /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */ |
| 702 | /* 8.4.1 c) FIXME: listen for ESH PDUs */ |
| 703 | |
| 704 | /* 8.4.1 d) */ |
| 705 | /* dr election will commence in... */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 706 | if (circuit->is_type & IS_LEVEL_1) |
| 707 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1, |
| 708 | circuit, 2 * circuit->hello_interval[0]); |
| 709 | if (circuit->is_type & IS_LEVEL_2) |
| 710 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2, |
| 711 | circuit, 2 * circuit->hello_interval[1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 712 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 713 | else |
| 714 | { |
| 715 | /* initializing the hello send threads |
| 716 | * for a ptp IF |
| 717 | */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 718 | circuit->u.p2p.neighbor = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 719 | thread_add_event (master, send_p2p_hello, circuit, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 720 | } |
| 721 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 722 | /* initializing PSNP timers */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 723 | if (circuit->is_type & IS_LEVEL_1) |
| 724 | THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit, |
| 725 | isis_jitter (circuit->psnp_interval[0], PSNP_JITTER)); |
| 726 | |
| 727 | if (circuit->is_type & IS_LEVEL_2) |
| 728 | THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit, |
| 729 | isis_jitter (circuit->psnp_interval[1], PSNP_JITTER)); |
| 730 | |
| 731 | /* unified init for circuits; ignore warnings below this level */ |
| 732 | retv = isis_sock_init (circuit); |
| 733 | if (retv != ISIS_OK) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 734 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 735 | isis_circuit_down (circuit); |
| 736 | return retv; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 737 | } |
| 738 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 739 | /* initialize the circuit streams after opening connection */ |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 740 | isis_circuit_stream(circuit, &circuit->rcv_stream); |
| 741 | isis_circuit_stream(circuit, &circuit->snd_stream); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 742 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 743 | #ifdef GNU_LINUX |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 744 | THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 745 | circuit->fd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 746 | #else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 747 | THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 748 | circuit->fd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 749 | #endif |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 750 | |
| 751 | circuit->lsp_queue = list_new (); |
| 752 | circuit->lsp_queue_last_cleared = time (NULL); |
| 753 | |
| 754 | return ISIS_OK; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 755 | } |
| 756 | |
| 757 | void |
| 758 | isis_circuit_down (struct isis_circuit *circuit) |
| 759 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 760 | if (circuit->state != C_STATE_UP) |
| 761 | return; |
| 762 | |
| 763 | /* Clear the flags for all the lsps of the circuit. */ |
| 764 | isis_circuit_update_all_srmflags (circuit, 0); |
| 765 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 766 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 767 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 768 | /* destroy neighbour lists */ |
| 769 | if (circuit->u.bc.lan_neighs[0]) |
| 770 | { |
| 771 | list_delete (circuit->u.bc.lan_neighs[0]); |
| 772 | circuit->u.bc.lan_neighs[0] = NULL; |
| 773 | } |
| 774 | if (circuit->u.bc.lan_neighs[1]) |
| 775 | { |
| 776 | list_delete (circuit->u.bc.lan_neighs[1]); |
| 777 | circuit->u.bc.lan_neighs[1] = NULL; |
| 778 | } |
| 779 | /* destroy adjacency databases */ |
| 780 | if (circuit->u.bc.adjdb[0]) |
| 781 | { |
| 782 | circuit->u.bc.adjdb[0]->del = isis_delete_adj; |
| 783 | list_delete (circuit->u.bc.adjdb[0]); |
| 784 | circuit->u.bc.adjdb[0] = NULL; |
| 785 | } |
| 786 | if (circuit->u.bc.adjdb[1]) |
| 787 | { |
| 788 | circuit->u.bc.adjdb[1]->del = isis_delete_adj; |
| 789 | list_delete (circuit->u.bc.adjdb[1]); |
| 790 | circuit->u.bc.adjdb[1] = NULL; |
| 791 | } |
| 792 | if (circuit->u.bc.is_dr[0]) |
| 793 | { |
| 794 | isis_dr_resign (circuit, 1); |
| 795 | circuit->u.bc.is_dr[0] = 0; |
| 796 | } |
| 797 | memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1); |
| 798 | if (circuit->u.bc.is_dr[1]) |
| 799 | { |
| 800 | isis_dr_resign (circuit, 2); |
| 801 | circuit->u.bc.is_dr[1] = 0; |
| 802 | } |
| 803 | memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1); |
| 804 | memset (circuit->u.bc.snpa, 0, ETH_ALEN); |
| 805 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 806 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]); |
| 807 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 808 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]); |
| 809 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 810 | THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[0]); |
| 811 | THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[1]); |
Christian Franke | 61010c3 | 2015-11-10 18:43:34 +0100 | [diff] [blame] | 812 | circuit->lsp_regenerate_pending[0] = 0; |
| 813 | circuit->lsp_regenerate_pending[1] = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 814 | } |
| 815 | else if (circuit->circ_type == CIRCUIT_T_P2P) |
| 816 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 817 | isis_delete_adj (circuit->u.p2p.neighbor); |
| 818 | circuit->u.p2p.neighbor = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 819 | THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello); |
| 820 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 821 | |
| 822 | /* Cancel all active threads */ |
| 823 | THREAD_TIMER_OFF (circuit->t_send_csnp[0]); |
| 824 | THREAD_TIMER_OFF (circuit->t_send_csnp[1]); |
| 825 | THREAD_TIMER_OFF (circuit->t_send_psnp[0]); |
| 826 | THREAD_TIMER_OFF (circuit->t_send_psnp[1]); |
| 827 | THREAD_OFF (circuit->t_read); |
| 828 | |
| 829 | if (circuit->lsp_queue) |
| 830 | { |
| 831 | circuit->lsp_queue->del = NULL; |
| 832 | list_delete (circuit->lsp_queue); |
| 833 | circuit->lsp_queue = NULL; |
| 834 | } |
| 835 | |
| 836 | /* send one gratuitous hello to spead up convergence */ |
| 837 | if (circuit->is_type & IS_LEVEL_1) |
| 838 | send_hello (circuit, IS_LEVEL_1); |
| 839 | if (circuit->is_type & IS_LEVEL_2) |
| 840 | send_hello (circuit, IS_LEVEL_2); |
| 841 | |
| 842 | circuit->upadjcount[0] = 0; |
| 843 | circuit->upadjcount[1] = 0; |
| 844 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 845 | /* close the socket */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 846 | if (circuit->fd) |
| 847 | { |
| 848 | close (circuit->fd); |
| 849 | circuit->fd = 0; |
| 850 | } |
| 851 | |
| 852 | if (circuit->rcv_stream != NULL) |
| 853 | { |
| 854 | stream_free (circuit->rcv_stream); |
| 855 | circuit->rcv_stream = NULL; |
| 856 | } |
| 857 | |
| 858 | if (circuit->snd_stream != NULL) |
| 859 | { |
| 860 | stream_free (circuit->snd_stream); |
| 861 | circuit->snd_stream = NULL; |
| 862 | } |
| 863 | |
| 864 | thread_cancel_event (master, circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 865 | |
| 866 | return; |
| 867 | } |
| 868 | |
| 869 | void |
| 870 | circuit_update_nlpids (struct isis_circuit *circuit) |
| 871 | { |
| 872 | circuit->nlpids.count = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 873 | |
| 874 | if (circuit->ip_router) |
| 875 | { |
| 876 | circuit->nlpids.nlpids[0] = NLPID_IP; |
| 877 | circuit->nlpids.count++; |
| 878 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 879 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 880 | if (circuit->ipv6_router) |
| 881 | { |
| 882 | circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6; |
| 883 | circuit->nlpids.count++; |
| 884 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 885 | #endif /* HAVE_IPV6 */ |
| 886 | return; |
| 887 | } |
| 888 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 889 | void |
| 890 | isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty, |
| 891 | char detail) |
| 892 | { |
| 893 | if (detail == ISIS_UI_LEVEL_BRIEF) |
| 894 | { |
| 895 | vty_out (vty, " %-12s", circuit->interface->name); |
| 896 | vty_out (vty, "0x%-7x", circuit->circuit_id); |
| 897 | vty_out (vty, "%-9s", circuit_state2string (circuit->state)); |
| 898 | vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type)); |
| 899 | vty_out (vty, "%-9s", circuit_t2string (circuit->is_type)); |
| 900 | vty_out (vty, "%s", VTY_NEWLINE); |
| 901 | } |
| 902 | |
| 903 | if (detail == ISIS_UI_LEVEL_DETAIL) |
| 904 | { |
Christian Franke | cb32a19 | 2015-11-10 18:33:13 +0100 | [diff] [blame] | 905 | struct listnode *node; |
| 906 | struct prefix *ip_addr; |
| 907 | u_char buf[BUFSIZ]; |
| 908 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 909 | vty_out (vty, " Interface: %s", circuit->interface->name); |
| 910 | vty_out (vty, ", State: %s", circuit_state2string (circuit->state)); |
| 911 | if (circuit->is_passive) |
| 912 | vty_out (vty, ", Passive"); |
| 913 | else |
| 914 | vty_out (vty, ", Active"); |
| 915 | vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id); |
| 916 | vty_out (vty, "%s", VTY_NEWLINE); |
| 917 | vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type)); |
| 918 | vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type)); |
| 919 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 920 | vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa)); |
| 921 | vty_out (vty, "%s", VTY_NEWLINE); |
| 922 | if (circuit->is_type & IS_LEVEL_1) |
| 923 | { |
| 924 | vty_out (vty, " Level-1 Information:%s", VTY_NEWLINE); |
| 925 | if (circuit->area->newmetric) |
| 926 | vty_out (vty, " Metric: %d", circuit->te_metric[0]); |
| 927 | else |
| 928 | vty_out (vty, " Metric: %d", |
| 929 | circuit->metrics[0].metric_default); |
| 930 | if (!circuit->is_passive) |
| 931 | { |
| 932 | vty_out (vty, ", Active neighbors: %u%s", |
| 933 | circuit->upadjcount[0], VTY_NEWLINE); |
| 934 | vty_out (vty, " Hello interval: %u, " |
| 935 | "Holddown count: %u %s%s", |
| 936 | circuit->hello_interval[0], |
| 937 | circuit->hello_multiplier[0], |
| 938 | (circuit->pad_hellos ? "(pad)" : "(no-pad)"), |
| 939 | VTY_NEWLINE); |
| 940 | vty_out (vty, " CNSP interval: %u, " |
| 941 | "PSNP interval: %u%s", |
| 942 | circuit->csnp_interval[0], |
| 943 | circuit->psnp_interval[0], VTY_NEWLINE); |
| 944 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 945 | vty_out (vty, " LAN Priority: %u, %s%s", |
| 946 | circuit->priority[0], |
| 947 | (circuit->u.bc.is_dr[0] ? \ |
| 948 | "is DIS" : "is not DIS"), VTY_NEWLINE); |
| 949 | } |
| 950 | else |
| 951 | { |
| 952 | vty_out (vty, "%s", VTY_NEWLINE); |
| 953 | } |
| 954 | } |
| 955 | if (circuit->is_type & IS_LEVEL_2) |
| 956 | { |
| 957 | vty_out (vty, " Level-2 Information:%s", VTY_NEWLINE); |
| 958 | if (circuit->area->newmetric) |
| 959 | vty_out (vty, " Metric: %d", circuit->te_metric[1]); |
| 960 | else |
| 961 | vty_out (vty, " Metric: %d", |
| 962 | circuit->metrics[1].metric_default); |
| 963 | if (!circuit->is_passive) |
| 964 | { |
| 965 | vty_out (vty, ", Active neighbors: %u%s", |
| 966 | circuit->upadjcount[1], VTY_NEWLINE); |
| 967 | vty_out (vty, " Hello interval: %u, " |
| 968 | "Holddown count: %u %s%s", |
| 969 | circuit->hello_interval[1], |
| 970 | circuit->hello_multiplier[1], |
| 971 | (circuit->pad_hellos ? "(pad)" : "(no-pad)"), |
| 972 | VTY_NEWLINE); |
| 973 | vty_out (vty, " CNSP interval: %u, " |
| 974 | "PSNP interval: %u%s", |
| 975 | circuit->csnp_interval[1], |
| 976 | circuit->psnp_interval[1], VTY_NEWLINE); |
| 977 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 978 | vty_out (vty, " LAN Priority: %u, %s%s", |
| 979 | circuit->priority[1], |
| 980 | (circuit->u.bc.is_dr[1] ? \ |
| 981 | "is DIS" : "is not DIS"), VTY_NEWLINE); |
| 982 | } |
| 983 | else |
| 984 | { |
| 985 | vty_out (vty, "%s", VTY_NEWLINE); |
| 986 | } |
| 987 | } |
| 988 | if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0) |
| 989 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 990 | vty_out (vty, " IP Prefix(es):%s", VTY_NEWLINE); |
| 991 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr)) |
| 992 | { |
| 993 | prefix2str (ip_addr, (char*)buf, BUFSIZ), |
| 994 | vty_out (vty, " %s%s", buf, VTY_NEWLINE); |
| 995 | } |
| 996 | } |
Christian Franke | cb32a19 | 2015-11-10 18:33:13 +0100 | [diff] [blame] | 997 | if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0) |
| 998 | { |
| 999 | vty_out(vty, " IPv6 Link-Locals:%s", VTY_NEWLINE); |
| 1000 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip_addr)) |
| 1001 | { |
| 1002 | prefix2str(ip_addr, (char*)buf, BUFSIZ), |
| 1003 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); |
| 1004 | } |
| 1005 | } |
| 1006 | if (circuit->ipv6_link && listcount(circuit->ipv6_non_link) > 0) |
| 1007 | { |
| 1008 | vty_out(vty, " IPv6 Prefixes:%s", VTY_NEWLINE); |
| 1009 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip_addr)) |
| 1010 | { |
| 1011 | prefix2str(ip_addr, (char*)buf, BUFSIZ), |
| 1012 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); |
| 1013 | } |
| 1014 | } |
| 1015 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1016 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1017 | } |
| 1018 | return; |
| 1019 | } |
| 1020 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1021 | int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1022 | isis_interface_config_write (struct vty *vty) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1023 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1024 | int write = 0; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1025 | struct listnode *node, *node2; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1026 | struct interface *ifp; |
| 1027 | struct isis_area *area; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1028 | struct isis_circuit *circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1029 | int i; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1030 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1031 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1032 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1033 | /* IF name */ |
| 1034 | vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); |
| 1035 | write++; |
| 1036 | /* IF desc */ |
| 1037 | if (ifp->desc) |
| 1038 | { |
| 1039 | vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE); |
| 1040 | write++; |
| 1041 | } |
| 1042 | /* ISIS Circuit */ |
| 1043 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area)) |
| 1044 | { |
| 1045 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1046 | if (circuit == NULL) |
| 1047 | continue; |
| 1048 | if (circuit->ip_router) |
| 1049 | { |
| 1050 | vty_out (vty, " ip router isis %s%s", area->area_tag, |
| 1051 | VTY_NEWLINE); |
| 1052 | write++; |
| 1053 | } |
| 1054 | if (circuit->is_passive) |
| 1055 | { |
| 1056 | vty_out (vty, " isis passive%s", VTY_NEWLINE); |
| 1057 | write++; |
| 1058 | } |
| 1059 | if (circuit->circ_type_config == CIRCUIT_T_P2P) |
| 1060 | { |
| 1061 | vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE); |
| 1062 | write++; |
| 1063 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1064 | #ifdef HAVE_IPV6 |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1065 | if (circuit->ipv6_router) |
| 1066 | { |
| 1067 | vty_out (vty, " ipv6 router isis %s%s", area->area_tag, |
| 1068 | VTY_NEWLINE); |
| 1069 | write++; |
| 1070 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1071 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1072 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1073 | /* ISIS - circuit type */ |
| 1074 | if (circuit->is_type == IS_LEVEL_1) |
| 1075 | { |
| 1076 | vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE); |
| 1077 | write++; |
| 1078 | } |
| 1079 | else |
| 1080 | { |
| 1081 | if (circuit->is_type == IS_LEVEL_2) |
| 1082 | { |
| 1083 | vty_out (vty, " isis circuit-type level-2-only%s", |
| 1084 | VTY_NEWLINE); |
| 1085 | write++; |
| 1086 | } |
| 1087 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1088 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1089 | /* ISIS - CSNP interval */ |
| 1090 | if (circuit->csnp_interval[0] == circuit->csnp_interval[1]) |
| 1091 | { |
| 1092 | if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL) |
| 1093 | { |
| 1094 | vty_out (vty, " isis csnp-interval %d%s", |
| 1095 | circuit->csnp_interval[0], VTY_NEWLINE); |
| 1096 | write++; |
| 1097 | } |
| 1098 | } |
| 1099 | else |
| 1100 | { |
| 1101 | for (i = 0; i < 2; i++) |
| 1102 | { |
| 1103 | if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL) |
| 1104 | { |
| 1105 | vty_out (vty, " isis csnp-interval %d level-%d%s", |
| 1106 | circuit->csnp_interval[i], i + 1, VTY_NEWLINE); |
| 1107 | write++; |
| 1108 | } |
| 1109 | } |
| 1110 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1111 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1112 | /* ISIS - PSNP interval */ |
| 1113 | if (circuit->psnp_interval[0] == circuit->psnp_interval[1]) |
| 1114 | { |
| 1115 | if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL) |
| 1116 | { |
| 1117 | vty_out (vty, " isis psnp-interval %d%s", |
| 1118 | circuit->psnp_interval[0], VTY_NEWLINE); |
| 1119 | write++; |
| 1120 | } |
| 1121 | } |
| 1122 | else |
| 1123 | { |
| 1124 | for (i = 0; i < 2; i++) |
| 1125 | { |
| 1126 | if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL) |
| 1127 | { |
| 1128 | vty_out (vty, " isis psnp-interval %d level-%d%s", |
| 1129 | circuit->psnp_interval[i], i + 1, VTY_NEWLINE); |
| 1130 | write++; |
| 1131 | } |
| 1132 | } |
| 1133 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1134 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1135 | /* ISIS - Hello padding - Defaults to true so only display if false */ |
| 1136 | if (circuit->pad_hellos == 0) |
| 1137 | { |
| 1138 | vty_out (vty, " no isis hello padding%s", VTY_NEWLINE); |
| 1139 | write++; |
| 1140 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1141 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1142 | /* ISIS - Hello interval */ |
| 1143 | if (circuit->hello_interval[0] == circuit->hello_interval[1]) |
| 1144 | { |
| 1145 | if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL) |
| 1146 | { |
| 1147 | vty_out (vty, " isis hello-interval %d%s", |
| 1148 | circuit->hello_interval[0], VTY_NEWLINE); |
| 1149 | write++; |
| 1150 | } |
| 1151 | } |
| 1152 | else |
| 1153 | { |
| 1154 | for (i = 0; i < 2; i++) |
| 1155 | { |
| 1156 | if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL) |
| 1157 | { |
| 1158 | vty_out (vty, " isis hello-interval %d level-%d%s", |
| 1159 | circuit->hello_interval[i], i + 1, VTY_NEWLINE); |
| 1160 | write++; |
| 1161 | } |
| 1162 | } |
| 1163 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1164 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1165 | /* ISIS - Hello Multiplier */ |
| 1166 | if (circuit->hello_multiplier[0] == circuit->hello_multiplier[1]) |
| 1167 | { |
| 1168 | if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER) |
| 1169 | { |
| 1170 | vty_out (vty, " isis hello-multiplier %d%s", |
| 1171 | circuit->hello_multiplier[0], VTY_NEWLINE); |
| 1172 | write++; |
| 1173 | } |
| 1174 | } |
| 1175 | else |
| 1176 | { |
| 1177 | for (i = 0; i < 2; i++) |
| 1178 | { |
| 1179 | if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER) |
| 1180 | { |
| 1181 | vty_out (vty, " isis hello-multiplier %d level-%d%s", |
| 1182 | circuit->hello_multiplier[i], i + 1, |
| 1183 | VTY_NEWLINE); |
| 1184 | write++; |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | /* ISIS - Priority */ |
| 1190 | if (circuit->priority[0] == circuit->priority[1]) |
| 1191 | { |
| 1192 | if (circuit->priority[0] != DEFAULT_PRIORITY) |
| 1193 | { |
| 1194 | vty_out (vty, " isis priority %d%s", |
| 1195 | circuit->priority[0], VTY_NEWLINE); |
| 1196 | write++; |
| 1197 | } |
| 1198 | } |
| 1199 | else |
| 1200 | { |
| 1201 | for (i = 0; i < 2; i++) |
| 1202 | { |
| 1203 | if (circuit->priority[i] != DEFAULT_PRIORITY) |
| 1204 | { |
| 1205 | vty_out (vty, " isis priority %d level-%d%s", |
| 1206 | circuit->priority[i], i + 1, VTY_NEWLINE); |
| 1207 | write++; |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | /* ISIS - Metric */ |
| 1213 | if (circuit->te_metric[0] == circuit->te_metric[1]) |
| 1214 | { |
| 1215 | if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC) |
| 1216 | { |
| 1217 | vty_out (vty, " isis metric %d%s", circuit->te_metric[0], |
| 1218 | VTY_NEWLINE); |
| 1219 | write++; |
| 1220 | } |
| 1221 | } |
| 1222 | else |
| 1223 | { |
| 1224 | for (i = 0; i < 2; i++) |
| 1225 | { |
| 1226 | if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC) |
| 1227 | { |
| 1228 | vty_out (vty, " isis metric %d level-%d%s", |
| 1229 | circuit->te_metric[i], i + 1, VTY_NEWLINE); |
| 1230 | write++; |
| 1231 | } |
| 1232 | } |
| 1233 | } |
| 1234 | if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) |
| 1235 | { |
| 1236 | vty_out (vty, " isis password md5 %s%s", circuit->passwd.passwd, |
| 1237 | VTY_NEWLINE); |
| 1238 | write++; |
| 1239 | } |
| 1240 | else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) |
| 1241 | { |
| 1242 | vty_out (vty, " isis password clear %s%s", circuit->passwd.passwd, |
| 1243 | VTY_NEWLINE); |
| 1244 | write++; |
| 1245 | } |
| 1246 | } |
| 1247 | vty_out (vty, "!%s", VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1248 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1249 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1250 | return write; |
| 1251 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1252 | |
| 1253 | DEFUN (ip_router_isis, |
| 1254 | ip_router_isis_cmd, |
| 1255 | "ip router isis WORD", |
| 1256 | "Interface Internet Protocol config commands\n" |
| 1257 | "IP router interface commands\n" |
| 1258 | "IS-IS Routing for IP\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1259 | "Routing process tag\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1260 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1261 | struct isis_circuit *circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1262 | struct interface *ifp; |
| 1263 | struct isis_area *area; |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1264 | int rv; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1265 | |
| 1266 | ifp = (struct interface *) vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1267 | assert (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1268 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1269 | /* Prevent more than one area per circuit */ |
| 1270 | circuit = circuit_scan_by_ifp (ifp); |
| 1271 | if (circuit) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1272 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1273 | if (circuit->ip_router == 1) |
| 1274 | { |
| 1275 | if (strcmp (circuit->area->area_tag, argv[0])) |
| 1276 | { |
| 1277 | vty_out (vty, "ISIS circuit is already defined on %s%s", |
| 1278 | circuit->area->area_tag, VTY_NEWLINE); |
| 1279 | return CMD_ERR_NOTHING_TODO; |
| 1280 | } |
| 1281 | return CMD_SUCCESS; |
| 1282 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1283 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1284 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1285 | if (isis_area_get (vty, argv[0]) != CMD_SUCCESS) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1286 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1287 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1288 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1289 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1290 | area = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1291 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1292 | circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area); |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1293 | if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP) |
| 1294 | { |
| 1295 | vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE); |
| 1296 | rv = CMD_WARNING; |
| 1297 | } |
| 1298 | else |
| 1299 | { |
| 1300 | isis_circuit_if_bind (circuit, ifp); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1301 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1302 | circuit->ip_router = 1; |
| 1303 | area->ip_circuits++; |
| 1304 | circuit_update_nlpids (circuit); |
| 1305 | rv = CMD_SUCCESS; |
| 1306 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1307 | |
| 1308 | vty->node = INTERFACE_NODE; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1309 | vty->index = ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1310 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1311 | return rv; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1312 | } |
| 1313 | |
| 1314 | DEFUN (no_ip_router_isis, |
| 1315 | no_ip_router_isis_cmd, |
| 1316 | "no ip router isis WORD", |
| 1317 | NO_STR |
| 1318 | "Interface Internet Protocol config commands\n" |
| 1319 | "IP router interface commands\n" |
| 1320 | "IS-IS Routing for IP\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1321 | "Routing process tag\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1322 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1323 | struct interface *ifp; |
| 1324 | struct isis_area *area; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1325 | struct isis_circuit *circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1326 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1327 | ifp = (struct interface *) vty->index; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1328 | if (!ifp) |
| 1329 | { |
| 1330 | vty_out (vty, "Invalid interface %s", VTY_NEWLINE); |
| 1331 | return CMD_ERR_NO_MATCH; |
| 1332 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1333 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1334 | area = isis_area_lookup (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1335 | if (!area) |
| 1336 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1337 | vty_out (vty, "Can't find ISIS instance %s%s", |
| 1338 | argv[0], VTY_NEWLINE); |
| 1339 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1340 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1341 | |
| 1342 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1343 | if (!circuit) |
| 1344 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1345 | vty_out (vty, "ISIS is not enabled on circuit %s%s", |
| 1346 | ifp->name, VTY_NEWLINE); |
| 1347 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1348 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1349 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1350 | circuit->ip_router = 0; |
| 1351 | area->ip_circuits--; |
| 1352 | #ifdef HAVE_IPV6 |
| 1353 | if (circuit->ipv6_router == 0) |
| 1354 | #endif |
| 1355 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1356 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1357 | return CMD_SUCCESS; |
| 1358 | } |
| 1359 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1360 | #ifdef HAVE_IPV6 |
| 1361 | DEFUN (ipv6_router_isis, |
| 1362 | ipv6_router_isis_cmd, |
| 1363 | "ipv6 router isis WORD", |
| 1364 | "IPv6 interface subcommands\n" |
| 1365 | "IPv6 Router interface commands\n" |
| 1366 | "IS-IS Routing for IPv6\n" |
| 1367 | "Routing process tag\n") |
| 1368 | { |
| 1369 | struct isis_circuit *circuit; |
| 1370 | struct interface *ifp; |
| 1371 | struct isis_area *area; |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1372 | int rv; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1373 | |
| 1374 | ifp = (struct interface *) vty->index; |
| 1375 | assert (ifp); |
| 1376 | |
| 1377 | /* Prevent more than one area per circuit */ |
| 1378 | circuit = circuit_scan_by_ifp (ifp); |
| 1379 | if (circuit) |
| 1380 | { |
| 1381 | if (circuit->ipv6_router == 1) |
| 1382 | { |
| 1383 | if (strcmp (circuit->area->area_tag, argv[0])) |
| 1384 | { |
| 1385 | vty_out (vty, "ISIS circuit is already defined for IPv6 on %s%s", |
| 1386 | circuit->area->area_tag, VTY_NEWLINE); |
| 1387 | return CMD_ERR_NOTHING_TODO; |
| 1388 | } |
| 1389 | return CMD_SUCCESS; |
| 1390 | } |
| 1391 | } |
| 1392 | |
| 1393 | if (isis_area_get (vty, argv[0]) != CMD_SUCCESS) |
| 1394 | { |
| 1395 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1396 | return CMD_ERR_NO_MATCH; |
| 1397 | } |
| 1398 | area = vty->index; |
| 1399 | |
| 1400 | circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area); |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1401 | if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP) |
| 1402 | { |
| 1403 | vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE); |
| 1404 | rv = CMD_WARNING; |
| 1405 | } |
| 1406 | else |
| 1407 | { |
| 1408 | isis_circuit_if_bind (circuit, ifp); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1409 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1410 | circuit->ipv6_router = 1; |
| 1411 | area->ipv6_circuits++; |
| 1412 | circuit_update_nlpids (circuit); |
| 1413 | rv = CMD_SUCCESS; |
| 1414 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1415 | |
| 1416 | vty->node = INTERFACE_NODE; |
| 1417 | vty->index = ifp; |
| 1418 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 1419 | return rv; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | DEFUN (no_ipv6_router_isis, |
| 1423 | no_ipv6_router_isis_cmd, |
| 1424 | "no ipv6 router isis WORD", |
| 1425 | NO_STR |
| 1426 | "IPv6 interface subcommands\n" |
| 1427 | "IPv6 Router interface commands\n" |
| 1428 | "IS-IS Routing for IPv6\n" |
| 1429 | "Routing process tag\n") |
| 1430 | { |
| 1431 | struct interface *ifp; |
| 1432 | struct isis_area *area; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1433 | struct isis_circuit *circuit; |
| 1434 | |
| 1435 | ifp = (struct interface *) vty->index; |
| 1436 | if (!ifp) |
| 1437 | { |
| 1438 | vty_out (vty, "Invalid interface %s", VTY_NEWLINE); |
| 1439 | return CMD_ERR_NO_MATCH; |
| 1440 | } |
| 1441 | |
| 1442 | area = isis_area_lookup (argv[0]); |
| 1443 | if (!area) |
| 1444 | { |
| 1445 | vty_out (vty, "Can't find ISIS instance %s%s", |
| 1446 | argv[0], VTY_NEWLINE); |
| 1447 | return CMD_ERR_NO_MATCH; |
| 1448 | } |
| 1449 | |
| 1450 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1451 | if (!circuit) |
| 1452 | { |
| 1453 | vty_out (vty, "ISIS is not enabled on circuit %s%s", |
| 1454 | ifp->name, VTY_NEWLINE); |
| 1455 | return CMD_ERR_NO_MATCH; |
| 1456 | } |
| 1457 | |
| 1458 | circuit->ipv6_router = 0; |
| 1459 | area->ipv6_circuits--; |
| 1460 | if (circuit->ip_router == 0) |
| 1461 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
| 1462 | |
| 1463 | return CMD_SUCCESS; |
| 1464 | } |
| 1465 | #endif /* HAVE_IPV6 */ |
| 1466 | |
| 1467 | DEFUN (isis_passive, |
| 1468 | isis_passive_cmd, |
| 1469 | "isis passive", |
| 1470 | "IS-IS commands\n" |
| 1471 | "Configure the passive mode for interface\n") |
| 1472 | { |
| 1473 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1474 | if (!circuit) |
| 1475 | return CMD_ERR_NO_MATCH; |
| 1476 | |
| 1477 | if (circuit->is_passive == 1) |
| 1478 | return CMD_SUCCESS; |
| 1479 | |
| 1480 | if (circuit->state != C_STATE_UP) |
| 1481 | { |
| 1482 | circuit->is_passive = 1; |
| 1483 | } |
| 1484 | else |
| 1485 | { |
| 1486 | struct isis_area *area = circuit->area; |
| 1487 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
| 1488 | circuit->is_passive = 1; |
| 1489 | isis_csm_state_change (ISIS_ENABLE, circuit, area); |
| 1490 | } |
| 1491 | |
| 1492 | return CMD_SUCCESS; |
| 1493 | } |
| 1494 | |
| 1495 | DEFUN (no_isis_passive, |
| 1496 | no_isis_passive_cmd, |
| 1497 | "no isis passive", |
| 1498 | NO_STR |
| 1499 | "IS-IS commands\n" |
| 1500 | "Configure the passive mode for interface\n") |
| 1501 | { |
| 1502 | struct interface *ifp; |
| 1503 | struct isis_circuit *circuit; |
| 1504 | |
| 1505 | ifp = (struct interface *) vty->index; |
| 1506 | if (!ifp) |
| 1507 | { |
| 1508 | vty_out (vty, "Invalid interface %s", VTY_NEWLINE); |
| 1509 | return CMD_ERR_NO_MATCH; |
| 1510 | } |
| 1511 | |
| 1512 | /* FIXME: what is wrong with circuit = ifp->info ? */ |
| 1513 | circuit = circuit_scan_by_ifp (ifp); |
| 1514 | if (!circuit) |
| 1515 | { |
| 1516 | vty_out (vty, "ISIS is not enabled on circuit %s%s", |
| 1517 | ifp->name, VTY_NEWLINE); |
| 1518 | return CMD_ERR_NO_MATCH; |
| 1519 | } |
| 1520 | |
| 1521 | if (if_is_loopback(ifp)) |
| 1522 | { |
| 1523 | vty_out (vty, "Can't set no passive for loopback interface%s", |
| 1524 | VTY_NEWLINE); |
| 1525 | return CMD_ERR_AMBIGUOUS; |
| 1526 | } |
| 1527 | |
| 1528 | if (circuit->is_passive == 0) |
| 1529 | return CMD_SUCCESS; |
| 1530 | |
| 1531 | if (circuit->state != C_STATE_UP) |
| 1532 | { |
| 1533 | circuit->is_passive = 0; |
| 1534 | } |
| 1535 | else |
| 1536 | { |
| 1537 | struct isis_area *area = circuit->area; |
| 1538 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
| 1539 | circuit->is_passive = 0; |
| 1540 | isis_csm_state_change (ISIS_ENABLE, circuit, area); |
| 1541 | } |
| 1542 | |
| 1543 | return CMD_SUCCESS; |
| 1544 | } |
| 1545 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1546 | DEFUN (isis_circuit_type, |
| 1547 | isis_circuit_type_cmd, |
| 1548 | "isis circuit-type (level-1|level-1-2|level-2-only)", |
| 1549 | "IS-IS commands\n" |
| 1550 | "Configure circuit type for interface\n" |
| 1551 | "Level-1 only adjacencies are formed\n" |
| 1552 | "Level-1-2 adjacencies are formed\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1553 | "Level-2 only adjacencies are formed\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1554 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1555 | int circuit_type; |
| 1556 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1557 | if (!circuit) |
| 1558 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1559 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1560 | circuit_type = string2circuit_t (argv[0]); |
| 1561 | if (!circuit_type) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1562 | { |
| 1563 | vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1564 | return CMD_ERR_AMBIGUOUS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1565 | } |
| 1566 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1567 | if (circuit->state == C_STATE_UP && |
| 1568 | circuit->area->is_type != IS_LEVEL_1_AND_2 && |
| 1569 | circuit->area->is_type != circuit_type) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1570 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1571 | vty_out (vty, "Invalid circuit level for area %s.%s", |
| 1572 | circuit->area->area_tag, VTY_NEWLINE); |
| 1573 | return CMD_ERR_AMBIGUOUS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1574 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1575 | isis_event_circuit_type_change (circuit, circuit_type); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1576 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1577 | return CMD_SUCCESS; |
| 1578 | } |
| 1579 | |
| 1580 | DEFUN (no_isis_circuit_type, |
| 1581 | no_isis_circuit_type_cmd, |
| 1582 | "no isis circuit-type (level-1|level-1-2|level-2-only)", |
| 1583 | NO_STR |
| 1584 | "IS-IS commands\n" |
| 1585 | "Configure circuit type for interface\n" |
| 1586 | "Level-1 only adjacencies are formed\n" |
| 1587 | "Level-1-2 adjacencies are formed\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1588 | "Level-2 only adjacencies are formed\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1589 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1590 | int circuit_type; |
| 1591 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1592 | if (!circuit) |
| 1593 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1594 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1595 | /* |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1596 | * Set the circuits level to its default value |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1597 | */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1598 | if (circuit->state == C_STATE_UP) |
| 1599 | circuit_type = circuit->area->is_type; |
| 1600 | else |
| 1601 | circuit_type = IS_LEVEL_1_AND_2; |
| 1602 | isis_event_circuit_type_change (circuit, circuit_type); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1603 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1604 | return CMD_SUCCESS; |
| 1605 | } |
| 1606 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1607 | DEFUN (isis_passwd_md5, |
| 1608 | isis_passwd_md5_cmd, |
| 1609 | "isis password md5 WORD", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1610 | "IS-IS commands\n" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1611 | "Configure the authentication password for a circuit\n" |
| 1612 | "Authentication type\n" |
| 1613 | "Circuit password\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1614 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1615 | int len; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1616 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1617 | if (!circuit) |
| 1618 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1619 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1620 | len = strlen (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1621 | if (len > 254) |
| 1622 | { |
| 1623 | vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1624 | return CMD_ERR_AMBIGUOUS; |
| 1625 | } |
| 1626 | circuit->passwd.len = len; |
| 1627 | circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5; |
| 1628 | strncpy ((char *)circuit->passwd.passwd, argv[0], 255); |
| 1629 | |
| 1630 | return CMD_SUCCESS; |
| 1631 | } |
| 1632 | |
| 1633 | DEFUN (isis_passwd_clear, |
| 1634 | isis_passwd_clear_cmd, |
| 1635 | "isis password clear WORD", |
| 1636 | "IS-IS commands\n" |
| 1637 | "Configure the authentication password for a circuit\n" |
| 1638 | "Authentication type\n" |
| 1639 | "Circuit password\n") |
| 1640 | { |
| 1641 | int len; |
| 1642 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1643 | if (!circuit) |
| 1644 | return CMD_ERR_NO_MATCH; |
| 1645 | |
| 1646 | len = strlen (argv[0]); |
| 1647 | if (len > 254) |
| 1648 | { |
| 1649 | vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); |
| 1650 | return CMD_ERR_AMBIGUOUS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1651 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1652 | circuit->passwd.len = len; |
| 1653 | circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT; |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 1654 | strncpy ((char *)circuit->passwd.passwd, argv[0], 255); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1655 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1656 | return CMD_SUCCESS; |
| 1657 | } |
| 1658 | |
| 1659 | DEFUN (no_isis_passwd, |
| 1660 | no_isis_passwd_cmd, |
| 1661 | "no isis password", |
| 1662 | NO_STR |
| 1663 | "IS-IS commands\n" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1664 | "Configure the authentication password for a circuit\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1665 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1666 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1667 | if (!circuit) |
| 1668 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1669 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1670 | memset (&circuit->passwd, 0, sizeof (struct isis_passwd)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1671 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1672 | return CMD_SUCCESS; |
| 1673 | } |
| 1674 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1675 | DEFUN (isis_priority, |
| 1676 | isis_priority_cmd, |
| 1677 | "isis priority <0-127>", |
| 1678 | "IS-IS commands\n" |
| 1679 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1680 | "Priority value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1681 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1682 | int prio; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1683 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1684 | if (!circuit) |
| 1685 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1686 | |
| 1687 | prio = atoi (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1688 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) |
| 1689 | { |
| 1690 | vty_out (vty, "Invalid priority %d - should be <0-127>%s", |
| 1691 | prio, VTY_NEWLINE); |
| 1692 | return CMD_ERR_AMBIGUOUS; |
| 1693 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1694 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1695 | circuit->priority[0] = prio; |
| 1696 | circuit->priority[1] = prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1697 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1698 | return CMD_SUCCESS; |
| 1699 | } |
| 1700 | |
| 1701 | DEFUN (no_isis_priority, |
| 1702 | no_isis_priority_cmd, |
| 1703 | "no isis priority", |
| 1704 | NO_STR |
| 1705 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1706 | "Set priority for Designated Router election\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1707 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1708 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1709 | if (!circuit) |
| 1710 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1711 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1712 | circuit->priority[0] = DEFAULT_PRIORITY; |
| 1713 | circuit->priority[1] = DEFAULT_PRIORITY; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1714 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1715 | return CMD_SUCCESS; |
| 1716 | } |
| 1717 | |
| 1718 | ALIAS (no_isis_priority, |
| 1719 | no_isis_priority_arg_cmd, |
| 1720 | "no isis priority <0-127>", |
| 1721 | NO_STR |
| 1722 | "IS-IS commands\n" |
| 1723 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1724 | "Priority value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1725 | |
| 1726 | DEFUN (isis_priority_l1, |
| 1727 | isis_priority_l1_cmd, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1728 | "isis priority <0-127> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1729 | "IS-IS commands\n" |
| 1730 | "Set priority for Designated Router election\n" |
| 1731 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1732 | "Specify priority for level-1 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1733 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1734 | int prio; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1735 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1736 | if (!circuit) |
| 1737 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1738 | |
| 1739 | prio = atoi (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1740 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) |
| 1741 | { |
| 1742 | vty_out (vty, "Invalid priority %d - should be <0-127>%s", |
| 1743 | prio, VTY_NEWLINE); |
| 1744 | return CMD_ERR_AMBIGUOUS; |
| 1745 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1746 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1747 | circuit->priority[0] = prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1748 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1749 | return CMD_SUCCESS; |
| 1750 | } |
| 1751 | |
| 1752 | DEFUN (no_isis_priority_l1, |
| 1753 | no_isis_priority_l1_cmd, |
| 1754 | "no isis priority level-1", |
| 1755 | NO_STR |
| 1756 | "IS-IS commands\n" |
| 1757 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1758 | "Specify priority for level-1 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1759 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1760 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1761 | if (!circuit) |
| 1762 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1763 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1764 | circuit->priority[0] = DEFAULT_PRIORITY; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1765 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1766 | return CMD_SUCCESS; |
| 1767 | } |
| 1768 | |
| 1769 | ALIAS (no_isis_priority_l1, |
| 1770 | no_isis_priority_l1_arg_cmd, |
| 1771 | "no isis priority <0-127> level-1", |
| 1772 | NO_STR |
| 1773 | "IS-IS commands\n" |
| 1774 | "Set priority for Designated Router election\n" |
| 1775 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1776 | "Specify priority for level-1 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1777 | |
| 1778 | DEFUN (isis_priority_l2, |
| 1779 | isis_priority_l2_cmd, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1780 | "isis priority <0-127> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1781 | "IS-IS commands\n" |
| 1782 | "Set priority for Designated Router election\n" |
| 1783 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1784 | "Specify priority for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1785 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1786 | int prio; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1787 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1788 | if (!circuit) |
| 1789 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1790 | |
| 1791 | prio = atoi (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1792 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) |
| 1793 | { |
| 1794 | vty_out (vty, "Invalid priority %d - should be <0-127>%s", |
| 1795 | prio, VTY_NEWLINE); |
| 1796 | return CMD_ERR_AMBIGUOUS; |
| 1797 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1798 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1799 | circuit->priority[1] = prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1800 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1801 | return CMD_SUCCESS; |
| 1802 | } |
| 1803 | |
| 1804 | DEFUN (no_isis_priority_l2, |
| 1805 | no_isis_priority_l2_cmd, |
| 1806 | "no isis priority level-2", |
| 1807 | NO_STR |
| 1808 | "IS-IS commands\n" |
| 1809 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1810 | "Specify priority for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1811 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1812 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1813 | if (!circuit) |
| 1814 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1815 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1816 | circuit->priority[1] = DEFAULT_PRIORITY; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1817 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1818 | return CMD_SUCCESS; |
| 1819 | } |
| 1820 | |
| 1821 | ALIAS (no_isis_priority_l2, |
| 1822 | no_isis_priority_l2_arg_cmd, |
| 1823 | "no isis priority <0-127> level-2", |
| 1824 | NO_STR |
| 1825 | "IS-IS commands\n" |
| 1826 | "Set priority for Designated Router election\n" |
| 1827 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1828 | "Specify priority for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1829 | |
| 1830 | /* Metric command */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1831 | DEFUN (isis_metric, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1832 | isis_metric_cmd, |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1833 | "isis metric <0-16777215>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1834 | "IS-IS commands\n" |
| 1835 | "Set default metric for circuit\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1836 | "Default metric value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1837 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1838 | int met; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1839 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1840 | if (!circuit) |
| 1841 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1842 | |
| 1843 | met = atoi (argv[0]); |
| 1844 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1845 | /* RFC3787 section 5.1 */ |
| 1846 | if (circuit->area && circuit->area->oldmetric == 1 && |
| 1847 | met > MAX_NARROW_LINK_METRIC) |
| 1848 | { |
| 1849 | vty_out (vty, "Invalid metric %d - should be <0-63> " |
| 1850 | "when narrow metric type enabled%s", |
| 1851 | met, VTY_NEWLINE); |
| 1852 | return CMD_ERR_AMBIGUOUS; |
| 1853 | } |
| 1854 | |
| 1855 | /* RFC4444 */ |
| 1856 | if (circuit->area && circuit->area->newmetric == 1 && |
| 1857 | met > MAX_WIDE_LINK_METRIC) |
| 1858 | { |
| 1859 | vty_out (vty, "Invalid metric %d - should be <0-16777215> " |
| 1860 | "when wide metric type enabled%s", |
| 1861 | met, VTY_NEWLINE); |
| 1862 | return CMD_ERR_AMBIGUOUS; |
| 1863 | } |
| 1864 | |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1865 | circuit->te_metric[0] = met; |
| 1866 | circuit->te_metric[1] = met; |
| 1867 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1868 | circuit->metrics[0].metric_default = met; |
| 1869 | circuit->metrics[1].metric_default = met; |
| 1870 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1871 | if (circuit->area) |
| 1872 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
| 1873 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1874 | return CMD_SUCCESS; |
| 1875 | } |
| 1876 | |
| 1877 | DEFUN (no_isis_metric, |
| 1878 | no_isis_metric_cmd, |
| 1879 | "no isis metric", |
| 1880 | NO_STR |
| 1881 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1882 | "Set default metric for circuit\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1883 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1884 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1885 | if (!circuit) |
| 1886 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1887 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1888 | circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC; |
| 1889 | circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC; |
| 1890 | circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC; |
| 1891 | circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1892 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1893 | if (circuit->area) |
| 1894 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1895 | |
| 1896 | return CMD_SUCCESS; |
| 1897 | } |
| 1898 | |
| 1899 | ALIAS (no_isis_metric, |
| 1900 | no_isis_metric_arg_cmd, |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1901 | "no isis metric <0-16777215>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1902 | NO_STR |
| 1903 | "IS-IS commands\n" |
| 1904 | "Set default metric for circuit\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1905 | "Default metric value\n") |
| 1906 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1907 | DEFUN (isis_metric_l1, |
| 1908 | isis_metric_l1_cmd, |
| 1909 | "isis metric <0-16777215> level-1", |
| 1910 | "IS-IS commands\n" |
| 1911 | "Set default metric for circuit\n" |
| 1912 | "Default metric value\n" |
| 1913 | "Specify metric for level-1 routing\n") |
| 1914 | { |
| 1915 | int met; |
| 1916 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1917 | if (!circuit) |
| 1918 | return CMD_ERR_NO_MATCH; |
| 1919 | |
| 1920 | met = atoi (argv[0]); |
| 1921 | |
| 1922 | /* RFC3787 section 5.1 */ |
| 1923 | if (circuit->area && circuit->area->oldmetric == 1 && |
| 1924 | met > MAX_NARROW_LINK_METRIC) |
| 1925 | { |
| 1926 | vty_out (vty, "Invalid metric %d - should be <0-63> " |
| 1927 | "when narrow metric type enabled%s", |
| 1928 | met, VTY_NEWLINE); |
| 1929 | return CMD_ERR_AMBIGUOUS; |
| 1930 | } |
| 1931 | |
| 1932 | /* RFC4444 */ |
| 1933 | if (circuit->area && circuit->area->newmetric == 1 && |
| 1934 | met > MAX_WIDE_LINK_METRIC) |
| 1935 | { |
| 1936 | vty_out (vty, "Invalid metric %d - should be <0-16777215> " |
| 1937 | "when wide metric type enabled%s", |
| 1938 | met, VTY_NEWLINE); |
| 1939 | return CMD_ERR_AMBIGUOUS; |
| 1940 | } |
| 1941 | |
| 1942 | circuit->te_metric[0] = met; |
| 1943 | circuit->metrics[0].metric_default = met; |
| 1944 | |
| 1945 | if (circuit->area) |
| 1946 | lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0); |
| 1947 | |
| 1948 | return CMD_SUCCESS; |
| 1949 | } |
| 1950 | |
| 1951 | DEFUN (no_isis_metric_l1, |
| 1952 | no_isis_metric_l1_cmd, |
| 1953 | "no isis metric level-1", |
| 1954 | NO_STR |
| 1955 | "IS-IS commands\n" |
| 1956 | "Set default metric for circuit\n" |
| 1957 | "Specify metric for level-1 routing\n") |
| 1958 | { |
| 1959 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1960 | if (!circuit) |
| 1961 | return CMD_ERR_NO_MATCH; |
| 1962 | |
| 1963 | circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC; |
| 1964 | circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC; |
| 1965 | |
| 1966 | if (circuit->area) |
| 1967 | lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0); |
| 1968 | |
| 1969 | return CMD_SUCCESS; |
| 1970 | } |
| 1971 | |
| 1972 | ALIAS (no_isis_metric_l1, |
| 1973 | no_isis_metric_l1_arg_cmd, |
| 1974 | "no isis metric <0-16777215> level-1", |
| 1975 | NO_STR |
| 1976 | "IS-IS commands\n" |
| 1977 | "Set default metric for circuit\n" |
| 1978 | "Default metric value\n" |
| 1979 | "Specify metric for level-1 routing\n") |
| 1980 | |
| 1981 | DEFUN (isis_metric_l2, |
| 1982 | isis_metric_l2_cmd, |
| 1983 | "isis metric <0-16777215> level-2", |
| 1984 | "IS-IS commands\n" |
| 1985 | "Set default metric for circuit\n" |
| 1986 | "Default metric value\n" |
| 1987 | "Specify metric for level-2 routing\n") |
| 1988 | { |
| 1989 | int met; |
| 1990 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 1991 | if (!circuit) |
| 1992 | return CMD_ERR_NO_MATCH; |
| 1993 | |
| 1994 | met = atoi (argv[0]); |
| 1995 | |
| 1996 | /* RFC3787 section 5.1 */ |
| 1997 | if (circuit->area && circuit->area->oldmetric == 1 && |
| 1998 | met > MAX_NARROW_LINK_METRIC) |
| 1999 | { |
| 2000 | vty_out (vty, "Invalid metric %d - should be <0-63> " |
| 2001 | "when narrow metric type enabled%s", |
| 2002 | met, VTY_NEWLINE); |
| 2003 | return CMD_ERR_AMBIGUOUS; |
| 2004 | } |
| 2005 | |
| 2006 | /* RFC4444 */ |
| 2007 | if (circuit->area && circuit->area->newmetric == 1 && |
| 2008 | met > MAX_WIDE_LINK_METRIC) |
| 2009 | { |
| 2010 | vty_out (vty, "Invalid metric %d - should be <0-16777215> " |
| 2011 | "when wide metric type enabled%s", |
| 2012 | met, VTY_NEWLINE); |
| 2013 | return CMD_ERR_AMBIGUOUS; |
| 2014 | } |
| 2015 | |
| 2016 | circuit->te_metric[1] = met; |
| 2017 | circuit->metrics[1].metric_default = met; |
| 2018 | |
| 2019 | if (circuit->area) |
| 2020 | lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0); |
| 2021 | |
| 2022 | return CMD_SUCCESS; |
| 2023 | } |
| 2024 | |
| 2025 | DEFUN (no_isis_metric_l2, |
| 2026 | no_isis_metric_l2_cmd, |
| 2027 | "no isis metric level-2", |
| 2028 | NO_STR |
| 2029 | "IS-IS commands\n" |
| 2030 | "Set default metric for circuit\n" |
| 2031 | "Specify metric for level-2 routing\n") |
| 2032 | { |
| 2033 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2034 | if (!circuit) |
| 2035 | return CMD_ERR_NO_MATCH; |
| 2036 | |
| 2037 | circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC; |
| 2038 | circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC; |
| 2039 | |
| 2040 | if (circuit->area) |
| 2041 | lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0); |
| 2042 | |
| 2043 | return CMD_SUCCESS; |
| 2044 | } |
| 2045 | |
| 2046 | ALIAS (no_isis_metric_l2, |
| 2047 | no_isis_metric_l2_arg_cmd, |
| 2048 | "no isis metric <0-16777215> level-2", |
| 2049 | NO_STR |
| 2050 | "IS-IS commands\n" |
| 2051 | "Set default metric for circuit\n" |
| 2052 | "Default metric value\n" |
| 2053 | "Specify metric for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2054 | /* end of metrics */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2055 | |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 2056 | DEFUN (isis_hello_interval, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2057 | isis_hello_interval_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2058 | "isis hello-interval <1-600>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2059 | "IS-IS commands\n" |
| 2060 | "Set Hello interval\n" |
| 2061 | "Hello interval value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2062 | "Holdtime 1 seconds, interval depends on multiplier\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2063 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2064 | int interval; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2065 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2066 | if (!circuit) |
| 2067 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2068 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2069 | interval = atoi (argv[0]); |
| 2070 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2071 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2072 | vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s", |
| 2073 | interval, VTY_NEWLINE); |
| 2074 | return CMD_ERR_AMBIGUOUS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2075 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2076 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2077 | circuit->hello_interval[0] = (u_int16_t) interval; |
| 2078 | circuit->hello_interval[1] = (u_int16_t) interval; |
| 2079 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2080 | return CMD_SUCCESS; |
| 2081 | } |
| 2082 | |
| 2083 | DEFUN (no_isis_hello_interval, |
| 2084 | no_isis_hello_interval_cmd, |
| 2085 | "no isis hello-interval", |
| 2086 | NO_STR |
| 2087 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2088 | "Set Hello interval\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2089 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2090 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2091 | if (!circuit) |
| 2092 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2093 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2094 | circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; |
| 2095 | circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2096 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2097 | return CMD_SUCCESS; |
| 2098 | } |
| 2099 | |
| 2100 | ALIAS (no_isis_hello_interval, |
| 2101 | no_isis_hello_interval_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2102 | "no isis hello-interval <1-600>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2103 | NO_STR |
| 2104 | "IS-IS commands\n" |
| 2105 | "Set Hello interval\n" |
| 2106 | "Hello interval value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2107 | "Holdtime 1 second, interval depends on multiplier\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2108 | |
| 2109 | DEFUN (isis_hello_interval_l1, |
| 2110 | isis_hello_interval_l1_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2111 | "isis hello-interval <1-600> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2112 | "IS-IS commands\n" |
| 2113 | "Set Hello interval\n" |
| 2114 | "Hello interval value\n" |
| 2115 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2116 | "Specify hello-interval for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2117 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2118 | long interval; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2119 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2120 | if (!circuit) |
| 2121 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2122 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2123 | interval = atoi (argv[0]); |
| 2124 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2125 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2126 | vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", |
| 2127 | interval, VTY_NEWLINE); |
| 2128 | return CMD_ERR_AMBIGUOUS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2129 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2130 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2131 | circuit->hello_interval[0] = (u_int16_t) interval; |
| 2132 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2133 | return CMD_SUCCESS; |
| 2134 | } |
| 2135 | |
| 2136 | DEFUN (no_isis_hello_interval_l1, |
| 2137 | no_isis_hello_interval_l1_cmd, |
| 2138 | "no isis hello-interval level-1", |
| 2139 | NO_STR |
| 2140 | "IS-IS commands\n" |
| 2141 | "Set Hello interval\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2142 | "Specify hello-interval for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2143 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2144 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2145 | if (!circuit) |
| 2146 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2147 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2148 | circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2149 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2150 | return CMD_SUCCESS; |
| 2151 | } |
| 2152 | |
| 2153 | ALIAS (no_isis_hello_interval_l1, |
| 2154 | no_isis_hello_interval_l1_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2155 | "no isis hello-interval <1-600> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2156 | NO_STR |
| 2157 | "IS-IS commands\n" |
| 2158 | "Set Hello interval\n" |
| 2159 | "Hello interval value\n" |
| 2160 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2161 | "Specify hello-interval for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2162 | |
| 2163 | DEFUN (isis_hello_interval_l2, |
| 2164 | isis_hello_interval_l2_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2165 | "isis hello-interval <1-600> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2166 | "IS-IS commands\n" |
| 2167 | "Set Hello interval\n" |
| 2168 | "Hello interval value\n" |
| 2169 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2170 | "Specify hello-interval for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2171 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2172 | long interval; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2173 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2174 | if (!circuit) |
| 2175 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2176 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2177 | interval = atoi (argv[0]); |
| 2178 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2179 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2180 | vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s", |
| 2181 | interval, VTY_NEWLINE); |
| 2182 | return CMD_ERR_AMBIGUOUS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2183 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2184 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2185 | circuit->hello_interval[1] = (u_int16_t) interval; |
| 2186 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2187 | return CMD_SUCCESS; |
| 2188 | } |
| 2189 | |
| 2190 | DEFUN (no_isis_hello_interval_l2, |
| 2191 | no_isis_hello_interval_l2_cmd, |
| 2192 | "no isis hello-interval level-2", |
| 2193 | NO_STR |
| 2194 | "IS-IS commands\n" |
| 2195 | "Set Hello interval\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2196 | "Specify hello-interval for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2197 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2198 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2199 | if (!circuit) |
| 2200 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2201 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2202 | circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2203 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2204 | return CMD_SUCCESS; |
| 2205 | } |
| 2206 | |
| 2207 | ALIAS (no_isis_hello_interval_l2, |
| 2208 | no_isis_hello_interval_l2_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2209 | "no isis hello-interval <1-600> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2210 | NO_STR |
| 2211 | "IS-IS commands\n" |
| 2212 | "Set Hello interval\n" |
| 2213 | "Hello interval value\n" |
| 2214 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2215 | "Specify hello-interval for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2216 | |
| 2217 | DEFUN (isis_hello_multiplier, |
| 2218 | isis_hello_multiplier_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2219 | "isis hello-multiplier <2-100>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2220 | "IS-IS commands\n" |
| 2221 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2222 | "Hello multiplier value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2223 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2224 | int mult; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2225 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2226 | if (!circuit) |
| 2227 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2228 | |
| 2229 | mult = atoi (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2230 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) |
| 2231 | { |
| 2232 | vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", |
| 2233 | mult, VTY_NEWLINE); |
| 2234 | return CMD_ERR_AMBIGUOUS; |
| 2235 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2236 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2237 | circuit->hello_multiplier[0] = (u_int16_t) mult; |
| 2238 | circuit->hello_multiplier[1] = (u_int16_t) mult; |
| 2239 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2240 | return CMD_SUCCESS; |
| 2241 | } |
| 2242 | |
| 2243 | DEFUN (no_isis_hello_multiplier, |
| 2244 | no_isis_hello_multiplier_cmd, |
| 2245 | "no isis hello-multiplier", |
| 2246 | NO_STR |
| 2247 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2248 | "Set multiplier for Hello holding time\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2249 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2250 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2251 | if (!circuit) |
| 2252 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2253 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2254 | circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER; |
| 2255 | circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2256 | |
| 2257 | return CMD_SUCCESS; |
| 2258 | } |
| 2259 | |
| 2260 | ALIAS (no_isis_hello_multiplier, |
| 2261 | no_isis_hello_multiplier_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2262 | "no isis hello-multiplier <2-100>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2263 | NO_STR |
| 2264 | "IS-IS commands\n" |
| 2265 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2266 | "Hello multiplier value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2267 | |
| 2268 | DEFUN (isis_hello_multiplier_l1, |
| 2269 | isis_hello_multiplier_l1_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2270 | "isis hello-multiplier <2-100> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2271 | "IS-IS commands\n" |
| 2272 | "Set multiplier for Hello holding time\n" |
| 2273 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2274 | "Specify hello multiplier for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2275 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2276 | int mult; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2277 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2278 | if (!circuit) |
| 2279 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2280 | |
| 2281 | mult = atoi (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2282 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) |
| 2283 | { |
| 2284 | vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", |
| 2285 | mult, VTY_NEWLINE); |
| 2286 | return CMD_ERR_AMBIGUOUS; |
| 2287 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2288 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2289 | circuit->hello_multiplier[0] = (u_int16_t) mult; |
| 2290 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2291 | return CMD_SUCCESS; |
| 2292 | } |
| 2293 | |
| 2294 | DEFUN (no_isis_hello_multiplier_l1, |
| 2295 | no_isis_hello_multiplier_l1_cmd, |
| 2296 | "no isis hello-multiplier level-1", |
| 2297 | NO_STR |
| 2298 | "IS-IS commands\n" |
| 2299 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2300 | "Specify hello multiplier for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2301 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2302 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2303 | if (!circuit) |
| 2304 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2305 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2306 | circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2307 | |
| 2308 | return CMD_SUCCESS; |
| 2309 | } |
| 2310 | |
| 2311 | ALIAS (no_isis_hello_multiplier_l1, |
| 2312 | no_isis_hello_multiplier_l1_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2313 | "no isis hello-multiplier <2-100> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2314 | NO_STR |
| 2315 | "IS-IS commands\n" |
| 2316 | "Set multiplier for Hello holding time\n" |
| 2317 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2318 | "Specify hello multiplier for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2319 | |
| 2320 | DEFUN (isis_hello_multiplier_l2, |
| 2321 | isis_hello_multiplier_l2_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2322 | "isis hello-multiplier <2-100> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2323 | "IS-IS commands\n" |
| 2324 | "Set multiplier for Hello holding time\n" |
| 2325 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2326 | "Specify hello multiplier for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2327 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2328 | int mult; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2329 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2330 | if (!circuit) |
| 2331 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2332 | |
| 2333 | mult = atoi (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2334 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) |
| 2335 | { |
| 2336 | vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s", |
| 2337 | mult, VTY_NEWLINE); |
| 2338 | return CMD_ERR_AMBIGUOUS; |
| 2339 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2340 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2341 | circuit->hello_multiplier[1] = (u_int16_t) mult; |
| 2342 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2343 | return CMD_SUCCESS; |
| 2344 | } |
| 2345 | |
| 2346 | DEFUN (no_isis_hello_multiplier_l2, |
| 2347 | no_isis_hello_multiplier_l2_cmd, |
| 2348 | "no isis hello-multiplier level-2", |
| 2349 | NO_STR |
| 2350 | "IS-IS commands\n" |
| 2351 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2352 | "Specify hello multiplier for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2353 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2354 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2355 | if (!circuit) |
| 2356 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2357 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2358 | circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2359 | |
| 2360 | return CMD_SUCCESS; |
| 2361 | } |
| 2362 | |
| 2363 | ALIAS (no_isis_hello_multiplier_l2, |
| 2364 | no_isis_hello_multiplier_l2_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2365 | "no isis hello-multiplier <2-100> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2366 | NO_STR |
| 2367 | "IS-IS commands\n" |
| 2368 | "Set multiplier for Hello holding time\n" |
| 2369 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2370 | "Specify hello multiplier for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2371 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2372 | DEFUN (isis_hello_padding, |
| 2373 | isis_hello_padding_cmd, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2374 | "isis hello padding", |
| 2375 | "IS-IS commands\n" |
| 2376 | "Add padding to IS-IS hello packets\n" |
| 2377 | "Pad hello packets\n" |
| 2378 | "<cr>\n") |
| 2379 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2380 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2381 | if (!circuit) |
| 2382 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2383 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2384 | circuit->pad_hellos = 1; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2385 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2386 | return CMD_SUCCESS; |
| 2387 | } |
| 2388 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2389 | DEFUN (no_isis_hello_padding, |
| 2390 | no_isis_hello_padding_cmd, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2391 | "no isis hello padding", |
| 2392 | NO_STR |
| 2393 | "IS-IS commands\n" |
| 2394 | "Add padding to IS-IS hello packets\n" |
| 2395 | "Pad hello packets\n" |
| 2396 | "<cr>\n") |
| 2397 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2398 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2399 | if (!circuit) |
| 2400 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2401 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2402 | circuit->pad_hellos = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2403 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2404 | return CMD_SUCCESS; |
| 2405 | } |
| 2406 | |
| 2407 | DEFUN (csnp_interval, |
| 2408 | csnp_interval_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2409 | "isis csnp-interval <1-600>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2410 | "IS-IS commands\n" |
| 2411 | "Set CSNP interval in seconds\n" |
| 2412 | "CSNP interval value\n") |
| 2413 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2414 | unsigned long interval; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2415 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2416 | if (!circuit) |
| 2417 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2418 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2419 | interval = atol (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2420 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) |
| 2421 | { |
| 2422 | vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", |
| 2423 | interval, VTY_NEWLINE); |
| 2424 | return CMD_ERR_AMBIGUOUS; |
| 2425 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2426 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2427 | circuit->csnp_interval[0] = (u_int16_t) interval; |
| 2428 | circuit->csnp_interval[1] = (u_int16_t) interval; |
| 2429 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2430 | return CMD_SUCCESS; |
| 2431 | } |
| 2432 | |
| 2433 | DEFUN (no_csnp_interval, |
| 2434 | no_csnp_interval_cmd, |
| 2435 | "no isis csnp-interval", |
| 2436 | NO_STR |
| 2437 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2438 | "Set CSNP interval in seconds\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2439 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2440 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2441 | if (!circuit) |
| 2442 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2443 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2444 | circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL; |
| 2445 | circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2446 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2447 | return CMD_SUCCESS; |
| 2448 | } |
| 2449 | |
| 2450 | ALIAS (no_csnp_interval, |
| 2451 | no_csnp_interval_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2452 | "no isis csnp-interval <1-600>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2453 | NO_STR |
| 2454 | "IS-IS commands\n" |
| 2455 | "Set CSNP interval in seconds\n" |
| 2456 | "CSNP interval value\n") |
| 2457 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2458 | DEFUN (csnp_interval_l1, |
| 2459 | csnp_interval_l1_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2460 | "isis csnp-interval <1-600> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2461 | "IS-IS commands\n" |
| 2462 | "Set CSNP interval in seconds\n" |
| 2463 | "CSNP interval value\n" |
| 2464 | "Specify interval for level-1 CSNPs\n") |
| 2465 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2466 | unsigned long interval; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2467 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2468 | if (!circuit) |
| 2469 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2470 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2471 | interval = atol (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2472 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) |
| 2473 | { |
| 2474 | vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", |
| 2475 | interval, VTY_NEWLINE); |
| 2476 | return CMD_ERR_AMBIGUOUS; |
| 2477 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2478 | |
| 2479 | circuit->csnp_interval[0] = (u_int16_t) interval; |
| 2480 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2481 | return CMD_SUCCESS; |
| 2482 | } |
| 2483 | |
| 2484 | DEFUN (no_csnp_interval_l1, |
| 2485 | no_csnp_interval_l1_cmd, |
| 2486 | "no isis csnp-interval level-1", |
| 2487 | NO_STR |
| 2488 | "IS-IS commands\n" |
| 2489 | "Set CSNP interval in seconds\n" |
| 2490 | "Specify interval for level-1 CSNPs\n") |
| 2491 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2492 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2493 | if (!circuit) |
| 2494 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2495 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2496 | circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2497 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2498 | return CMD_SUCCESS; |
| 2499 | } |
| 2500 | |
| 2501 | ALIAS (no_csnp_interval_l1, |
| 2502 | no_csnp_interval_l1_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2503 | "no isis csnp-interval <1-600> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2504 | NO_STR |
| 2505 | "IS-IS commands\n" |
| 2506 | "Set CSNP interval in seconds\n" |
| 2507 | "CSNP interval value\n" |
| 2508 | "Specify interval for level-1 CSNPs\n") |
| 2509 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2510 | DEFUN (csnp_interval_l2, |
| 2511 | csnp_interval_l2_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2512 | "isis csnp-interval <1-600> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2513 | "IS-IS commands\n" |
| 2514 | "Set CSNP interval in seconds\n" |
| 2515 | "CSNP interval value\n" |
| 2516 | "Specify interval for level-2 CSNPs\n") |
| 2517 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2518 | unsigned long interval; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2519 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2520 | if (!circuit) |
| 2521 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2522 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2523 | interval = atol (argv[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2524 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) |
| 2525 | { |
| 2526 | vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s", |
| 2527 | interval, VTY_NEWLINE); |
| 2528 | return CMD_ERR_AMBIGUOUS; |
| 2529 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2530 | |
| 2531 | circuit->csnp_interval[1] = (u_int16_t) interval; |
| 2532 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2533 | return CMD_SUCCESS; |
| 2534 | } |
| 2535 | |
| 2536 | DEFUN (no_csnp_interval_l2, |
| 2537 | no_csnp_interval_l2_cmd, |
| 2538 | "no isis csnp-interval level-2", |
| 2539 | NO_STR |
| 2540 | "IS-IS commands\n" |
| 2541 | "Set CSNP interval in seconds\n" |
| 2542 | "Specify interval for level-2 CSNPs\n") |
| 2543 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2544 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2545 | if (!circuit) |
| 2546 | return CMD_ERR_NO_MATCH; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2547 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2548 | circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2549 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2550 | return CMD_SUCCESS; |
| 2551 | } |
| 2552 | |
| 2553 | ALIAS (no_csnp_interval_l2, |
| 2554 | no_csnp_interval_l2_arg_cmd, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2555 | "no isis csnp-interval <1-600> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2556 | NO_STR |
| 2557 | "IS-IS commands\n" |
| 2558 | "Set CSNP interval in seconds\n" |
| 2559 | "CSNP interval value\n" |
| 2560 | "Specify interval for level-2 CSNPs\n") |
| 2561 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2562 | DEFUN (psnp_interval, |
| 2563 | psnp_interval_cmd, |
| 2564 | "isis psnp-interval <1-120>", |
| 2565 | "IS-IS commands\n" |
| 2566 | "Set PSNP interval in seconds\n" |
| 2567 | "PSNP interval value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2568 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2569 | unsigned long interval; |
| 2570 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2571 | if (!circuit) |
| 2572 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2573 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2574 | interval = atol (argv[0]); |
| 2575 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2576 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2577 | vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", |
| 2578 | interval, VTY_NEWLINE); |
| 2579 | return CMD_ERR_AMBIGUOUS; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2580 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2581 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2582 | circuit->psnp_interval[0] = (u_int16_t) interval; |
| 2583 | circuit->psnp_interval[1] = (u_int16_t) interval; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2584 | |
| 2585 | return CMD_SUCCESS; |
| 2586 | } |
| 2587 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2588 | DEFUN (no_psnp_interval, |
| 2589 | no_psnp_interval_cmd, |
| 2590 | "no isis psnp-interval", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2591 | NO_STR |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2592 | "IS-IS commands\n" |
| 2593 | "Set PSNP interval in seconds\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2594 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2595 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2596 | if (!circuit) |
| 2597 | return CMD_ERR_NO_MATCH; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2598 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2599 | circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL; |
| 2600 | circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2601 | |
| 2602 | return CMD_SUCCESS; |
| 2603 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2604 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2605 | ALIAS (no_psnp_interval, |
| 2606 | no_psnp_interval_arg_cmd, |
| 2607 | "no isis psnp-interval <1-120>", |
| 2608 | NO_STR |
| 2609 | "IS-IS commands\n" |
| 2610 | "Set PSNP interval in seconds\n" |
| 2611 | "PSNP interval value\n") |
| 2612 | |
| 2613 | DEFUN (psnp_interval_l1, |
| 2614 | psnp_interval_l1_cmd, |
| 2615 | "isis psnp-interval <1-120> level-1", |
| 2616 | "IS-IS commands\n" |
| 2617 | "Set PSNP interval in seconds\n" |
| 2618 | "PSNP interval value\n" |
| 2619 | "Specify interval for level-1 PSNPs\n") |
| 2620 | { |
| 2621 | unsigned long interval; |
| 2622 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2623 | if (!circuit) |
| 2624 | return CMD_ERR_NO_MATCH; |
| 2625 | |
| 2626 | interval = atol (argv[0]); |
| 2627 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) |
| 2628 | { |
| 2629 | vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", |
| 2630 | interval, VTY_NEWLINE); |
| 2631 | return CMD_ERR_AMBIGUOUS; |
| 2632 | } |
| 2633 | |
| 2634 | circuit->psnp_interval[0] = (u_int16_t) interval; |
| 2635 | |
| 2636 | return CMD_SUCCESS; |
| 2637 | } |
| 2638 | |
| 2639 | DEFUN (no_psnp_interval_l1, |
| 2640 | no_psnp_interval_l1_cmd, |
| 2641 | "no isis psnp-interval level-1", |
| 2642 | NO_STR |
| 2643 | "IS-IS commands\n" |
| 2644 | "Set PSNP interval in seconds\n" |
| 2645 | "Specify interval for level-1 PSNPs\n") |
| 2646 | { |
| 2647 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2648 | if (!circuit) |
| 2649 | return CMD_ERR_NO_MATCH; |
| 2650 | |
| 2651 | circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL; |
| 2652 | |
| 2653 | return CMD_SUCCESS; |
| 2654 | } |
| 2655 | |
| 2656 | ALIAS (no_psnp_interval_l1, |
| 2657 | no_psnp_interval_l1_arg_cmd, |
| 2658 | "no isis psnp-interval <1-120> level-1", |
| 2659 | NO_STR |
| 2660 | "IS-IS commands\n" |
| 2661 | "Set PSNP interval in seconds\n" |
| 2662 | "PSNP interval value\n" |
| 2663 | "Specify interval for level-1 PSNPs\n") |
| 2664 | |
| 2665 | DEFUN (psnp_interval_l2, |
| 2666 | psnp_interval_l2_cmd, |
| 2667 | "isis psnp-interval <1-120> level-2", |
| 2668 | "IS-IS commands\n" |
| 2669 | "Set PSNP interval in seconds\n" |
| 2670 | "PSNP interval value\n" |
| 2671 | "Specify interval for level-2 PSNPs\n") |
| 2672 | { |
| 2673 | unsigned long interval; |
| 2674 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2675 | if (!circuit) |
| 2676 | return CMD_ERR_NO_MATCH; |
| 2677 | |
| 2678 | interval = atol (argv[0]); |
| 2679 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) |
| 2680 | { |
| 2681 | vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s", |
| 2682 | interval, VTY_NEWLINE); |
| 2683 | return CMD_ERR_AMBIGUOUS; |
| 2684 | } |
| 2685 | |
| 2686 | circuit->psnp_interval[1] = (u_int16_t) interval; |
| 2687 | |
| 2688 | return CMD_SUCCESS; |
| 2689 | } |
| 2690 | |
| 2691 | DEFUN (no_psnp_interval_l2, |
| 2692 | no_psnp_interval_l2_cmd, |
| 2693 | "no isis psnp-interval level-2", |
| 2694 | NO_STR |
| 2695 | "IS-IS commands\n" |
| 2696 | "Set PSNP interval in seconds\n" |
| 2697 | "Specify interval for level-2 PSNPs\n") |
| 2698 | { |
| 2699 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2700 | if (!circuit) |
| 2701 | return CMD_ERR_NO_MATCH; |
| 2702 | |
| 2703 | circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL; |
| 2704 | |
| 2705 | return CMD_SUCCESS; |
| 2706 | } |
| 2707 | |
| 2708 | ALIAS (no_psnp_interval_l2, |
| 2709 | no_psnp_interval_l2_arg_cmd, |
| 2710 | "no isis psnp-interval <1-120> level-2", |
| 2711 | NO_STR |
| 2712 | "IS-IS commands\n" |
| 2713 | "Set PSNP interval in seconds\n" |
| 2714 | "PSNP interval value\n" |
| 2715 | "Specify interval for level-2 PSNPs\n") |
| 2716 | |
| 2717 | struct cmd_node interface_node = { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2718 | INTERFACE_NODE, |
| 2719 | "%s(config-if)# ", |
| 2720 | 1, |
| 2721 | }; |
| 2722 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2723 | DEFUN (isis_network, |
| 2724 | isis_network_cmd, |
| 2725 | "isis network point-to-point", |
| 2726 | "IS-IS commands\n" |
| 2727 | "Set network type\n" |
| 2728 | "point-to-point network type\n") |
| 2729 | { |
| 2730 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2731 | if (!circuit) |
| 2732 | return CMD_ERR_NO_MATCH; |
| 2733 | |
| 2734 | /* RFC5309 section 4 */ |
| 2735 | if (circuit->circ_type == CIRCUIT_T_P2P) |
| 2736 | return CMD_SUCCESS; |
| 2737 | |
| 2738 | if (circuit->state != C_STATE_UP) |
| 2739 | { |
| 2740 | circuit->circ_type = CIRCUIT_T_P2P; |
| 2741 | circuit->circ_type_config = CIRCUIT_T_P2P; |
| 2742 | } |
| 2743 | else |
| 2744 | { |
| 2745 | struct isis_area *area = circuit->area; |
| 2746 | if (!if_is_broadcast (circuit->interface)) |
| 2747 | { |
| 2748 | vty_out (vty, "isis network point-to-point " |
| 2749 | "is valid only on broadcast interfaces%s", |
| 2750 | VTY_NEWLINE); |
| 2751 | return CMD_ERR_AMBIGUOUS; |
| 2752 | } |
| 2753 | |
| 2754 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
| 2755 | circuit->circ_type = CIRCUIT_T_P2P; |
| 2756 | circuit->circ_type_config = CIRCUIT_T_P2P; |
| 2757 | isis_csm_state_change (ISIS_ENABLE, circuit, area); |
| 2758 | } |
| 2759 | |
| 2760 | return CMD_SUCCESS; |
| 2761 | } |
| 2762 | |
| 2763 | DEFUN (no_isis_network, |
| 2764 | no_isis_network_cmd, |
| 2765 | "no isis network point-to-point", |
| 2766 | NO_STR |
| 2767 | "IS-IS commands\n" |
| 2768 | "Set network type for circuit\n" |
| 2769 | "point-to-point network type\n") |
| 2770 | { |
| 2771 | struct isis_circuit *circuit = isis_circuit_lookup (vty); |
| 2772 | if (!circuit) |
| 2773 | return CMD_ERR_NO_MATCH; |
| 2774 | |
| 2775 | /* RFC5309 section 4 */ |
| 2776 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 2777 | return CMD_SUCCESS; |
| 2778 | |
| 2779 | if (circuit->state != C_STATE_UP) |
| 2780 | { |
| 2781 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
| 2782 | circuit->circ_type_config = CIRCUIT_T_BROADCAST; |
| 2783 | } |
| 2784 | else |
| 2785 | { |
| 2786 | struct isis_area *area = circuit->area; |
| 2787 | if (circuit->interface && |
| 2788 | !if_is_broadcast (circuit->interface)) |
| 2789 | { |
| 2790 | vty_out (vty, "no isis network point-to-point " |
| 2791 | "is valid only on broadcast interfaces%s", |
| 2792 | VTY_NEWLINE); |
| 2793 | return CMD_ERR_AMBIGUOUS; |
| 2794 | } |
| 2795 | |
| 2796 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
| 2797 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
| 2798 | circuit->circ_type_config = CIRCUIT_T_BROADCAST; |
| 2799 | isis_csm_state_change (ISIS_ENABLE, circuit, area); |
| 2800 | } |
| 2801 | |
| 2802 | return CMD_SUCCESS; |
| 2803 | } |
| 2804 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2805 | int |
| 2806 | isis_if_new_hook (struct interface *ifp) |
| 2807 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2808 | return 0; |
| 2809 | } |
| 2810 | |
| 2811 | int |
| 2812 | isis_if_delete_hook (struct interface *ifp) |
| 2813 | { |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 2814 | struct isis_circuit *circuit; |
| 2815 | /* Clean up the circuit data */ |
| 2816 | if (ifp && ifp->info) |
| 2817 | { |
| 2818 | circuit = ifp->info; |
| 2819 | isis_csm_state_change (IF_DOWN_FROM_Z, circuit, circuit->area); |
| 2820 | isis_csm_state_change (ISIS_DISABLE, circuit, circuit->area); |
| 2821 | } |
| 2822 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2823 | return 0; |
| 2824 | } |
| 2825 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2826 | void |
| 2827 | isis_circuit_init () |
| 2828 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2829 | /* Initialize Zebra interface data structure */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2830 | if_add_hook (IF_NEW_HOOK, isis_if_new_hook); |
| 2831 | if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook); |
| 2832 | |
| 2833 | /* Install interface node */ |
| 2834 | install_node (&interface_node, isis_interface_config_write); |
| 2835 | install_element (CONFIG_NODE, &interface_cmd); |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 2836 | install_element (CONFIG_NODE, &no_interface_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2837 | |
| 2838 | install_default (INTERFACE_NODE); |
| 2839 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 2840 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 2841 | |
| 2842 | install_element (INTERFACE_NODE, &ip_router_isis_cmd); |
| 2843 | install_element (INTERFACE_NODE, &no_ip_router_isis_cmd); |
| 2844 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2845 | install_element (INTERFACE_NODE, &isis_passive_cmd); |
| 2846 | install_element (INTERFACE_NODE, &no_isis_passive_cmd); |
| 2847 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2848 | install_element (INTERFACE_NODE, &isis_circuit_type_cmd); |
| 2849 | install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd); |
| 2850 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2851 | install_element (INTERFACE_NODE, &isis_passwd_clear_cmd); |
| 2852 | install_element (INTERFACE_NODE, &isis_passwd_md5_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2853 | install_element (INTERFACE_NODE, &no_isis_passwd_cmd); |
| 2854 | |
| 2855 | install_element (INTERFACE_NODE, &isis_priority_cmd); |
| 2856 | install_element (INTERFACE_NODE, &no_isis_priority_cmd); |
| 2857 | install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd); |
| 2858 | install_element (INTERFACE_NODE, &isis_priority_l1_cmd); |
| 2859 | install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd); |
| 2860 | install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd); |
| 2861 | install_element (INTERFACE_NODE, &isis_priority_l2_cmd); |
| 2862 | install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd); |
| 2863 | install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd); |
| 2864 | |
| 2865 | install_element (INTERFACE_NODE, &isis_metric_cmd); |
| 2866 | install_element (INTERFACE_NODE, &no_isis_metric_cmd); |
| 2867 | install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2868 | install_element (INTERFACE_NODE, &isis_metric_l1_cmd); |
| 2869 | install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd); |
| 2870 | install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd); |
| 2871 | install_element (INTERFACE_NODE, &isis_metric_l2_cmd); |
| 2872 | install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd); |
| 2873 | install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2874 | |
| 2875 | install_element (INTERFACE_NODE, &isis_hello_interval_cmd); |
| 2876 | install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd); |
| 2877 | install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd); |
| 2878 | install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd); |
| 2879 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); |
| 2880 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd); |
| 2881 | install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd); |
| 2882 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); |
| 2883 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd); |
| 2884 | |
| 2885 | install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd); |
| 2886 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd); |
| 2887 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd); |
| 2888 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); |
| 2889 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); |
| 2890 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd); |
| 2891 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); |
| 2892 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); |
| 2893 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd); |
| 2894 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2895 | install_element (INTERFACE_NODE, &isis_hello_padding_cmd); |
| 2896 | install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd); |
| 2897 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2898 | install_element (INTERFACE_NODE, &csnp_interval_cmd); |
| 2899 | install_element (INTERFACE_NODE, &no_csnp_interval_cmd); |
| 2900 | install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd); |
| 2901 | install_element (INTERFACE_NODE, &csnp_interval_l1_cmd); |
| 2902 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd); |
| 2903 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd); |
| 2904 | install_element (INTERFACE_NODE, &csnp_interval_l2_cmd); |
| 2905 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd); |
| 2906 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd); |
| 2907 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 2908 | install_element (INTERFACE_NODE, &psnp_interval_cmd); |
| 2909 | install_element (INTERFACE_NODE, &no_psnp_interval_cmd); |
| 2910 | install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd); |
| 2911 | install_element (INTERFACE_NODE, &psnp_interval_l1_cmd); |
| 2912 | install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd); |
| 2913 | install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd); |
| 2914 | install_element (INTERFACE_NODE, &psnp_interval_l2_cmd); |
| 2915 | install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd); |
| 2916 | install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd); |
| 2917 | |
| 2918 | install_element (INTERFACE_NODE, &isis_network_cmd); |
| 2919 | install_element (INTERFACE_NODE, &no_isis_network_cmd); |
| 2920 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2921 | #ifdef HAVE_IPV6 |
| 2922 | install_element (INTERFACE_NODE, &ipv6_router_isis_cmd); |
| 2923 | install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2924 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2925 | } |