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" |
Olivier Dugeon | 4f59357 | 2016-04-19 19:03:05 +0200 | [diff] [blame] | 39 | #include "vty.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 40 | #include "hash.h" |
| 41 | #include "prefix.h" |
| 42 | #include "stream.h" |
| 43 | |
| 44 | #include "isisd/dict.h" |
| 45 | #include "isisd/include-netbsd/iso.h" |
| 46 | #include "isisd/isis_constants.h" |
| 47 | #include "isisd/isis_common.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 48 | #include "isisd/isis_flags.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 49 | #include "isisd/isis_circuit.h" |
| 50 | #include "isisd/isis_tlv.h" |
| 51 | #include "isisd/isis_lsp.h" |
| 52 | #include "isisd/isis_pdu.h" |
| 53 | #include "isisd/isis_network.h" |
| 54 | #include "isisd/isis_misc.h" |
| 55 | #include "isisd/isis_constants.h" |
| 56 | #include "isisd/isis_adjacency.h" |
| 57 | #include "isisd/isis_dr.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 58 | #include "isisd/isisd.h" |
| 59 | #include "isisd/isis_csm.h" |
| 60 | #include "isisd/isis_events.h" |
Olivier Dugeon | 4f59357 | 2016-04-19 19:03:05 +0200 | [diff] [blame] | 61 | #include "isisd/isis_te.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 62 | |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 63 | /* |
| 64 | * Prototypes. |
| 65 | */ |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 66 | int isis_interface_config_write(struct vty *); |
| 67 | int isis_if_new_hook(struct interface *); |
| 68 | int isis_if_delete_hook(struct interface *); |
| 69 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 70 | struct isis_circuit * |
| 71 | isis_circuit_new () |
| 72 | { |
| 73 | struct isis_circuit *circuit; |
| 74 | int i; |
| 75 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 76 | circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit)); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 77 | if (circuit == NULL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 78 | { |
| 79 | zlog_err ("Can't malloc isis circuit"); |
| 80 | return NULL; |
| 81 | } |
| 82 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 83 | /* |
| 84 | * Default values |
| 85 | */ |
| 86 | circuit->is_type = IS_LEVEL_1_AND_2; |
| 87 | circuit->flags = 0; |
| 88 | circuit->pad_hellos = 1; |
| 89 | for (i = 0; i < 2; i++) |
| 90 | { |
| 91 | circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL; |
| 92 | circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER; |
| 93 | circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL; |
| 94 | circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL; |
| 95 | circuit->priority[i] = DEFAULT_PRIORITY; |
David Lamparter | f263413 | 2016-07-28 17:23:32 +0200 | [diff] [blame] | 96 | circuit->metric[i] = DEFAULT_CIRCUIT_METRIC; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 97 | circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC; |
| 98 | } |
| 99 | |
Olivier Dugeon | 4f59357 | 2016-04-19 19:03:05 +0200 | [diff] [blame] | 100 | circuit->mtc = mpls_te_circuit_new(); |
| 101 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 102 | return circuit; |
| 103 | } |
| 104 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 105 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 106 | isis_circuit_del (struct isis_circuit *circuit) |
| 107 | { |
| 108 | if (!circuit) |
| 109 | return; |
| 110 | |
| 111 | isis_circuit_if_unbind (circuit, circuit->interface); |
| 112 | |
| 113 | /* and lastly the circuit itself */ |
| 114 | XFREE (MTYPE_ISIS_CIRCUIT, circuit); |
| 115 | |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 120 | isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area) |
| 121 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 122 | assert (area); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 123 | circuit->area = area; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 124 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 125 | /* |
Christian Franke | 7324ae1 | 2015-11-10 18:04:48 +0100 | [diff] [blame] | 126 | * Whenever the is-type of an area is changed, the is-type of each circuit |
| 127 | * in that area is updated to a non-empty subset of the area is-type. |
| 128 | * Inversely, when configuring a new circuit, this property should be |
| 129 | * ensured as well. |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 130 | */ |
Christian Franke | 7324ae1 | 2015-11-10 18:04:48 +0100 | [diff] [blame] | 131 | if (area->is_type != IS_LEVEL_1_AND_2) |
| 132 | circuit->is_type = area->is_type; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 133 | |
| 134 | /* |
| 135 | * Add the circuit into area |
| 136 | */ |
| 137 | listnode_add (area->circuit_list, circuit); |
| 138 | |
| 139 | circuit->idx = flags_get_index (&area->flags); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 140 | |
| 141 | return; |
| 142 | } |
| 143 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 144 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 145 | isis_circuit_deconfigure (struct isis_circuit *circuit, struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 146 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 147 | /* Free the index of SRM and SSN flags */ |
| 148 | flags_free_index (&area->flags, circuit->idx); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 149 | circuit->idx = 0; |
| 150 | /* Remove circuit from area */ |
| 151 | assert (circuit->area == area); |
| 152 | listnode_delete (area->circuit_list, circuit); |
| 153 | circuit->area = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 154 | |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | struct isis_circuit * |
| 159 | circuit_lookup_by_ifp (struct interface *ifp, struct list *list) |
| 160 | { |
| 161 | struct isis_circuit *circuit = NULL; |
| 162 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 163 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 164 | if (!list) |
| 165 | return NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 166 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 167 | for (ALL_LIST_ELEMENTS_RO (list, node, circuit)) |
| 168 | if (circuit->interface == ifp) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 169 | { |
| 170 | assert (ifp->info == circuit); |
| 171 | return circuit; |
| 172 | } |
| 173 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 174 | return NULL; |
| 175 | } |
| 176 | |
| 177 | struct isis_circuit * |
| 178 | circuit_scan_by_ifp (struct interface *ifp) |
| 179 | { |
| 180 | struct isis_area *area; |
| 181 | struct listnode *node; |
| 182 | struct isis_circuit *circuit; |
| 183 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 184 | if (ifp->info) |
| 185 | return (struct isis_circuit *)ifp->info; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 186 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 187 | if (isis->area_list) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 188 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 189 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
| 190 | { |
| 191 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 192 | if (circuit) |
| 193 | return circuit; |
| 194 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 195 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 196 | return circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 197 | } |
| 198 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 199 | void |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 200 | isis_circuit_add_addr (struct isis_circuit *circuit, |
| 201 | struct connected *connected) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 202 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 203 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 204 | struct prefix_ipv4 *ipv4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 205 | u_char buf[BUFSIZ]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 206 | #ifdef HAVE_IPV6 |
| 207 | struct prefix_ipv6 *ipv6; |
| 208 | #endif /* HAVE_IPV6 */ |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 209 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 210 | memset (&buf, 0, BUFSIZ); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 211 | if (connected->address->family == AF_INET) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 212 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 213 | u_int32_t addr = connected->address->u.prefix4.s_addr; |
| 214 | addr = ntohl (addr); |
| 215 | if (IPV4_NET0(addr) || |
| 216 | IPV4_NET127(addr) || |
| 217 | IN_CLASSD(addr) || |
| 218 | IPV4_LINKLOCAL(addr)) |
| 219 | return; |
| 220 | |
| 221 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ipv4)) |
| 222 | if (prefix_same ((struct prefix *) ipv4, connected->address)) |
| 223 | return; |
| 224 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 225 | ipv4 = prefix_ipv4_new (); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 226 | ipv4->prefixlen = connected->address->prefixlen; |
| 227 | ipv4->prefix = connected->address->u.prefix4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 228 | listnode_add (circuit->ip_addrs, ipv4); |
Olivier Dugeon | 4f59357 | 2016-04-19 19:03:05 +0200 | [diff] [blame] | 229 | |
| 230 | /* Update MPLS TE Local IP address parameter */ |
| 231 | set_circuitparams_local_ipaddr (circuit->mtc, ipv4->prefix); |
| 232 | |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 233 | if (circuit->area) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 234 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 235 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 236 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 237 | prefix2str (connected->address, buf, BUFSIZ); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 238 | zlog_debug ("Added IP address %s to circuit %d", buf, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 239 | circuit->circuit_id); |
| 240 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 241 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 242 | #ifdef HAVE_IPV6 |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 243 | if (connected->address->family == AF_INET6) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 244 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 245 | if (IN6_IS_ADDR_LOOPBACK(&connected->address->u.prefix6)) |
| 246 | return; |
| 247 | |
| 248 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ipv6)) |
| 249 | if (prefix_same ((struct prefix *) ipv6, connected->address)) |
| 250 | return; |
| 251 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ipv6)) |
| 252 | if (prefix_same ((struct prefix *) ipv6, connected->address)) |
| 253 | return; |
| 254 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 255 | ipv6 = prefix_ipv6_new (); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 256 | ipv6->prefixlen = connected->address->prefixlen; |
| 257 | ipv6->prefix = connected->address->u.prefix6; |
| 258 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 259 | if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 260 | listnode_add (circuit->ipv6_link, ipv6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 261 | else |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 262 | listnode_add (circuit->ipv6_non_link, ipv6); |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 263 | if (circuit->area) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 264 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 265 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 266 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 267 | prefix2str (connected->address, buf, BUFSIZ); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 268 | zlog_debug ("Added IPv6 address %s to circuit %d", buf, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 269 | circuit->circuit_id); |
| 270 | #endif /* EXTREME_DEBUG */ |
| 271 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 272 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 273 | return; |
| 274 | } |
| 275 | |
| 276 | void |
| 277 | isis_circuit_del_addr (struct isis_circuit *circuit, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 278 | struct connected *connected) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 279 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 280 | struct prefix_ipv4 *ipv4, *ip = NULL; |
| 281 | struct listnode *node; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 282 | u_char buf[BUFSIZ]; |
| 283 | #ifdef HAVE_IPV6 |
| 284 | struct prefix_ipv6 *ipv6, *ip6 = NULL; |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 285 | int found = 0; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 286 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 287 | |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 288 | memset (&buf, 0, BUFSIZ); |
| 289 | if (connected->address->family == AF_INET) |
| 290 | { |
| 291 | ipv4 = prefix_ipv4_new (); |
| 292 | ipv4->prefixlen = connected->address->prefixlen; |
| 293 | ipv4->prefix = connected->address->u.prefix4; |
| 294 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 295 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip)) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 296 | if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 297 | break; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 298 | |
| 299 | if (ip) |
| 300 | { |
| 301 | listnode_delete (circuit->ip_addrs, ip); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 302 | if (circuit->area) |
| 303 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 304 | } |
| 305 | else |
| 306 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 307 | prefix2str (connected->address, (char *)buf, BUFSIZ); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 308 | zlog_warn ("Nonexitant ip address %s removal attempt from \ |
| 309 | circuit %d", buf, circuit->circuit_id); |
Christian Franke | ec87416 | 2015-11-10 18:33:12 +0100 | [diff] [blame] | 310 | zlog_warn ("Current ip addresses on %s:", circuit->interface->name); |
| 311 | for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, ip)) |
| 312 | { |
| 313 | prefix2str((struct prefix*)ip, (char *)buf, BUFSIZ); |
| 314 | zlog_warn(" %s", buf); |
| 315 | } |
| 316 | zlog_warn("End of addresses"); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 317 | } |
David Lamparter | e8aca32 | 2012-11-27 01:10:30 +0000 | [diff] [blame] | 318 | |
| 319 | prefix_ipv4_free (ipv4); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 320 | } |
| 321 | #ifdef HAVE_IPV6 |
| 322 | if (connected->address->family == AF_INET6) |
| 323 | { |
| 324 | ipv6 = prefix_ipv6_new (); |
| 325 | ipv6->prefixlen = connected->address->prefixlen; |
| 326 | ipv6->prefix = connected->address->u.prefix6; |
| 327 | |
| 328 | if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix)) |
| 329 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 330 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 331 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 332 | if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6)) |
| 333 | break; |
| 334 | } |
| 335 | if (ip6) |
| 336 | { |
| 337 | listnode_delete (circuit->ipv6_link, ip6); |
| 338 | found = 1; |
| 339 | } |
| 340 | } |
| 341 | else |
| 342 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 343 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 344 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 345 | if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6)) |
| 346 | break; |
| 347 | } |
| 348 | if (ip6) |
| 349 | { |
| 350 | listnode_delete (circuit->ipv6_non_link, ip6); |
| 351 | found = 1; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | if (!found) |
| 356 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 357 | prefix2str (connected->address, (char *)buf, BUFSIZ); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 358 | zlog_warn ("Nonexitant ip address %s removal attempt from \ |
| 359 | circuit %d", buf, circuit->circuit_id); |
Christian Franke | ec87416 | 2015-11-10 18:33:12 +0100 | [diff] [blame] | 360 | zlog_warn ("Current ip addresses on %s:", circuit->interface->name); |
| 361 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip6)) |
| 362 | { |
| 363 | prefix2str((struct prefix*)ip6, (char *)buf, BUFSIZ); |
| 364 | zlog_warn(" %s", buf); |
| 365 | } |
| 366 | zlog_warn(" -----"); |
| 367 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip6)) |
| 368 | { |
| 369 | prefix2str((struct prefix*)ip6, (char *)buf, BUFSIZ); |
| 370 | zlog_warn(" %s", buf); |
| 371 | } |
| 372 | zlog_warn("End of addresses"); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 373 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 374 | else if (circuit->area) |
| 375 | lsp_regenerate_schedule (circuit->area, circuit->is_type, 0); |
David Lamparter | e8aca32 | 2012-11-27 01:10:30 +0000 | [diff] [blame] | 376 | |
| 377 | prefix_ipv6_free (ipv6); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 378 | } |
| 379 | #endif /* HAVE_IPV6 */ |
| 380 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 381 | } |
| 382 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 383 | static u_char |
| 384 | isis_circuit_id_gen (struct interface *ifp) |
| 385 | { |
| 386 | u_char id = 0; |
| 387 | char ifname[16]; |
| 388 | unsigned int i; |
| 389 | int start = -1, end = -1; |
| 390 | |
| 391 | /* |
| 392 | * Get a stable circuit id from ifname. This makes |
| 393 | * the ifindex from flapping when netdevs are created |
| 394 | * and deleted on the fly. Note that this circuit id |
| 395 | * is used in pseudo lsps so it is better to be stable. |
| 396 | * The following code works on any reasonanle ifname |
| 397 | * like: eth1 or trk-1.1 etc. |
| 398 | */ |
| 399 | for (i = 0; i < strlen (ifp->name); i++) |
| 400 | { |
David Lamparter | 52f02b4 | 2015-04-10 09:14:30 +0200 | [diff] [blame] | 401 | if (isdigit((unsigned char)ifp->name[i])) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 402 | { |
| 403 | if (start < 0) |
| 404 | { |
| 405 | start = i; |
| 406 | end = i + 1; |
| 407 | } |
| 408 | else |
| 409 | { |
| 410 | end = i + 1; |
| 411 | } |
| 412 | } |
| 413 | else if (start >= 0) |
| 414 | break; |
| 415 | } |
| 416 | |
| 417 | if ((start >= 0) && (end >= start) && (end - start) < 16) |
| 418 | { |
| 419 | memset (ifname, 0, 16); |
| 420 | strncpy (ifname, &ifp->name[start], end - start); |
| 421 | id = (u_char)atoi(ifname); |
| 422 | } |
| 423 | |
| 424 | /* Try to be unique. */ |
| 425 | if (!id) |
| 426 | id = (u_char)((ifp->ifindex & 0xff) | 0x80); |
| 427 | |
| 428 | return id; |
| 429 | } |
| 430 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 431 | void |
| 432 | isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp) |
| 433 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 434 | struct listnode *node, *nnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 435 | struct connected *conn; |
| 436 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 437 | circuit->circuit_id = isis_circuit_id_gen (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 438 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 439 | isis_circuit_if_bind (circuit, ifp); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 440 | /* isis_circuit_update_addrs (circuit, ifp); */ |
| 441 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 442 | if (if_is_broadcast (ifp)) |
| 443 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 444 | if (circuit->circ_type_config == CIRCUIT_T_P2P) |
| 445 | circuit->circ_type = CIRCUIT_T_P2P; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 446 | else |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 447 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 448 | } |
| 449 | else if (if_is_pointopoint (ifp)) |
| 450 | { |
| 451 | circuit->circ_type = CIRCUIT_T_P2P; |
| 452 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 453 | else if (if_is_loopback (ifp)) |
| 454 | { |
| 455 | circuit->circ_type = CIRCUIT_T_LOOPBACK; |
| 456 | circuit->is_passive = 1; |
| 457 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 458 | else |
| 459 | { |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 460 | /* It's normal in case of loopback etc. */ |
| 461 | if (isis->debugs & DEBUG_EVENTS) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 462 | zlog_debug ("isis_circuit_if_add: unsupported media"); |
| 463 | circuit->circ_type = CIRCUIT_T_UNKNOWN; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 464 | } |
| 465 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 466 | circuit->ip_addrs = list_new (); |
| 467 | #ifdef HAVE_IPV6 |
| 468 | circuit->ipv6_link = list_new (); |
| 469 | circuit->ipv6_non_link = list_new (); |
| 470 | #endif /* HAVE_IPV6 */ |
| 471 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 472 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn)) |
| 473 | isis_circuit_add_addr (circuit, conn); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 474 | |
| 475 | return; |
| 476 | } |
| 477 | |
| 478 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 479 | isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 480 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 481 | struct listnode *node, *nnode; |
| 482 | struct connected *conn; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 483 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 484 | assert (circuit->interface == ifp); |
| 485 | |
| 486 | /* destroy addresses */ |
| 487 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn)) |
| 488 | isis_circuit_del_addr (circuit, conn); |
| 489 | |
| 490 | if (circuit->ip_addrs) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 491 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 492 | assert (listcount(circuit->ip_addrs) == 0); |
| 493 | list_delete (circuit->ip_addrs); |
| 494 | circuit->ip_addrs = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 495 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 496 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 497 | #ifdef HAVE_IPV6 |
| 498 | if (circuit->ipv6_link) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 499 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 500 | assert (listcount(circuit->ipv6_link) == 0); |
| 501 | list_delete (circuit->ipv6_link); |
| 502 | circuit->ipv6_link = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 503 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 504 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 505 | if (circuit->ipv6_non_link) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 506 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 507 | assert (listcount(circuit->ipv6_non_link) == 0); |
| 508 | list_delete (circuit->ipv6_non_link); |
| 509 | circuit->ipv6_non_link = NULL; |
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 | #endif /* HAVE_IPV6 */ |
| 512 | |
| 513 | circuit->circ_type = CIRCUIT_T_UNKNOWN; |
| 514 | circuit->circuit_id = 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 515 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 516 | return; |
| 517 | } |
| 518 | |
| 519 | void |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 520 | isis_circuit_if_bind (struct isis_circuit *circuit, struct interface *ifp) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 521 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 522 | assert (circuit != NULL); |
| 523 | assert (ifp != NULL); |
| 524 | if (circuit->interface) |
| 525 | assert (circuit->interface == ifp); |
| 526 | else |
| 527 | circuit->interface = ifp; |
| 528 | if (ifp->info) |
| 529 | assert (ifp->info == circuit); |
| 530 | else |
| 531 | ifp->info = circuit; |
Olivier Dugeon | 4f59357 | 2016-04-19 19:03:05 +0200 | [diff] [blame] | 532 | isis_link_params_update (circuit, ifp); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | void |
| 536 | isis_circuit_if_unbind (struct isis_circuit *circuit, struct interface *ifp) |
| 537 | { |
| 538 | assert (circuit != NULL); |
| 539 | assert (ifp != NULL); |
| 540 | assert (circuit->interface == ifp); |
| 541 | assert (ifp->info == circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 542 | circuit->interface = NULL; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 543 | ifp->info = NULL; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 546 | static void |
| 547 | isis_circuit_update_all_srmflags (struct isis_circuit *circuit, int is_set) |
| 548 | { |
| 549 | struct isis_area *area; |
| 550 | struct isis_lsp *lsp; |
| 551 | dnode_t *dnode, *dnode_next; |
| 552 | int level; |
| 553 | |
| 554 | assert (circuit); |
| 555 | area = circuit->area; |
| 556 | assert (area); |
| 557 | for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) |
| 558 | { |
| 559 | if (level & circuit->is_type) |
| 560 | { |
| 561 | if (area->lspdb[level - 1] && |
| 562 | dict_count (area->lspdb[level - 1]) > 0) |
| 563 | { |
| 564 | for (dnode = dict_first (area->lspdb[level - 1]); |
| 565 | dnode != NULL; dnode = dnode_next) |
| 566 | { |
| 567 | dnode_next = dict_next (area->lspdb[level - 1], dnode); |
| 568 | lsp = dnode_get (dnode); |
| 569 | if (is_set) |
| 570 | { |
| 571 | ISIS_SET_FLAG (lsp->SRMflags, circuit); |
| 572 | } |
| 573 | else |
| 574 | { |
| 575 | ISIS_CLEAR_FLAG (lsp->SRMflags, circuit); |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | } |
| 582 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 583 | size_t |
| 584 | isis_circuit_pdu_size(struct isis_circuit *circuit) |
| 585 | { |
| 586 | return ISO_MTU(circuit); |
| 587 | } |
| 588 | |
| 589 | void |
| 590 | isis_circuit_stream(struct isis_circuit *circuit, struct stream **stream) |
| 591 | { |
| 592 | size_t stream_size = isis_circuit_pdu_size(circuit); |
| 593 | |
| 594 | if (!*stream) |
| 595 | { |
| 596 | *stream = stream_new(stream_size); |
| 597 | } |
| 598 | else |
| 599 | { |
| 600 | if (STREAM_SIZE(*stream) != stream_size) |
| 601 | stream_resize(*stream, stream_size); |
| 602 | stream_reset(*stream); |
| 603 | } |
| 604 | } |
| 605 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 606 | int |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 607 | isis_circuit_up (struct isis_circuit *circuit) |
| 608 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 609 | int retv; |
| 610 | |
| 611 | /* Set the flags for all the lsps of the circuit. */ |
| 612 | isis_circuit_update_all_srmflags (circuit, 1); |
| 613 | |
| 614 | if (circuit->state == C_STATE_UP) |
| 615 | return ISIS_OK; |
| 616 | |
| 617 | if (circuit->is_passive) |
| 618 | return ISIS_OK; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 619 | |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 620 | if (circuit->area->lsp_mtu > isis_circuit_pdu_size(circuit)) |
| 621 | { |
| 622 | zlog_err("Interface MTU %zu on %s is too low to support area lsp mtu %u!", |
| 623 | isis_circuit_pdu_size(circuit), circuit->interface->name, |
| 624 | circuit->area->lsp_mtu); |
Christian Franke | 8ed8d0b | 2016-04-03 12:46:26 -0300 | [diff] [blame] | 625 | isis_circuit_update_all_srmflags(circuit, 0); |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 626 | return ISIS_ERROR; |
| 627 | } |
| 628 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 629 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 630 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 631 | /* |
| 632 | * Get the Hardware Address |
| 633 | */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 634 | if (circuit->interface->hw_addr_len != ETH_ALEN) |
| 635 | { |
| 636 | zlog_warn ("unsupported link layer"); |
| 637 | } |
| 638 | else |
| 639 | { |
| 640 | memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN); |
| 641 | } |
| 642 | #ifdef EXTREME_DEGUG |
| 643 | zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s", |
| 644 | circuit->interface->ifindex, ISO_MTU (circuit), |
| 645 | snpa_print (circuit->u.bc.snpa)); |
| 646 | #endif /* EXTREME_DEBUG */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 647 | |
| 648 | circuit->u.bc.adjdb[0] = list_new (); |
| 649 | circuit->u.bc.adjdb[1] = list_new (); |
| 650 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 651 | /* |
| 652 | * ISO 10589 - 8.4.1 Enabling of broadcast circuits |
| 653 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 654 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 655 | /* initilizing the hello sending threads |
| 656 | * for a broadcast IF |
| 657 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 658 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 659 | /* 8.4.1 a) commence sending of IIH PDUs */ |
| 660 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 661 | if (circuit->is_type & IS_LEVEL_1) |
| 662 | { |
| 663 | thread_add_event (master, send_lan_l1_hello, circuit, 0); |
| 664 | circuit->u.bc.lan_neighs[0] = list_new (); |
| 665 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 666 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 667 | if (circuit->is_type & IS_LEVEL_2) |
| 668 | { |
| 669 | thread_add_event (master, send_lan_l2_hello, circuit, 0); |
| 670 | circuit->u.bc.lan_neighs[1] = list_new (); |
| 671 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 672 | |
| 673 | /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */ |
| 674 | /* 8.4.1 c) FIXME: listen for ESH PDUs */ |
| 675 | |
| 676 | /* 8.4.1 d) */ |
| 677 | /* dr election will commence in... */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 678 | if (circuit->is_type & IS_LEVEL_1) |
| 679 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1, |
| 680 | circuit, 2 * circuit->hello_interval[0]); |
| 681 | if (circuit->is_type & IS_LEVEL_2) |
| 682 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2, |
| 683 | circuit, 2 * circuit->hello_interval[1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 684 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 685 | else |
| 686 | { |
| 687 | /* initializing the hello send threads |
| 688 | * for a ptp IF |
| 689 | */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 690 | circuit->u.p2p.neighbor = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 691 | thread_add_event (master, send_p2p_hello, circuit, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 692 | } |
| 693 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 694 | /* initializing PSNP timers */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 695 | if (circuit->is_type & IS_LEVEL_1) |
| 696 | THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit, |
| 697 | isis_jitter (circuit->psnp_interval[0], PSNP_JITTER)); |
| 698 | |
| 699 | if (circuit->is_type & IS_LEVEL_2) |
| 700 | THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit, |
| 701 | isis_jitter (circuit->psnp_interval[1], PSNP_JITTER)); |
| 702 | |
| 703 | /* unified init for circuits; ignore warnings below this level */ |
| 704 | retv = isis_sock_init (circuit); |
| 705 | if (retv != ISIS_OK) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 706 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 707 | isis_circuit_down (circuit); |
| 708 | return retv; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 709 | } |
| 710 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 711 | /* initialize the circuit streams after opening connection */ |
Christian Franke | f1fc1db | 2015-11-10 18:43:31 +0100 | [diff] [blame] | 712 | isis_circuit_stream(circuit, &circuit->rcv_stream); |
| 713 | isis_circuit_stream(circuit, &circuit->snd_stream); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 714 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 715 | #ifdef GNU_LINUX |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 716 | THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 717 | circuit->fd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 718 | #else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 719 | THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit, |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 720 | circuit->fd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 721 | #endif |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 722 | |
| 723 | circuit->lsp_queue = list_new (); |
| 724 | circuit->lsp_queue_last_cleared = time (NULL); |
| 725 | |
| 726 | return ISIS_OK; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | void |
| 730 | isis_circuit_down (struct isis_circuit *circuit) |
| 731 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 732 | if (circuit->state != C_STATE_UP) |
| 733 | return; |
| 734 | |
| 735 | /* Clear the flags for all the lsps of the circuit. */ |
| 736 | isis_circuit_update_all_srmflags (circuit, 0); |
| 737 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 738 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 739 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 740 | /* destroy neighbour lists */ |
| 741 | if (circuit->u.bc.lan_neighs[0]) |
| 742 | { |
| 743 | list_delete (circuit->u.bc.lan_neighs[0]); |
| 744 | circuit->u.bc.lan_neighs[0] = NULL; |
| 745 | } |
| 746 | if (circuit->u.bc.lan_neighs[1]) |
| 747 | { |
| 748 | list_delete (circuit->u.bc.lan_neighs[1]); |
| 749 | circuit->u.bc.lan_neighs[1] = NULL; |
| 750 | } |
| 751 | /* destroy adjacency databases */ |
| 752 | if (circuit->u.bc.adjdb[0]) |
| 753 | { |
| 754 | circuit->u.bc.adjdb[0]->del = isis_delete_adj; |
| 755 | list_delete (circuit->u.bc.adjdb[0]); |
| 756 | circuit->u.bc.adjdb[0] = NULL; |
| 757 | } |
| 758 | if (circuit->u.bc.adjdb[1]) |
| 759 | { |
| 760 | circuit->u.bc.adjdb[1]->del = isis_delete_adj; |
| 761 | list_delete (circuit->u.bc.adjdb[1]); |
| 762 | circuit->u.bc.adjdb[1] = NULL; |
| 763 | } |
| 764 | if (circuit->u.bc.is_dr[0]) |
| 765 | { |
| 766 | isis_dr_resign (circuit, 1); |
| 767 | circuit->u.bc.is_dr[0] = 0; |
| 768 | } |
| 769 | memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1); |
| 770 | if (circuit->u.bc.is_dr[1]) |
| 771 | { |
| 772 | isis_dr_resign (circuit, 2); |
| 773 | circuit->u.bc.is_dr[1] = 0; |
| 774 | } |
| 775 | memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1); |
| 776 | memset (circuit->u.bc.snpa, 0, ETH_ALEN); |
| 777 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 778 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]); |
| 779 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 780 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]); |
| 781 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 782 | THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[0]); |
| 783 | THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[1]); |
Christian Franke | 61010c3 | 2015-11-10 18:43:34 +0100 | [diff] [blame] | 784 | circuit->lsp_regenerate_pending[0] = 0; |
| 785 | circuit->lsp_regenerate_pending[1] = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 786 | } |
| 787 | else if (circuit->circ_type == CIRCUIT_T_P2P) |
| 788 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 789 | isis_delete_adj (circuit->u.p2p.neighbor); |
| 790 | circuit->u.p2p.neighbor = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 791 | THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello); |
| 792 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 793 | |
| 794 | /* Cancel all active threads */ |
| 795 | THREAD_TIMER_OFF (circuit->t_send_csnp[0]); |
| 796 | THREAD_TIMER_OFF (circuit->t_send_csnp[1]); |
| 797 | THREAD_TIMER_OFF (circuit->t_send_psnp[0]); |
| 798 | THREAD_TIMER_OFF (circuit->t_send_psnp[1]); |
| 799 | THREAD_OFF (circuit->t_read); |
| 800 | |
| 801 | if (circuit->lsp_queue) |
| 802 | { |
| 803 | circuit->lsp_queue->del = NULL; |
| 804 | list_delete (circuit->lsp_queue); |
| 805 | circuit->lsp_queue = NULL; |
| 806 | } |
| 807 | |
| 808 | /* send one gratuitous hello to spead up convergence */ |
| 809 | if (circuit->is_type & IS_LEVEL_1) |
| 810 | send_hello (circuit, IS_LEVEL_1); |
| 811 | if (circuit->is_type & IS_LEVEL_2) |
| 812 | send_hello (circuit, IS_LEVEL_2); |
| 813 | |
| 814 | circuit->upadjcount[0] = 0; |
| 815 | circuit->upadjcount[1] = 0; |
| 816 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 817 | /* close the socket */ |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 818 | if (circuit->fd) |
| 819 | { |
| 820 | close (circuit->fd); |
| 821 | circuit->fd = 0; |
| 822 | } |
| 823 | |
| 824 | if (circuit->rcv_stream != NULL) |
| 825 | { |
| 826 | stream_free (circuit->rcv_stream); |
| 827 | circuit->rcv_stream = NULL; |
| 828 | } |
| 829 | |
| 830 | if (circuit->snd_stream != NULL) |
| 831 | { |
| 832 | stream_free (circuit->snd_stream); |
| 833 | circuit->snd_stream = NULL; |
| 834 | } |
| 835 | |
| 836 | thread_cancel_event (master, circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 837 | |
| 838 | return; |
| 839 | } |
| 840 | |
| 841 | void |
| 842 | circuit_update_nlpids (struct isis_circuit *circuit) |
| 843 | { |
| 844 | circuit->nlpids.count = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 845 | |
| 846 | if (circuit->ip_router) |
| 847 | { |
| 848 | circuit->nlpids.nlpids[0] = NLPID_IP; |
| 849 | circuit->nlpids.count++; |
| 850 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 851 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 852 | if (circuit->ipv6_router) |
| 853 | { |
| 854 | circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6; |
| 855 | circuit->nlpids.count++; |
| 856 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 857 | #endif /* HAVE_IPV6 */ |
| 858 | return; |
| 859 | } |
| 860 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 861 | void |
| 862 | isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty, |
| 863 | char detail) |
| 864 | { |
| 865 | if (detail == ISIS_UI_LEVEL_BRIEF) |
| 866 | { |
| 867 | vty_out (vty, " %-12s", circuit->interface->name); |
| 868 | vty_out (vty, "0x%-7x", circuit->circuit_id); |
| 869 | vty_out (vty, "%-9s", circuit_state2string (circuit->state)); |
| 870 | vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type)); |
| 871 | vty_out (vty, "%-9s", circuit_t2string (circuit->is_type)); |
| 872 | vty_out (vty, "%s", VTY_NEWLINE); |
| 873 | } |
| 874 | |
| 875 | if (detail == ISIS_UI_LEVEL_DETAIL) |
| 876 | { |
Christian Franke | cb32a19 | 2015-11-10 18:33:13 +0100 | [diff] [blame] | 877 | struct listnode *node; |
| 878 | struct prefix *ip_addr; |
| 879 | u_char buf[BUFSIZ]; |
| 880 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 881 | vty_out (vty, " Interface: %s", circuit->interface->name); |
| 882 | vty_out (vty, ", State: %s", circuit_state2string (circuit->state)); |
| 883 | if (circuit->is_passive) |
| 884 | vty_out (vty, ", Passive"); |
| 885 | else |
| 886 | vty_out (vty, ", Active"); |
| 887 | vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id); |
| 888 | vty_out (vty, "%s", VTY_NEWLINE); |
| 889 | vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type)); |
| 890 | vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type)); |
| 891 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 892 | vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa)); |
| 893 | vty_out (vty, "%s", VTY_NEWLINE); |
| 894 | if (circuit->is_type & IS_LEVEL_1) |
| 895 | { |
| 896 | vty_out (vty, " Level-1 Information:%s", VTY_NEWLINE); |
| 897 | if (circuit->area->newmetric) |
| 898 | vty_out (vty, " Metric: %d", circuit->te_metric[0]); |
| 899 | else |
| 900 | vty_out (vty, " Metric: %d", |
David Lamparter | f263413 | 2016-07-28 17:23:32 +0200 | [diff] [blame] | 901 | circuit->metric[0]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 902 | if (!circuit->is_passive) |
| 903 | { |
| 904 | vty_out (vty, ", Active neighbors: %u%s", |
| 905 | circuit->upadjcount[0], VTY_NEWLINE); |
| 906 | vty_out (vty, " Hello interval: %u, " |
| 907 | "Holddown count: %u %s%s", |
| 908 | circuit->hello_interval[0], |
| 909 | circuit->hello_multiplier[0], |
| 910 | (circuit->pad_hellos ? "(pad)" : "(no-pad)"), |
| 911 | VTY_NEWLINE); |
| 912 | vty_out (vty, " CNSP interval: %u, " |
| 913 | "PSNP interval: %u%s", |
| 914 | circuit->csnp_interval[0], |
| 915 | circuit->psnp_interval[0], VTY_NEWLINE); |
| 916 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 917 | vty_out (vty, " LAN Priority: %u, %s%s", |
| 918 | circuit->priority[0], |
| 919 | (circuit->u.bc.is_dr[0] ? \ |
| 920 | "is DIS" : "is not DIS"), VTY_NEWLINE); |
| 921 | } |
| 922 | else |
| 923 | { |
| 924 | vty_out (vty, "%s", VTY_NEWLINE); |
| 925 | } |
| 926 | } |
| 927 | if (circuit->is_type & IS_LEVEL_2) |
| 928 | { |
| 929 | vty_out (vty, " Level-2 Information:%s", VTY_NEWLINE); |
| 930 | if (circuit->area->newmetric) |
| 931 | vty_out (vty, " Metric: %d", circuit->te_metric[1]); |
| 932 | else |
| 933 | vty_out (vty, " Metric: %d", |
David Lamparter | f263413 | 2016-07-28 17:23:32 +0200 | [diff] [blame] | 934 | circuit->metric[1]); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 935 | if (!circuit->is_passive) |
| 936 | { |
| 937 | vty_out (vty, ", Active neighbors: %u%s", |
| 938 | circuit->upadjcount[1], VTY_NEWLINE); |
| 939 | vty_out (vty, " Hello interval: %u, " |
| 940 | "Holddown count: %u %s%s", |
| 941 | circuit->hello_interval[1], |
| 942 | circuit->hello_multiplier[1], |
| 943 | (circuit->pad_hellos ? "(pad)" : "(no-pad)"), |
| 944 | VTY_NEWLINE); |
| 945 | vty_out (vty, " CNSP interval: %u, " |
| 946 | "PSNP interval: %u%s", |
| 947 | circuit->csnp_interval[1], |
| 948 | circuit->psnp_interval[1], VTY_NEWLINE); |
| 949 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 950 | vty_out (vty, " LAN Priority: %u, %s%s", |
| 951 | circuit->priority[1], |
| 952 | (circuit->u.bc.is_dr[1] ? \ |
| 953 | "is DIS" : "is not DIS"), VTY_NEWLINE); |
| 954 | } |
| 955 | else |
| 956 | { |
| 957 | vty_out (vty, "%s", VTY_NEWLINE); |
| 958 | } |
| 959 | } |
| 960 | if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0) |
| 961 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 962 | vty_out (vty, " IP Prefix(es):%s", VTY_NEWLINE); |
| 963 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr)) |
| 964 | { |
| 965 | prefix2str (ip_addr, (char*)buf, BUFSIZ), |
| 966 | vty_out (vty, " %s%s", buf, VTY_NEWLINE); |
| 967 | } |
| 968 | } |
Christian Franke | cb32a19 | 2015-11-10 18:33:13 +0100 | [diff] [blame] | 969 | if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0) |
| 970 | { |
| 971 | vty_out(vty, " IPv6 Link-Locals:%s", VTY_NEWLINE); |
| 972 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip_addr)) |
| 973 | { |
| 974 | prefix2str(ip_addr, (char*)buf, BUFSIZ), |
| 975 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); |
| 976 | } |
| 977 | } |
| 978 | if (circuit->ipv6_link && listcount(circuit->ipv6_non_link) > 0) |
| 979 | { |
| 980 | vty_out(vty, " IPv6 Prefixes:%s", VTY_NEWLINE); |
| 981 | for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip_addr)) |
| 982 | { |
| 983 | prefix2str(ip_addr, (char*)buf, BUFSIZ), |
| 984 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); |
| 985 | } |
| 986 | } |
| 987 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 988 | vty_out (vty, "%s", VTY_NEWLINE); |
| 989 | } |
| 990 | return; |
| 991 | } |
| 992 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 993 | int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 994 | isis_interface_config_write (struct vty *vty) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 995 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 996 | int write = 0; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 997 | struct listnode *node, *node2; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 998 | struct interface *ifp; |
| 999 | struct isis_area *area; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1000 | struct isis_circuit *circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1001 | int i; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1002 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 1003 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1004 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1005 | /* IF name */ |
| 1006 | vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); |
| 1007 | write++; |
| 1008 | /* IF desc */ |
| 1009 | if (ifp->desc) |
| 1010 | { |
| 1011 | vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE); |
| 1012 | write++; |
| 1013 | } |
| 1014 | /* ISIS Circuit */ |
| 1015 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area)) |
| 1016 | { |
| 1017 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 1018 | if (circuit == NULL) |
| 1019 | continue; |
| 1020 | if (circuit->ip_router) |
| 1021 | { |
| 1022 | vty_out (vty, " ip router isis %s%s", area->area_tag, |
| 1023 | VTY_NEWLINE); |
| 1024 | write++; |
| 1025 | } |
| 1026 | if (circuit->is_passive) |
| 1027 | { |
| 1028 | vty_out (vty, " isis passive%s", VTY_NEWLINE); |
| 1029 | write++; |
| 1030 | } |
| 1031 | if (circuit->circ_type_config == CIRCUIT_T_P2P) |
| 1032 | { |
| 1033 | vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE); |
| 1034 | write++; |
| 1035 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1036 | #ifdef HAVE_IPV6 |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1037 | if (circuit->ipv6_router) |
| 1038 | { |
| 1039 | vty_out (vty, " ipv6 router isis %s%s", area->area_tag, |
| 1040 | VTY_NEWLINE); |
| 1041 | write++; |
| 1042 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1043 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1044 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1045 | /* ISIS - circuit type */ |
| 1046 | if (circuit->is_type == IS_LEVEL_1) |
| 1047 | { |
| 1048 | vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE); |
| 1049 | write++; |
| 1050 | } |
| 1051 | else |
| 1052 | { |
| 1053 | if (circuit->is_type == IS_LEVEL_2) |
| 1054 | { |
| 1055 | vty_out (vty, " isis circuit-type level-2-only%s", |
| 1056 | VTY_NEWLINE); |
| 1057 | write++; |
| 1058 | } |
| 1059 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1060 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1061 | /* ISIS - CSNP interval */ |
| 1062 | if (circuit->csnp_interval[0] == circuit->csnp_interval[1]) |
| 1063 | { |
| 1064 | if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL) |
| 1065 | { |
| 1066 | vty_out (vty, " isis csnp-interval %d%s", |
| 1067 | circuit->csnp_interval[0], VTY_NEWLINE); |
| 1068 | write++; |
| 1069 | } |
| 1070 | } |
| 1071 | else |
| 1072 | { |
| 1073 | for (i = 0; i < 2; i++) |
| 1074 | { |
| 1075 | if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL) |
| 1076 | { |
| 1077 | vty_out (vty, " isis csnp-interval %d level-%d%s", |
| 1078 | circuit->csnp_interval[i], i + 1, VTY_NEWLINE); |
| 1079 | write++; |
| 1080 | } |
| 1081 | } |
| 1082 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1083 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1084 | /* ISIS - PSNP interval */ |
| 1085 | if (circuit->psnp_interval[0] == circuit->psnp_interval[1]) |
| 1086 | { |
| 1087 | if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL) |
| 1088 | { |
| 1089 | vty_out (vty, " isis psnp-interval %d%s", |
| 1090 | circuit->psnp_interval[0], VTY_NEWLINE); |
| 1091 | write++; |
| 1092 | } |
| 1093 | } |
| 1094 | else |
| 1095 | { |
| 1096 | for (i = 0; i < 2; i++) |
| 1097 | { |
| 1098 | if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL) |
| 1099 | { |
| 1100 | vty_out (vty, " isis psnp-interval %d level-%d%s", |
| 1101 | circuit->psnp_interval[i], i + 1, VTY_NEWLINE); |
| 1102 | write++; |
| 1103 | } |
| 1104 | } |
| 1105 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1106 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1107 | /* ISIS - Hello padding - Defaults to true so only display if false */ |
| 1108 | if (circuit->pad_hellos == 0) |
| 1109 | { |
| 1110 | vty_out (vty, " no isis hello padding%s", VTY_NEWLINE); |
| 1111 | write++; |
| 1112 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1113 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1114 | /* ISIS - Hello interval */ |
| 1115 | if (circuit->hello_interval[0] == circuit->hello_interval[1]) |
| 1116 | { |
| 1117 | if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL) |
| 1118 | { |
| 1119 | vty_out (vty, " isis hello-interval %d%s", |
| 1120 | circuit->hello_interval[0], VTY_NEWLINE); |
| 1121 | write++; |
| 1122 | } |
| 1123 | } |
| 1124 | else |
| 1125 | { |
| 1126 | for (i = 0; i < 2; i++) |
| 1127 | { |
| 1128 | if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL) |
| 1129 | { |
| 1130 | vty_out (vty, " isis hello-interval %d level-%d%s", |
| 1131 | circuit->hello_interval[i], i + 1, VTY_NEWLINE); |
| 1132 | write++; |
| 1133 | } |
| 1134 | } |
| 1135 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1136 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1137 | /* ISIS - Hello Multiplier */ |
| 1138 | if (circuit->hello_multiplier[0] == circuit->hello_multiplier[1]) |
| 1139 | { |
| 1140 | if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER) |
| 1141 | { |
| 1142 | vty_out (vty, " isis hello-multiplier %d%s", |
| 1143 | circuit->hello_multiplier[0], VTY_NEWLINE); |
| 1144 | write++; |
| 1145 | } |
| 1146 | } |
| 1147 | else |
| 1148 | { |
| 1149 | for (i = 0; i < 2; i++) |
| 1150 | { |
| 1151 | if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER) |
| 1152 | { |
| 1153 | vty_out (vty, " isis hello-multiplier %d level-%d%s", |
| 1154 | circuit->hello_multiplier[i], i + 1, |
| 1155 | VTY_NEWLINE); |
| 1156 | write++; |
| 1157 | } |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /* ISIS - Priority */ |
| 1162 | if (circuit->priority[0] == circuit->priority[1]) |
| 1163 | { |
| 1164 | if (circuit->priority[0] != DEFAULT_PRIORITY) |
| 1165 | { |
| 1166 | vty_out (vty, " isis priority %d%s", |
| 1167 | circuit->priority[0], VTY_NEWLINE); |
| 1168 | write++; |
| 1169 | } |
| 1170 | } |
| 1171 | else |
| 1172 | { |
| 1173 | for (i = 0; i < 2; i++) |
| 1174 | { |
| 1175 | if (circuit->priority[i] != DEFAULT_PRIORITY) |
| 1176 | { |
| 1177 | vty_out (vty, " isis priority %d level-%d%s", |
| 1178 | circuit->priority[i], i + 1, VTY_NEWLINE); |
| 1179 | write++; |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | /* ISIS - Metric */ |
| 1185 | if (circuit->te_metric[0] == circuit->te_metric[1]) |
| 1186 | { |
| 1187 | if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC) |
| 1188 | { |
| 1189 | vty_out (vty, " isis metric %d%s", circuit->te_metric[0], |
| 1190 | VTY_NEWLINE); |
| 1191 | write++; |
| 1192 | } |
| 1193 | } |
| 1194 | else |
| 1195 | { |
| 1196 | for (i = 0; i < 2; i++) |
| 1197 | { |
| 1198 | if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC) |
| 1199 | { |
| 1200 | vty_out (vty, " isis metric %d level-%d%s", |
| 1201 | circuit->te_metric[i], i + 1, VTY_NEWLINE); |
| 1202 | write++; |
| 1203 | } |
| 1204 | } |
| 1205 | } |
| 1206 | if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5) |
| 1207 | { |
| 1208 | vty_out (vty, " isis password md5 %s%s", circuit->passwd.passwd, |
| 1209 | VTY_NEWLINE); |
| 1210 | write++; |
| 1211 | } |
| 1212 | else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT) |
| 1213 | { |
| 1214 | vty_out (vty, " isis password clear %s%s", circuit->passwd.passwd, |
| 1215 | VTY_NEWLINE); |
| 1216 | write++; |
| 1217 | } |
| 1218 | } |
| 1219 | vty_out (vty, "!%s", VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1220 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1221 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1222 | return write; |
| 1223 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1224 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1225 | struct isis_circuit * |
| 1226 | isis_circuit_create (struct isis_area *area, struct interface *ifp) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1227 | { |
David Lamparter | 515812d | 2016-08-11 16:59:08 +0200 | [diff] [blame^] | 1228 | struct isis_circuit *circuit = circuit_scan_by_ifp (ifp); |
| 1229 | if (circuit && circuit->area) |
| 1230 | return NULL; |
| 1231 | circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area); |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1232 | assert (circuit->state == C_STATE_CONF || circuit->state == C_STATE_UP); |
| 1233 | isis_circuit_if_bind (circuit, ifp); |
| 1234 | return circuit; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1235 | } |
| 1236 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1237 | void |
| 1238 | isis_circuit_af_set (struct isis_circuit *circuit, bool ip_router, bool ipv6_router) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1239 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1240 | struct isis_area *area = circuit->area; |
| 1241 | bool change = circuit->ip_router != ip_router || circuit->ipv6_router != ipv6_router; |
| 1242 | bool was_enabled = circuit->ip_router || circuit->ipv6_router; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1243 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1244 | area->ip_circuits += ip_router - circuit->ip_router; |
| 1245 | area->ipv6_circuits += ipv6_router - circuit->ipv6_router; |
| 1246 | circuit->ip_router = ip_router; |
| 1247 | circuit->ipv6_router = ipv6_router; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1248 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1249 | if (!change) |
| 1250 | return; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1251 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1252 | circuit_update_nlpids (circuit); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1253 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1254 | if (!ip_router && !ipv6_router) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1255 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1256 | else if (!was_enabled) |
| 1257 | isis_csm_state_change (ISIS_ENABLE, circuit, area); |
Christian Franke | 84a4da0 | 2016-04-03 12:46:27 -0300 | [diff] [blame] | 1258 | else |
Christian Franke | 84a4da0 | 2016-04-03 12:46:27 -0300 | [diff] [blame] | 1259 | lsp_regenerate_schedule(circuit->area, circuit->is_type, 0); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1262 | int |
| 1263 | isis_circuit_passive_set (struct isis_circuit *circuit, bool passive) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1264 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1265 | if (circuit->is_passive == passive) |
| 1266 | return 0; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1267 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1268 | if (if_is_loopback (circuit->interface) && !passive) |
| 1269 | return -1; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1270 | |
| 1271 | if (circuit->state != C_STATE_UP) |
| 1272 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1273 | circuit->is_passive = passive; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1274 | } |
| 1275 | else |
| 1276 | { |
| 1277 | struct isis_area *area = circuit->area; |
| 1278 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1279 | circuit->is_passive = passive; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1280 | isis_csm_state_change (ISIS_ENABLE, circuit, area); |
| 1281 | } |
| 1282 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1283 | return 0; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1284 | } |
| 1285 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1286 | void |
| 1287 | isis_circuit_is_type_set (struct isis_circuit *circuit, int circ_type) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1288 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1289 | if (circuit->circ_type != circ_type) |
| 1290 | isis_event_circuit_type_change (circuit, circ_type); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1291 | } |
| 1292 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1293 | int |
| 1294 | isis_circuit_metric_set (struct isis_circuit *circuit, int level, int metric) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1295 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1296 | assert (level == IS_LEVEL_1 || level == IS_LEVEL_2); |
| 1297 | if (metric > MAX_WIDE_LINK_METRIC) |
| 1298 | return -1; |
| 1299 | if (circuit->area && circuit->area->oldmetric |
| 1300 | && metric > MAX_NARROW_LINK_METRIC) |
| 1301 | return -1; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1302 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1303 | circuit->te_metric[level - 1] = metric; |
David Lamparter | f263413 | 2016-07-28 17:23:32 +0200 | [diff] [blame] | 1304 | circuit->metric[level - 1] = metric; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1305 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1306 | if (circuit->area) |
| 1307 | lsp_regenerate_schedule (circuit->area, level, 0); |
| 1308 | return 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1309 | } |
| 1310 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1311 | int |
| 1312 | isis_circuit_passwd_unset (struct isis_circuit *circuit) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1313 | { |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1314 | memset(&circuit->passwd, 0, sizeof(circuit->passwd)); |
| 1315 | return 0; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1316 | } |
| 1317 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1318 | static int |
| 1319 | isis_circuit_passwd_set (struct isis_circuit *circuit, u_char passwd_type, const char *passwd) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1320 | { |
| 1321 | int len; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1322 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1323 | if (!passwd) |
| 1324 | return -1; |
| 1325 | |
| 1326 | len = strlen(passwd); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1327 | if (len > 254) |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1328 | return -1; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1329 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1330 | circuit->passwd.len = len; |
| 1331 | strncpy((char *)circuit->passwd.passwd, passwd, 255); |
| 1332 | circuit->passwd.type = passwd_type; |
| 1333 | return 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1334 | } |
| 1335 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1336 | int |
| 1337 | isis_circuit_passwd_cleartext_set (struct isis_circuit *circuit, const char *passwd) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1338 | { |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1339 | return isis_circuit_passwd_set (circuit, ISIS_PASSWD_TYPE_CLEARTXT, passwd); |
| 1340 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1341 | |
Christian Franke | f5fbfb2 | 2016-07-28 17:23:27 +0200 | [diff] [blame] | 1342 | int |
| 1343 | isis_circuit_passwd_hmac_md5_set (struct isis_circuit *circuit, const char *passwd) |
| 1344 | { |
| 1345 | return isis_circuit_passwd_set (circuit, ISIS_PASSWD_TYPE_HMAC_MD5, passwd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1346 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1347 | struct cmd_node interface_node = { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1348 | INTERFACE_NODE, |
| 1349 | "%s(config-if)# ", |
| 1350 | 1, |
| 1351 | }; |
| 1352 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1353 | int |
| 1354 | isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type) |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1355 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1356 | /* Changing the network type to/of loopback or unknown interfaces |
| 1357 | * is not supported. */ |
| 1358 | if (circ_type == CIRCUIT_T_UNKNOWN |
| 1359 | || circ_type == CIRCUIT_T_LOOPBACK |
| 1360 | || circuit->circ_type == CIRCUIT_T_UNKNOWN |
| 1361 | || circuit->circ_type == CIRCUIT_T_LOOPBACK) |
| 1362 | { |
| 1363 | if (circuit->circ_type != circ_type) |
| 1364 | return -1; |
| 1365 | else |
| 1366 | return 0; |
| 1367 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1368 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1369 | if (circuit->circ_type == circ_type) |
| 1370 | return 0; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1371 | |
| 1372 | if (circuit->state != C_STATE_UP) |
| 1373 | { |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1374 | circuit->circ_type = circ_type; |
| 1375 | circuit->circ_type_config = circ_type; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1376 | } |
| 1377 | else |
| 1378 | { |
| 1379 | struct isis_area *area = circuit->area; |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1380 | if (circ_type == CIRCUIT_T_BROADCAST |
| 1381 | && !if_is_broadcast(circuit->interface)) |
| 1382 | return -1; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1383 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1384 | isis_csm_state_change(ISIS_DISABLE, circuit, area); |
| 1385 | circuit->circ_type = circ_type; |
| 1386 | circuit->circ_type_config = circ_type; |
| 1387 | isis_csm_state_change(ISIS_ENABLE, circuit, area); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1388 | } |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1389 | return 0; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 1390 | } |
| 1391 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1392 | int |
| 1393 | isis_if_new_hook (struct interface *ifp) |
| 1394 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1395 | return 0; |
| 1396 | } |
| 1397 | |
| 1398 | int |
| 1399 | isis_if_delete_hook (struct interface *ifp) |
| 1400 | { |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 1401 | struct isis_circuit *circuit; |
| 1402 | /* Clean up the circuit data */ |
| 1403 | if (ifp && ifp->info) |
| 1404 | { |
| 1405 | circuit = ifp->info; |
| 1406 | isis_csm_state_change (IF_DOWN_FROM_Z, circuit, circuit->area); |
| 1407 | isis_csm_state_change (ISIS_DISABLE, circuit, circuit->area); |
| 1408 | } |
| 1409 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1410 | return 0; |
| 1411 | } |
| 1412 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1413 | void |
| 1414 | isis_circuit_init () |
| 1415 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1416 | /* Initialize Zebra interface data structure */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1417 | if_add_hook (IF_NEW_HOOK, isis_if_new_hook); |
| 1418 | if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook); |
| 1419 | |
| 1420 | /* Install interface node */ |
| 1421 | install_node (&interface_node, isis_interface_config_write); |
| 1422 | install_element (CONFIG_NODE, &interface_cmd); |
Subbaiah Venkata | e38e0df | 2012-03-27 23:48:05 -0700 | [diff] [blame] | 1423 | install_element (CONFIG_NODE, &no_interface_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1424 | |
| 1425 | install_default (INTERFACE_NODE); |
| 1426 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 1427 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 1428 | |
David Lamparter | 3732cba | 2016-07-29 16:19:40 +0200 | [diff] [blame] | 1429 | isis_vty_init (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1430 | } |