blob: 99e2bf6f2c4e683cd980b59eaaa057701a0ce34c [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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 */
jardineb5d44e2003-12-23 08:09:43 +000022#include <zebra.h>
hasso37da8c02004-05-19 11:38:40 +000023#ifdef GNU_LINUX
jardineb5d44e2003-12-23 08:09:43 +000024#include <net/ethernet.h>
hasso37da8c02004-05-19 11:38:40 +000025#else
26#include <netinet/if_ether.h>
27#endif
jardineb5d44e2003-12-23 08:09:43 +000028
Paul Jakma238497f2007-08-07 18:49:18 +000029#ifndef ETHER_ADDR_LEN
30#define ETHER_ADDR_LEN ETHERADDRL
31#endif
32
jardineb5d44e2003-12-23 08:09:43 +000033#include "log.h"
34#include "memory.h"
35#include "if.h"
36#include "linklist.h"
37#include "command.h"
38#include "thread.h"
39#include "hash.h"
40#include "prefix.h"
41#include "stream.h"
42
43#include "isisd/dict.h"
44#include "isisd/include-netbsd/iso.h"
45#include "isisd/isis_constants.h"
46#include "isisd/isis_common.h"
47#include "isisd/isis_circuit.h"
48#include "isisd/isis_tlv.h"
49#include "isisd/isis_lsp.h"
50#include "isisd/isis_pdu.h"
51#include "isisd/isis_network.h"
52#include "isisd/isis_misc.h"
53#include "isisd/isis_constants.h"
54#include "isisd/isis_adjacency.h"
55#include "isisd/isis_dr.h"
56#include "isisd/isis_flags.h"
57#include "isisd/isisd.h"
58#include "isisd/isis_csm.h"
59#include "isisd/isis_events.h"
60
61extern struct thread_master *master;
62extern struct isis *isis;
63
Paul Jakma41b36e92006-12-08 01:09:50 +000064/*
65 * Prototypes.
66 */
67void isis_circuit_down(struct isis_circuit *);
68int isis_interface_config_write(struct vty *);
69int isis_if_new_hook(struct interface *);
70int isis_if_delete_hook(struct interface *);
71
jardineb5d44e2003-12-23 08:09:43 +000072struct isis_circuit *
73isis_circuit_new ()
74{
75 struct isis_circuit *circuit;
76 int i;
77
hasso3fdb2dd2005-09-28 18:45:54 +000078 circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
hassof390d2c2004-09-10 20:48:21 +000079 if (circuit)
80 {
hassof390d2c2004-09-10 20:48:21 +000081 /* set default metrics for circuit */
82 for (i = 0; i < 2; i++)
83 {
84 circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS;
85 circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
86 circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
87 circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
hassof21fb272005-09-26 17:05:55 +000088 circuit->te_metric[i] = DEFAULT_CIRCUIT_METRICS;
hassof390d2c2004-09-10 20:48:21 +000089 }
jardineb5d44e2003-12-23 08:09:43 +000090 }
hassof390d2c2004-09-10 20:48:21 +000091 else
92 {
93 zlog_err ("Can't malloc isis circuit");
94 return NULL;
95 }
96
jardineb5d44e2003-12-23 08:09:43 +000097 return circuit;
98}
99
jardineb5d44e2003-12-23 08:09:43 +0000100void
101isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
102{
103 int i;
104 circuit->area = area;
105 /*
106 * The level for the circuit is same as for the area, unless configured
107 * otherwise.
108 */
109 circuit->circuit_is_type = area->is_type;
110 /*
111 * Default values
112 */
hassof390d2c2004-09-10 20:48:21 +0000113 for (i = 0; i < 2; i++)
114 {
115 circuit->hello_interval[i] = HELLO_INTERVAL;
116 circuit->hello_multiplier[i] = HELLO_MULTIPLIER;
117 circuit->csnp_interval[i] = CSNP_INTERVAL;
118 circuit->psnp_interval[i] = PSNP_INTERVAL;
119 circuit->u.bc.priority[i] = DEFAULT_PRIORITY;
120 }
121 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
122 {
123 circuit->u.bc.adjdb[0] = list_new ();
124 circuit->u.bc.adjdb[1] = list_new ();
125 circuit->u.bc.pad_hellos = 1;
126 }
jardineb5d44e2003-12-23 08:09:43 +0000127 circuit->lsp_interval = LSP_INTERVAL;
128
129 /*
130 * Add the circuit into area
131 */
132 listnode_add (area->circuit_list, circuit);
133
134 circuit->idx = flags_get_index (&area->flags);
135 circuit->lsp_queue = list_new ();
136
137 return;
138}
139
hassof390d2c2004-09-10 20:48:21 +0000140void
jardineb5d44e2003-12-23 08:09:43 +0000141isis_circuit_deconfigure (struct isis_circuit *circuit,
hassof390d2c2004-09-10 20:48:21 +0000142 struct isis_area *area)
jardineb5d44e2003-12-23 08:09:43 +0000143{
hassof390d2c2004-09-10 20:48:21 +0000144
Fritz Reichmann55749992011-09-14 19:31:51 +0400145 /* destroy adjacencies */
146 if (circuit->u.bc.adjdb[0])
147 isis_adjdb_iterate (circuit->u.bc.adjdb[0], (void(*) (struct isis_adjacency *, void *)) isis_delete_adj, circuit->u.bc.adjdb[0]);
148 if (circuit->u.bc.adjdb[1])
149 isis_adjdb_iterate (circuit->u.bc.adjdb[1], (void(*) (struct isis_adjacency *, void *)) isis_delete_adj, circuit->u.bc.adjdb[1]);
jardineb5d44e2003-12-23 08:09:43 +0000150 /* Remove circuit from area */
151 listnode_delete (area->circuit_list, circuit);
152 /* Free the index of SRM and SSN flags */
153 flags_free_index (&area->flags, circuit->idx);
154
155 return;
156}
157
158struct isis_circuit *
159circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
160{
161 struct isis_circuit *circuit = NULL;
162 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000163
jardineb5d44e2003-12-23 08:09:43 +0000164 if (!list)
165 return NULL;
hassof390d2c2004-09-10 20:48:21 +0000166
paul1eb8ef22005-04-07 07:30:20 +0000167 for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
168 if (circuit->interface == ifp)
169 return circuit;
170
jardineb5d44e2003-12-23 08:09:43 +0000171 return NULL;
172}
173
174struct isis_circuit *
175circuit_scan_by_ifp (struct interface *ifp)
176{
177 struct isis_area *area;
178 struct listnode *node;
179 struct isis_circuit *circuit;
180
181 if (!isis->area_list)
182 return NULL;
183
paul1eb8ef22005-04-07 07:30:20 +0000184 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
hassof390d2c2004-09-10 20:48:21 +0000185 {
hassof390d2c2004-09-10 20:48:21 +0000186 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
187 if (circuit)
188 return circuit;
189 }
190
jardineb5d44e2003-12-23 08:09:43 +0000191 return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
192}
193
194void
195isis_circuit_del (struct isis_circuit *circuit)
196{
197
198 if (!circuit)
199 return;
200
hassof390d2c2004-09-10 20:48:21 +0000201 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
202 {
203 /* destroy adjacency databases */
hasso46606872004-12-29 19:34:22 +0000204 if (circuit->u.bc.adjdb[0])
205 list_delete (circuit->u.bc.adjdb[0]);
206 if (circuit->u.bc.adjdb[1])
207 list_delete (circuit->u.bc.adjdb[1]);
hassof390d2c2004-09-10 20:48:21 +0000208 /* destroy neighbour lists */
209 if (circuit->u.bc.lan_neighs[0])
210 list_delete (circuit->u.bc.lan_neighs[0]);
211 if (circuit->u.bc.lan_neighs[1])
212 list_delete (circuit->u.bc.lan_neighs[1]);
213 /* destroy addresses */
214 }
jardineb5d44e2003-12-23 08:09:43 +0000215 if (circuit->ip_addrs)
216 list_delete (circuit->ip_addrs);
217#ifdef HAVE_IPV6
218 if (circuit->ipv6_link)
219 list_delete (circuit->ipv6_link);
220 if (circuit->ipv6_non_link)
221 list_delete (circuit->ipv6_non_link);
222#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000223
jardineb5d44e2003-12-23 08:09:43 +0000224 /* and lastly the circuit itself */
225 XFREE (MTYPE_ISIS_CIRCUIT, circuit);
226
227 return;
228}
229
230void
hassof891f442004-09-14 13:54:30 +0000231isis_circuit_add_addr (struct isis_circuit *circuit,
232 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000233{
234 struct prefix_ipv4 *ipv4;
hassof390d2c2004-09-10 20:48:21 +0000235 u_char buf[BUFSIZ];
jardineb5d44e2003-12-23 08:09:43 +0000236#ifdef HAVE_IPV6
237 struct prefix_ipv6 *ipv6;
238#endif /* HAVE_IPV6 */
hassof891f442004-09-14 13:54:30 +0000239
hassof390d2c2004-09-10 20:48:21 +0000240 if (!circuit->ip_addrs)
hassof891f442004-09-14 13:54:30 +0000241 circuit->ip_addrs = list_new ();
jardineb5d44e2003-12-23 08:09:43 +0000242#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000243 if (!circuit->ipv6_link)
hassof891f442004-09-14 13:54:30 +0000244 circuit->ipv6_link = list_new ();
hassof390d2c2004-09-10 20:48:21 +0000245 if (!circuit->ipv6_non_link)
hassof891f442004-09-14 13:54:30 +0000246 circuit->ipv6_non_link = list_new ();
jardineb5d44e2003-12-23 08:09:43 +0000247#endif /* HAVE_IPV6 */
248
249 memset (&buf, 0, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000250 if (connected->address->family == AF_INET)
hassof390d2c2004-09-10 20:48:21 +0000251 {
252 ipv4 = prefix_ipv4_new ();
hassof891f442004-09-14 13:54:30 +0000253 ipv4->prefixlen = connected->address->prefixlen;
254 ipv4->prefix = connected->address->u.prefix4;
hassof390d2c2004-09-10 20:48:21 +0000255 listnode_add (circuit->ip_addrs, ipv4);
hasso0dae85e2004-09-26 19:53:47 +0000256 if (circuit->area)
257 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000258
jardineb5d44e2003-12-23 08:09:43 +0000259#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000260 prefix2str (connected->address, buf, BUFSIZ);
hasso529d65b2004-12-24 00:14:50 +0000261 zlog_debug ("Added IP address %s to circuit %d", buf,
hassof390d2c2004-09-10 20:48:21 +0000262 circuit->circuit_id);
263#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +0000264 }
hassof390d2c2004-09-10 20:48:21 +0000265#ifdef HAVE_IPV6
hassof891f442004-09-14 13:54:30 +0000266 if (connected->address->family == AF_INET6)
hassof390d2c2004-09-10 20:48:21 +0000267 {
268 ipv6 = prefix_ipv6_new ();
hassof891f442004-09-14 13:54:30 +0000269 ipv6->prefixlen = connected->address->prefixlen;
270 ipv6->prefix = connected->address->u.prefix6;
271
hassof390d2c2004-09-10 20:48:21 +0000272 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
hassof891f442004-09-14 13:54:30 +0000273 listnode_add (circuit->ipv6_link, ipv6);
hassof390d2c2004-09-10 20:48:21 +0000274 else
hassof891f442004-09-14 13:54:30 +0000275 listnode_add (circuit->ipv6_non_link, ipv6);
hasso0dae85e2004-09-26 19:53:47 +0000276 if (circuit->area)
277 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000278
jardineb5d44e2003-12-23 08:09:43 +0000279#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000280 prefix2str (connected->address, buf, BUFSIZ);
hasso529d65b2004-12-24 00:14:50 +0000281 zlog_debug ("Added IPv6 address %s to circuit %d", buf,
hassof390d2c2004-09-10 20:48:21 +0000282 circuit->circuit_id);
283#endif /* EXTREME_DEBUG */
284 }
jardineb5d44e2003-12-23 08:09:43 +0000285#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000286 return;
287}
288
289void
290isis_circuit_del_addr (struct isis_circuit *circuit,
hassof390d2c2004-09-10 20:48:21 +0000291 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000292{
hassof891f442004-09-14 13:54:30 +0000293 struct prefix_ipv4 *ipv4, *ip = NULL;
294 struct listnode *node;
hassof891f442004-09-14 13:54:30 +0000295 u_char buf[BUFSIZ];
296#ifdef HAVE_IPV6
297 struct prefix_ipv6 *ipv6, *ip6 = NULL;
Paul Jakma41b36e92006-12-08 01:09:50 +0000298 int found = 0;
hassof891f442004-09-14 13:54:30 +0000299#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000300
hassof891f442004-09-14 13:54:30 +0000301 memset (&buf, 0, BUFSIZ);
302 if (connected->address->family == AF_INET)
303 {
304 ipv4 = prefix_ipv4_new ();
305 ipv4->prefixlen = connected->address->prefixlen;
306 ipv4->prefix = connected->address->u.prefix4;
307
paul1eb8ef22005-04-07 07:30:20 +0000308 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
309 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
310 break;
hassof891f442004-09-14 13:54:30 +0000311
312 if (ip)
313 {
314 listnode_delete (circuit->ip_addrs, ip);
hasso0dae85e2004-09-26 19:53:47 +0000315 if (circuit->area)
316 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000317 }
318 else
319 {
hassof7c43dc2004-09-26 16:24:14 +0000320 prefix2str (connected->address, (char *)buf, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000321 zlog_warn("Nonexitant ip address %s removal attempt from circuit \
322 %d", buf, circuit->circuit_id);
323 }
324 }
325#ifdef HAVE_IPV6
326 if (connected->address->family == AF_INET6)
327 {
328 ipv6 = prefix_ipv6_new ();
329 ipv6->prefixlen = connected->address->prefixlen;
330 ipv6->prefix = connected->address->u.prefix6;
331
332 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
333 {
paul1eb8ef22005-04-07 07:30:20 +0000334 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
hassof891f442004-09-14 13:54:30 +0000335 {
hassof891f442004-09-14 13:54:30 +0000336 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
337 break;
338 }
339 if (ip6)
340 {
341 listnode_delete (circuit->ipv6_link, ip6);
342 found = 1;
343 }
344 }
345 else
346 {
paul1eb8ef22005-04-07 07:30:20 +0000347 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
hassof891f442004-09-14 13:54:30 +0000348 {
hassof891f442004-09-14 13:54:30 +0000349 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
350 break;
351 }
352 if (ip6)
353 {
354 listnode_delete (circuit->ipv6_non_link, ip6);
355 found = 1;
356 }
357 }
358
359 if (!found)
360 {
hassof7c43dc2004-09-26 16:24:14 +0000361 prefix2str (connected->address, (char *)buf, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000362 zlog_warn("Nonexitant ip address %s removal attempt from \
363 circuit %d", buf, circuit->circuit_id);
364 }
365 else
hasso0dae85e2004-09-26 19:53:47 +0000366 if (circuit->area)
367 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000368 }
369#endif /* HAVE_IPV6 */
370 return;
jardineb5d44e2003-12-23 08:09:43 +0000371}
372
373void
374isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
375{
paul1eb8ef22005-04-07 07:30:20 +0000376 struct listnode *node, *nnode;
jardineb5d44e2003-12-23 08:09:43 +0000377 struct connected *conn;
378
379 circuit->interface = ifp;
380 ifp->info = circuit;
hassof390d2c2004-09-10 20:48:21 +0000381
382 circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
jardineb5d44e2003-12-23 08:09:43 +0000383
384 /* isis_circuit_update_addrs (circuit, ifp); */
385
hassof390d2c2004-09-10 20:48:21 +0000386 if (if_is_broadcast (ifp))
387 {
388 circuit->circ_type = CIRCUIT_T_BROADCAST;
389 /*
390 * Get the Hardware Address
391 */
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000392#ifdef HAVE_STRUCT_SOCKADDR_DL
Paul Jakma238497f2007-08-07 18:49:18 +0000393#ifndef SUNOS_5
hassof390d2c2004-09-10 20:48:21 +0000394 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
395 zlog_warn ("unsupported link layer");
396 else
397 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
398 ETH_ALEN);
Paul Jakma238497f2007-08-07 18:49:18 +0000399#endif
jardineb5d44e2003-12-23 08:09:43 +0000400#else
hassof390d2c2004-09-10 20:48:21 +0000401 if (circuit->interface->hw_addr_len != ETH_ALEN)
402 {
403 zlog_warn ("unsupported link layer");
404 }
405 else
406 {
407 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
408 }
jardineb5d44e2003-12-23 08:09:43 +0000409#ifdef EXTREME_DEGUG
hasso529d65b2004-12-24 00:14:50 +0000410 zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
hassof390d2c2004-09-10 20:48:21 +0000411 circuit->interface->ifindex, ISO_MTU (circuit),
412 snpa_print (circuit->u.bc.snpa));
jardineb5d44e2003-12-23 08:09:43 +0000413
414#endif /* EXTREME_DEBUG */
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000415#endif /* HAVE_STRUCT_SOCKADDR_DL */
hassof390d2c2004-09-10 20:48:21 +0000416 }
417 else if (if_is_pointopoint (ifp))
418 {
419 circuit->circ_type = CIRCUIT_T_P2P;
420 }
421 else
422 {
hassoc89c05d2005-09-04 21:36:36 +0000423 /* It's normal in case of loopback etc. */
424 if (isis->debugs & DEBUG_EVENTS)
425 zlog_debug ("isis_circuit_if_add: unsupported media");
hassof390d2c2004-09-10 20:48:21 +0000426 }
427
paul1eb8ef22005-04-07 07:30:20 +0000428 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
429 isis_circuit_add_addr (circuit, conn);
jardineb5d44e2003-12-23 08:09:43 +0000430
431 return;
432}
433
434void
hassof390d2c2004-09-10 20:48:21 +0000435isis_circuit_update_params (struct isis_circuit *circuit,
436 struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000437{
hassob30c5e62004-12-29 20:06:41 +0000438 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +0000439
440 if (circuit->circuit_id != ifp->ifindex)
441 {
442 zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
443 ifp->ifindex);
444 circuit->circuit_id = ifp->ifindex % 255;
445 }
jardineb5d44e2003-12-23 08:09:43 +0000446
447 /* FIXME: Why is this needed? shouldn't we compare to the area's mtu */
448 /* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig)
449 The areas MTU is the minimum of mtu's of circuits in the area
450 now we can't catch the change
451 if (circuit->mtu != ifp->mtu) {
452 zlog_warn ("changing circuit mtu %d->%d", circuit->mtu,
453 ifp->mtu);
454 circuit->mtu = ifp->mtu;
455 }
hassof390d2c2004-09-10 20:48:21 +0000456 */
jardineb5d44e2003-12-23 08:09:43 +0000457 /*
458 * Get the Hardware Address
459 */
Paul Jakma6f0e3f62007-05-10 02:38:51 +0000460#ifdef HAVE_STRUCT_SOCKADDR_DL
Paul Jakma238497f2007-08-07 18:49:18 +0000461#ifndef SUNOS_5
jardineb5d44e2003-12-23 08:09:43 +0000462 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
jardineb5d44e2003-12-23 08:09:43 +0000463 zlog_warn ("unsupported link layer");
hassof390d2c2004-09-10 20:48:21 +0000464 else
465 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN);
Paul Jakma238497f2007-08-07 18:49:18 +0000466#endif
hassof390d2c2004-09-10 20:48:21 +0000467#else
468 if (circuit->interface->hw_addr_len != ETH_ALEN)
469 {
470 zlog_warn ("unsupported link layer");
jardineb5d44e2003-12-23 08:09:43 +0000471 }
hassof390d2c2004-09-10 20:48:21 +0000472 else
473 {
474 if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN))
475 {
476 zlog_warn ("changing circuit snpa %s->%s",
477 snpa_print (circuit->u.bc.snpa),
478 snpa_print (circuit->interface->hw_addr));
479 }
480 }
481#endif
jardineb5d44e2003-12-23 08:09:43 +0000482
hassof390d2c2004-09-10 20:48:21 +0000483 if (if_is_broadcast (ifp))
484 {
485 circuit->circ_type = CIRCUIT_T_BROADCAST;
486 }
487 else if (if_is_pointopoint (ifp))
488 {
489 circuit->circ_type = CIRCUIT_T_P2P;
490 }
491 else
492 {
493 zlog_warn ("isis_circuit_update_params: unsupported media");
494 }
jardineb5d44e2003-12-23 08:09:43 +0000495
jardineb5d44e2003-12-23 08:09:43 +0000496 return;
497}
498
499void
hassof390d2c2004-09-10 20:48:21 +0000500isis_circuit_if_del (struct isis_circuit *circuit)
jardineb5d44e2003-12-23 08:09:43 +0000501{
502 circuit->interface->info = NULL;
503 circuit->interface = NULL;
hassof390d2c2004-09-10 20:48:21 +0000504
jardineb5d44e2003-12-23 08:09:43 +0000505 return;
506}
507
508void
509isis_circuit_up (struct isis_circuit *circuit)
510{
jardineb5d44e2003-12-23 08:09:43 +0000511
hassof390d2c2004-09-10 20:48:21 +0000512 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
513 {
514 if (circuit->area->min_bcast_mtu == 0 ||
515 ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
516 circuit->area->min_bcast_mtu = ISO_MTU (circuit);
517 /*
518 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
519 */
jardineb5d44e2003-12-23 08:09:43 +0000520
hassof390d2c2004-09-10 20:48:21 +0000521 /* initilizing the hello sending threads
522 * for a broadcast IF
523 */
jardineb5d44e2003-12-23 08:09:43 +0000524
hassof390d2c2004-09-10 20:48:21 +0000525 /* 8.4.1 a) commence sending of IIH PDUs */
526
527 if (circuit->circuit_is_type & IS_LEVEL_1)
528 {
529 thread_add_event (master, send_lan_l1_hello, circuit, 0);
530 circuit->u.bc.lan_neighs[0] = list_new ();
531 }
532
533 if (circuit->circuit_is_type & IS_LEVEL_2)
534 {
535 thread_add_event (master, send_lan_l2_hello, circuit, 0);
536 circuit->u.bc.lan_neighs[1] = list_new ();
537 }
538
539 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
540 /* 8.4.1 c) FIXME: listen for ESH PDUs */
541
542 /* 8.4.1 d) */
543 /* dr election will commence in... */
544 if (circuit->circuit_is_type & IS_LEVEL_1)
545 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
hassobf731012004-09-17 07:59:57 +0000546 circuit, 2 * circuit->hello_interval[0]);
hassof390d2c2004-09-10 20:48:21 +0000547 if (circuit->circuit_is_type & IS_LEVEL_2)
548 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
hassobf731012004-09-17 07:59:57 +0000549 circuit, 2 * circuit->hello_interval[1]);
jardineb5d44e2003-12-23 08:09:43 +0000550 }
hassof390d2c2004-09-10 20:48:21 +0000551 else
552 {
553 /* initializing the hello send threads
554 * for a ptp IF
555 */
556 thread_add_event (master, send_p2p_hello, circuit, 0);
jardineb5d44e2003-12-23 08:09:43 +0000557
jardineb5d44e2003-12-23 08:09:43 +0000558 }
559
jardineb5d44e2003-12-23 08:09:43 +0000560 /* initializing PSNP timers */
hassof390d2c2004-09-10 20:48:21 +0000561 if (circuit->circuit_is_type & IS_LEVEL_1)
562 {
563 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
564 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
565 }
566
567 if (circuit->circuit_is_type & IS_LEVEL_2)
568 {
569 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
570 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
571 }
572
jardineb5d44e2003-12-23 08:09:43 +0000573 /* initialize the circuit streams */
574 if (circuit->rcv_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000575 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000576
577 if (circuit->snd_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000578 circuit->snd_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000579
580 /* unified init for circuits */
581 isis_sock_init (circuit);
582
583#ifdef GNU_LINUX
hassof390d2c2004-09-10 20:48:21 +0000584 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
585 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000586#else
hassof390d2c2004-09-10 20:48:21 +0000587 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
588 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000589#endif
590 return;
591}
592
593void
594isis_circuit_down (struct isis_circuit *circuit)
595{
hassof390d2c2004-09-10 20:48:21 +0000596 /* Cancel all active threads -- FIXME: wrong place */
hassod70f99e2004-02-11 20:26:31 +0000597 /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
hassof390d2c2004-09-10 20:48:21 +0000598 THREAD_OFF (circuit->t_read);
599 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
600 {
601 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
602 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
hassof891f442004-09-14 13:54:30 +0000603 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
604 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
hassof390d2c2004-09-10 20:48:21 +0000605 }
606 else if (circuit->circ_type == CIRCUIT_T_P2P)
607 {
608 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
609 }
Fritz Reichmann55749992011-09-14 19:31:51 +0400610
611 if (circuit->t_send_psnp[0]) {
612 THREAD_TIMER_OFF (circuit->t_send_psnp[0]);
613 }
614 if (circuit->t_send_psnp[1]) {
615 THREAD_TIMER_OFF (circuit->t_send_psnp[1]);
616 }
jardineb5d44e2003-12-23 08:09:43 +0000617 /* close the socket */
618 close (circuit->fd);
619
620 return;
621}
622
623void
624circuit_update_nlpids (struct isis_circuit *circuit)
625{
626 circuit->nlpids.count = 0;
hassof390d2c2004-09-10 20:48:21 +0000627
628 if (circuit->ip_router)
629 {
630 circuit->nlpids.nlpids[0] = NLPID_IP;
631 circuit->nlpids.count++;
632 }
jardineb5d44e2003-12-23 08:09:43 +0000633#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000634 if (circuit->ipv6_router)
635 {
636 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
637 circuit->nlpids.count++;
638 }
jardineb5d44e2003-12-23 08:09:43 +0000639#endif /* HAVE_IPV6 */
640 return;
641}
642
643int
hassof390d2c2004-09-10 20:48:21 +0000644isis_interface_config_write (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000645{
646
647 int write = 0;
hasso3fdb2dd2005-09-28 18:45:54 +0000648 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +0000649 struct interface *ifp;
650 struct isis_area *area;
651 struct isis_circuit *c;
jardineb5d44e2003-12-23 08:09:43 +0000652 int i;
jardineb5d44e2003-12-23 08:09:43 +0000653
hasso3fdb2dd2005-09-28 18:45:54 +0000654 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
jardineb5d44e2003-12-23 08:09:43 +0000655 {
656 /* IF name */
hassof390d2c2004-09-10 20:48:21 +0000657 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000658 write++;
659 /* IF desc */
hassof390d2c2004-09-10 20:48:21 +0000660 if (ifp->desc)
661 {
662 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
663 write++;
664 }
jardineb5d44e2003-12-23 08:09:43 +0000665 /* ISIS Circuit */
hasso3fdb2dd2005-09-28 18:45:54 +0000666 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
jardineb5d44e2003-12-23 08:09:43 +0000667 {
668 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000669 if (c)
670 {
671 if (c->ip_router)
672 {
673 vty_out (vty, " ip router isis %s%s", area->area_tag,
674 VTY_NEWLINE);
675 write++;
676 }
jardineb5d44e2003-12-23 08:09:43 +0000677#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000678 if (c->ipv6_router)
679 {
680 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
681 VTY_NEWLINE);
682 write++;
683 }
jardineb5d44e2003-12-23 08:09:43 +0000684#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000685
hassof390d2c2004-09-10 20:48:21 +0000686 /* ISIS - circuit type */
687 if (c->circuit_is_type == IS_LEVEL_1)
688 {
689 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
690 write++;
691 }
692 else
693 {
694 if (c->circuit_is_type == IS_LEVEL_2)
695 {
696 vty_out (vty, " isis circuit-type level-2-only%s",
697 VTY_NEWLINE);
698 write++;
699 }
700 }
jardineb5d44e2003-12-23 08:09:43 +0000701
hassof390d2c2004-09-10 20:48:21 +0000702 /* ISIS - CSNP interval - FIXME: compare to cisco */
703 if (c->csnp_interval[0] == c->csnp_interval[1])
704 {
705 if (c->csnp_interval[0] != CSNP_INTERVAL)
706 {
707 vty_out (vty, " isis csnp-interval %d%s",
708 c->csnp_interval[0], VTY_NEWLINE);
709 write++;
710 }
711 }
712 else
713 {
714 for (i = 0; i < 2; i++)
715 {
716 if (c->csnp_interval[1] != CSNP_INTERVAL)
717 {
718 vty_out (vty, " isis csnp-interval %d level-%d%s",
719 c->csnp_interval[1], i + 1, VTY_NEWLINE);
720 write++;
721 }
722 }
723 }
jardineb5d44e2003-12-23 08:09:43 +0000724
hassof390d2c2004-09-10 20:48:21 +0000725 /* ISIS - Hello padding - Defaults to true so only display if false */
726 if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
727 {
728 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
729 write++;
730 }
jardineb5d44e2003-12-23 08:09:43 +0000731
hassof390d2c2004-09-10 20:48:21 +0000732 /* ISIS - Hello interval - FIXME: compare to cisco */
733 if (c->hello_interval[0] == c->hello_interval[1])
734 {
735 if (c->hello_interval[0] != HELLO_INTERVAL)
736 {
737 vty_out (vty, " isis hello-interval %d%s",
738 c->hello_interval[0], VTY_NEWLINE);
739 write++;
740 }
741 }
742 else
743 {
744 for (i = 0; i < 2; i++)
745 {
746 if (c->hello_interval[i] != HELLO_INTERVAL)
747 {
748 if (c->hello_interval[i] == HELLO_MINIMAL)
749 {
750 vty_out (vty,
751 " isis hello-interval minimal level-%d%s",
752 i + 1, VTY_NEWLINE);
753 }
754 else
755 {
756 vty_out (vty, " isis hello-interval %d level-%d%s",
757 c->hello_interval[i], i + 1, VTY_NEWLINE);
758 }
759 write++;
760 }
761 }
762 }
jardineb5d44e2003-12-23 08:09:43 +0000763
hassof390d2c2004-09-10 20:48:21 +0000764 /* ISIS - Hello Multiplier */
765 if (c->hello_multiplier[0] == c->hello_multiplier[1])
766 {
767 if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
768 {
769 vty_out (vty, " isis hello-multiplier %d%s",
770 c->hello_multiplier[0], VTY_NEWLINE);
771 write++;
772 }
773 }
774 else
775 {
776 for (i = 0; i < 2; i++)
777 {
778 if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
779 {
780 vty_out (vty, " isis hello-multiplier %d level-%d%s",
781 c->hello_multiplier[i], i + 1, VTY_NEWLINE);
782 write++;
783 }
784 }
785 }
786 /* ISIS - Priority */
787 if (c->circ_type == CIRCUIT_T_BROADCAST)
788 {
789 if (c->u.bc.priority[0] == c->u.bc.priority[1])
790 {
791 if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
792 {
793 vty_out (vty, " isis priority %d%s",
794 c->u.bc.priority[0], VTY_NEWLINE);
795 write++;
796 }
797 }
798 else
799 {
800 for (i = 0; i < 2; i++)
801 {
802 if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
803 {
804 vty_out (vty, " isis priority %d level-%d%s",
805 c->u.bc.priority[i], i + 1, VTY_NEWLINE);
806 write++;
807 }
808 }
809 }
810 }
811 /* ISIS - Metric */
hassof21fb272005-09-26 17:05:55 +0000812 if (c->te_metric[0] == c->te_metric[1])
hassof390d2c2004-09-10 20:48:21 +0000813 {
hassof21fb272005-09-26 17:05:55 +0000814 if (c->te_metric[0] != DEFAULT_CIRCUIT_METRICS)
hassof390d2c2004-09-10 20:48:21 +0000815 {
hassof21fb272005-09-26 17:05:55 +0000816 vty_out (vty, " isis metric %d%s", c->te_metric[0],
817 VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +0000818 write++;
819 }
820 }
821 else
822 {
823 for (i = 0; i < 2; i++)
824 {
hassof21fb272005-09-26 17:05:55 +0000825 if (c->te_metric[i] != DEFAULT_CIRCUIT_METRICS)
hassof390d2c2004-09-10 20:48:21 +0000826 {
827 vty_out (vty, " isis metric %d level-%d%s",
hassof21fb272005-09-26 17:05:55 +0000828 c->te_metric[i], i + 1, VTY_NEWLINE);
hassof390d2c2004-09-10 20:48:21 +0000829 write++;
830 }
831 }
832 }
Fritz Reichmanne6b03b72011-10-01 17:49:48 +0400833 if (c->passwd.type==ISIS_PASSWD_TYPE_HMAC_MD5)
834 {
835 vty_out (vty, " isis password md5 %s%s", c->passwd.passwd,
836 VTY_NEWLINE);
837 write++;
838 }
839 else
840 {
841 if (c->passwd.type==ISIS_PASSWD_TYPE_CLEARTXT)
842 {
843 vty_out (vty, " isis password clear %s%s", c->passwd.passwd,
844 VTY_NEWLINE);
845 write++;
846 }
847 }
jardineb5d44e2003-12-23 08:09:43 +0000848
hassof390d2c2004-09-10 20:48:21 +0000849 }
jardineb5d44e2003-12-23 08:09:43 +0000850 }
hassof390d2c2004-09-10 20:48:21 +0000851 vty_out (vty, "!%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000852 }
hassof390d2c2004-09-10 20:48:21 +0000853
jardineb5d44e2003-12-23 08:09:43 +0000854 return write;
855}
jardineb5d44e2003-12-23 08:09:43 +0000856
857DEFUN (ip_router_isis,
858 ip_router_isis_cmd,
859 "ip router isis WORD",
860 "Interface Internet Protocol config commands\n"
861 "IP router interface commands\n"
862 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000863 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000864{
865 struct isis_circuit *c;
866 struct interface *ifp;
867 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000868
869 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000870 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000871
jardineb5d44e2003-12-23 08:09:43 +0000872 area = isis_area_lookup (argv[0]);
873
874 /* Prevent more than one circuit per interface */
875 if (area)
876 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000877 else
878 c = NULL;
879 if (c && (ifp->info != NULL))
880 {
jardineb5d44e2003-12-23 08:09:43 +0000881#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000882 if (c->ipv6_router == 0)
883 {
jardineb5d44e2003-12-23 08:09:43 +0000884#endif /* HAVE_IPV6 */
hassoc89c05d2005-09-04 21:36:36 +0000885 /* FIXME: Find the way to warn only vty users. */
886 /* vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE); */
hassof390d2c2004-09-10 20:48:21 +0000887 return CMD_WARNING;
jardineb5d44e2003-12-23 08:09:43 +0000888#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000889 }
890#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000891 }
hassof390d2c2004-09-10 20:48:21 +0000892
jardineb5d44e2003-12-23 08:09:43 +0000893 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +0000894 if (!area)
895 {
hassoc89c05d2005-09-04 21:36:36 +0000896 /* FIXME: Find the way to warn only vty users. */
897 /* vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); */
hassof390d2c2004-09-10 20:48:21 +0000898 return CMD_WARNING;
899 }
jardineb5d44e2003-12-23 08:09:43 +0000900
hassof390d2c2004-09-10 20:48:21 +0000901 if (!c)
902 {
903 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
904 c = isis_csm_state_change (ISIS_ENABLE, c, area);
905 c->interface = ifp; /* this is automatic */
906 ifp->info = c; /* hardly related to the FSM */
907 }
jardineb5d44e2003-12-23 08:09:43 +0000908
hassof390d2c2004-09-10 20:48:21 +0000909 if (!c)
jardineb5d44e2003-12-23 08:09:43 +0000910 return CMD_WARNING;
911
912 c->ip_router = 1;
913 area->ip_circuits++;
914 circuit_update_nlpids (c);
915
916 vty->node = INTERFACE_NODE;
hassof390d2c2004-09-10 20:48:21 +0000917
jardineb5d44e2003-12-23 08:09:43 +0000918 return CMD_SUCCESS;
919}
920
921DEFUN (no_ip_router_isis,
922 no_ip_router_isis_cmd,
923 "no ip router isis WORD",
924 NO_STR
925 "Interface Internet Protocol config commands\n"
926 "IP router interface commands\n"
927 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000928 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000929{
930 struct isis_circuit *circuit = NULL;
931 struct interface *ifp;
932 struct isis_area *area;
hasso3fdb2dd2005-09-28 18:45:54 +0000933 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000934
hassof390d2c2004-09-10 20:48:21 +0000935 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000936 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000937
jardineb5d44e2003-12-23 08:09:43 +0000938 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +0000939 if (!area)
940 {
941 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
942 return CMD_WARNING;
943 }
hasso3fdb2dd2005-09-28 18:45:54 +0000944 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
jardineb5d44e2003-12-23 08:09:43 +0000945 if (circuit->interface == ifp)
946 break;
hassof390d2c2004-09-10 20:48:21 +0000947 if (!circuit)
948 {
949 vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
950 return CMD_WARNING;
951 }
jardineb5d44e2003-12-23 08:09:43 +0000952 circuit->ip_router = 0;
953 area->ip_circuits--;
954#ifdef HAVE_IPV6
955 if (circuit->ipv6_router == 0)
956#endif
957 isis_csm_state_change (ISIS_DISABLE, circuit, area);
hassof390d2c2004-09-10 20:48:21 +0000958
jardineb5d44e2003-12-23 08:09:43 +0000959 return CMD_SUCCESS;
960}
961
962DEFUN (isis_circuit_type,
963 isis_circuit_type_cmd,
964 "isis circuit-type (level-1|level-1-2|level-2-only)",
965 "IS-IS commands\n"
966 "Configure circuit type for interface\n"
967 "Level-1 only adjacencies are formed\n"
968 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000969 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000970{
971 struct isis_circuit *circuit;
972 struct interface *ifp;
973 int circuit_t;
974 int is_type;
hassof390d2c2004-09-10 20:48:21 +0000975
976 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000977 circuit = ifp->info;
978 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +0000979 if (circuit == NULL)
980 {
981 return CMD_WARNING;
982 }
jardineb5d44e2003-12-23 08:09:43 +0000983
hasso13c48f72004-09-10 21:19:13 +0000984 /* XXX what to do when ip_router_isis is not executed */
985 if (circuit->area == NULL)
986 return CMD_WARNING;
987
jardineb5d44e2003-12-23 08:09:43 +0000988 assert (circuit);
989
Paul Jakma41b36e92006-12-08 01:09:50 +0000990 circuit_t = string2circuit_t (argv[0]);
jardineb5d44e2003-12-23 08:09:43 +0000991
hassof390d2c2004-09-10 20:48:21 +0000992 if (!circuit_t)
993 {
994 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
995 return CMD_SUCCESS;
996 }
997
jardineb5d44e2003-12-23 08:09:43 +0000998 is_type = circuit->area->is_type;
999 if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
hassof390d2c2004-09-10 20:48:21 +00001000 isis_event_circuit_type_change (circuit, circuit_t);
1001 else
1002 {
1003 vty_out (vty, "invalid circuit level for area %s.%s",
1004 circuit->area->area_tag, VTY_NEWLINE);
1005 }
1006
jardineb5d44e2003-12-23 08:09:43 +00001007 return CMD_SUCCESS;
1008}
1009
1010DEFUN (no_isis_circuit_type,
1011 no_isis_circuit_type_cmd,
1012 "no isis circuit-type (level-1|level-1-2|level-2-only)",
1013 NO_STR
1014 "IS-IS commands\n"
1015 "Configure circuit type for interface\n"
1016 "Level-1 only adjacencies are formed\n"
1017 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +00001018 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +00001019{
1020 struct isis_circuit *circuit;
1021 struct interface *ifp;
jardineb5d44e2003-12-23 08:09:43 +00001022
hassof390d2c2004-09-10 20:48:21 +00001023 ifp = vty->index;
1024 circuit = ifp->info;
1025 if (circuit == NULL)
1026 {
1027 return CMD_WARNING;
1028 }
1029
1030 assert (circuit);
1031
jardineb5d44e2003-12-23 08:09:43 +00001032 /*
1033 * Set the circuits level to its default value which is that of the area
1034 */
1035 isis_event_circuit_type_change (circuit, circuit->area->is_type);
hassof390d2c2004-09-10 20:48:21 +00001036
jardineb5d44e2003-12-23 08:09:43 +00001037 return CMD_SUCCESS;
1038}
1039
Fritz Reichmanne6b03b72011-10-01 17:49:48 +04001040DEFUN (isis_passwd_md5,
1041 isis_passwd_md5_cmd,
1042 "isis password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001043 "IS-IS commands\n"
1044 "Configure the authentication password for interface\n"
Fritz Reichmanne6b03b72011-10-01 17:49:48 +04001045 "Authentication Type\n"
1046 "Password\n")
1047{
1048 struct isis_circuit *circuit;
1049 struct interface *ifp;
1050 int len;
1051
1052 ifp = vty->index;
1053 circuit = ifp->info;
1054 if (circuit == NULL)
1055 {
1056 return CMD_WARNING;
1057 }
1058
1059 len = strlen (argv[0]);
1060 if (len > 254)
1061 {
1062 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1063 return CMD_WARNING;
1064 }
1065 circuit->passwd.len = len;
1066 circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1067 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
1068
1069 return CMD_SUCCESS;
1070}
1071
1072DEFUN (isis_passwd_clear,
1073 isis_passwd_clear_cmd,
1074 "isis password clear WORD",
1075 "IS-IS commands\n"
1076 "Configure the authentication password for interface\n"
1077 "Authentication Type\n"
jardineb5d44e2003-12-23 08:09:43 +00001078 "Password\n")
1079{
1080 struct isis_circuit *circuit;
1081 struct interface *ifp;
1082 int len;
hassof390d2c2004-09-10 20:48:21 +00001083
1084 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001085 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001086 if (circuit == NULL)
1087 {
1088 return CMD_WARNING;
1089 }
1090
jardineb5d44e2003-12-23 08:09:43 +00001091 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001092 if (len > 254)
1093 {
1094 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1095 return CMD_WARNING;
1096 }
jardineb5d44e2003-12-23 08:09:43 +00001097 circuit->passwd.len = len;
1098 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001099 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001100
jardineb5d44e2003-12-23 08:09:43 +00001101 return CMD_SUCCESS;
1102}
1103
1104DEFUN (no_isis_passwd,
1105 no_isis_passwd_cmd,
1106 "no isis password",
1107 NO_STR
1108 "IS-IS commands\n"
1109 "Configure the authentication password for interface\n")
1110{
1111 struct isis_circuit *circuit;
1112 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001113
1114 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001115 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001116 if (circuit == NULL)
1117 {
1118 return CMD_WARNING;
1119 }
1120
jardineb5d44e2003-12-23 08:09:43 +00001121 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
hassof390d2c2004-09-10 20:48:21 +00001122
jardineb5d44e2003-12-23 08:09:43 +00001123 return CMD_SUCCESS;
1124}
1125
jardineb5d44e2003-12-23 08:09:43 +00001126DEFUN (isis_priority,
1127 isis_priority_cmd,
1128 "isis priority <0-127>",
1129 "IS-IS commands\n"
1130 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001131 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001132{
1133 struct isis_circuit *circuit;
1134 struct interface *ifp;
1135 int prio;
hassof390d2c2004-09-10 20:48:21 +00001136
1137 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001138 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001139 if (circuit == NULL)
1140 {
1141 return CMD_WARNING;
1142 }
jardineb5d44e2003-12-23 08:09:43 +00001143 assert (circuit);
1144
1145 prio = atoi (argv[0]);
1146
1147 circuit->u.bc.priority[0] = prio;
1148 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001149
jardineb5d44e2003-12-23 08:09:43 +00001150 return CMD_SUCCESS;
1151}
1152
1153DEFUN (no_isis_priority,
1154 no_isis_priority_cmd,
1155 "no isis priority",
1156 NO_STR
1157 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001158 "Set priority for Designated Router election\n")
jardineb5d44e2003-12-23 08:09:43 +00001159{
1160 struct isis_circuit *circuit;
1161 struct interface *ifp;
1162
hassof390d2c2004-09-10 20:48:21 +00001163 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001164 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001165 if (circuit == NULL)
1166 {
1167 return CMD_WARNING;
1168 }
jardineb5d44e2003-12-23 08:09:43 +00001169 assert (circuit);
1170
1171 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
1172 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001173
jardineb5d44e2003-12-23 08:09:43 +00001174 return CMD_SUCCESS;
1175}
1176
1177ALIAS (no_isis_priority,
1178 no_isis_priority_arg_cmd,
1179 "no isis priority <0-127>",
1180 NO_STR
1181 "IS-IS commands\n"
1182 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001183 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001184
1185DEFUN (isis_priority_l1,
1186 isis_priority_l1_cmd,
hassof390d2c2004-09-10 20:48:21 +00001187 "isis priority <0-127> level-1",
jardineb5d44e2003-12-23 08:09:43 +00001188 "IS-IS commands\n"
1189 "Set priority for Designated Router election\n"
1190 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001191 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001192{
1193 struct isis_circuit *circuit;
1194 struct interface *ifp;
1195 int prio;
hassof390d2c2004-09-10 20:48:21 +00001196
1197 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001198 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001199 if (circuit == NULL)
1200 {
1201 return CMD_WARNING;
1202 }
jardineb5d44e2003-12-23 08:09:43 +00001203 assert (circuit);
1204
1205 prio = atoi (argv[0]);
1206
1207 circuit->u.bc.priority[0] = prio;
hassof390d2c2004-09-10 20:48:21 +00001208
jardineb5d44e2003-12-23 08:09:43 +00001209 return CMD_SUCCESS;
1210}
1211
1212DEFUN (no_isis_priority_l1,
1213 no_isis_priority_l1_cmd,
1214 "no isis priority level-1",
1215 NO_STR
1216 "IS-IS commands\n"
1217 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001218 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001219{
1220 struct isis_circuit *circuit;
1221 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001222
1223 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001224 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001225 if (circuit == NULL)
1226 {
1227 return CMD_WARNING;
1228 }
jardineb5d44e2003-12-23 08:09:43 +00001229 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001230
jardineb5d44e2003-12-23 08:09:43 +00001231 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001232
jardineb5d44e2003-12-23 08:09:43 +00001233 return CMD_SUCCESS;
1234}
1235
1236ALIAS (no_isis_priority_l1,
1237 no_isis_priority_l1_arg_cmd,
1238 "no isis priority <0-127> level-1",
1239 NO_STR
1240 "IS-IS commands\n"
1241 "Set priority for Designated Router election\n"
1242 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001243 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001244
1245DEFUN (isis_priority_l2,
1246 isis_priority_l2_cmd,
hassof390d2c2004-09-10 20:48:21 +00001247 "isis priority <0-127> level-2",
jardineb5d44e2003-12-23 08:09:43 +00001248 "IS-IS commands\n"
1249 "Set priority for Designated Router election\n"
1250 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001251 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001252{
1253 struct isis_circuit *circuit;
1254 struct interface *ifp;
1255 int prio;
hassof390d2c2004-09-10 20:48:21 +00001256
1257 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001258 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001259 if (circuit == NULL)
1260 {
1261 return CMD_WARNING;
1262 }
jardineb5d44e2003-12-23 08:09:43 +00001263 assert (circuit);
1264
1265 prio = atoi (argv[0]);
1266
1267 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001268
jardineb5d44e2003-12-23 08:09:43 +00001269 return CMD_SUCCESS;
1270}
1271
1272DEFUN (no_isis_priority_l2,
1273 no_isis_priority_l2_cmd,
1274 "no isis priority level-2",
1275 NO_STR
1276 "IS-IS commands\n"
1277 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001278 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001279{
1280 struct isis_circuit *circuit;
1281 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001282
1283 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001284 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001285 if (circuit == NULL)
1286 {
1287 return CMD_WARNING;
1288 }
jardineb5d44e2003-12-23 08:09:43 +00001289 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001290
jardineb5d44e2003-12-23 08:09:43 +00001291 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001292
jardineb5d44e2003-12-23 08:09:43 +00001293 return CMD_SUCCESS;
1294}
1295
1296ALIAS (no_isis_priority_l2,
1297 no_isis_priority_l2_arg_cmd,
1298 "no isis priority <0-127> level-2",
1299 NO_STR
1300 "IS-IS commands\n"
1301 "Set priority for Designated Router election\n"
1302 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001303 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001304
1305/* Metric command */
hassof390d2c2004-09-10 20:48:21 +00001306 DEFUN (isis_metric,
jardineb5d44e2003-12-23 08:09:43 +00001307 isis_metric_cmd,
hassof21fb272005-09-26 17:05:55 +00001308 "isis metric <0-16777215>",
jardineb5d44e2003-12-23 08:09:43 +00001309 "IS-IS commands\n"
1310 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001311 "Default metric value\n")
jardineb5d44e2003-12-23 08:09:43 +00001312{
1313 struct isis_circuit *circuit;
1314 struct interface *ifp;
1315 int met;
1316
hassof390d2c2004-09-10 20:48:21 +00001317 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001318 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001319 if (circuit == NULL)
1320 {
1321 return CMD_WARNING;
1322 }
jardineb5d44e2003-12-23 08:09:43 +00001323 assert (circuit);
1324
1325 met = atoi (argv[0]);
1326
hassof21fb272005-09-26 17:05:55 +00001327 circuit->te_metric[0] = met;
1328 circuit->te_metric[1] = met;
1329
1330 if (met > 63)
1331 met = 63;
1332
jardineb5d44e2003-12-23 08:09:43 +00001333 circuit->metrics[0].metric_default = met;
1334 circuit->metrics[1].metric_default = met;
1335
1336 return CMD_SUCCESS;
1337}
1338
1339DEFUN (no_isis_metric,
1340 no_isis_metric_cmd,
1341 "no isis metric",
1342 NO_STR
1343 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001344 "Set default metric for circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001345{
1346 struct isis_circuit *circuit;
1347 struct interface *ifp;
1348
hassof390d2c2004-09-10 20:48:21 +00001349 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001350 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001351 if (circuit == NULL)
1352 {
1353 return CMD_WARNING;
1354 }
jardineb5d44e2003-12-23 08:09:43 +00001355 assert (circuit);
1356
hassof21fb272005-09-26 17:05:55 +00001357 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRICS;
1358 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRICS;
jardineb5d44e2003-12-23 08:09:43 +00001359 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
1360 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS;
1361
1362 return CMD_SUCCESS;
1363}
1364
1365ALIAS (no_isis_metric,
1366 no_isis_metric_arg_cmd,
hassof21fb272005-09-26 17:05:55 +00001367 "no isis metric <0-16777215>",
jardineb5d44e2003-12-23 08:09:43 +00001368 NO_STR
1369 "IS-IS commands\n"
1370 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001371 "Default metric value\n")
1372
jardineb5d44e2003-12-23 08:09:43 +00001373/* end of metrics */
hassof21fb272005-09-26 17:05:55 +00001374DEFUN (isis_hello_interval,
jardineb5d44e2003-12-23 08:09:43 +00001375 isis_hello_interval_cmd,
1376 "isis hello-interval (<1-65535>|minimal)",
1377 "IS-IS commands\n"
1378 "Set Hello interval\n"
1379 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001380 "Holdtime 1 seconds, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001381{
1382 struct isis_circuit *circuit;
1383 struct interface *ifp;
1384 int interval;
1385 char c;
1386
hassof390d2c2004-09-10 20:48:21 +00001387 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001388 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001389 if (circuit == NULL)
1390 {
1391 return CMD_WARNING;
1392 }
1393 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001394 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001395 if (isdigit ((int) c))
1396 {
1397 interval = atoi (argv[0]);
1398 }
1399 else
1400 interval = HELLO_MINIMAL; /* FIXME: should be calculated */
jardineb5d44e2003-12-23 08:09:43 +00001401
hassof390d2c2004-09-10 20:48:21 +00001402 circuit->hello_interval[0] = (u_int16_t) interval;
1403 circuit->hello_interval[1] = (u_int16_t) interval;
1404
jardineb5d44e2003-12-23 08:09:43 +00001405 return CMD_SUCCESS;
1406}
1407
1408DEFUN (no_isis_hello_interval,
1409 no_isis_hello_interval_cmd,
1410 "no isis hello-interval",
1411 NO_STR
1412 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001413 "Set Hello interval\n")
jardineb5d44e2003-12-23 08:09:43 +00001414{
1415 struct isis_circuit *circuit;
1416 struct interface *ifp;
1417
hassof390d2c2004-09-10 20:48:21 +00001418 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001419 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001420 if (circuit == NULL)
1421 {
1422 return CMD_WARNING;
1423 }
jardineb5d44e2003-12-23 08:09:43 +00001424 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001425
hassof390d2c2004-09-10 20:48:21 +00001426
1427 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
jardineb5d44e2003-12-23 08:09:43 +00001428 circuit->hello_interval[1] = HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001429
jardineb5d44e2003-12-23 08:09:43 +00001430 return CMD_SUCCESS;
1431}
1432
1433ALIAS (no_isis_hello_interval,
1434 no_isis_hello_interval_arg_cmd,
1435 "no isis hello-interval (<1-65535>|minimal)",
1436 NO_STR
1437 "IS-IS commands\n"
1438 "Set Hello interval\n"
1439 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001440 "Holdtime 1 second, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001441
1442DEFUN (isis_hello_interval_l1,
1443 isis_hello_interval_l1_cmd,
1444 "isis hello-interval (<1-65535>|minimal) level-1",
1445 "IS-IS commands\n"
1446 "Set Hello interval\n"
1447 "Hello interval value\n"
1448 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001449 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001450{
1451 struct isis_circuit *circuit;
1452 struct interface *ifp;
1453 long interval;
1454 char c;
1455
hassof390d2c2004-09-10 20:48:21 +00001456 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001457 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001458 if (circuit == NULL)
1459 {
1460 return CMD_WARNING;
1461 }
jardineb5d44e2003-12-23 08:09:43 +00001462 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001463
jardineb5d44e2003-12-23 08:09:43 +00001464 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001465 if (isdigit ((int) c))
1466 {
1467 interval = atoi (argv[0]);
1468 }
1469 else
jardineb5d44e2003-12-23 08:09:43 +00001470 interval = HELLO_MINIMAL;
1471
hassof390d2c2004-09-10 20:48:21 +00001472 circuit->hello_interval[0] = (u_int16_t) interval;
1473
jardineb5d44e2003-12-23 08:09:43 +00001474 return CMD_SUCCESS;
1475}
1476
1477DEFUN (no_isis_hello_interval_l1,
1478 no_isis_hello_interval_l1_cmd,
1479 "no isis hello-interval level-1",
1480 NO_STR
1481 "IS-IS commands\n"
1482 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001483 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001484{
1485 struct isis_circuit *circuit;
1486 struct interface *ifp;
1487
hassof390d2c2004-09-10 20:48:21 +00001488 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001489 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001490 if (circuit == NULL)
1491 {
1492 return CMD_WARNING;
1493 }
jardineb5d44e2003-12-23 08:09:43 +00001494 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001495
hassof390d2c2004-09-10 20:48:21 +00001496
1497 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
1498
jardineb5d44e2003-12-23 08:09:43 +00001499 return CMD_SUCCESS;
1500}
1501
1502ALIAS (no_isis_hello_interval_l1,
1503 no_isis_hello_interval_l1_arg_cmd,
1504 "no isis hello-interval (<1-65535>|minimal) level-1",
1505 NO_STR
1506 "IS-IS commands\n"
1507 "Set Hello interval\n"
1508 "Hello interval value\n"
1509 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001510 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001511
1512DEFUN (isis_hello_interval_l2,
1513 isis_hello_interval_l2_cmd,
1514 "isis hello-interval (<1-65535>|minimal) level-2",
1515 "IS-IS commands\n"
1516 "Set Hello interval\n"
1517 "Hello interval value\n"
1518 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001519 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001520{
1521 struct isis_circuit *circuit;
1522 struct interface *ifp;
1523 long interval;
1524 char c;
1525
hassof390d2c2004-09-10 20:48:21 +00001526 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001527 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001528 if (circuit == NULL)
1529 {
1530 return CMD_WARNING;
1531 }
jardineb5d44e2003-12-23 08:09:43 +00001532 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001533
jardineb5d44e2003-12-23 08:09:43 +00001534 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001535 if (isdigit ((int) c))
1536 {
1537 interval = atoi (argv[0]);
1538 }
1539 else
jardineb5d44e2003-12-23 08:09:43 +00001540 interval = HELLO_MINIMAL;
1541
hassof390d2c2004-09-10 20:48:21 +00001542 circuit->hello_interval[1] = (u_int16_t) interval;
1543
jardineb5d44e2003-12-23 08:09:43 +00001544 return CMD_SUCCESS;
1545}
1546
1547DEFUN (no_isis_hello_interval_l2,
1548 no_isis_hello_interval_l2_cmd,
1549 "no isis hello-interval level-2",
1550 NO_STR
1551 "IS-IS commands\n"
1552 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001553 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001554{
1555 struct isis_circuit *circuit;
1556 struct interface *ifp;
1557
hassof390d2c2004-09-10 20:48:21 +00001558 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001559 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001560 if (circuit == NULL)
1561 {
1562 return CMD_WARNING;
1563 }
jardineb5d44e2003-12-23 08:09:43 +00001564 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001565
hassof390d2c2004-09-10 20:48:21 +00001566
1567 circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
1568
jardineb5d44e2003-12-23 08:09:43 +00001569 return CMD_SUCCESS;
1570}
1571
1572ALIAS (no_isis_hello_interval_l2,
1573 no_isis_hello_interval_l2_arg_cmd,
1574 "no isis hello-interval (<1-65535>|minimal) level-2",
1575 NO_STR
1576 "IS-IS commands\n"
1577 "Set Hello interval\n"
1578 "Hello interval value\n"
1579 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001580 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001581
1582DEFUN (isis_hello_multiplier,
1583 isis_hello_multiplier_cmd,
1584 "isis hello-multiplier <3-1000>",
1585 "IS-IS commands\n"
1586 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001587 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001588{
1589 struct isis_circuit *circuit;
1590 struct interface *ifp;
1591 int mult;
hassof390d2c2004-09-10 20:48:21 +00001592
1593 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001594 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001595 if (circuit == NULL)
1596 {
1597 return CMD_WARNING;
1598 }
jardineb5d44e2003-12-23 08:09:43 +00001599 assert (circuit);
1600
1601 mult = atoi (argv[0]);
1602
hassof390d2c2004-09-10 20:48:21 +00001603 circuit->hello_multiplier[0] = (u_int16_t) mult;
1604 circuit->hello_multiplier[1] = (u_int16_t) mult;
1605
jardineb5d44e2003-12-23 08:09:43 +00001606 return CMD_SUCCESS;
1607}
1608
1609DEFUN (no_isis_hello_multiplier,
1610 no_isis_hello_multiplier_cmd,
1611 "no isis hello-multiplier",
1612 NO_STR
1613 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001614 "Set multiplier for Hello holding time\n")
jardineb5d44e2003-12-23 08:09:43 +00001615{
1616 struct isis_circuit *circuit;
1617 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001618
1619 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001620 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001621 if (circuit == NULL)
1622 {
1623 return CMD_WARNING;
1624 }
jardineb5d44e2003-12-23 08:09:43 +00001625 assert (circuit);
1626
1627 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1628 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1629
1630 return CMD_SUCCESS;
1631}
1632
1633ALIAS (no_isis_hello_multiplier,
1634 no_isis_hello_multiplier_arg_cmd,
1635 "no isis hello-multiplier <3-1000>",
1636 NO_STR
1637 "IS-IS commands\n"
1638 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001639 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001640
1641DEFUN (isis_hello_multiplier_l1,
1642 isis_hello_multiplier_l1_cmd,
1643 "isis hello-multiplier <3-1000> level-1",
1644 "IS-IS commands\n"
1645 "Set multiplier for Hello holding time\n"
1646 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001647 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001648{
1649 struct isis_circuit *circuit;
1650 struct interface *ifp;
1651 int mult;
hassof390d2c2004-09-10 20:48:21 +00001652
1653 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001654 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001655 if (circuit == NULL)
1656 {
1657 return CMD_WARNING;
1658 }
jardineb5d44e2003-12-23 08:09:43 +00001659 assert (circuit);
1660
1661 mult = atoi (argv[0]);
1662
hassof390d2c2004-09-10 20:48:21 +00001663 circuit->hello_multiplier[0] = (u_int16_t) mult;
1664
jardineb5d44e2003-12-23 08:09:43 +00001665 return CMD_SUCCESS;
1666}
1667
1668DEFUN (no_isis_hello_multiplier_l1,
1669 no_isis_hello_multiplier_l1_cmd,
1670 "no isis hello-multiplier level-1",
1671 NO_STR
1672 "IS-IS commands\n"
1673 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001674 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001675{
1676 struct isis_circuit *circuit;
1677 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001678
1679 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001680 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001681 if (circuit == NULL)
1682 {
1683 return CMD_WARNING;
1684 }
jardineb5d44e2003-12-23 08:09:43 +00001685 assert (circuit);
1686
1687 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1688
1689 return CMD_SUCCESS;
1690}
1691
1692ALIAS (no_isis_hello_multiplier_l1,
1693 no_isis_hello_multiplier_l1_arg_cmd,
1694 "no isis hello-multiplier <3-1000> level-1",
1695 NO_STR
1696 "IS-IS commands\n"
1697 "Set multiplier for Hello holding time\n"
1698 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001699 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001700
1701DEFUN (isis_hello_multiplier_l2,
1702 isis_hello_multiplier_l2_cmd,
1703 "isis hello-multiplier <3-1000> level-2",
1704 "IS-IS commands\n"
1705 "Set multiplier for Hello holding time\n"
1706 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001707 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001708{
1709 struct isis_circuit *circuit;
1710 struct interface *ifp;
1711 int mult;
hassof390d2c2004-09-10 20:48:21 +00001712
1713 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001714 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001715 if (circuit == NULL)
1716 {
1717 return CMD_WARNING;
1718 }
jardineb5d44e2003-12-23 08:09:43 +00001719 assert (circuit);
1720
1721 mult = atoi (argv[0]);
1722
hassof390d2c2004-09-10 20:48:21 +00001723 circuit->hello_multiplier[1] = (u_int16_t) mult;
1724
jardineb5d44e2003-12-23 08:09:43 +00001725 return CMD_SUCCESS;
1726}
1727
1728DEFUN (no_isis_hello_multiplier_l2,
1729 no_isis_hello_multiplier_l2_cmd,
1730 "no isis hello-multiplier level-2",
1731 NO_STR
1732 "IS-IS commands\n"
1733 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001734 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001735{
1736 struct isis_circuit *circuit;
1737 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001738
1739 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001740 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001741 if (circuit == NULL)
1742 {
1743 return CMD_WARNING;
1744 }
jardineb5d44e2003-12-23 08:09:43 +00001745 assert (circuit);
1746
1747 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1748
1749 return CMD_SUCCESS;
1750}
1751
1752ALIAS (no_isis_hello_multiplier_l2,
1753 no_isis_hello_multiplier_l2_arg_cmd,
1754 "no isis hello-multiplier <3-1000> level-2",
1755 NO_STR
1756 "IS-IS commands\n"
1757 "Set multiplier for Hello holding time\n"
1758 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001759 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001760
1761DEFUN (isis_hello,
1762 isis_hello_cmd,
1763 "isis hello padding",
1764 "IS-IS commands\n"
1765 "Add padding to IS-IS hello packets\n"
1766 "Pad hello packets\n"
1767 "<cr>\n")
1768{
1769 struct interface *ifp;
1770 struct isis_circuit *circuit;
hassof390d2c2004-09-10 20:48:21 +00001771
1772 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001773 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001774 if (circuit == NULL)
1775 {
1776 return CMD_WARNING;
1777 }
jardineb5d44e2003-12-23 08:09:43 +00001778 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001779
jardineb5d44e2003-12-23 08:09:43 +00001780 circuit->u.bc.pad_hellos = 1;
hassof390d2c2004-09-10 20:48:21 +00001781
jardineb5d44e2003-12-23 08:09:43 +00001782 return CMD_SUCCESS;
1783}
1784
jardineb5d44e2003-12-23 08:09:43 +00001785DEFUN (no_isis_hello,
1786 no_isis_hello_cmd,
1787 "no isis hello padding",
1788 NO_STR
1789 "IS-IS commands\n"
1790 "Add padding to IS-IS hello packets\n"
1791 "Pad hello packets\n"
1792 "<cr>\n")
1793{
1794 struct isis_circuit *circuit;
1795 struct interface *ifp;
1796
hassof390d2c2004-09-10 20:48:21 +00001797 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001798 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001799 if (circuit == NULL)
1800 {
1801 return CMD_WARNING;
1802 }
jardineb5d44e2003-12-23 08:09:43 +00001803 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001804
jardineb5d44e2003-12-23 08:09:43 +00001805 circuit->u.bc.pad_hellos = 0;
hassof390d2c2004-09-10 20:48:21 +00001806
jardineb5d44e2003-12-23 08:09:43 +00001807 return CMD_SUCCESS;
1808}
1809
1810DEFUN (csnp_interval,
1811 csnp_interval_cmd,
1812 "isis csnp-interval <0-65535>",
1813 "IS-IS commands\n"
1814 "Set CSNP interval in seconds\n"
1815 "CSNP interval value\n")
1816{
1817 struct isis_circuit *circuit;
1818 struct interface *ifp;
1819 unsigned long interval;
1820
hassof390d2c2004-09-10 20:48:21 +00001821 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001822 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001823 if (circuit == NULL)
1824 {
1825 return CMD_WARNING;
1826 }
jardineb5d44e2003-12-23 08:09:43 +00001827 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001828
jardineb5d44e2003-12-23 08:09:43 +00001829 interval = atol (argv[0]);
1830
hassof390d2c2004-09-10 20:48:21 +00001831 circuit->csnp_interval[0] = (u_int16_t) interval;
1832 circuit->csnp_interval[1] = (u_int16_t) interval;
1833
jardineb5d44e2003-12-23 08:09:43 +00001834 return CMD_SUCCESS;
1835}
1836
1837DEFUN (no_csnp_interval,
1838 no_csnp_interval_cmd,
1839 "no isis csnp-interval",
1840 NO_STR
1841 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001842 "Set CSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001843{
1844 struct isis_circuit *circuit;
1845 struct interface *ifp;
1846
hassof390d2c2004-09-10 20:48:21 +00001847 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001848 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001849 if (circuit == NULL)
1850 {
1851 return CMD_WARNING;
1852 }
jardineb5d44e2003-12-23 08:09:43 +00001853 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001854
jardineb5d44e2003-12-23 08:09:43 +00001855 circuit->csnp_interval[0] = CSNP_INTERVAL;
1856 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001857
jardineb5d44e2003-12-23 08:09:43 +00001858 return CMD_SUCCESS;
1859}
1860
1861ALIAS (no_csnp_interval,
1862 no_csnp_interval_arg_cmd,
1863 "no isis csnp-interval <0-65535>",
1864 NO_STR
1865 "IS-IS commands\n"
1866 "Set CSNP interval in seconds\n"
1867 "CSNP interval value\n")
1868
jardineb5d44e2003-12-23 08:09:43 +00001869DEFUN (csnp_interval_l1,
1870 csnp_interval_l1_cmd,
1871 "isis csnp-interval <0-65535> level-1",
1872 "IS-IS commands\n"
1873 "Set CSNP interval in seconds\n"
1874 "CSNP interval value\n"
1875 "Specify interval for level-1 CSNPs\n")
1876{
1877 struct isis_circuit *circuit;
1878 struct interface *ifp;
1879 unsigned long interval;
1880
hassof390d2c2004-09-10 20:48:21 +00001881 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001882 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001883 if (circuit == NULL)
1884 {
1885 return CMD_WARNING;
1886 }
jardineb5d44e2003-12-23 08:09:43 +00001887 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001888
jardineb5d44e2003-12-23 08:09:43 +00001889 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001890
1891 circuit->csnp_interval[0] = (u_int16_t) interval;
1892
jardineb5d44e2003-12-23 08:09:43 +00001893 return CMD_SUCCESS;
1894}
1895
1896DEFUN (no_csnp_interval_l1,
1897 no_csnp_interval_l1_cmd,
1898 "no isis csnp-interval level-1",
1899 NO_STR
1900 "IS-IS commands\n"
1901 "Set CSNP interval in seconds\n"
1902 "Specify interval for level-1 CSNPs\n")
1903{
1904 struct isis_circuit *circuit;
1905 struct interface *ifp;
1906
hassof390d2c2004-09-10 20:48:21 +00001907 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001908 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001909 if (circuit == NULL)
1910 {
1911 return CMD_WARNING;
1912 }
jardineb5d44e2003-12-23 08:09:43 +00001913 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001914
jardineb5d44e2003-12-23 08:09:43 +00001915 circuit->csnp_interval[0] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001916
jardineb5d44e2003-12-23 08:09:43 +00001917 return CMD_SUCCESS;
1918}
1919
1920ALIAS (no_csnp_interval_l1,
1921 no_csnp_interval_l1_arg_cmd,
1922 "no isis csnp-interval <0-65535> level-1",
1923 NO_STR
1924 "IS-IS commands\n"
1925 "Set CSNP interval in seconds\n"
1926 "CSNP interval value\n"
1927 "Specify interval for level-1 CSNPs\n")
1928
jardineb5d44e2003-12-23 08:09:43 +00001929DEFUN (csnp_interval_l2,
1930 csnp_interval_l2_cmd,
1931 "isis csnp-interval <0-65535> level-2",
1932 "IS-IS commands\n"
1933 "Set CSNP interval in seconds\n"
1934 "CSNP interval value\n"
1935 "Specify interval for level-2 CSNPs\n")
1936{
1937 struct isis_circuit *circuit;
1938 struct interface *ifp;
1939 unsigned long interval;
1940
hassof390d2c2004-09-10 20:48:21 +00001941 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001942 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001943 if (circuit == NULL)
1944 {
1945 return CMD_WARNING;
1946 }
jardineb5d44e2003-12-23 08:09:43 +00001947 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001948
jardineb5d44e2003-12-23 08:09:43 +00001949 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001950
1951 circuit->csnp_interval[1] = (u_int16_t) interval;
1952
jardineb5d44e2003-12-23 08:09:43 +00001953 return CMD_SUCCESS;
1954}
1955
1956DEFUN (no_csnp_interval_l2,
1957 no_csnp_interval_l2_cmd,
1958 "no isis csnp-interval level-2",
1959 NO_STR
1960 "IS-IS commands\n"
1961 "Set CSNP interval in seconds\n"
1962 "Specify interval for level-2 CSNPs\n")
1963{
1964 struct isis_circuit *circuit;
1965 struct interface *ifp;
1966
hassof390d2c2004-09-10 20:48:21 +00001967 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001968 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001969 if (circuit == NULL)
1970 {
1971 return CMD_WARNING;
1972 }
jardineb5d44e2003-12-23 08:09:43 +00001973 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001974
jardineb5d44e2003-12-23 08:09:43 +00001975 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001976
jardineb5d44e2003-12-23 08:09:43 +00001977 return CMD_SUCCESS;
1978}
1979
1980ALIAS (no_csnp_interval_l2,
1981 no_csnp_interval_l2_arg_cmd,
1982 "no isis csnp-interval <0-65535> level-2",
1983 NO_STR
1984 "IS-IS commands\n"
1985 "Set CSNP interval in seconds\n"
1986 "CSNP interval value\n"
1987 "Specify interval for level-2 CSNPs\n")
1988
jardineb5d44e2003-12-23 08:09:43 +00001989#ifdef HAVE_IPV6
1990DEFUN (ipv6_router_isis,
1991 ipv6_router_isis_cmd,
1992 "ipv6 router isis WORD",
1993 "IPv6 interface subcommands\n"
1994 "IPv6 Router interface commands\n"
1995 "IS-IS Routing for IPv6\n"
1996 "Routing process tag\n")
1997{
1998 struct isis_circuit *c;
1999 struct interface *ifp;
2000 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002001
2002 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002003 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002004
jardineb5d44e2003-12-23 08:09:43 +00002005 area = isis_area_lookup (argv[0]);
2006
2007 /* Prevent more than one circuit per interface */
2008 if (area)
2009 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +00002010 else
2011 c = NULL;
2012
2013 if (c && (ifp->info != NULL))
2014 {
2015 if (c->ipv6_router == 1)
2016 {
2017 vty_out (vty, "ISIS circuit is already defined for IPv6%s",
2018 VTY_NEWLINE);
2019 return CMD_WARNING;
2020 }
jardineb5d44e2003-12-23 08:09:43 +00002021 }
jardineb5d44e2003-12-23 08:09:43 +00002022
2023 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +00002024 if (!area)
2025 {
2026 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2027 return CMD_WARNING;
2028 }
jardineb5d44e2003-12-23 08:09:43 +00002029
hassof390d2c2004-09-10 20:48:21 +00002030 if (!c)
2031 {
2032 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
2033 c = isis_csm_state_change (ISIS_ENABLE, c, area);
2034 c->interface = ifp;
2035 ifp->info = c;
2036 }
jardineb5d44e2003-12-23 08:09:43 +00002037
hassof390d2c2004-09-10 20:48:21 +00002038 if (!c)
jardineb5d44e2003-12-23 08:09:43 +00002039 return CMD_WARNING;
2040
2041 c->ipv6_router = 1;
2042 area->ipv6_circuits++;
2043 circuit_update_nlpids (c);
2044
2045 vty->node = INTERFACE_NODE;
2046
2047 return CMD_SUCCESS;
2048}
2049
2050DEFUN (no_ipv6_router_isis,
2051 no_ipv6_router_isis_cmd,
2052 "no ipv6 router isis WORD",
2053 NO_STR
2054 "IPv6 interface subcommands\n"
2055 "IPv6 Router interface commands\n"
2056 "IS-IS Routing for IPv6\n"
2057 "Routing process tag\n")
2058{
2059 struct isis_circuit *c;
2060 struct interface *ifp;
2061 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002062
2063 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002064 /* UGLY - will remove l8r
2065 if (circuit == NULL) {
hassof390d2c2004-09-10 20:48:21 +00002066 return CMD_WARNING;
2067 } */
jardineb5d44e2003-12-23 08:09:43 +00002068 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002069
jardineb5d44e2003-12-23 08:09:43 +00002070 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002071 if (!area)
2072 {
2073 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2074 return CMD_WARNING;
2075 }
2076
jardineb5d44e2003-12-23 08:09:43 +00002077 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
2078 if (!c)
2079 return CMD_WARNING;
2080
2081 c->ipv6_router = 0;
2082 area->ipv6_circuits--;
2083 if (c->ip_router == 0)
2084 isis_csm_state_change (ISIS_DISABLE, c, area);
2085
2086 return CMD_SUCCESS;
2087}
hassof390d2c2004-09-10 20:48:21 +00002088#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00002089
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002090static struct cmd_node interface_node = {
jardineb5d44e2003-12-23 08:09:43 +00002091 INTERFACE_NODE,
2092 "%s(config-if)# ",
2093 1,
2094};
2095
jardineb5d44e2003-12-23 08:09:43 +00002096int
2097isis_if_new_hook (struct interface *ifp)
2098{
2099/* FIXME: Discuss if the circuit should be created here
2100 ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */
2101 ifp->info = NULL;
2102 return 0;
2103}
2104
2105int
2106isis_if_delete_hook (struct interface *ifp)
2107{
2108/* FIXME: Discuss if the circuit should be created here
2109 XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/
2110 ifp->info = NULL;
2111 return 0;
2112}
2113
jardineb5d44e2003-12-23 08:09:43 +00002114void
2115isis_circuit_init ()
2116{
jardineb5d44e2003-12-23 08:09:43 +00002117 /* Initialize Zebra interface data structure */
2118 if_init ();
2119 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2120 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2121
2122 /* Install interface node */
2123 install_node (&interface_node, isis_interface_config_write);
2124 install_element (CONFIG_NODE, &interface_cmd);
2125
2126 install_default (INTERFACE_NODE);
2127 install_element (INTERFACE_NODE, &interface_desc_cmd);
2128 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2129
2130 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2131 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2132
2133 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2134 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2135
Fritz Reichmanne6b03b72011-10-01 17:49:48 +04002136 install_element (INTERFACE_NODE, &isis_passwd_clear_cmd);
2137 install_element (INTERFACE_NODE, &isis_passwd_md5_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002138 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2139
2140 install_element (INTERFACE_NODE, &isis_priority_cmd);
2141 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2142 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2143 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2144 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2145 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2146 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2147 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2148 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2149
2150 install_element (INTERFACE_NODE, &isis_metric_cmd);
2151 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2152 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
2153
2154 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2155 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2156 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2157 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2158 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2159 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2160 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2161 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2162 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2163
2164 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2165 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2166 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2167 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2168 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2169 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2170 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2171 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2172 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2173
2174 install_element (INTERFACE_NODE, &isis_hello_cmd);
2175 install_element (INTERFACE_NODE, &no_isis_hello_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002176 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2177 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2178 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2179 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2180 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2181 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2182 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2183 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2184 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2185
2186#ifdef HAVE_IPV6
2187 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2188 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002189#endif
jardineb5d44e2003-12-23 08:09:43 +00002190}