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 | */ |
| 22 | #include <stdlib.h> |
| 23 | #include <stdio.h> |
| 24 | #include <ctype.h> |
| 25 | #include <zebra.h> |
hasso | 37da8c0 | 2004-05-19 11:38:40 +0000 | [diff] [blame] | 26 | #ifdef GNU_LINUX |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 27 | #include <net/ethernet.h> |
hasso | 37da8c0 | 2004-05-19 11:38:40 +0000 | [diff] [blame] | 28 | #else |
| 29 | #include <netinet/if_ether.h> |
| 30 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 31 | |
| 32 | #include "log.h" |
| 33 | #include "memory.h" |
| 34 | #include "if.h" |
| 35 | #include "linklist.h" |
| 36 | #include "command.h" |
| 37 | #include "thread.h" |
| 38 | #include "hash.h" |
| 39 | #include "prefix.h" |
| 40 | #include "stream.h" |
| 41 | |
| 42 | #include "isisd/dict.h" |
| 43 | #include "isisd/include-netbsd/iso.h" |
| 44 | #include "isisd/isis_constants.h" |
| 45 | #include "isisd/isis_common.h" |
| 46 | #include "isisd/isis_circuit.h" |
| 47 | #include "isisd/isis_tlv.h" |
| 48 | #include "isisd/isis_lsp.h" |
| 49 | #include "isisd/isis_pdu.h" |
| 50 | #include "isisd/isis_network.h" |
| 51 | #include "isisd/isis_misc.h" |
| 52 | #include "isisd/isis_constants.h" |
| 53 | #include "isisd/isis_adjacency.h" |
| 54 | #include "isisd/isis_dr.h" |
| 55 | #include "isisd/isis_flags.h" |
| 56 | #include "isisd/isisd.h" |
| 57 | #include "isisd/isis_csm.h" |
| 58 | #include "isisd/isis_events.h" |
| 59 | |
| 60 | extern struct thread_master *master; |
| 61 | extern struct isis *isis; |
| 62 | |
| 63 | struct isis_circuit * |
| 64 | isis_circuit_new () |
| 65 | { |
| 66 | struct isis_circuit *circuit; |
| 67 | int i; |
| 68 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 69 | circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 70 | if (circuit) |
| 71 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 72 | /* set default metrics for circuit */ |
| 73 | for (i = 0; i < 2; i++) |
| 74 | { |
| 75 | circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS; |
| 76 | circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED; |
| 77 | circuit->metrics[i].metric_error = METRICS_UNSUPPORTED; |
| 78 | circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED; |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 79 | circuit->te_metric[i] = DEFAULT_CIRCUIT_METRICS; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 80 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 81 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 82 | else |
| 83 | { |
| 84 | zlog_err ("Can't malloc isis circuit"); |
| 85 | return NULL; |
| 86 | } |
| 87 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 88 | return circuit; |
| 89 | } |
| 90 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 91 | void |
| 92 | isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area) |
| 93 | { |
| 94 | int i; |
| 95 | circuit->area = area; |
| 96 | /* |
| 97 | * The level for the circuit is same as for the area, unless configured |
| 98 | * otherwise. |
| 99 | */ |
| 100 | circuit->circuit_is_type = area->is_type; |
| 101 | /* |
| 102 | * Default values |
| 103 | */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 104 | for (i = 0; i < 2; i++) |
| 105 | { |
| 106 | circuit->hello_interval[i] = HELLO_INTERVAL; |
| 107 | circuit->hello_multiplier[i] = HELLO_MULTIPLIER; |
| 108 | circuit->csnp_interval[i] = CSNP_INTERVAL; |
| 109 | circuit->psnp_interval[i] = PSNP_INTERVAL; |
| 110 | circuit->u.bc.priority[i] = DEFAULT_PRIORITY; |
| 111 | } |
| 112 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 113 | { |
| 114 | circuit->u.bc.adjdb[0] = list_new (); |
| 115 | circuit->u.bc.adjdb[1] = list_new (); |
| 116 | circuit->u.bc.pad_hellos = 1; |
| 117 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 118 | circuit->lsp_interval = LSP_INTERVAL; |
| 119 | |
| 120 | /* |
| 121 | * Add the circuit into area |
| 122 | */ |
| 123 | listnode_add (area->circuit_list, circuit); |
| 124 | |
| 125 | circuit->idx = flags_get_index (&area->flags); |
| 126 | circuit->lsp_queue = list_new (); |
| 127 | |
| 128 | return; |
| 129 | } |
| 130 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 131 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 132 | isis_circuit_deconfigure (struct isis_circuit *circuit, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 133 | struct isis_area *area) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 134 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 135 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 136 | /* Remove circuit from area */ |
| 137 | listnode_delete (area->circuit_list, circuit); |
| 138 | /* Free the index of SRM and SSN flags */ |
| 139 | flags_free_index (&area->flags, circuit->idx); |
| 140 | |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | struct isis_circuit * |
| 145 | circuit_lookup_by_ifp (struct interface *ifp, struct list *list) |
| 146 | { |
| 147 | struct isis_circuit *circuit = NULL; |
| 148 | struct listnode *node; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 149 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 150 | if (!list) |
| 151 | return NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 152 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 153 | for (ALL_LIST_ELEMENTS_RO (list, node, circuit)) |
| 154 | if (circuit->interface == ifp) |
| 155 | return circuit; |
| 156 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 157 | return NULL; |
| 158 | } |
| 159 | |
| 160 | struct isis_circuit * |
| 161 | circuit_scan_by_ifp (struct interface *ifp) |
| 162 | { |
| 163 | struct isis_area *area; |
| 164 | struct listnode *node; |
| 165 | struct isis_circuit *circuit; |
| 166 | |
| 167 | if (!isis->area_list) |
| 168 | return NULL; |
| 169 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 170 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 171 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 172 | circuit = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 173 | if (circuit) |
| 174 | return circuit; |
| 175 | } |
| 176 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 177 | return circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 178 | } |
| 179 | |
| 180 | void |
| 181 | isis_circuit_del (struct isis_circuit *circuit) |
| 182 | { |
| 183 | |
| 184 | if (!circuit) |
| 185 | return; |
| 186 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 187 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 188 | { |
| 189 | /* destroy adjacency databases */ |
hasso | 4660687 | 2004-12-29 19:34:22 +0000 | [diff] [blame] | 190 | if (circuit->u.bc.adjdb[0]) |
| 191 | list_delete (circuit->u.bc.adjdb[0]); |
| 192 | if (circuit->u.bc.adjdb[1]) |
| 193 | list_delete (circuit->u.bc.adjdb[1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 194 | /* destroy neighbour lists */ |
| 195 | if (circuit->u.bc.lan_neighs[0]) |
| 196 | list_delete (circuit->u.bc.lan_neighs[0]); |
| 197 | if (circuit->u.bc.lan_neighs[1]) |
| 198 | list_delete (circuit->u.bc.lan_neighs[1]); |
| 199 | /* destroy addresses */ |
| 200 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 201 | if (circuit->ip_addrs) |
| 202 | list_delete (circuit->ip_addrs); |
| 203 | #ifdef HAVE_IPV6 |
| 204 | if (circuit->ipv6_link) |
| 205 | list_delete (circuit->ipv6_link); |
| 206 | if (circuit->ipv6_non_link) |
| 207 | list_delete (circuit->ipv6_non_link); |
| 208 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 209 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 210 | /* and lastly the circuit itself */ |
| 211 | XFREE (MTYPE_ISIS_CIRCUIT, circuit); |
| 212 | |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | void |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 217 | isis_circuit_add_addr (struct isis_circuit *circuit, |
| 218 | struct connected *connected) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 219 | { |
| 220 | struct prefix_ipv4 *ipv4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 221 | u_char buf[BUFSIZ]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 222 | #ifdef HAVE_IPV6 |
| 223 | struct prefix_ipv6 *ipv6; |
| 224 | #endif /* HAVE_IPV6 */ |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 225 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 226 | if (!circuit->ip_addrs) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 227 | circuit->ip_addrs = list_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 228 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 229 | if (!circuit->ipv6_link) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 230 | circuit->ipv6_link = list_new (); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 231 | if (!circuit->ipv6_non_link) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 232 | circuit->ipv6_non_link = list_new (); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 233 | #endif /* HAVE_IPV6 */ |
| 234 | |
| 235 | memset (&buf, 0, BUFSIZ); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 236 | if (connected->address->family == AF_INET) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 237 | { |
| 238 | ipv4 = prefix_ipv4_new (); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 239 | ipv4->prefixlen = connected->address->prefixlen; |
| 240 | ipv4->prefix = connected->address->u.prefix4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 241 | listnode_add (circuit->ip_addrs, ipv4); |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 242 | if (circuit->area) |
| 243 | lsp_regenerate_schedule (circuit->area); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 244 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 245 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 246 | prefix2str (connected->address, buf, BUFSIZ); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 247 | zlog_debug ("Added IP address %s to circuit %d", buf, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 248 | circuit->circuit_id); |
| 249 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 250 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 251 | #ifdef HAVE_IPV6 |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 252 | if (connected->address->family == AF_INET6) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 253 | { |
| 254 | ipv6 = prefix_ipv6_new (); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 255 | ipv6->prefixlen = connected->address->prefixlen; |
| 256 | ipv6->prefix = connected->address->u.prefix6; |
| 257 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 258 | if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 259 | listnode_add (circuit->ipv6_link, ipv6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 260 | else |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 261 | listnode_add (circuit->ipv6_non_link, ipv6); |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 262 | if (circuit->area) |
| 263 | lsp_regenerate_schedule (circuit->area); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 264 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 265 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 266 | prefix2str (connected->address, buf, BUFSIZ); |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 267 | zlog_debug ("Added IPv6 address %s to circuit %d", buf, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 268 | circuit->circuit_id); |
| 269 | #endif /* EXTREME_DEBUG */ |
| 270 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 271 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 272 | return; |
| 273 | } |
| 274 | |
| 275 | void |
| 276 | isis_circuit_del_addr (struct isis_circuit *circuit, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 277 | struct connected *connected) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 278 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 279 | struct prefix_ipv4 *ipv4, *ip = NULL; |
| 280 | struct listnode *node; |
| 281 | int found = 0; |
| 282 | u_char buf[BUFSIZ]; |
| 283 | #ifdef HAVE_IPV6 |
| 284 | struct prefix_ipv6 *ipv6, *ip6 = NULL; |
| 285 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 286 | |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 287 | memset (&buf, 0, BUFSIZ); |
| 288 | if (connected->address->family == AF_INET) |
| 289 | { |
| 290 | ipv4 = prefix_ipv4_new (); |
| 291 | ipv4->prefixlen = connected->address->prefixlen; |
| 292 | ipv4->prefix = connected->address->u.prefix4; |
| 293 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 294 | for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip)) |
| 295 | if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4)) |
| 296 | break; |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 297 | |
| 298 | if (ip) |
| 299 | { |
| 300 | listnode_delete (circuit->ip_addrs, ip); |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 301 | if (circuit->area) |
| 302 | lsp_regenerate_schedule (circuit->area); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 303 | } |
| 304 | else |
| 305 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 306 | prefix2str (connected->address, (char *)buf, BUFSIZ); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 307 | zlog_warn("Nonexitant ip address %s removal attempt from circuit \ |
| 308 | %d", buf, circuit->circuit_id); |
| 309 | } |
| 310 | } |
| 311 | #ifdef HAVE_IPV6 |
| 312 | if (connected->address->family == AF_INET6) |
| 313 | { |
| 314 | ipv6 = prefix_ipv6_new (); |
| 315 | ipv6->prefixlen = connected->address->prefixlen; |
| 316 | ipv6->prefix = connected->address->u.prefix6; |
| 317 | |
| 318 | if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix)) |
| 319 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 320 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 321 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 322 | if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6)) |
| 323 | break; |
| 324 | } |
| 325 | if (ip6) |
| 326 | { |
| 327 | listnode_delete (circuit->ipv6_link, ip6); |
| 328 | found = 1; |
| 329 | } |
| 330 | } |
| 331 | else |
| 332 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 333 | for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6)) |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 334 | { |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 335 | if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6)) |
| 336 | break; |
| 337 | } |
| 338 | if (ip6) |
| 339 | { |
| 340 | listnode_delete (circuit->ipv6_non_link, ip6); |
| 341 | found = 1; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | if (!found) |
| 346 | { |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 347 | prefix2str (connected->address, (char *)buf, BUFSIZ); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 348 | zlog_warn("Nonexitant ip address %s removal attempt from \ |
| 349 | circuit %d", buf, circuit->circuit_id); |
| 350 | } |
| 351 | else |
hasso | 0dae85e | 2004-09-26 19:53:47 +0000 | [diff] [blame] | 352 | if (circuit->area) |
| 353 | lsp_regenerate_schedule (circuit->area); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 354 | } |
| 355 | #endif /* HAVE_IPV6 */ |
| 356 | return; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | void |
| 360 | isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp) |
| 361 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 362 | struct listnode *node, *nnode; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 363 | struct connected *conn; |
| 364 | |
| 365 | circuit->interface = ifp; |
| 366 | ifp->info = circuit; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 367 | |
| 368 | circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 369 | |
| 370 | /* isis_circuit_update_addrs (circuit, ifp); */ |
| 371 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 372 | if (if_is_broadcast (ifp)) |
| 373 | { |
| 374 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
| 375 | /* |
| 376 | * Get the Hardware Address |
| 377 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 378 | #ifdef HAVE_SOCKADDR_DL |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 379 | if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN) |
| 380 | zlog_warn ("unsupported link layer"); |
| 381 | else |
| 382 | memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), |
| 383 | ETH_ALEN); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 384 | #else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 385 | if (circuit->interface->hw_addr_len != ETH_ALEN) |
| 386 | { |
| 387 | zlog_warn ("unsupported link layer"); |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN); |
| 392 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 393 | #ifdef EXTREME_DEGUG |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 394 | zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 395 | circuit->interface->ifindex, ISO_MTU (circuit), |
| 396 | snpa_print (circuit->u.bc.snpa)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 397 | |
| 398 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 399 | #endif /* HAVE_SOCKADDR_DL */ |
| 400 | } |
| 401 | else if (if_is_pointopoint (ifp)) |
| 402 | { |
| 403 | circuit->circ_type = CIRCUIT_T_P2P; |
| 404 | } |
| 405 | else |
| 406 | { |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 407 | /* It's normal in case of loopback etc. */ |
| 408 | if (isis->debugs & DEBUG_EVENTS) |
| 409 | zlog_debug ("isis_circuit_if_add: unsupported media"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 410 | } |
| 411 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 412 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn)) |
| 413 | isis_circuit_add_addr (circuit, conn); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 414 | |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 419 | isis_circuit_update_params (struct isis_circuit *circuit, |
| 420 | struct interface *ifp) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 421 | { |
hasso | b30c5e6 | 2004-12-29 20:06:41 +0000 | [diff] [blame] | 422 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 423 | |
| 424 | if (circuit->circuit_id != ifp->ifindex) |
| 425 | { |
| 426 | zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id, |
| 427 | ifp->ifindex); |
| 428 | circuit->circuit_id = ifp->ifindex % 255; |
| 429 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 430 | |
| 431 | /* FIXME: Why is this needed? shouldn't we compare to the area's mtu */ |
| 432 | /* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig) |
| 433 | The areas MTU is the minimum of mtu's of circuits in the area |
| 434 | now we can't catch the change |
| 435 | if (circuit->mtu != ifp->mtu) { |
| 436 | zlog_warn ("changing circuit mtu %d->%d", circuit->mtu, |
| 437 | ifp->mtu); |
| 438 | circuit->mtu = ifp->mtu; |
| 439 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 440 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 441 | /* |
| 442 | * Get the Hardware Address |
| 443 | */ |
| 444 | #ifdef HAVE_SOCKADDR_DL |
| 445 | if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 446 | zlog_warn ("unsupported link layer"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 447 | else |
| 448 | memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN); |
| 449 | #else |
| 450 | if (circuit->interface->hw_addr_len != ETH_ALEN) |
| 451 | { |
| 452 | zlog_warn ("unsupported link layer"); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 453 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 454 | else |
| 455 | { |
| 456 | if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN)) |
| 457 | { |
| 458 | zlog_warn ("changing circuit snpa %s->%s", |
| 459 | snpa_print (circuit->u.bc.snpa), |
| 460 | snpa_print (circuit->interface->hw_addr)); |
| 461 | } |
| 462 | } |
| 463 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 464 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 465 | if (if_is_broadcast (ifp)) |
| 466 | { |
| 467 | circuit->circ_type = CIRCUIT_T_BROADCAST; |
| 468 | } |
| 469 | else if (if_is_pointopoint (ifp)) |
| 470 | { |
| 471 | circuit->circ_type = CIRCUIT_T_P2P; |
| 472 | } |
| 473 | else |
| 474 | { |
| 475 | zlog_warn ("isis_circuit_update_params: unsupported media"); |
| 476 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 477 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 478 | return; |
| 479 | } |
| 480 | |
| 481 | void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 482 | isis_circuit_if_del (struct isis_circuit *circuit) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 483 | { |
| 484 | circuit->interface->info = NULL; |
| 485 | circuit->interface = NULL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 486 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 487 | return; |
| 488 | } |
| 489 | |
| 490 | void |
| 491 | isis_circuit_up (struct isis_circuit *circuit) |
| 492 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 493 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 494 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 495 | { |
| 496 | if (circuit->area->min_bcast_mtu == 0 || |
| 497 | ISO_MTU (circuit) < circuit->area->min_bcast_mtu) |
| 498 | circuit->area->min_bcast_mtu = ISO_MTU (circuit); |
| 499 | /* |
| 500 | * ISO 10589 - 8.4.1 Enabling of broadcast circuits |
| 501 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 502 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 503 | /* initilizing the hello sending threads |
| 504 | * for a broadcast IF |
| 505 | */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 506 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 507 | /* 8.4.1 a) commence sending of IIH PDUs */ |
| 508 | |
| 509 | if (circuit->circuit_is_type & IS_LEVEL_1) |
| 510 | { |
| 511 | thread_add_event (master, send_lan_l1_hello, circuit, 0); |
| 512 | circuit->u.bc.lan_neighs[0] = list_new (); |
| 513 | } |
| 514 | |
| 515 | if (circuit->circuit_is_type & IS_LEVEL_2) |
| 516 | { |
| 517 | thread_add_event (master, send_lan_l2_hello, circuit, 0); |
| 518 | circuit->u.bc.lan_neighs[1] = list_new (); |
| 519 | } |
| 520 | |
| 521 | /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */ |
| 522 | /* 8.4.1 c) FIXME: listen for ESH PDUs */ |
| 523 | |
| 524 | /* 8.4.1 d) */ |
| 525 | /* dr election will commence in... */ |
| 526 | if (circuit->circuit_is_type & IS_LEVEL_1) |
| 527 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1, |
hasso | bf73101 | 2004-09-17 07:59:57 +0000 | [diff] [blame] | 528 | circuit, 2 * circuit->hello_interval[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 529 | if (circuit->circuit_is_type & IS_LEVEL_2) |
| 530 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2, |
hasso | bf73101 | 2004-09-17 07:59:57 +0000 | [diff] [blame] | 531 | circuit, 2 * circuit->hello_interval[1]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 532 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 533 | else |
| 534 | { |
| 535 | /* initializing the hello send threads |
| 536 | * for a ptp IF |
| 537 | */ |
| 538 | thread_add_event (master, send_p2p_hello, circuit, 0); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 539 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 540 | } |
| 541 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 542 | /* initializing PSNP timers */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 543 | if (circuit->circuit_is_type & IS_LEVEL_1) |
| 544 | { |
| 545 | THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit, |
| 546 | isis_jitter (circuit->psnp_interval[0], PSNP_JITTER)); |
| 547 | } |
| 548 | |
| 549 | if (circuit->circuit_is_type & IS_LEVEL_2) |
| 550 | { |
| 551 | THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit, |
| 552 | isis_jitter (circuit->psnp_interval[1], PSNP_JITTER)); |
| 553 | } |
| 554 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 555 | /* initialize the circuit streams */ |
| 556 | if (circuit->rcv_stream == NULL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 557 | circuit->rcv_stream = stream_new (ISO_MTU (circuit)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 558 | |
| 559 | if (circuit->snd_stream == NULL) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 560 | circuit->snd_stream = stream_new (ISO_MTU (circuit)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 561 | |
| 562 | /* unified init for circuits */ |
| 563 | isis_sock_init (circuit); |
| 564 | |
| 565 | #ifdef GNU_LINUX |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 566 | THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit, |
| 567 | circuit->fd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 568 | #else |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 569 | THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit, |
| 570 | circuit->fd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 571 | #endif |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | void |
| 576 | isis_circuit_down (struct isis_circuit *circuit) |
| 577 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 578 | /* Cancel all active threads -- FIXME: wrong place */ |
hasso | d70f99e | 2004-02-11 20:26:31 +0000 | [diff] [blame] | 579 | /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 580 | THREAD_OFF (circuit->t_read); |
| 581 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 582 | { |
| 583 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]); |
| 584 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 585 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]); |
| 586 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 587 | } |
| 588 | else if (circuit->circ_type == CIRCUIT_T_P2P) |
| 589 | { |
| 590 | THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello); |
| 591 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 592 | /* close the socket */ |
| 593 | close (circuit->fd); |
| 594 | |
| 595 | return; |
| 596 | } |
| 597 | |
| 598 | void |
| 599 | circuit_update_nlpids (struct isis_circuit *circuit) |
| 600 | { |
| 601 | circuit->nlpids.count = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 602 | |
| 603 | if (circuit->ip_router) |
| 604 | { |
| 605 | circuit->nlpids.nlpids[0] = NLPID_IP; |
| 606 | circuit->nlpids.count++; |
| 607 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 608 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 609 | if (circuit->ipv6_router) |
| 610 | { |
| 611 | circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6; |
| 612 | circuit->nlpids.count++; |
| 613 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 614 | #endif /* HAVE_IPV6 */ |
| 615 | return; |
| 616 | } |
| 617 | |
| 618 | int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 619 | isis_interface_config_write (struct vty *vty) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 620 | { |
| 621 | |
| 622 | int write = 0; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 623 | struct listnode *node, *node2; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 624 | struct interface *ifp; |
| 625 | struct isis_area *area; |
| 626 | struct isis_circuit *c; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 627 | int i; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 628 | |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 629 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 630 | { |
| 631 | /* IF name */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 632 | vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 633 | write++; |
| 634 | /* IF desc */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 635 | if (ifp->desc) |
| 636 | { |
| 637 | vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE); |
| 638 | write++; |
| 639 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 640 | /* ISIS Circuit */ |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 641 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 642 | { |
| 643 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 644 | if (c) |
| 645 | { |
| 646 | if (c->ip_router) |
| 647 | { |
| 648 | vty_out (vty, " ip router isis %s%s", area->area_tag, |
| 649 | VTY_NEWLINE); |
| 650 | write++; |
| 651 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 652 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 653 | if (c->ipv6_router) |
| 654 | { |
| 655 | vty_out (vty, " ipv6 router isis %s%s", area->area_tag, |
| 656 | VTY_NEWLINE); |
| 657 | write++; |
| 658 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 659 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 660 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 661 | /* ISIS - circuit type */ |
| 662 | if (c->circuit_is_type == IS_LEVEL_1) |
| 663 | { |
| 664 | vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE); |
| 665 | write++; |
| 666 | } |
| 667 | else |
| 668 | { |
| 669 | if (c->circuit_is_type == IS_LEVEL_2) |
| 670 | { |
| 671 | vty_out (vty, " isis circuit-type level-2-only%s", |
| 672 | VTY_NEWLINE); |
| 673 | write++; |
| 674 | } |
| 675 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 676 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 677 | /* ISIS - CSNP interval - FIXME: compare to cisco */ |
| 678 | if (c->csnp_interval[0] == c->csnp_interval[1]) |
| 679 | { |
| 680 | if (c->csnp_interval[0] != CSNP_INTERVAL) |
| 681 | { |
| 682 | vty_out (vty, " isis csnp-interval %d%s", |
| 683 | c->csnp_interval[0], VTY_NEWLINE); |
| 684 | write++; |
| 685 | } |
| 686 | } |
| 687 | else |
| 688 | { |
| 689 | for (i = 0; i < 2; i++) |
| 690 | { |
| 691 | if (c->csnp_interval[1] != CSNP_INTERVAL) |
| 692 | { |
| 693 | vty_out (vty, " isis csnp-interval %d level-%d%s", |
| 694 | c->csnp_interval[1], i + 1, VTY_NEWLINE); |
| 695 | write++; |
| 696 | } |
| 697 | } |
| 698 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 699 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 700 | /* ISIS - Hello padding - Defaults to true so only display if false */ |
| 701 | if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos) |
| 702 | { |
| 703 | vty_out (vty, " no isis hello padding%s", VTY_NEWLINE); |
| 704 | write++; |
| 705 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 706 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 707 | /* ISIS - Hello interval - FIXME: compare to cisco */ |
| 708 | if (c->hello_interval[0] == c->hello_interval[1]) |
| 709 | { |
| 710 | if (c->hello_interval[0] != HELLO_INTERVAL) |
| 711 | { |
| 712 | vty_out (vty, " isis hello-interval %d%s", |
| 713 | c->hello_interval[0], VTY_NEWLINE); |
| 714 | write++; |
| 715 | } |
| 716 | } |
| 717 | else |
| 718 | { |
| 719 | for (i = 0; i < 2; i++) |
| 720 | { |
| 721 | if (c->hello_interval[i] != HELLO_INTERVAL) |
| 722 | { |
| 723 | if (c->hello_interval[i] == HELLO_MINIMAL) |
| 724 | { |
| 725 | vty_out (vty, |
| 726 | " isis hello-interval minimal level-%d%s", |
| 727 | i + 1, VTY_NEWLINE); |
| 728 | } |
| 729 | else |
| 730 | { |
| 731 | vty_out (vty, " isis hello-interval %d level-%d%s", |
| 732 | c->hello_interval[i], i + 1, VTY_NEWLINE); |
| 733 | } |
| 734 | write++; |
| 735 | } |
| 736 | } |
| 737 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 738 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 739 | /* ISIS - Hello Multiplier */ |
| 740 | if (c->hello_multiplier[0] == c->hello_multiplier[1]) |
| 741 | { |
| 742 | if (c->hello_multiplier[0] != HELLO_MULTIPLIER) |
| 743 | { |
| 744 | vty_out (vty, " isis hello-multiplier %d%s", |
| 745 | c->hello_multiplier[0], VTY_NEWLINE); |
| 746 | write++; |
| 747 | } |
| 748 | } |
| 749 | else |
| 750 | { |
| 751 | for (i = 0; i < 2; i++) |
| 752 | { |
| 753 | if (c->hello_multiplier[i] != HELLO_MULTIPLIER) |
| 754 | { |
| 755 | vty_out (vty, " isis hello-multiplier %d level-%d%s", |
| 756 | c->hello_multiplier[i], i + 1, VTY_NEWLINE); |
| 757 | write++; |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | /* ISIS - Priority */ |
| 762 | if (c->circ_type == CIRCUIT_T_BROADCAST) |
| 763 | { |
| 764 | if (c->u.bc.priority[0] == c->u.bc.priority[1]) |
| 765 | { |
| 766 | if (c->u.bc.priority[0] != DEFAULT_PRIORITY) |
| 767 | { |
| 768 | vty_out (vty, " isis priority %d%s", |
| 769 | c->u.bc.priority[0], VTY_NEWLINE); |
| 770 | write++; |
| 771 | } |
| 772 | } |
| 773 | else |
| 774 | { |
| 775 | for (i = 0; i < 2; i++) |
| 776 | { |
| 777 | if (c->u.bc.priority[i] != DEFAULT_PRIORITY) |
| 778 | { |
| 779 | vty_out (vty, " isis priority %d level-%d%s", |
| 780 | c->u.bc.priority[i], i + 1, VTY_NEWLINE); |
| 781 | write++; |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | } |
| 786 | /* ISIS - Metric */ |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 787 | if (c->te_metric[0] == c->te_metric[1]) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 788 | { |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 789 | if (c->te_metric[0] != DEFAULT_CIRCUIT_METRICS) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 790 | { |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 791 | vty_out (vty, " isis metric %d%s", c->te_metric[0], |
| 792 | VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 793 | write++; |
| 794 | } |
| 795 | } |
| 796 | else |
| 797 | { |
| 798 | for (i = 0; i < 2; i++) |
| 799 | { |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 800 | if (c->te_metric[i] != DEFAULT_CIRCUIT_METRICS) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 801 | { |
| 802 | vty_out (vty, " isis metric %d level-%d%s", |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 803 | c->te_metric[i], i + 1, VTY_NEWLINE); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 804 | write++; |
| 805 | } |
| 806 | } |
| 807 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 808 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 809 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 810 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 811 | vty_out (vty, "!%s", VTY_NEWLINE); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 812 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 813 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 814 | return write; |
| 815 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 816 | |
| 817 | DEFUN (ip_router_isis, |
| 818 | ip_router_isis_cmd, |
| 819 | "ip router isis WORD", |
| 820 | "Interface Internet Protocol config commands\n" |
| 821 | "IP router interface commands\n" |
| 822 | "IS-IS Routing for IP\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 823 | "Routing process tag\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 824 | { |
| 825 | struct isis_circuit *c; |
| 826 | struct interface *ifp; |
| 827 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 828 | |
| 829 | ifp = (struct interface *) vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 830 | assert (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 831 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 832 | area = isis_area_lookup (argv[0]); |
| 833 | |
| 834 | /* Prevent more than one circuit per interface */ |
| 835 | if (area) |
| 836 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 837 | else |
| 838 | c = NULL; |
| 839 | if (c && (ifp->info != NULL)) |
| 840 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 841 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 842 | if (c->ipv6_router == 0) |
| 843 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 844 | #endif /* HAVE_IPV6 */ |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 845 | /* FIXME: Find the way to warn only vty users. */ |
| 846 | /* vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE); */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 847 | return CMD_WARNING; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 848 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 849 | } |
| 850 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 851 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 852 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 853 | /* this is here for ciscopability */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 854 | if (!area) |
| 855 | { |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 856 | /* FIXME: Find the way to warn only vty users. */ |
| 857 | /* vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 858 | return CMD_WARNING; |
| 859 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 860 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 861 | if (!c) |
| 862 | { |
| 863 | c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 864 | c = isis_csm_state_change (ISIS_ENABLE, c, area); |
| 865 | c->interface = ifp; /* this is automatic */ |
| 866 | ifp->info = c; /* hardly related to the FSM */ |
| 867 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 868 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 869 | if (!c) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 870 | return CMD_WARNING; |
| 871 | |
| 872 | c->ip_router = 1; |
| 873 | area->ip_circuits++; |
| 874 | circuit_update_nlpids (c); |
| 875 | |
| 876 | vty->node = INTERFACE_NODE; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 877 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 878 | return CMD_SUCCESS; |
| 879 | } |
| 880 | |
| 881 | DEFUN (no_ip_router_isis, |
| 882 | no_ip_router_isis_cmd, |
| 883 | "no ip router isis WORD", |
| 884 | NO_STR |
| 885 | "Interface Internet Protocol config commands\n" |
| 886 | "IP router interface commands\n" |
| 887 | "IS-IS Routing for IP\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 888 | "Routing process tag\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 889 | { |
| 890 | struct isis_circuit *circuit = NULL; |
| 891 | struct interface *ifp; |
| 892 | struct isis_area *area; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 893 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 894 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 895 | ifp = (struct interface *) vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 896 | assert (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 897 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 898 | area = isis_area_lookup (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 899 | if (!area) |
| 900 | { |
| 901 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 902 | return CMD_WARNING; |
| 903 | } |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 904 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 905 | if (circuit->interface == ifp) |
| 906 | break; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 907 | if (!circuit) |
| 908 | { |
| 909 | vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE); |
| 910 | return CMD_WARNING; |
| 911 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 912 | circuit->ip_router = 0; |
| 913 | area->ip_circuits--; |
| 914 | #ifdef HAVE_IPV6 |
| 915 | if (circuit->ipv6_router == 0) |
| 916 | #endif |
| 917 | isis_csm_state_change (ISIS_DISABLE, circuit, area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 918 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 919 | return CMD_SUCCESS; |
| 920 | } |
| 921 | |
| 922 | DEFUN (isis_circuit_type, |
| 923 | isis_circuit_type_cmd, |
| 924 | "isis circuit-type (level-1|level-1-2|level-2-only)", |
| 925 | "IS-IS commands\n" |
| 926 | "Configure circuit type for interface\n" |
| 927 | "Level-1 only adjacencies are formed\n" |
| 928 | "Level-1-2 adjacencies are formed\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 929 | "Level-2 only adjacencies are formed\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 930 | { |
| 931 | struct isis_circuit *circuit; |
| 932 | struct interface *ifp; |
| 933 | int circuit_t; |
| 934 | int is_type; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 935 | |
| 936 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 937 | circuit = ifp->info; |
| 938 | /* UGLY - will remove l8r */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 939 | if (circuit == NULL) |
| 940 | { |
| 941 | return CMD_WARNING; |
| 942 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 943 | |
hasso | 13c48f7 | 2004-09-10 21:19:13 +0000 | [diff] [blame] | 944 | /* XXX what to do when ip_router_isis is not executed */ |
| 945 | if (circuit->area == NULL) |
| 946 | return CMD_WARNING; |
| 947 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 948 | assert (circuit); |
| 949 | |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 950 | circuit_t = string2circuit_t ((u_char *)argv[0]); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 951 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 952 | if (!circuit_t) |
| 953 | { |
| 954 | vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE); |
| 955 | return CMD_SUCCESS; |
| 956 | } |
| 957 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 958 | is_type = circuit->area->is_type; |
| 959 | if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 960 | isis_event_circuit_type_change (circuit, circuit_t); |
| 961 | else |
| 962 | { |
| 963 | vty_out (vty, "invalid circuit level for area %s.%s", |
| 964 | circuit->area->area_tag, VTY_NEWLINE); |
| 965 | } |
| 966 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 967 | return CMD_SUCCESS; |
| 968 | } |
| 969 | |
| 970 | DEFUN (no_isis_circuit_type, |
| 971 | no_isis_circuit_type_cmd, |
| 972 | "no isis circuit-type (level-1|level-1-2|level-2-only)", |
| 973 | NO_STR |
| 974 | "IS-IS commands\n" |
| 975 | "Configure circuit type for interface\n" |
| 976 | "Level-1 only adjacencies are formed\n" |
| 977 | "Level-1-2 adjacencies are formed\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 978 | "Level-2 only adjacencies are formed\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 979 | { |
| 980 | struct isis_circuit *circuit; |
| 981 | struct interface *ifp; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 982 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 983 | ifp = vty->index; |
| 984 | circuit = ifp->info; |
| 985 | if (circuit == NULL) |
| 986 | { |
| 987 | return CMD_WARNING; |
| 988 | } |
| 989 | |
| 990 | assert (circuit); |
| 991 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 992 | /* |
| 993 | * Set the circuits level to its default value which is that of the area |
| 994 | */ |
| 995 | isis_event_circuit_type_change (circuit, circuit->area->is_type); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 996 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 997 | return CMD_SUCCESS; |
| 998 | } |
| 999 | |
| 1000 | DEFUN (isis_passwd, |
| 1001 | isis_passwd_cmd, |
| 1002 | "isis password WORD", |
| 1003 | "IS-IS commands\n" |
| 1004 | "Configure the authentication password for interface\n" |
| 1005 | "Password\n") |
| 1006 | { |
| 1007 | struct isis_circuit *circuit; |
| 1008 | struct interface *ifp; |
| 1009 | int len; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1010 | |
| 1011 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1012 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1013 | if (circuit == NULL) |
| 1014 | { |
| 1015 | return CMD_WARNING; |
| 1016 | } |
| 1017 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1018 | len = strlen (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1019 | if (len > 254) |
| 1020 | { |
| 1021 | vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE); |
| 1022 | return CMD_WARNING; |
| 1023 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1024 | circuit->passwd.len = len; |
| 1025 | circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT; |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 1026 | strncpy ((char *)circuit->passwd.passwd, argv[0], 255); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1027 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1028 | return CMD_SUCCESS; |
| 1029 | } |
| 1030 | |
| 1031 | DEFUN (no_isis_passwd, |
| 1032 | no_isis_passwd_cmd, |
| 1033 | "no isis password", |
| 1034 | NO_STR |
| 1035 | "IS-IS commands\n" |
| 1036 | "Configure the authentication password for interface\n") |
| 1037 | { |
| 1038 | struct isis_circuit *circuit; |
| 1039 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1040 | |
| 1041 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1042 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1043 | if (circuit == NULL) |
| 1044 | { |
| 1045 | return CMD_WARNING; |
| 1046 | } |
| 1047 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1048 | memset (&circuit->passwd, 0, sizeof (struct isis_passwd)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1049 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1050 | return CMD_SUCCESS; |
| 1051 | } |
| 1052 | |
| 1053 | |
| 1054 | DEFUN (isis_priority, |
| 1055 | isis_priority_cmd, |
| 1056 | "isis priority <0-127>", |
| 1057 | "IS-IS commands\n" |
| 1058 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1059 | "Priority value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1060 | { |
| 1061 | struct isis_circuit *circuit; |
| 1062 | struct interface *ifp; |
| 1063 | int prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1064 | |
| 1065 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1066 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1067 | if (circuit == NULL) |
| 1068 | { |
| 1069 | return CMD_WARNING; |
| 1070 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1071 | assert (circuit); |
| 1072 | |
| 1073 | prio = atoi (argv[0]); |
| 1074 | |
| 1075 | circuit->u.bc.priority[0] = prio; |
| 1076 | circuit->u.bc.priority[1] = prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1077 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1078 | return CMD_SUCCESS; |
| 1079 | } |
| 1080 | |
| 1081 | DEFUN (no_isis_priority, |
| 1082 | no_isis_priority_cmd, |
| 1083 | "no isis priority", |
| 1084 | NO_STR |
| 1085 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1086 | "Set priority for Designated Router election\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1087 | { |
| 1088 | struct isis_circuit *circuit; |
| 1089 | struct interface *ifp; |
| 1090 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1091 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1092 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1093 | if (circuit == NULL) |
| 1094 | { |
| 1095 | return CMD_WARNING; |
| 1096 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1097 | assert (circuit); |
| 1098 | |
| 1099 | circuit->u.bc.priority[0] = DEFAULT_PRIORITY; |
| 1100 | circuit->u.bc.priority[1] = DEFAULT_PRIORITY; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1101 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1102 | return CMD_SUCCESS; |
| 1103 | } |
| 1104 | |
| 1105 | ALIAS (no_isis_priority, |
| 1106 | no_isis_priority_arg_cmd, |
| 1107 | "no isis priority <0-127>", |
| 1108 | NO_STR |
| 1109 | "IS-IS commands\n" |
| 1110 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1111 | "Priority value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1112 | |
| 1113 | DEFUN (isis_priority_l1, |
| 1114 | isis_priority_l1_cmd, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1115 | "isis priority <0-127> level-1", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1116 | "IS-IS commands\n" |
| 1117 | "Set priority for Designated Router election\n" |
| 1118 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1119 | "Specify priority for level-1 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1120 | { |
| 1121 | struct isis_circuit *circuit; |
| 1122 | struct interface *ifp; |
| 1123 | int prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1124 | |
| 1125 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1126 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1127 | if (circuit == NULL) |
| 1128 | { |
| 1129 | return CMD_WARNING; |
| 1130 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1131 | assert (circuit); |
| 1132 | |
| 1133 | prio = atoi (argv[0]); |
| 1134 | |
| 1135 | circuit->u.bc.priority[0] = prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1136 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1137 | return CMD_SUCCESS; |
| 1138 | } |
| 1139 | |
| 1140 | DEFUN (no_isis_priority_l1, |
| 1141 | no_isis_priority_l1_cmd, |
| 1142 | "no isis priority level-1", |
| 1143 | NO_STR |
| 1144 | "IS-IS commands\n" |
| 1145 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1146 | "Specify priority for level-1 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1147 | { |
| 1148 | struct isis_circuit *circuit; |
| 1149 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1150 | |
| 1151 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1152 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1153 | if (circuit == NULL) |
| 1154 | { |
| 1155 | return CMD_WARNING; |
| 1156 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1157 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1158 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1159 | circuit->u.bc.priority[0] = DEFAULT_PRIORITY; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1160 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1161 | return CMD_SUCCESS; |
| 1162 | } |
| 1163 | |
| 1164 | ALIAS (no_isis_priority_l1, |
| 1165 | no_isis_priority_l1_arg_cmd, |
| 1166 | "no isis priority <0-127> level-1", |
| 1167 | NO_STR |
| 1168 | "IS-IS commands\n" |
| 1169 | "Set priority for Designated Router election\n" |
| 1170 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1171 | "Specify priority for level-1 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1172 | |
| 1173 | DEFUN (isis_priority_l2, |
| 1174 | isis_priority_l2_cmd, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1175 | "isis priority <0-127> level-2", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1176 | "IS-IS commands\n" |
| 1177 | "Set priority for Designated Router election\n" |
| 1178 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1179 | "Specify priority for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1180 | { |
| 1181 | struct isis_circuit *circuit; |
| 1182 | struct interface *ifp; |
| 1183 | int prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1184 | |
| 1185 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1186 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1187 | if (circuit == NULL) |
| 1188 | { |
| 1189 | return CMD_WARNING; |
| 1190 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1191 | assert (circuit); |
| 1192 | |
| 1193 | prio = atoi (argv[0]); |
| 1194 | |
| 1195 | circuit->u.bc.priority[1] = prio; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1196 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1197 | return CMD_SUCCESS; |
| 1198 | } |
| 1199 | |
| 1200 | DEFUN (no_isis_priority_l2, |
| 1201 | no_isis_priority_l2_cmd, |
| 1202 | "no isis priority level-2", |
| 1203 | NO_STR |
| 1204 | "IS-IS commands\n" |
| 1205 | "Set priority for Designated Router election\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1206 | "Specify priority for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1207 | { |
| 1208 | struct isis_circuit *circuit; |
| 1209 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1210 | |
| 1211 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1212 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1213 | if (circuit == NULL) |
| 1214 | { |
| 1215 | return CMD_WARNING; |
| 1216 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1217 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1218 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1219 | circuit->u.bc.priority[1] = DEFAULT_PRIORITY; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1220 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1221 | return CMD_SUCCESS; |
| 1222 | } |
| 1223 | |
| 1224 | ALIAS (no_isis_priority_l2, |
| 1225 | no_isis_priority_l2_arg_cmd, |
| 1226 | "no isis priority <0-127> level-2", |
| 1227 | NO_STR |
| 1228 | "IS-IS commands\n" |
| 1229 | "Set priority for Designated Router election\n" |
| 1230 | "Priority value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1231 | "Specify priority for level-2 routing\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1232 | |
| 1233 | /* Metric command */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1234 | DEFUN (isis_metric, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1235 | isis_metric_cmd, |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1236 | "isis metric <0-16777215>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1237 | "IS-IS commands\n" |
| 1238 | "Set default metric for circuit\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1239 | "Default metric value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1240 | { |
| 1241 | struct isis_circuit *circuit; |
| 1242 | struct interface *ifp; |
| 1243 | int met; |
| 1244 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1245 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1246 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1247 | if (circuit == NULL) |
| 1248 | { |
| 1249 | return CMD_WARNING; |
| 1250 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1251 | assert (circuit); |
| 1252 | |
| 1253 | met = atoi (argv[0]); |
| 1254 | |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1255 | circuit->te_metric[0] = met; |
| 1256 | circuit->te_metric[1] = met; |
| 1257 | |
| 1258 | if (met > 63) |
| 1259 | met = 63; |
| 1260 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1261 | circuit->metrics[0].metric_default = met; |
| 1262 | circuit->metrics[1].metric_default = met; |
| 1263 | |
| 1264 | return CMD_SUCCESS; |
| 1265 | } |
| 1266 | |
| 1267 | DEFUN (no_isis_metric, |
| 1268 | no_isis_metric_cmd, |
| 1269 | "no isis metric", |
| 1270 | NO_STR |
| 1271 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1272 | "Set default metric for circuit\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1273 | { |
| 1274 | struct isis_circuit *circuit; |
| 1275 | struct interface *ifp; |
| 1276 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1277 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1278 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1279 | if (circuit == NULL) |
| 1280 | { |
| 1281 | return CMD_WARNING; |
| 1282 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1283 | assert (circuit); |
| 1284 | |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1285 | circuit->te_metric[0] = DEFAULT_CIRCUIT_METRICS; |
| 1286 | circuit->te_metric[1] = DEFAULT_CIRCUIT_METRICS; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1287 | circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS; |
| 1288 | circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS; |
| 1289 | |
| 1290 | return CMD_SUCCESS; |
| 1291 | } |
| 1292 | |
| 1293 | ALIAS (no_isis_metric, |
| 1294 | no_isis_metric_arg_cmd, |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1295 | "no isis metric <0-16777215>", |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1296 | NO_STR |
| 1297 | "IS-IS commands\n" |
| 1298 | "Set default metric for circuit\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1299 | "Default metric value\n") |
| 1300 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1301 | /* end of metrics */ |
hasso | f21fb27 | 2005-09-26 17:05:55 +0000 | [diff] [blame] | 1302 | DEFUN (isis_hello_interval, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1303 | isis_hello_interval_cmd, |
| 1304 | "isis hello-interval (<1-65535>|minimal)", |
| 1305 | "IS-IS commands\n" |
| 1306 | "Set Hello interval\n" |
| 1307 | "Hello interval value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1308 | "Holdtime 1 seconds, interval depends on multiplier\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1309 | { |
| 1310 | struct isis_circuit *circuit; |
| 1311 | struct interface *ifp; |
| 1312 | int interval; |
| 1313 | char c; |
| 1314 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1315 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1316 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1317 | if (circuit == NULL) |
| 1318 | { |
| 1319 | return CMD_WARNING; |
| 1320 | } |
| 1321 | assert (circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1322 | c = *argv[0]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1323 | if (isdigit ((int) c)) |
| 1324 | { |
| 1325 | interval = atoi (argv[0]); |
| 1326 | } |
| 1327 | else |
| 1328 | interval = HELLO_MINIMAL; /* FIXME: should be calculated */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1329 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1330 | circuit->hello_interval[0] = (u_int16_t) interval; |
| 1331 | circuit->hello_interval[1] = (u_int16_t) interval; |
| 1332 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1333 | return CMD_SUCCESS; |
| 1334 | } |
| 1335 | |
| 1336 | DEFUN (no_isis_hello_interval, |
| 1337 | no_isis_hello_interval_cmd, |
| 1338 | "no isis hello-interval", |
| 1339 | NO_STR |
| 1340 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1341 | "Set Hello interval\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1342 | { |
| 1343 | struct isis_circuit *circuit; |
| 1344 | struct interface *ifp; |
| 1345 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1346 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1347 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1348 | if (circuit == NULL) |
| 1349 | { |
| 1350 | return CMD_WARNING; |
| 1351 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1352 | assert (circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1353 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1354 | |
| 1355 | circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1356 | circuit->hello_interval[1] = HELLO_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1357 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1358 | return CMD_SUCCESS; |
| 1359 | } |
| 1360 | |
| 1361 | ALIAS (no_isis_hello_interval, |
| 1362 | no_isis_hello_interval_arg_cmd, |
| 1363 | "no isis hello-interval (<1-65535>|minimal)", |
| 1364 | NO_STR |
| 1365 | "IS-IS commands\n" |
| 1366 | "Set Hello interval\n" |
| 1367 | "Hello interval value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1368 | "Holdtime 1 second, interval depends on multiplier\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1369 | |
| 1370 | DEFUN (isis_hello_interval_l1, |
| 1371 | isis_hello_interval_l1_cmd, |
| 1372 | "isis hello-interval (<1-65535>|minimal) level-1", |
| 1373 | "IS-IS commands\n" |
| 1374 | "Set Hello interval\n" |
| 1375 | "Hello interval value\n" |
| 1376 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1377 | "Specify hello-interval for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1378 | { |
| 1379 | struct isis_circuit *circuit; |
| 1380 | struct interface *ifp; |
| 1381 | long interval; |
| 1382 | char c; |
| 1383 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1384 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1385 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1386 | if (circuit == NULL) |
| 1387 | { |
| 1388 | return CMD_WARNING; |
| 1389 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1390 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1391 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1392 | c = *argv[0]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1393 | if (isdigit ((int) c)) |
| 1394 | { |
| 1395 | interval = atoi (argv[0]); |
| 1396 | } |
| 1397 | else |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1398 | interval = HELLO_MINIMAL; |
| 1399 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1400 | circuit->hello_interval[0] = (u_int16_t) interval; |
| 1401 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1402 | return CMD_SUCCESS; |
| 1403 | } |
| 1404 | |
| 1405 | DEFUN (no_isis_hello_interval_l1, |
| 1406 | no_isis_hello_interval_l1_cmd, |
| 1407 | "no isis hello-interval level-1", |
| 1408 | NO_STR |
| 1409 | "IS-IS commands\n" |
| 1410 | "Set Hello interval\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1411 | "Specify hello-interval for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1412 | { |
| 1413 | struct isis_circuit *circuit; |
| 1414 | struct interface *ifp; |
| 1415 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1416 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1417 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1418 | if (circuit == NULL) |
| 1419 | { |
| 1420 | return CMD_WARNING; |
| 1421 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1422 | assert (circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1423 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1424 | |
| 1425 | circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */ |
| 1426 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1427 | return CMD_SUCCESS; |
| 1428 | } |
| 1429 | |
| 1430 | ALIAS (no_isis_hello_interval_l1, |
| 1431 | no_isis_hello_interval_l1_arg_cmd, |
| 1432 | "no isis hello-interval (<1-65535>|minimal) level-1", |
| 1433 | NO_STR |
| 1434 | "IS-IS commands\n" |
| 1435 | "Set Hello interval\n" |
| 1436 | "Hello interval value\n" |
| 1437 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1438 | "Specify hello-interval for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1439 | |
| 1440 | DEFUN (isis_hello_interval_l2, |
| 1441 | isis_hello_interval_l2_cmd, |
| 1442 | "isis hello-interval (<1-65535>|minimal) level-2", |
| 1443 | "IS-IS commands\n" |
| 1444 | "Set Hello interval\n" |
| 1445 | "Hello interval value\n" |
| 1446 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1447 | "Specify hello-interval for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1448 | { |
| 1449 | struct isis_circuit *circuit; |
| 1450 | struct interface *ifp; |
| 1451 | long interval; |
| 1452 | char c; |
| 1453 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1454 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1455 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1456 | if (circuit == NULL) |
| 1457 | { |
| 1458 | return CMD_WARNING; |
| 1459 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1460 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1461 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1462 | c = *argv[0]; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1463 | if (isdigit ((int) c)) |
| 1464 | { |
| 1465 | interval = atoi (argv[0]); |
| 1466 | } |
| 1467 | else |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1468 | interval = HELLO_MINIMAL; |
| 1469 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1470 | circuit->hello_interval[1] = (u_int16_t) interval; |
| 1471 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1472 | return CMD_SUCCESS; |
| 1473 | } |
| 1474 | |
| 1475 | DEFUN (no_isis_hello_interval_l2, |
| 1476 | no_isis_hello_interval_l2_cmd, |
| 1477 | "no isis hello-interval level-2", |
| 1478 | NO_STR |
| 1479 | "IS-IS commands\n" |
| 1480 | "Set Hello interval\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1481 | "Specify hello-interval for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1482 | { |
| 1483 | struct isis_circuit *circuit; |
| 1484 | struct interface *ifp; |
| 1485 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1486 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1487 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1488 | if (circuit == NULL) |
| 1489 | { |
| 1490 | return CMD_WARNING; |
| 1491 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1492 | assert (circuit); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1493 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1494 | |
| 1495 | circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */ |
| 1496 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1497 | return CMD_SUCCESS; |
| 1498 | } |
| 1499 | |
| 1500 | ALIAS (no_isis_hello_interval_l2, |
| 1501 | no_isis_hello_interval_l2_arg_cmd, |
| 1502 | "no isis hello-interval (<1-65535>|minimal) level-2", |
| 1503 | NO_STR |
| 1504 | "IS-IS commands\n" |
| 1505 | "Set Hello interval\n" |
| 1506 | "Hello interval value\n" |
| 1507 | "Holdtime 1 second, interval depends on multiplier\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1508 | "Specify hello-interval for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1509 | |
| 1510 | DEFUN (isis_hello_multiplier, |
| 1511 | isis_hello_multiplier_cmd, |
| 1512 | "isis hello-multiplier <3-1000>", |
| 1513 | "IS-IS commands\n" |
| 1514 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1515 | "Hello multiplier value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1516 | { |
| 1517 | struct isis_circuit *circuit; |
| 1518 | struct interface *ifp; |
| 1519 | int mult; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1520 | |
| 1521 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1522 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1523 | if (circuit == NULL) |
| 1524 | { |
| 1525 | return CMD_WARNING; |
| 1526 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1527 | assert (circuit); |
| 1528 | |
| 1529 | mult = atoi (argv[0]); |
| 1530 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1531 | circuit->hello_multiplier[0] = (u_int16_t) mult; |
| 1532 | circuit->hello_multiplier[1] = (u_int16_t) mult; |
| 1533 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1534 | return CMD_SUCCESS; |
| 1535 | } |
| 1536 | |
| 1537 | DEFUN (no_isis_hello_multiplier, |
| 1538 | no_isis_hello_multiplier_cmd, |
| 1539 | "no isis hello-multiplier", |
| 1540 | NO_STR |
| 1541 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1542 | "Set multiplier for Hello holding time\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1543 | { |
| 1544 | struct isis_circuit *circuit; |
| 1545 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1546 | |
| 1547 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1548 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1549 | if (circuit == NULL) |
| 1550 | { |
| 1551 | return CMD_WARNING; |
| 1552 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1553 | assert (circuit); |
| 1554 | |
| 1555 | circuit->hello_multiplier[0] = HELLO_MULTIPLIER; |
| 1556 | circuit->hello_multiplier[1] = HELLO_MULTIPLIER; |
| 1557 | |
| 1558 | return CMD_SUCCESS; |
| 1559 | } |
| 1560 | |
| 1561 | ALIAS (no_isis_hello_multiplier, |
| 1562 | no_isis_hello_multiplier_arg_cmd, |
| 1563 | "no isis hello-multiplier <3-1000>", |
| 1564 | NO_STR |
| 1565 | "IS-IS commands\n" |
| 1566 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1567 | "Hello multiplier value\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1568 | |
| 1569 | DEFUN (isis_hello_multiplier_l1, |
| 1570 | isis_hello_multiplier_l1_cmd, |
| 1571 | "isis hello-multiplier <3-1000> level-1", |
| 1572 | "IS-IS commands\n" |
| 1573 | "Set multiplier for Hello holding time\n" |
| 1574 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1575 | "Specify hello multiplier for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1576 | { |
| 1577 | struct isis_circuit *circuit; |
| 1578 | struct interface *ifp; |
| 1579 | int mult; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1580 | |
| 1581 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1582 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1583 | if (circuit == NULL) |
| 1584 | { |
| 1585 | return CMD_WARNING; |
| 1586 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1587 | assert (circuit); |
| 1588 | |
| 1589 | mult = atoi (argv[0]); |
| 1590 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1591 | circuit->hello_multiplier[0] = (u_int16_t) mult; |
| 1592 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1593 | return CMD_SUCCESS; |
| 1594 | } |
| 1595 | |
| 1596 | DEFUN (no_isis_hello_multiplier_l1, |
| 1597 | no_isis_hello_multiplier_l1_cmd, |
| 1598 | "no isis hello-multiplier level-1", |
| 1599 | NO_STR |
| 1600 | "IS-IS commands\n" |
| 1601 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1602 | "Specify hello multiplier for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1603 | { |
| 1604 | struct isis_circuit *circuit; |
| 1605 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1606 | |
| 1607 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1608 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1609 | if (circuit == NULL) |
| 1610 | { |
| 1611 | return CMD_WARNING; |
| 1612 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1613 | assert (circuit); |
| 1614 | |
| 1615 | circuit->hello_multiplier[0] = HELLO_MULTIPLIER; |
| 1616 | |
| 1617 | return CMD_SUCCESS; |
| 1618 | } |
| 1619 | |
| 1620 | ALIAS (no_isis_hello_multiplier_l1, |
| 1621 | no_isis_hello_multiplier_l1_arg_cmd, |
| 1622 | "no isis hello-multiplier <3-1000> level-1", |
| 1623 | NO_STR |
| 1624 | "IS-IS commands\n" |
| 1625 | "Set multiplier for Hello holding time\n" |
| 1626 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1627 | "Specify hello multiplier for level-1 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1628 | |
| 1629 | DEFUN (isis_hello_multiplier_l2, |
| 1630 | isis_hello_multiplier_l2_cmd, |
| 1631 | "isis hello-multiplier <3-1000> level-2", |
| 1632 | "IS-IS commands\n" |
| 1633 | "Set multiplier for Hello holding time\n" |
| 1634 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1635 | "Specify hello multiplier for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1636 | { |
| 1637 | struct isis_circuit *circuit; |
| 1638 | struct interface *ifp; |
| 1639 | int mult; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1640 | |
| 1641 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1642 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1643 | if (circuit == NULL) |
| 1644 | { |
| 1645 | return CMD_WARNING; |
| 1646 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1647 | assert (circuit); |
| 1648 | |
| 1649 | mult = atoi (argv[0]); |
| 1650 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1651 | circuit->hello_multiplier[1] = (u_int16_t) mult; |
| 1652 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1653 | return CMD_SUCCESS; |
| 1654 | } |
| 1655 | |
| 1656 | DEFUN (no_isis_hello_multiplier_l2, |
| 1657 | no_isis_hello_multiplier_l2_cmd, |
| 1658 | "no isis hello-multiplier level-2", |
| 1659 | NO_STR |
| 1660 | "IS-IS commands\n" |
| 1661 | "Set multiplier for Hello holding time\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1662 | "Specify hello multiplier for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1663 | { |
| 1664 | struct isis_circuit *circuit; |
| 1665 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1666 | |
| 1667 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1668 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1669 | if (circuit == NULL) |
| 1670 | { |
| 1671 | return CMD_WARNING; |
| 1672 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1673 | assert (circuit); |
| 1674 | |
| 1675 | circuit->hello_multiplier[1] = HELLO_MULTIPLIER; |
| 1676 | |
| 1677 | return CMD_SUCCESS; |
| 1678 | } |
| 1679 | |
| 1680 | ALIAS (no_isis_hello_multiplier_l2, |
| 1681 | no_isis_hello_multiplier_l2_arg_cmd, |
| 1682 | "no isis hello-multiplier <3-1000> level-2", |
| 1683 | NO_STR |
| 1684 | "IS-IS commands\n" |
| 1685 | "Set multiplier for Hello holding time\n" |
| 1686 | "Hello multiplier value\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1687 | "Specify hello multiplier for level-2 IIHs\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1688 | |
| 1689 | DEFUN (isis_hello, |
| 1690 | isis_hello_cmd, |
| 1691 | "isis hello padding", |
| 1692 | "IS-IS commands\n" |
| 1693 | "Add padding to IS-IS hello packets\n" |
| 1694 | "Pad hello packets\n" |
| 1695 | "<cr>\n") |
| 1696 | { |
| 1697 | struct interface *ifp; |
| 1698 | struct isis_circuit *circuit; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1699 | |
| 1700 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1701 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1702 | if (circuit == NULL) |
| 1703 | { |
| 1704 | return CMD_WARNING; |
| 1705 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1706 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1707 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1708 | circuit->u.bc.pad_hellos = 1; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1709 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1710 | return CMD_SUCCESS; |
| 1711 | } |
| 1712 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1713 | DEFUN (no_isis_hello, |
| 1714 | no_isis_hello_cmd, |
| 1715 | "no isis hello padding", |
| 1716 | NO_STR |
| 1717 | "IS-IS commands\n" |
| 1718 | "Add padding to IS-IS hello packets\n" |
| 1719 | "Pad hello packets\n" |
| 1720 | "<cr>\n") |
| 1721 | { |
| 1722 | struct isis_circuit *circuit; |
| 1723 | struct interface *ifp; |
| 1724 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1725 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1726 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1727 | if (circuit == NULL) |
| 1728 | { |
| 1729 | return CMD_WARNING; |
| 1730 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1731 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1732 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1733 | circuit->u.bc.pad_hellos = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1734 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1735 | return CMD_SUCCESS; |
| 1736 | } |
| 1737 | |
| 1738 | DEFUN (csnp_interval, |
| 1739 | csnp_interval_cmd, |
| 1740 | "isis csnp-interval <0-65535>", |
| 1741 | "IS-IS commands\n" |
| 1742 | "Set CSNP interval in seconds\n" |
| 1743 | "CSNP interval value\n") |
| 1744 | { |
| 1745 | struct isis_circuit *circuit; |
| 1746 | struct interface *ifp; |
| 1747 | unsigned long interval; |
| 1748 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1749 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1750 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1751 | if (circuit == NULL) |
| 1752 | { |
| 1753 | return CMD_WARNING; |
| 1754 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1755 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1756 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1757 | interval = atol (argv[0]); |
| 1758 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1759 | circuit->csnp_interval[0] = (u_int16_t) interval; |
| 1760 | circuit->csnp_interval[1] = (u_int16_t) interval; |
| 1761 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1762 | return CMD_SUCCESS; |
| 1763 | } |
| 1764 | |
| 1765 | DEFUN (no_csnp_interval, |
| 1766 | no_csnp_interval_cmd, |
| 1767 | "no isis csnp-interval", |
| 1768 | NO_STR |
| 1769 | "IS-IS commands\n" |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1770 | "Set CSNP interval in seconds\n") |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1771 | { |
| 1772 | struct isis_circuit *circuit; |
| 1773 | struct interface *ifp; |
| 1774 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1775 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1776 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1777 | if (circuit == NULL) |
| 1778 | { |
| 1779 | return CMD_WARNING; |
| 1780 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1781 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1782 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1783 | circuit->csnp_interval[0] = CSNP_INTERVAL; |
| 1784 | circuit->csnp_interval[1] = CSNP_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1785 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1786 | return CMD_SUCCESS; |
| 1787 | } |
| 1788 | |
| 1789 | ALIAS (no_csnp_interval, |
| 1790 | no_csnp_interval_arg_cmd, |
| 1791 | "no isis csnp-interval <0-65535>", |
| 1792 | NO_STR |
| 1793 | "IS-IS commands\n" |
| 1794 | "Set CSNP interval in seconds\n" |
| 1795 | "CSNP interval value\n") |
| 1796 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1797 | DEFUN (csnp_interval_l1, |
| 1798 | csnp_interval_l1_cmd, |
| 1799 | "isis csnp-interval <0-65535> level-1", |
| 1800 | "IS-IS commands\n" |
| 1801 | "Set CSNP interval in seconds\n" |
| 1802 | "CSNP interval value\n" |
| 1803 | "Specify interval for level-1 CSNPs\n") |
| 1804 | { |
| 1805 | struct isis_circuit *circuit; |
| 1806 | struct interface *ifp; |
| 1807 | unsigned long interval; |
| 1808 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1809 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1810 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1811 | if (circuit == NULL) |
| 1812 | { |
| 1813 | return CMD_WARNING; |
| 1814 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1815 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1816 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1817 | interval = atol (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1818 | |
| 1819 | circuit->csnp_interval[0] = (u_int16_t) interval; |
| 1820 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1821 | return CMD_SUCCESS; |
| 1822 | } |
| 1823 | |
| 1824 | DEFUN (no_csnp_interval_l1, |
| 1825 | no_csnp_interval_l1_cmd, |
| 1826 | "no isis csnp-interval level-1", |
| 1827 | NO_STR |
| 1828 | "IS-IS commands\n" |
| 1829 | "Set CSNP interval in seconds\n" |
| 1830 | "Specify interval for level-1 CSNPs\n") |
| 1831 | { |
| 1832 | struct isis_circuit *circuit; |
| 1833 | struct interface *ifp; |
| 1834 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1835 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1836 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1837 | if (circuit == NULL) |
| 1838 | { |
| 1839 | return CMD_WARNING; |
| 1840 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1841 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1842 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1843 | circuit->csnp_interval[0] = CSNP_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1844 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1845 | return CMD_SUCCESS; |
| 1846 | } |
| 1847 | |
| 1848 | ALIAS (no_csnp_interval_l1, |
| 1849 | no_csnp_interval_l1_arg_cmd, |
| 1850 | "no isis csnp-interval <0-65535> level-1", |
| 1851 | NO_STR |
| 1852 | "IS-IS commands\n" |
| 1853 | "Set CSNP interval in seconds\n" |
| 1854 | "CSNP interval value\n" |
| 1855 | "Specify interval for level-1 CSNPs\n") |
| 1856 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1857 | DEFUN (csnp_interval_l2, |
| 1858 | csnp_interval_l2_cmd, |
| 1859 | "isis csnp-interval <0-65535> level-2", |
| 1860 | "IS-IS commands\n" |
| 1861 | "Set CSNP interval in seconds\n" |
| 1862 | "CSNP interval value\n" |
| 1863 | "Specify interval for level-2 CSNPs\n") |
| 1864 | { |
| 1865 | struct isis_circuit *circuit; |
| 1866 | struct interface *ifp; |
| 1867 | unsigned long interval; |
| 1868 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1869 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1870 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1871 | if (circuit == NULL) |
| 1872 | { |
| 1873 | return CMD_WARNING; |
| 1874 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1875 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1876 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1877 | interval = atol (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1878 | |
| 1879 | circuit->csnp_interval[1] = (u_int16_t) interval; |
| 1880 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1881 | return CMD_SUCCESS; |
| 1882 | } |
| 1883 | |
| 1884 | DEFUN (no_csnp_interval_l2, |
| 1885 | no_csnp_interval_l2_cmd, |
| 1886 | "no isis csnp-interval level-2", |
| 1887 | NO_STR |
| 1888 | "IS-IS commands\n" |
| 1889 | "Set CSNP interval in seconds\n" |
| 1890 | "Specify interval for level-2 CSNPs\n") |
| 1891 | { |
| 1892 | struct isis_circuit *circuit; |
| 1893 | struct interface *ifp; |
| 1894 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1895 | ifp = vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1896 | circuit = ifp->info; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1897 | if (circuit == NULL) |
| 1898 | { |
| 1899 | return CMD_WARNING; |
| 1900 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1901 | assert (circuit); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1902 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1903 | circuit->csnp_interval[1] = CSNP_INTERVAL; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1904 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1905 | return CMD_SUCCESS; |
| 1906 | } |
| 1907 | |
| 1908 | ALIAS (no_csnp_interval_l2, |
| 1909 | no_csnp_interval_l2_arg_cmd, |
| 1910 | "no isis csnp-interval <0-65535> level-2", |
| 1911 | NO_STR |
| 1912 | "IS-IS commands\n" |
| 1913 | "Set CSNP interval in seconds\n" |
| 1914 | "CSNP interval value\n" |
| 1915 | "Specify interval for level-2 CSNPs\n") |
| 1916 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1917 | #ifdef HAVE_IPV6 |
| 1918 | DEFUN (ipv6_router_isis, |
| 1919 | ipv6_router_isis_cmd, |
| 1920 | "ipv6 router isis WORD", |
| 1921 | "IPv6 interface subcommands\n" |
| 1922 | "IPv6 Router interface commands\n" |
| 1923 | "IS-IS Routing for IPv6\n" |
| 1924 | "Routing process tag\n") |
| 1925 | { |
| 1926 | struct isis_circuit *c; |
| 1927 | struct interface *ifp; |
| 1928 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1929 | |
| 1930 | ifp = (struct interface *) vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1931 | assert (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1932 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1933 | area = isis_area_lookup (argv[0]); |
| 1934 | |
| 1935 | /* Prevent more than one circuit per interface */ |
| 1936 | if (area) |
| 1937 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1938 | else |
| 1939 | c = NULL; |
| 1940 | |
| 1941 | if (c && (ifp->info != NULL)) |
| 1942 | { |
| 1943 | if (c->ipv6_router == 1) |
| 1944 | { |
| 1945 | vty_out (vty, "ISIS circuit is already defined for IPv6%s", |
| 1946 | VTY_NEWLINE); |
| 1947 | return CMD_WARNING; |
| 1948 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1949 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1950 | |
| 1951 | /* this is here for ciscopability */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1952 | if (!area) |
| 1953 | { |
| 1954 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 1955 | return CMD_WARNING; |
| 1956 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1957 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1958 | if (!c) |
| 1959 | { |
| 1960 | c = circuit_lookup_by_ifp (ifp, isis->init_circ_list); |
| 1961 | c = isis_csm_state_change (ISIS_ENABLE, c, area); |
| 1962 | c->interface = ifp; |
| 1963 | ifp->info = c; |
| 1964 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1965 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1966 | if (!c) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1967 | return CMD_WARNING; |
| 1968 | |
| 1969 | c->ipv6_router = 1; |
| 1970 | area->ipv6_circuits++; |
| 1971 | circuit_update_nlpids (c); |
| 1972 | |
| 1973 | vty->node = INTERFACE_NODE; |
| 1974 | |
| 1975 | return CMD_SUCCESS; |
| 1976 | } |
| 1977 | |
| 1978 | DEFUN (no_ipv6_router_isis, |
| 1979 | no_ipv6_router_isis_cmd, |
| 1980 | "no ipv6 router isis WORD", |
| 1981 | NO_STR |
| 1982 | "IPv6 interface subcommands\n" |
| 1983 | "IPv6 Router interface commands\n" |
| 1984 | "IS-IS Routing for IPv6\n" |
| 1985 | "Routing process tag\n") |
| 1986 | { |
| 1987 | struct isis_circuit *c; |
| 1988 | struct interface *ifp; |
| 1989 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1990 | |
| 1991 | ifp = (struct interface *) vty->index; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1992 | /* UGLY - will remove l8r |
| 1993 | if (circuit == NULL) { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1994 | return CMD_WARNING; |
| 1995 | } */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1996 | assert (ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1997 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1998 | area = isis_area_lookup (argv[0]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 1999 | if (!area) |
| 2000 | { |
| 2001 | vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); |
| 2002 | return CMD_WARNING; |
| 2003 | } |
| 2004 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2005 | c = circuit_lookup_by_ifp (ifp, area->circuit_list); |
| 2006 | if (!c) |
| 2007 | return CMD_WARNING; |
| 2008 | |
| 2009 | c->ipv6_router = 0; |
| 2010 | area->ipv6_circuits--; |
| 2011 | if (c->ip_router == 0) |
| 2012 | isis_csm_state_change (ISIS_DISABLE, c, area); |
| 2013 | |
| 2014 | return CMD_SUCCESS; |
| 2015 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2016 | #endif /* HAVE_IPV6 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2017 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 2018 | struct cmd_node interface_node = { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2019 | INTERFACE_NODE, |
| 2020 | "%s(config-if)# ", |
| 2021 | 1, |
| 2022 | }; |
| 2023 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2024 | int |
| 2025 | isis_if_new_hook (struct interface *ifp) |
| 2026 | { |
| 2027 | /* FIXME: Discuss if the circuit should be created here |
| 2028 | ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */ |
| 2029 | ifp->info = NULL; |
| 2030 | return 0; |
| 2031 | } |
| 2032 | |
| 2033 | int |
| 2034 | isis_if_delete_hook (struct interface *ifp) |
| 2035 | { |
| 2036 | /* FIXME: Discuss if the circuit should be created here |
| 2037 | XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/ |
| 2038 | ifp->info = NULL; |
| 2039 | return 0; |
| 2040 | } |
| 2041 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2042 | void |
| 2043 | isis_circuit_init () |
| 2044 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2045 | /* Initialize Zebra interface data structure */ |
| 2046 | if_init (); |
| 2047 | if_add_hook (IF_NEW_HOOK, isis_if_new_hook); |
| 2048 | if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook); |
| 2049 | |
| 2050 | /* Install interface node */ |
| 2051 | install_node (&interface_node, isis_interface_config_write); |
| 2052 | install_element (CONFIG_NODE, &interface_cmd); |
| 2053 | |
| 2054 | install_default (INTERFACE_NODE); |
| 2055 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 2056 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 2057 | |
| 2058 | install_element (INTERFACE_NODE, &ip_router_isis_cmd); |
| 2059 | install_element (INTERFACE_NODE, &no_ip_router_isis_cmd); |
| 2060 | |
| 2061 | install_element (INTERFACE_NODE, &isis_circuit_type_cmd); |
| 2062 | install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd); |
| 2063 | |
| 2064 | install_element (INTERFACE_NODE, &isis_passwd_cmd); |
| 2065 | install_element (INTERFACE_NODE, &no_isis_passwd_cmd); |
| 2066 | |
| 2067 | install_element (INTERFACE_NODE, &isis_priority_cmd); |
| 2068 | install_element (INTERFACE_NODE, &no_isis_priority_cmd); |
| 2069 | install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd); |
| 2070 | install_element (INTERFACE_NODE, &isis_priority_l1_cmd); |
| 2071 | install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd); |
| 2072 | install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd); |
| 2073 | install_element (INTERFACE_NODE, &isis_priority_l2_cmd); |
| 2074 | install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd); |
| 2075 | install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd); |
| 2076 | |
| 2077 | install_element (INTERFACE_NODE, &isis_metric_cmd); |
| 2078 | install_element (INTERFACE_NODE, &no_isis_metric_cmd); |
| 2079 | install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd); |
| 2080 | |
| 2081 | install_element (INTERFACE_NODE, &isis_hello_interval_cmd); |
| 2082 | install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd); |
| 2083 | install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd); |
| 2084 | install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd); |
| 2085 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); |
| 2086 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd); |
| 2087 | install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd); |
| 2088 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); |
| 2089 | install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd); |
| 2090 | |
| 2091 | install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd); |
| 2092 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd); |
| 2093 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd); |
| 2094 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); |
| 2095 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); |
| 2096 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd); |
| 2097 | install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); |
| 2098 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); |
| 2099 | install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd); |
| 2100 | |
| 2101 | install_element (INTERFACE_NODE, &isis_hello_cmd); |
| 2102 | install_element (INTERFACE_NODE, &no_isis_hello_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2103 | install_element (INTERFACE_NODE, &csnp_interval_cmd); |
| 2104 | install_element (INTERFACE_NODE, &no_csnp_interval_cmd); |
| 2105 | install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd); |
| 2106 | install_element (INTERFACE_NODE, &csnp_interval_l1_cmd); |
| 2107 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd); |
| 2108 | install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd); |
| 2109 | install_element (INTERFACE_NODE, &csnp_interval_l2_cmd); |
| 2110 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd); |
| 2111 | install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd); |
| 2112 | |
| 2113 | #ifdef HAVE_IPV6 |
| 2114 | install_element (INTERFACE_NODE, &ipv6_router_isis_cmd); |
| 2115 | install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2116 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 2117 | } |