blob: 2ef43ccfd5845604a1de4df5c356637bd07c8f51 [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"
Josh Bailey3f045a02012-03-24 08:35:20 -070047#include "isisd/isis_flags.h"
jardineb5d44e2003-12-23 08:09:43 +000048#include "isisd/isis_circuit.h"
49#include "isisd/isis_tlv.h"
50#include "isisd/isis_lsp.h"
51#include "isisd/isis_pdu.h"
52#include "isisd/isis_network.h"
53#include "isisd/isis_misc.h"
54#include "isisd/isis_constants.h"
55#include "isisd/isis_adjacency.h"
56#include "isisd/isis_dr.h"
jardineb5d44e2003-12-23 08:09:43 +000057#include "isisd/isisd.h"
58#include "isisd/isis_csm.h"
59#include "isisd/isis_events.h"
60
Paul Jakma41b36e92006-12-08 01:09:50 +000061/*
62 * Prototypes.
63 */
Paul Jakma41b36e92006-12-08 01:09:50 +000064int isis_interface_config_write(struct vty *);
65int isis_if_new_hook(struct interface *);
66int isis_if_delete_hook(struct interface *);
67
jardineb5d44e2003-12-23 08:09:43 +000068struct isis_circuit *
69isis_circuit_new ()
70{
71 struct isis_circuit *circuit;
72 int i;
73
hasso3fdb2dd2005-09-28 18:45:54 +000074 circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
Josh Bailey3f045a02012-03-24 08:35:20 -070075 if (circuit == NULL)
hassof390d2c2004-09-10 20:48:21 +000076 {
77 zlog_err ("Can't malloc isis circuit");
78 return NULL;
79 }
80
Josh Bailey3f045a02012-03-24 08:35:20 -070081 /*
82 * Default values
83 */
84 circuit->is_type = IS_LEVEL_1_AND_2;
85 circuit->flags = 0;
86 circuit->pad_hellos = 1;
87 for (i = 0; i < 2; i++)
88 {
89 circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL;
90 circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER;
91 circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL;
92 circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL;
93 circuit->priority[i] = DEFAULT_PRIORITY;
94 circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRIC;
95 circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
96 circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
97 circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
98 circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC;
99 }
100
jardineb5d44e2003-12-23 08:09:43 +0000101 return circuit;
102}
103
jardineb5d44e2003-12-23 08:09:43 +0000104void
Josh Bailey3f045a02012-03-24 08:35:20 -0700105isis_circuit_del (struct isis_circuit *circuit)
106{
107 if (!circuit)
108 return;
109
110 isis_circuit_if_unbind (circuit, circuit->interface);
111
112 /* and lastly the circuit itself */
113 XFREE (MTYPE_ISIS_CIRCUIT, circuit);
114
115 return;
116}
117
118void
jardineb5d44e2003-12-23 08:09:43 +0000119isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
120{
Josh Bailey3f045a02012-03-24 08:35:20 -0700121 assert (area);
jardineb5d44e2003-12-23 08:09:43 +0000122 circuit->area = area;
Josh Bailey3f045a02012-03-24 08:35:20 -0700123
jardineb5d44e2003-12-23 08:09:43 +0000124 /*
125 * The level for the circuit is same as for the area, unless configured
126 * otherwise.
127 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700128 if (area->is_type != IS_LEVEL_1_AND_2 && area->is_type != circuit->is_type)
129 zlog_warn ("circut %s is_type %d mismatch with area %s is_type %d",
130 circuit->interface->name, circuit->is_type,
131 circuit->area->area_tag, area->is_type);
jardineb5d44e2003-12-23 08:09:43 +0000132
133 /*
134 * Add the circuit into area
135 */
136 listnode_add (area->circuit_list, circuit);
137
138 circuit->idx = flags_get_index (&area->flags);
jardineb5d44e2003-12-23 08:09:43 +0000139
140 return;
141}
142
hassof390d2c2004-09-10 20:48:21 +0000143void
Josh Bailey3f045a02012-03-24 08:35:20 -0700144isis_circuit_deconfigure (struct isis_circuit *circuit, struct isis_area *area)
jardineb5d44e2003-12-23 08:09:43 +0000145{
jardineb5d44e2003-12-23 08:09:43 +0000146 /* Free the index of SRM and SSN flags */
147 flags_free_index (&area->flags, circuit->idx);
Josh Bailey3f045a02012-03-24 08:35:20 -0700148 circuit->idx = 0;
149 /* Remove circuit from area */
150 assert (circuit->area == area);
151 listnode_delete (area->circuit_list, circuit);
152 circuit->area = NULL;
jardineb5d44e2003-12-23 08:09:43 +0000153
154 return;
155}
156
157struct isis_circuit *
158circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
159{
160 struct isis_circuit *circuit = NULL;
161 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000162
jardineb5d44e2003-12-23 08:09:43 +0000163 if (!list)
164 return NULL;
hassof390d2c2004-09-10 20:48:21 +0000165
paul1eb8ef22005-04-07 07:30:20 +0000166 for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
167 if (circuit->interface == ifp)
Josh Bailey3f045a02012-03-24 08:35:20 -0700168 {
169 assert (ifp->info == circuit);
170 return circuit;
171 }
172
jardineb5d44e2003-12-23 08:09:43 +0000173 return NULL;
174}
175
176struct isis_circuit *
177circuit_scan_by_ifp (struct interface *ifp)
178{
179 struct isis_area *area;
180 struct listnode *node;
181 struct isis_circuit *circuit;
182
Josh Bailey3f045a02012-03-24 08:35:20 -0700183 if (ifp->info)
184 return (struct isis_circuit *)ifp->info;
jardineb5d44e2003-12-23 08:09:43 +0000185
Josh Bailey3f045a02012-03-24 08:35:20 -0700186 if (isis->area_list)
hassof390d2c2004-09-10 20:48:21 +0000187 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700188 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
189 {
190 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
191 if (circuit)
192 return circuit;
193 }
hassof390d2c2004-09-10 20:48:21 +0000194 }
jardineb5d44e2003-12-23 08:09:43 +0000195 return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
196}
197
Josh Bailey3f045a02012-03-24 08:35:20 -0700198static struct isis_circuit *
199isis_circuit_lookup (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000200{
Josh Bailey3f045a02012-03-24 08:35:20 -0700201 struct interface *ifp;
202 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +0000203
Josh Bailey3f045a02012-03-24 08:35:20 -0700204 ifp = (struct interface *) vty->index;
205 if (!ifp)
hassof390d2c2004-09-10 20:48:21 +0000206 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700207 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
208 return NULL;
hassof390d2c2004-09-10 20:48:21 +0000209 }
hassof390d2c2004-09-10 20:48:21 +0000210
Josh Bailey3f045a02012-03-24 08:35:20 -0700211 circuit = circuit_scan_by_ifp (ifp);
212 if (!circuit)
213 {
214 vty_out (vty, "ISIS is not enabled on circuit %s%s",
215 ifp->name, VTY_NEWLINE);
216 return NULL;
217 }
jardineb5d44e2003-12-23 08:09:43 +0000218
Josh Bailey3f045a02012-03-24 08:35:20 -0700219 return circuit;
jardineb5d44e2003-12-23 08:09:43 +0000220}
221
222void
hassof891f442004-09-14 13:54:30 +0000223isis_circuit_add_addr (struct isis_circuit *circuit,
224 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000225{
Josh Bailey3f045a02012-03-24 08:35:20 -0700226 struct listnode *node;
jardineb5d44e2003-12-23 08:09:43 +0000227 struct prefix_ipv4 *ipv4;
hassof390d2c2004-09-10 20:48:21 +0000228 u_char buf[BUFSIZ];
jardineb5d44e2003-12-23 08:09:43 +0000229#ifdef HAVE_IPV6
230 struct prefix_ipv6 *ipv6;
231#endif /* HAVE_IPV6 */
hassof891f442004-09-14 13:54:30 +0000232
jardineb5d44e2003-12-23 08:09:43 +0000233 memset (&buf, 0, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000234 if (connected->address->family == AF_INET)
hassof390d2c2004-09-10 20:48:21 +0000235 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700236 u_int32_t addr = connected->address->u.prefix4.s_addr;
237 addr = ntohl (addr);
238 if (IPV4_NET0(addr) ||
239 IPV4_NET127(addr) ||
240 IN_CLASSD(addr) ||
241 IPV4_LINKLOCAL(addr))
242 return;
243
244 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ipv4))
245 if (prefix_same ((struct prefix *) ipv4, connected->address))
246 return;
247
hassof390d2c2004-09-10 20:48:21 +0000248 ipv4 = prefix_ipv4_new ();
hassof891f442004-09-14 13:54:30 +0000249 ipv4->prefixlen = connected->address->prefixlen;
250 ipv4->prefix = connected->address->u.prefix4;
hassof390d2c2004-09-10 20:48:21 +0000251 listnode_add (circuit->ip_addrs, ipv4);
hasso0dae85e2004-09-26 19:53:47 +0000252 if (circuit->area)
Josh Bailey3f045a02012-03-24 08:35:20 -0700253 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
hassof891f442004-09-14 13:54:30 +0000254
jardineb5d44e2003-12-23 08:09:43 +0000255#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000256 prefix2str (connected->address, buf, BUFSIZ);
hasso529d65b2004-12-24 00:14:50 +0000257 zlog_debug ("Added IP address %s to circuit %d", buf,
hassof390d2c2004-09-10 20:48:21 +0000258 circuit->circuit_id);
259#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +0000260 }
hassof390d2c2004-09-10 20:48:21 +0000261#ifdef HAVE_IPV6
hassof891f442004-09-14 13:54:30 +0000262 if (connected->address->family == AF_INET6)
hassof390d2c2004-09-10 20:48:21 +0000263 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700264 if (IN6_IS_ADDR_LOOPBACK(&connected->address->u.prefix6))
265 return;
266
267 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ipv6))
268 if (prefix_same ((struct prefix *) ipv6, connected->address))
269 return;
270 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ipv6))
271 if (prefix_same ((struct prefix *) ipv6, connected->address))
272 return;
273
hassof390d2c2004-09-10 20:48:21 +0000274 ipv6 = prefix_ipv6_new ();
hassof891f442004-09-14 13:54:30 +0000275 ipv6->prefixlen = connected->address->prefixlen;
276 ipv6->prefix = connected->address->u.prefix6;
277
hassof390d2c2004-09-10 20:48:21 +0000278 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
hassof891f442004-09-14 13:54:30 +0000279 listnode_add (circuit->ipv6_link, ipv6);
hassof390d2c2004-09-10 20:48:21 +0000280 else
hassof891f442004-09-14 13:54:30 +0000281 listnode_add (circuit->ipv6_non_link, ipv6);
hasso0dae85e2004-09-26 19:53:47 +0000282 if (circuit->area)
Josh Bailey3f045a02012-03-24 08:35:20 -0700283 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
hassof891f442004-09-14 13:54:30 +0000284
jardineb5d44e2003-12-23 08:09:43 +0000285#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000286 prefix2str (connected->address, buf, BUFSIZ);
hasso529d65b2004-12-24 00:14:50 +0000287 zlog_debug ("Added IPv6 address %s to circuit %d", buf,
hassof390d2c2004-09-10 20:48:21 +0000288 circuit->circuit_id);
289#endif /* EXTREME_DEBUG */
290 }
jardineb5d44e2003-12-23 08:09:43 +0000291#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000292 return;
293}
294
295void
296isis_circuit_del_addr (struct isis_circuit *circuit,
hassof390d2c2004-09-10 20:48:21 +0000297 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000298{
hassof891f442004-09-14 13:54:30 +0000299 struct prefix_ipv4 *ipv4, *ip = NULL;
300 struct listnode *node;
hassof891f442004-09-14 13:54:30 +0000301 u_char buf[BUFSIZ];
302#ifdef HAVE_IPV6
303 struct prefix_ipv6 *ipv6, *ip6 = NULL;
Paul Jakma41b36e92006-12-08 01:09:50 +0000304 int found = 0;
hassof891f442004-09-14 13:54:30 +0000305#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000306
hassof891f442004-09-14 13:54:30 +0000307 memset (&buf, 0, BUFSIZ);
308 if (connected->address->family == AF_INET)
309 {
310 ipv4 = prefix_ipv4_new ();
311 ipv4->prefixlen = connected->address->prefixlen;
312 ipv4->prefix = connected->address->u.prefix4;
313
paul1eb8ef22005-04-07 07:30:20 +0000314 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
Josh Bailey3f045a02012-03-24 08:35:20 -0700315 if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
paul1eb8ef22005-04-07 07:30:20 +0000316 break;
hassof891f442004-09-14 13:54:30 +0000317
318 if (ip)
319 {
320 listnode_delete (circuit->ip_addrs, ip);
Josh Bailey3f045a02012-03-24 08:35:20 -0700321 if (circuit->area)
322 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
hassof891f442004-09-14 13:54:30 +0000323 }
324 else
325 {
hassof7c43dc2004-09-26 16:24:14 +0000326 prefix2str (connected->address, (char *)buf, BUFSIZ);
Josh Bailey3f045a02012-03-24 08:35:20 -0700327 zlog_warn ("Nonexitant ip address %s removal attempt from \
328 circuit %d", buf, circuit->circuit_id);
hassof891f442004-09-14 13:54:30 +0000329 }
David Lampartere8aca322012-11-27 01:10:30 +0000330
331 prefix_ipv4_free (ipv4);
hassof891f442004-09-14 13:54:30 +0000332 }
333#ifdef HAVE_IPV6
334 if (connected->address->family == AF_INET6)
335 {
336 ipv6 = prefix_ipv6_new ();
337 ipv6->prefixlen = connected->address->prefixlen;
338 ipv6->prefix = connected->address->u.prefix6;
339
340 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
341 {
paul1eb8ef22005-04-07 07:30:20 +0000342 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
hassof891f442004-09-14 13:54:30 +0000343 {
hassof891f442004-09-14 13:54:30 +0000344 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
345 break;
346 }
347 if (ip6)
348 {
349 listnode_delete (circuit->ipv6_link, ip6);
350 found = 1;
351 }
352 }
353 else
354 {
paul1eb8ef22005-04-07 07:30:20 +0000355 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
hassof891f442004-09-14 13:54:30 +0000356 {
hassof891f442004-09-14 13:54:30 +0000357 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
358 break;
359 }
360 if (ip6)
361 {
362 listnode_delete (circuit->ipv6_non_link, ip6);
363 found = 1;
364 }
365 }
366
367 if (!found)
368 {
hassof7c43dc2004-09-26 16:24:14 +0000369 prefix2str (connected->address, (char *)buf, BUFSIZ);
Josh Bailey3f045a02012-03-24 08:35:20 -0700370 zlog_warn ("Nonexitant ip address %s removal attempt from \
371 circuit %d", buf, circuit->circuit_id);
hassof891f442004-09-14 13:54:30 +0000372 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700373 else if (circuit->area)
374 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
David Lampartere8aca322012-11-27 01:10:30 +0000375
376 prefix_ipv6_free (ipv6);
hassof891f442004-09-14 13:54:30 +0000377 }
378#endif /* HAVE_IPV6 */
379 return;
jardineb5d44e2003-12-23 08:09:43 +0000380}
381
Josh Bailey3f045a02012-03-24 08:35:20 -0700382static u_char
383isis_circuit_id_gen (struct interface *ifp)
384{
385 u_char id = 0;
386 char ifname[16];
387 unsigned int i;
388 int start = -1, end = -1;
389
390 /*
391 * Get a stable circuit id from ifname. This makes
392 * the ifindex from flapping when netdevs are created
393 * and deleted on the fly. Note that this circuit id
394 * is used in pseudo lsps so it is better to be stable.
395 * The following code works on any reasonanle ifname
396 * like: eth1 or trk-1.1 etc.
397 */
398 for (i = 0; i < strlen (ifp->name); i++)
399 {
David Lamparter52f02b42015-04-10 09:14:30 +0200400 if (isdigit((unsigned char)ifp->name[i]))
Josh Bailey3f045a02012-03-24 08:35:20 -0700401 {
402 if (start < 0)
403 {
404 start = i;
405 end = i + 1;
406 }
407 else
408 {
409 end = i + 1;
410 }
411 }
412 else if (start >= 0)
413 break;
414 }
415
416 if ((start >= 0) && (end >= start) && (end - start) < 16)
417 {
418 memset (ifname, 0, 16);
419 strncpy (ifname, &ifp->name[start], end - start);
420 id = (u_char)atoi(ifname);
421 }
422
423 /* Try to be unique. */
424 if (!id)
425 id = (u_char)((ifp->ifindex & 0xff) | 0x80);
426
427 return id;
428}
429
jardineb5d44e2003-12-23 08:09:43 +0000430void
431isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
432{
paul1eb8ef22005-04-07 07:30:20 +0000433 struct listnode *node, *nnode;
jardineb5d44e2003-12-23 08:09:43 +0000434 struct connected *conn;
435
Josh Bailey3f045a02012-03-24 08:35:20 -0700436 circuit->circuit_id = isis_circuit_id_gen (ifp);
hassof390d2c2004-09-10 20:48:21 +0000437
Josh Bailey3f045a02012-03-24 08:35:20 -0700438 isis_circuit_if_bind (circuit, ifp);
jardineb5d44e2003-12-23 08:09:43 +0000439 /* isis_circuit_update_addrs (circuit, ifp); */
440
hassof390d2c2004-09-10 20:48:21 +0000441 if (if_is_broadcast (ifp))
442 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700443 if (circuit->circ_type_config == CIRCUIT_T_P2P)
444 circuit->circ_type = CIRCUIT_T_P2P;
hassof390d2c2004-09-10 20:48:21 +0000445 else
Josh Bailey3f045a02012-03-24 08:35:20 -0700446 circuit->circ_type = CIRCUIT_T_BROADCAST;
hassof390d2c2004-09-10 20:48:21 +0000447 }
448 else if (if_is_pointopoint (ifp))
449 {
450 circuit->circ_type = CIRCUIT_T_P2P;
451 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700452 else if (if_is_loopback (ifp))
453 {
454 circuit->circ_type = CIRCUIT_T_LOOPBACK;
455 circuit->is_passive = 1;
456 }
hassof390d2c2004-09-10 20:48:21 +0000457 else
458 {
hassoc89c05d2005-09-04 21:36:36 +0000459 /* It's normal in case of loopback etc. */
460 if (isis->debugs & DEBUG_EVENTS)
Josh Bailey3f045a02012-03-24 08:35:20 -0700461 zlog_debug ("isis_circuit_if_add: unsupported media");
462 circuit->circ_type = CIRCUIT_T_UNKNOWN;
hassof390d2c2004-09-10 20:48:21 +0000463 }
464
Josh Bailey3f045a02012-03-24 08:35:20 -0700465 circuit->ip_addrs = list_new ();
466#ifdef HAVE_IPV6
467 circuit->ipv6_link = list_new ();
468 circuit->ipv6_non_link = list_new ();
469#endif /* HAVE_IPV6 */
470
paul1eb8ef22005-04-07 07:30:20 +0000471 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
472 isis_circuit_add_addr (circuit, conn);
jardineb5d44e2003-12-23 08:09:43 +0000473
474 return;
475}
476
477void
Josh Bailey3f045a02012-03-24 08:35:20 -0700478isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000479{
Josh Bailey3f045a02012-03-24 08:35:20 -0700480 struct listnode *node, *nnode;
481 struct connected *conn;
hassof390d2c2004-09-10 20:48:21 +0000482
Josh Bailey3f045a02012-03-24 08:35:20 -0700483 assert (circuit->interface == ifp);
484
485 /* destroy addresses */
486 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
487 isis_circuit_del_addr (circuit, conn);
488
489 if (circuit->ip_addrs)
hassof390d2c2004-09-10 20:48:21 +0000490 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700491 assert (listcount(circuit->ip_addrs) == 0);
492 list_delete (circuit->ip_addrs);
493 circuit->ip_addrs = NULL;
hassof390d2c2004-09-10 20:48:21 +0000494 }
jardineb5d44e2003-12-23 08:09:43 +0000495
Josh Bailey3f045a02012-03-24 08:35:20 -0700496#ifdef HAVE_IPV6
497 if (circuit->ipv6_link)
hassof390d2c2004-09-10 20:48:21 +0000498 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700499 assert (listcount(circuit->ipv6_link) == 0);
500 list_delete (circuit->ipv6_link);
501 circuit->ipv6_link = NULL;
jardineb5d44e2003-12-23 08:09:43 +0000502 }
jardineb5d44e2003-12-23 08:09:43 +0000503
Josh Bailey3f045a02012-03-24 08:35:20 -0700504 if (circuit->ipv6_non_link)
hassof390d2c2004-09-10 20:48:21 +0000505 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700506 assert (listcount(circuit->ipv6_non_link) == 0);
507 list_delete (circuit->ipv6_non_link);
508 circuit->ipv6_non_link = NULL;
hassof390d2c2004-09-10 20:48:21 +0000509 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700510#endif /* HAVE_IPV6 */
511
512 circuit->circ_type = CIRCUIT_T_UNKNOWN;
513 circuit->circuit_id = 0;
jardineb5d44e2003-12-23 08:09:43 +0000514
jardineb5d44e2003-12-23 08:09:43 +0000515 return;
516}
517
518void
Josh Bailey3f045a02012-03-24 08:35:20 -0700519isis_circuit_if_bind (struct isis_circuit *circuit, struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000520{
Josh Bailey3f045a02012-03-24 08:35:20 -0700521 assert (circuit != NULL);
522 assert (ifp != NULL);
523 if (circuit->interface)
524 assert (circuit->interface == ifp);
525 else
526 circuit->interface = ifp;
527 if (ifp->info)
528 assert (ifp->info == circuit);
529 else
530 ifp->info = circuit;
531}
532
533void
534isis_circuit_if_unbind (struct isis_circuit *circuit, struct interface *ifp)
535{
536 assert (circuit != NULL);
537 assert (ifp != NULL);
538 assert (circuit->interface == ifp);
539 assert (ifp->info == circuit);
jardineb5d44e2003-12-23 08:09:43 +0000540 circuit->interface = NULL;
Josh Bailey3f045a02012-03-24 08:35:20 -0700541 ifp->info = NULL;
jardineb5d44e2003-12-23 08:09:43 +0000542}
543
Josh Bailey3f045a02012-03-24 08:35:20 -0700544static void
545isis_circuit_update_all_srmflags (struct isis_circuit *circuit, int is_set)
546{
547 struct isis_area *area;
548 struct isis_lsp *lsp;
549 dnode_t *dnode, *dnode_next;
550 int level;
551
552 assert (circuit);
553 area = circuit->area;
554 assert (area);
555 for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++)
556 {
557 if (level & circuit->is_type)
558 {
559 if (area->lspdb[level - 1] &&
560 dict_count (area->lspdb[level - 1]) > 0)
561 {
562 for (dnode = dict_first (area->lspdb[level - 1]);
563 dnode != NULL; dnode = dnode_next)
564 {
565 dnode_next = dict_next (area->lspdb[level - 1], dnode);
566 lsp = dnode_get (dnode);
567 if (is_set)
568 {
569 ISIS_SET_FLAG (lsp->SRMflags, circuit);
570 }
571 else
572 {
573 ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
574 }
575 }
576 }
577 }
578 }
579}
580
581int
jardineb5d44e2003-12-23 08:09:43 +0000582isis_circuit_up (struct isis_circuit *circuit)
583{
Josh Bailey3f045a02012-03-24 08:35:20 -0700584 int retv;
585
586 /* Set the flags for all the lsps of the circuit. */
587 isis_circuit_update_all_srmflags (circuit, 1);
588
589 if (circuit->state == C_STATE_UP)
590 return ISIS_OK;
591
592 if (circuit->is_passive)
593 return ISIS_OK;
jardineb5d44e2003-12-23 08:09:43 +0000594
hassof390d2c2004-09-10 20:48:21 +0000595 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
596 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700597 /*
598 * Get the Hardware Address
599 */
600#ifdef HAVE_STRUCT_SOCKADDR_DL
601#ifndef SUNOS_5
602 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
603 zlog_warn ("unsupported link layer");
604 else
605 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
606 ETH_ALEN);
607#endif
608#else
609 if (circuit->interface->hw_addr_len != ETH_ALEN)
610 {
611 zlog_warn ("unsupported link layer");
612 }
613 else
614 {
615 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
616 }
617#ifdef EXTREME_DEGUG
618 zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
619 circuit->interface->ifindex, ISO_MTU (circuit),
620 snpa_print (circuit->u.bc.snpa));
621#endif /* EXTREME_DEBUG */
622#endif /* HAVE_STRUCT_SOCKADDR_DL */
623
624 circuit->u.bc.adjdb[0] = list_new ();
625 circuit->u.bc.adjdb[1] = list_new ();
626
hassof390d2c2004-09-10 20:48:21 +0000627 if (circuit->area->min_bcast_mtu == 0 ||
Josh Bailey3f045a02012-03-24 08:35:20 -0700628 ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
629 circuit->area->min_bcast_mtu = ISO_MTU (circuit);
hassof390d2c2004-09-10 20:48:21 +0000630 /*
631 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
632 */
jardineb5d44e2003-12-23 08:09:43 +0000633
hassof390d2c2004-09-10 20:48:21 +0000634 /* initilizing the hello sending threads
635 * for a broadcast IF
636 */
jardineb5d44e2003-12-23 08:09:43 +0000637
hassof390d2c2004-09-10 20:48:21 +0000638 /* 8.4.1 a) commence sending of IIH PDUs */
639
Josh Bailey3f045a02012-03-24 08:35:20 -0700640 if (circuit->is_type & IS_LEVEL_1)
641 {
642 thread_add_event (master, send_lan_l1_hello, circuit, 0);
643 circuit->u.bc.lan_neighs[0] = list_new ();
644 }
hassof390d2c2004-09-10 20:48:21 +0000645
Josh Bailey3f045a02012-03-24 08:35:20 -0700646 if (circuit->is_type & IS_LEVEL_2)
647 {
648 thread_add_event (master, send_lan_l2_hello, circuit, 0);
649 circuit->u.bc.lan_neighs[1] = list_new ();
650 }
hassof390d2c2004-09-10 20:48:21 +0000651
652 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
653 /* 8.4.1 c) FIXME: listen for ESH PDUs */
654
655 /* 8.4.1 d) */
656 /* dr election will commence in... */
Josh Bailey3f045a02012-03-24 08:35:20 -0700657 if (circuit->is_type & IS_LEVEL_1)
658 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
659 circuit, 2 * circuit->hello_interval[0]);
660 if (circuit->is_type & IS_LEVEL_2)
661 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
662 circuit, 2 * circuit->hello_interval[1]);
jardineb5d44e2003-12-23 08:09:43 +0000663 }
hassof390d2c2004-09-10 20:48:21 +0000664 else
665 {
666 /* initializing the hello send threads
667 * for a ptp IF
668 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700669 circuit->u.p2p.neighbor = NULL;
hassof390d2c2004-09-10 20:48:21 +0000670 thread_add_event (master, send_p2p_hello, circuit, 0);
jardineb5d44e2003-12-23 08:09:43 +0000671 }
672
jardineb5d44e2003-12-23 08:09:43 +0000673 /* initializing PSNP timers */
Josh Bailey3f045a02012-03-24 08:35:20 -0700674 if (circuit->is_type & IS_LEVEL_1)
675 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
676 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
677
678 if (circuit->is_type & IS_LEVEL_2)
679 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
680 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
681
682 /* unified init for circuits; ignore warnings below this level */
683 retv = isis_sock_init (circuit);
684 if (retv != ISIS_OK)
hassof390d2c2004-09-10 20:48:21 +0000685 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700686 isis_circuit_down (circuit);
687 return retv;
hassof390d2c2004-09-10 20:48:21 +0000688 }
689
Josh Bailey3f045a02012-03-24 08:35:20 -0700690 /* initialize the circuit streams after opening connection */
jardineb5d44e2003-12-23 08:09:43 +0000691 if (circuit->rcv_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000692 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000693
694 if (circuit->snd_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000695 circuit->snd_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000696
jardineb5d44e2003-12-23 08:09:43 +0000697#ifdef GNU_LINUX
hassof390d2c2004-09-10 20:48:21 +0000698 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
Josh Bailey3f045a02012-03-24 08:35:20 -0700699 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000700#else
hassof390d2c2004-09-10 20:48:21 +0000701 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
Josh Bailey3f045a02012-03-24 08:35:20 -0700702 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000703#endif
Josh Bailey3f045a02012-03-24 08:35:20 -0700704
705 circuit->lsp_queue = list_new ();
706 circuit->lsp_queue_last_cleared = time (NULL);
707
708 return ISIS_OK;
jardineb5d44e2003-12-23 08:09:43 +0000709}
710
711void
712isis_circuit_down (struct isis_circuit *circuit)
713{
Josh Bailey3f045a02012-03-24 08:35:20 -0700714 if (circuit->state != C_STATE_UP)
715 return;
716
717 /* Clear the flags for all the lsps of the circuit. */
718 isis_circuit_update_all_srmflags (circuit, 0);
719
hassof390d2c2004-09-10 20:48:21 +0000720 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
721 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700722 /* destroy neighbour lists */
723 if (circuit->u.bc.lan_neighs[0])
724 {
725 list_delete (circuit->u.bc.lan_neighs[0]);
726 circuit->u.bc.lan_neighs[0] = NULL;
727 }
728 if (circuit->u.bc.lan_neighs[1])
729 {
730 list_delete (circuit->u.bc.lan_neighs[1]);
731 circuit->u.bc.lan_neighs[1] = NULL;
732 }
733 /* destroy adjacency databases */
734 if (circuit->u.bc.adjdb[0])
735 {
736 circuit->u.bc.adjdb[0]->del = isis_delete_adj;
737 list_delete (circuit->u.bc.adjdb[0]);
738 circuit->u.bc.adjdb[0] = NULL;
739 }
740 if (circuit->u.bc.adjdb[1])
741 {
742 circuit->u.bc.adjdb[1]->del = isis_delete_adj;
743 list_delete (circuit->u.bc.adjdb[1]);
744 circuit->u.bc.adjdb[1] = NULL;
745 }
746 if (circuit->u.bc.is_dr[0])
747 {
748 isis_dr_resign (circuit, 1);
749 circuit->u.bc.is_dr[0] = 0;
750 }
751 memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1);
752 if (circuit->u.bc.is_dr[1])
753 {
754 isis_dr_resign (circuit, 2);
755 circuit->u.bc.is_dr[1] = 0;
756 }
757 memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1);
758 memset (circuit->u.bc.snpa, 0, ETH_ALEN);
759
hassof390d2c2004-09-10 20:48:21 +0000760 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
761 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
hassof891f442004-09-14 13:54:30 +0000762 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
763 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
Josh Bailey3f045a02012-03-24 08:35:20 -0700764 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[0]);
765 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[1]);
hassof390d2c2004-09-10 20:48:21 +0000766 }
767 else if (circuit->circ_type == CIRCUIT_T_P2P)
768 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700769 isis_delete_adj (circuit->u.p2p.neighbor);
770 circuit->u.p2p.neighbor = NULL;
hassof390d2c2004-09-10 20:48:21 +0000771 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
772 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700773
774 /* Cancel all active threads */
775 THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
776 THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
777 THREAD_TIMER_OFF (circuit->t_send_psnp[0]);
778 THREAD_TIMER_OFF (circuit->t_send_psnp[1]);
779 THREAD_OFF (circuit->t_read);
780
781 if (circuit->lsp_queue)
782 {
783 circuit->lsp_queue->del = NULL;
784 list_delete (circuit->lsp_queue);
785 circuit->lsp_queue = NULL;
786 }
787
788 /* send one gratuitous hello to spead up convergence */
789 if (circuit->is_type & IS_LEVEL_1)
790 send_hello (circuit, IS_LEVEL_1);
791 if (circuit->is_type & IS_LEVEL_2)
792 send_hello (circuit, IS_LEVEL_2);
793
794 circuit->upadjcount[0] = 0;
795 circuit->upadjcount[1] = 0;
796
jardineb5d44e2003-12-23 08:09:43 +0000797 /* close the socket */
Josh Bailey3f045a02012-03-24 08:35:20 -0700798 if (circuit->fd)
799 {
800 close (circuit->fd);
801 circuit->fd = 0;
802 }
803
804 if (circuit->rcv_stream != NULL)
805 {
806 stream_free (circuit->rcv_stream);
807 circuit->rcv_stream = NULL;
808 }
809
810 if (circuit->snd_stream != NULL)
811 {
812 stream_free (circuit->snd_stream);
813 circuit->snd_stream = NULL;
814 }
815
816 thread_cancel_event (master, circuit);
jardineb5d44e2003-12-23 08:09:43 +0000817
818 return;
819}
820
821void
822circuit_update_nlpids (struct isis_circuit *circuit)
823{
824 circuit->nlpids.count = 0;
hassof390d2c2004-09-10 20:48:21 +0000825
826 if (circuit->ip_router)
827 {
828 circuit->nlpids.nlpids[0] = NLPID_IP;
829 circuit->nlpids.count++;
830 }
jardineb5d44e2003-12-23 08:09:43 +0000831#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000832 if (circuit->ipv6_router)
833 {
834 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
835 circuit->nlpids.count++;
836 }
jardineb5d44e2003-12-23 08:09:43 +0000837#endif /* HAVE_IPV6 */
838 return;
839}
840
Josh Bailey3f045a02012-03-24 08:35:20 -0700841void
842isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty,
843 char detail)
844{
845 if (detail == ISIS_UI_LEVEL_BRIEF)
846 {
847 vty_out (vty, " %-12s", circuit->interface->name);
848 vty_out (vty, "0x%-7x", circuit->circuit_id);
849 vty_out (vty, "%-9s", circuit_state2string (circuit->state));
850 vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type));
851 vty_out (vty, "%-9s", circuit_t2string (circuit->is_type));
852 vty_out (vty, "%s", VTY_NEWLINE);
853 }
854
855 if (detail == ISIS_UI_LEVEL_DETAIL)
856 {
857 vty_out (vty, " Interface: %s", circuit->interface->name);
858 vty_out (vty, ", State: %s", circuit_state2string (circuit->state));
859 if (circuit->is_passive)
860 vty_out (vty, ", Passive");
861 else
862 vty_out (vty, ", Active");
863 vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id);
864 vty_out (vty, "%s", VTY_NEWLINE);
865 vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type));
866 vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type));
867 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
868 vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa));
869 vty_out (vty, "%s", VTY_NEWLINE);
870 if (circuit->is_type & IS_LEVEL_1)
871 {
872 vty_out (vty, " Level-1 Information:%s", VTY_NEWLINE);
873 if (circuit->area->newmetric)
874 vty_out (vty, " Metric: %d", circuit->te_metric[0]);
875 else
876 vty_out (vty, " Metric: %d",
877 circuit->metrics[0].metric_default);
878 if (!circuit->is_passive)
879 {
880 vty_out (vty, ", Active neighbors: %u%s",
881 circuit->upadjcount[0], VTY_NEWLINE);
882 vty_out (vty, " Hello interval: %u, "
883 "Holddown count: %u %s%s",
884 circuit->hello_interval[0],
885 circuit->hello_multiplier[0],
886 (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
887 VTY_NEWLINE);
888 vty_out (vty, " CNSP interval: %u, "
889 "PSNP interval: %u%s",
890 circuit->csnp_interval[0],
891 circuit->psnp_interval[0], VTY_NEWLINE);
892 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
893 vty_out (vty, " LAN Priority: %u, %s%s",
894 circuit->priority[0],
895 (circuit->u.bc.is_dr[0] ? \
896 "is DIS" : "is not DIS"), VTY_NEWLINE);
897 }
898 else
899 {
900 vty_out (vty, "%s", VTY_NEWLINE);
901 }
902 }
903 if (circuit->is_type & IS_LEVEL_2)
904 {
905 vty_out (vty, " Level-2 Information:%s", VTY_NEWLINE);
906 if (circuit->area->newmetric)
907 vty_out (vty, " Metric: %d", circuit->te_metric[1]);
908 else
909 vty_out (vty, " Metric: %d",
910 circuit->metrics[1].metric_default);
911 if (!circuit->is_passive)
912 {
913 vty_out (vty, ", Active neighbors: %u%s",
914 circuit->upadjcount[1], VTY_NEWLINE);
915 vty_out (vty, " Hello interval: %u, "
916 "Holddown count: %u %s%s",
917 circuit->hello_interval[1],
918 circuit->hello_multiplier[1],
919 (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
920 VTY_NEWLINE);
921 vty_out (vty, " CNSP interval: %u, "
922 "PSNP interval: %u%s",
923 circuit->csnp_interval[1],
924 circuit->psnp_interval[1], VTY_NEWLINE);
925 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
926 vty_out (vty, " LAN Priority: %u, %s%s",
927 circuit->priority[1],
928 (circuit->u.bc.is_dr[1] ? \
929 "is DIS" : "is not DIS"), VTY_NEWLINE);
930 }
931 else
932 {
933 vty_out (vty, "%s", VTY_NEWLINE);
934 }
935 }
936 if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0)
937 {
938 struct listnode *node;
939 struct prefix *ip_addr;
940 u_char buf[BUFSIZ];
941 vty_out (vty, " IP Prefix(es):%s", VTY_NEWLINE);
942 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr))
943 {
944 prefix2str (ip_addr, (char*)buf, BUFSIZ),
945 vty_out (vty, " %s%s", buf, VTY_NEWLINE);
946 }
947 }
948 vty_out (vty, "%s", VTY_NEWLINE);
949 }
950 return;
951}
952
jardineb5d44e2003-12-23 08:09:43 +0000953int
hassof390d2c2004-09-10 20:48:21 +0000954isis_interface_config_write (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000955{
jardineb5d44e2003-12-23 08:09:43 +0000956 int write = 0;
hasso3fdb2dd2005-09-28 18:45:54 +0000957 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +0000958 struct interface *ifp;
959 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -0700960 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +0000961 int i;
jardineb5d44e2003-12-23 08:09:43 +0000962
hasso3fdb2dd2005-09-28 18:45:54 +0000963 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
jardineb5d44e2003-12-23 08:09:43 +0000964 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700965 /* IF name */
966 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
967 write++;
968 /* IF desc */
969 if (ifp->desc)
970 {
971 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
972 write++;
973 }
974 /* ISIS Circuit */
975 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
976 {
977 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
978 if (circuit == NULL)
979 continue;
980 if (circuit->ip_router)
981 {
982 vty_out (vty, " ip router isis %s%s", area->area_tag,
983 VTY_NEWLINE);
984 write++;
985 }
986 if (circuit->is_passive)
987 {
988 vty_out (vty, " isis passive%s", VTY_NEWLINE);
989 write++;
990 }
991 if (circuit->circ_type_config == CIRCUIT_T_P2P)
992 {
993 vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE);
994 write++;
995 }
jardineb5d44e2003-12-23 08:09:43 +0000996#ifdef HAVE_IPV6
Josh Bailey3f045a02012-03-24 08:35:20 -0700997 if (circuit->ipv6_router)
998 {
999 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
1000 VTY_NEWLINE);
1001 write++;
1002 }
jardineb5d44e2003-12-23 08:09:43 +00001003#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00001004
Josh Bailey3f045a02012-03-24 08:35:20 -07001005 /* ISIS - circuit type */
1006 if (circuit->is_type == IS_LEVEL_1)
1007 {
1008 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
1009 write++;
1010 }
1011 else
1012 {
1013 if (circuit->is_type == IS_LEVEL_2)
1014 {
1015 vty_out (vty, " isis circuit-type level-2-only%s",
1016 VTY_NEWLINE);
1017 write++;
1018 }
1019 }
jardineb5d44e2003-12-23 08:09:43 +00001020
Josh Bailey3f045a02012-03-24 08:35:20 -07001021 /* ISIS - CSNP interval */
1022 if (circuit->csnp_interval[0] == circuit->csnp_interval[1])
1023 {
1024 if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL)
1025 {
1026 vty_out (vty, " isis csnp-interval %d%s",
1027 circuit->csnp_interval[0], VTY_NEWLINE);
1028 write++;
1029 }
1030 }
1031 else
1032 {
1033 for (i = 0; i < 2; i++)
1034 {
1035 if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL)
1036 {
1037 vty_out (vty, " isis csnp-interval %d level-%d%s",
1038 circuit->csnp_interval[i], i + 1, VTY_NEWLINE);
1039 write++;
1040 }
1041 }
1042 }
jardineb5d44e2003-12-23 08:09:43 +00001043
Josh Bailey3f045a02012-03-24 08:35:20 -07001044 /* ISIS - PSNP interval */
1045 if (circuit->psnp_interval[0] == circuit->psnp_interval[1])
1046 {
1047 if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL)
1048 {
1049 vty_out (vty, " isis psnp-interval %d%s",
1050 circuit->psnp_interval[0], VTY_NEWLINE);
1051 write++;
1052 }
1053 }
1054 else
1055 {
1056 for (i = 0; i < 2; i++)
1057 {
1058 if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL)
1059 {
1060 vty_out (vty, " isis psnp-interval %d level-%d%s",
1061 circuit->psnp_interval[i], i + 1, VTY_NEWLINE);
1062 write++;
1063 }
1064 }
1065 }
jardineb5d44e2003-12-23 08:09:43 +00001066
Josh Bailey3f045a02012-03-24 08:35:20 -07001067 /* ISIS - Hello padding - Defaults to true so only display if false */
1068 if (circuit->pad_hellos == 0)
1069 {
1070 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
1071 write++;
1072 }
jardineb5d44e2003-12-23 08:09:43 +00001073
Josh Bailey3f045a02012-03-24 08:35:20 -07001074 /* ISIS - Hello interval */
1075 if (circuit->hello_interval[0] == circuit->hello_interval[1])
1076 {
1077 if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL)
1078 {
1079 vty_out (vty, " isis hello-interval %d%s",
1080 circuit->hello_interval[0], VTY_NEWLINE);
1081 write++;
1082 }
1083 }
1084 else
1085 {
1086 for (i = 0; i < 2; i++)
1087 {
1088 if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL)
1089 {
1090 vty_out (vty, " isis hello-interval %d level-%d%s",
1091 circuit->hello_interval[i], i + 1, VTY_NEWLINE);
1092 write++;
1093 }
1094 }
1095 }
jardineb5d44e2003-12-23 08:09:43 +00001096
Josh Bailey3f045a02012-03-24 08:35:20 -07001097 /* ISIS - Hello Multiplier */
1098 if (circuit->hello_multiplier[0] == circuit->hello_multiplier[1])
1099 {
1100 if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER)
1101 {
1102 vty_out (vty, " isis hello-multiplier %d%s",
1103 circuit->hello_multiplier[0], VTY_NEWLINE);
1104 write++;
1105 }
1106 }
1107 else
1108 {
1109 for (i = 0; i < 2; i++)
1110 {
1111 if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER)
1112 {
1113 vty_out (vty, " isis hello-multiplier %d level-%d%s",
1114 circuit->hello_multiplier[i], i + 1,
1115 VTY_NEWLINE);
1116 write++;
1117 }
1118 }
1119 }
1120
1121 /* ISIS - Priority */
1122 if (circuit->priority[0] == circuit->priority[1])
1123 {
1124 if (circuit->priority[0] != DEFAULT_PRIORITY)
1125 {
1126 vty_out (vty, " isis priority %d%s",
1127 circuit->priority[0], VTY_NEWLINE);
1128 write++;
1129 }
1130 }
1131 else
1132 {
1133 for (i = 0; i < 2; i++)
1134 {
1135 if (circuit->priority[i] != DEFAULT_PRIORITY)
1136 {
1137 vty_out (vty, " isis priority %d level-%d%s",
1138 circuit->priority[i], i + 1, VTY_NEWLINE);
1139 write++;
1140 }
1141 }
1142 }
1143
1144 /* ISIS - Metric */
1145 if (circuit->te_metric[0] == circuit->te_metric[1])
1146 {
1147 if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC)
1148 {
1149 vty_out (vty, " isis metric %d%s", circuit->te_metric[0],
1150 VTY_NEWLINE);
1151 write++;
1152 }
1153 }
1154 else
1155 {
1156 for (i = 0; i < 2; i++)
1157 {
1158 if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC)
1159 {
1160 vty_out (vty, " isis metric %d level-%d%s",
1161 circuit->te_metric[i], i + 1, VTY_NEWLINE);
1162 write++;
1163 }
1164 }
1165 }
1166 if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
1167 {
1168 vty_out (vty, " isis password md5 %s%s", circuit->passwd.passwd,
1169 VTY_NEWLINE);
1170 write++;
1171 }
1172 else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
1173 {
1174 vty_out (vty, " isis password clear %s%s", circuit->passwd.passwd,
1175 VTY_NEWLINE);
1176 write++;
1177 }
1178 }
1179 vty_out (vty, "!%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +00001180 }
hassof390d2c2004-09-10 20:48:21 +00001181
jardineb5d44e2003-12-23 08:09:43 +00001182 return write;
1183}
jardineb5d44e2003-12-23 08:09:43 +00001184
1185DEFUN (ip_router_isis,
1186 ip_router_isis_cmd,
1187 "ip router isis WORD",
1188 "Interface Internet Protocol config commands\n"
1189 "IP router interface commands\n"
1190 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +00001191 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +00001192{
Josh Bailey3f045a02012-03-24 08:35:20 -07001193 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +00001194 struct interface *ifp;
1195 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001196
1197 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001198 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00001199
Josh Bailey3f045a02012-03-24 08:35:20 -07001200 /* Prevent more than one area per circuit */
1201 circuit = circuit_scan_by_ifp (ifp);
1202 if (circuit)
hassof390d2c2004-09-10 20:48:21 +00001203 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001204 if (circuit->ip_router == 1)
1205 {
1206 if (strcmp (circuit->area->area_tag, argv[0]))
1207 {
1208 vty_out (vty, "ISIS circuit is already defined on %s%s",
1209 circuit->area->area_tag, VTY_NEWLINE);
1210 return CMD_ERR_NOTHING_TODO;
1211 }
1212 return CMD_SUCCESS;
1213 }
jardineb5d44e2003-12-23 08:09:43 +00001214 }
hassof390d2c2004-09-10 20:48:21 +00001215
Josh Bailey3f045a02012-03-24 08:35:20 -07001216 if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
hassof390d2c2004-09-10 20:48:21 +00001217 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001218 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1219 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001220 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001221 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001222
Josh Bailey3f045a02012-03-24 08:35:20 -07001223 circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
1224 isis_circuit_if_bind (circuit, ifp);
jardineb5d44e2003-12-23 08:09:43 +00001225
Josh Bailey3f045a02012-03-24 08:35:20 -07001226 circuit->ip_router = 1;
jardineb5d44e2003-12-23 08:09:43 +00001227 area->ip_circuits++;
Josh Bailey3f045a02012-03-24 08:35:20 -07001228 circuit_update_nlpids (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001229
1230 vty->node = INTERFACE_NODE;
Josh Bailey3f045a02012-03-24 08:35:20 -07001231 vty->index = ifp;
hassof390d2c2004-09-10 20:48:21 +00001232
jardineb5d44e2003-12-23 08:09:43 +00001233 return CMD_SUCCESS;
1234}
1235
1236DEFUN (no_ip_router_isis,
1237 no_ip_router_isis_cmd,
1238 "no ip router isis WORD",
1239 NO_STR
1240 "Interface Internet Protocol config commands\n"
1241 "IP router interface commands\n"
1242 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +00001243 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +00001244{
jardineb5d44e2003-12-23 08:09:43 +00001245 struct interface *ifp;
1246 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001247 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +00001248
hassof390d2c2004-09-10 20:48:21 +00001249 ifp = (struct interface *) vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07001250 if (!ifp)
1251 {
1252 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1253 return CMD_ERR_NO_MATCH;
1254 }
hassof390d2c2004-09-10 20:48:21 +00001255
jardineb5d44e2003-12-23 08:09:43 +00001256 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001257 if (!area)
1258 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001259 vty_out (vty, "Can't find ISIS instance %s%s",
1260 argv[0], VTY_NEWLINE);
1261 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001262 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001263
1264 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +00001265 if (!circuit)
1266 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001267 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1268 ifp->name, VTY_NEWLINE);
1269 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001270 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001271
jardineb5d44e2003-12-23 08:09:43 +00001272 circuit->ip_router = 0;
1273 area->ip_circuits--;
1274#ifdef HAVE_IPV6
1275 if (circuit->ipv6_router == 0)
1276#endif
1277 isis_csm_state_change (ISIS_DISABLE, circuit, area);
hassof390d2c2004-09-10 20:48:21 +00001278
jardineb5d44e2003-12-23 08:09:43 +00001279 return CMD_SUCCESS;
1280}
1281
Josh Bailey3f045a02012-03-24 08:35:20 -07001282#ifdef HAVE_IPV6
1283DEFUN (ipv6_router_isis,
1284 ipv6_router_isis_cmd,
1285 "ipv6 router isis WORD",
1286 "IPv6 interface subcommands\n"
1287 "IPv6 Router interface commands\n"
1288 "IS-IS Routing for IPv6\n"
1289 "Routing process tag\n")
1290{
1291 struct isis_circuit *circuit;
1292 struct interface *ifp;
1293 struct isis_area *area;
1294
1295 ifp = (struct interface *) vty->index;
1296 assert (ifp);
1297
1298 /* Prevent more than one area per circuit */
1299 circuit = circuit_scan_by_ifp (ifp);
1300 if (circuit)
1301 {
1302 if (circuit->ipv6_router == 1)
1303 {
1304 if (strcmp (circuit->area->area_tag, argv[0]))
1305 {
1306 vty_out (vty, "ISIS circuit is already defined for IPv6 on %s%s",
1307 circuit->area->area_tag, VTY_NEWLINE);
1308 return CMD_ERR_NOTHING_TODO;
1309 }
1310 return CMD_SUCCESS;
1311 }
1312 }
1313
1314 if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
1315 {
1316 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1317 return CMD_ERR_NO_MATCH;
1318 }
1319 area = vty->index;
1320
1321 circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
1322 isis_circuit_if_bind (circuit, ifp);
1323
1324 circuit->ipv6_router = 1;
1325 area->ipv6_circuits++;
1326 circuit_update_nlpids (circuit);
1327
1328 vty->node = INTERFACE_NODE;
1329 vty->index = ifp;
1330
1331 return CMD_SUCCESS;
1332}
1333
1334DEFUN (no_ipv6_router_isis,
1335 no_ipv6_router_isis_cmd,
1336 "no ipv6 router isis WORD",
1337 NO_STR
1338 "IPv6 interface subcommands\n"
1339 "IPv6 Router interface commands\n"
1340 "IS-IS Routing for IPv6\n"
1341 "Routing process tag\n")
1342{
1343 struct interface *ifp;
1344 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001345 struct isis_circuit *circuit;
1346
1347 ifp = (struct interface *) vty->index;
1348 if (!ifp)
1349 {
1350 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1351 return CMD_ERR_NO_MATCH;
1352 }
1353
1354 area = isis_area_lookup (argv[0]);
1355 if (!area)
1356 {
1357 vty_out (vty, "Can't find ISIS instance %s%s",
1358 argv[0], VTY_NEWLINE);
1359 return CMD_ERR_NO_MATCH;
1360 }
1361
1362 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
1363 if (!circuit)
1364 {
1365 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1366 ifp->name, VTY_NEWLINE);
1367 return CMD_ERR_NO_MATCH;
1368 }
1369
1370 circuit->ipv6_router = 0;
1371 area->ipv6_circuits--;
1372 if (circuit->ip_router == 0)
1373 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1374
1375 return CMD_SUCCESS;
1376}
1377#endif /* HAVE_IPV6 */
1378
1379DEFUN (isis_passive,
1380 isis_passive_cmd,
1381 "isis passive",
1382 "IS-IS commands\n"
1383 "Configure the passive mode for interface\n")
1384{
1385 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1386 if (!circuit)
1387 return CMD_ERR_NO_MATCH;
1388
1389 if (circuit->is_passive == 1)
1390 return CMD_SUCCESS;
1391
1392 if (circuit->state != C_STATE_UP)
1393 {
1394 circuit->is_passive = 1;
1395 }
1396 else
1397 {
1398 struct isis_area *area = circuit->area;
1399 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1400 circuit->is_passive = 1;
1401 isis_csm_state_change (ISIS_ENABLE, circuit, area);
1402 }
1403
1404 return CMD_SUCCESS;
1405}
1406
1407DEFUN (no_isis_passive,
1408 no_isis_passive_cmd,
1409 "no isis passive",
1410 NO_STR
1411 "IS-IS commands\n"
1412 "Configure the passive mode for interface\n")
1413{
1414 struct interface *ifp;
1415 struct isis_circuit *circuit;
1416
1417 ifp = (struct interface *) vty->index;
1418 if (!ifp)
1419 {
1420 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1421 return CMD_ERR_NO_MATCH;
1422 }
1423
1424 /* FIXME: what is wrong with circuit = ifp->info ? */
1425 circuit = circuit_scan_by_ifp (ifp);
1426 if (!circuit)
1427 {
1428 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1429 ifp->name, VTY_NEWLINE);
1430 return CMD_ERR_NO_MATCH;
1431 }
1432
1433 if (if_is_loopback(ifp))
1434 {
1435 vty_out (vty, "Can't set no passive for loopback interface%s",
1436 VTY_NEWLINE);
1437 return CMD_ERR_AMBIGUOUS;
1438 }
1439
1440 if (circuit->is_passive == 0)
1441 return CMD_SUCCESS;
1442
1443 if (circuit->state != C_STATE_UP)
1444 {
1445 circuit->is_passive = 0;
1446 }
1447 else
1448 {
1449 struct isis_area *area = circuit->area;
1450 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1451 circuit->is_passive = 0;
1452 isis_csm_state_change (ISIS_ENABLE, circuit, area);
1453 }
1454
1455 return CMD_SUCCESS;
1456}
1457
jardineb5d44e2003-12-23 08:09:43 +00001458DEFUN (isis_circuit_type,
1459 isis_circuit_type_cmd,
1460 "isis circuit-type (level-1|level-1-2|level-2-only)",
1461 "IS-IS commands\n"
1462 "Configure circuit type for interface\n"
1463 "Level-1 only adjacencies are formed\n"
1464 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +00001465 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +00001466{
Josh Bailey3f045a02012-03-24 08:35:20 -07001467 int circuit_type;
1468 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1469 if (!circuit)
1470 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001471
Josh Bailey3f045a02012-03-24 08:35:20 -07001472 circuit_type = string2circuit_t (argv[0]);
1473 if (!circuit_type)
hassof390d2c2004-09-10 20:48:21 +00001474 {
1475 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001476 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001477 }
1478
Josh Bailey3f045a02012-03-24 08:35:20 -07001479 if (circuit->state == C_STATE_UP &&
1480 circuit->area->is_type != IS_LEVEL_1_AND_2 &&
1481 circuit->area->is_type != circuit_type)
hassof390d2c2004-09-10 20:48:21 +00001482 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001483 vty_out (vty, "Invalid circuit level for area %s.%s",
1484 circuit->area->area_tag, VTY_NEWLINE);
1485 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001486 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001487 isis_event_circuit_type_change (circuit, circuit_type);
hassof390d2c2004-09-10 20:48:21 +00001488
jardineb5d44e2003-12-23 08:09:43 +00001489 return CMD_SUCCESS;
1490}
1491
1492DEFUN (no_isis_circuit_type,
1493 no_isis_circuit_type_cmd,
1494 "no isis circuit-type (level-1|level-1-2|level-2-only)",
1495 NO_STR
1496 "IS-IS commands\n"
1497 "Configure circuit type for interface\n"
1498 "Level-1 only adjacencies are formed\n"
1499 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +00001500 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +00001501{
Josh Bailey3f045a02012-03-24 08:35:20 -07001502 int circuit_type;
1503 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1504 if (!circuit)
1505 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001506
jardineb5d44e2003-12-23 08:09:43 +00001507 /*
Josh Bailey3f045a02012-03-24 08:35:20 -07001508 * Set the circuits level to its default value
jardineb5d44e2003-12-23 08:09:43 +00001509 */
Josh Bailey3f045a02012-03-24 08:35:20 -07001510 if (circuit->state == C_STATE_UP)
1511 circuit_type = circuit->area->is_type;
1512 else
1513 circuit_type = IS_LEVEL_1_AND_2;
1514 isis_event_circuit_type_change (circuit, circuit_type);
hassof390d2c2004-09-10 20:48:21 +00001515
jardineb5d44e2003-12-23 08:09:43 +00001516 return CMD_SUCCESS;
1517}
1518
Josh Bailey3f045a02012-03-24 08:35:20 -07001519DEFUN (isis_passwd_md5,
1520 isis_passwd_md5_cmd,
1521 "isis password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001522 "IS-IS commands\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001523 "Configure the authentication password for a circuit\n"
1524 "Authentication type\n"
1525 "Circuit password\n")
jardineb5d44e2003-12-23 08:09:43 +00001526{
jardineb5d44e2003-12-23 08:09:43 +00001527 int len;
Josh Bailey3f045a02012-03-24 08:35:20 -07001528 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1529 if (!circuit)
1530 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001531
jardineb5d44e2003-12-23 08:09:43 +00001532 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001533 if (len > 254)
1534 {
1535 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001536 return CMD_ERR_AMBIGUOUS;
1537 }
1538 circuit->passwd.len = len;
1539 circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1540 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
1541
1542 return CMD_SUCCESS;
1543}
1544
1545DEFUN (isis_passwd_clear,
1546 isis_passwd_clear_cmd,
1547 "isis password clear WORD",
1548 "IS-IS commands\n"
1549 "Configure the authentication password for a circuit\n"
1550 "Authentication type\n"
1551 "Circuit password\n")
1552{
1553 int len;
1554 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1555 if (!circuit)
1556 return CMD_ERR_NO_MATCH;
1557
1558 len = strlen (argv[0]);
1559 if (len > 254)
1560 {
1561 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1562 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001563 }
jardineb5d44e2003-12-23 08:09:43 +00001564 circuit->passwd.len = len;
1565 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001566 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001567
jardineb5d44e2003-12-23 08:09:43 +00001568 return CMD_SUCCESS;
1569}
1570
1571DEFUN (no_isis_passwd,
1572 no_isis_passwd_cmd,
1573 "no isis password",
1574 NO_STR
1575 "IS-IS commands\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001576 "Configure the authentication password for a circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001577{
Josh Bailey3f045a02012-03-24 08:35:20 -07001578 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1579 if (!circuit)
1580 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001581
jardineb5d44e2003-12-23 08:09:43 +00001582 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
hassof390d2c2004-09-10 20:48:21 +00001583
jardineb5d44e2003-12-23 08:09:43 +00001584 return CMD_SUCCESS;
1585}
1586
jardineb5d44e2003-12-23 08:09:43 +00001587DEFUN (isis_priority,
1588 isis_priority_cmd,
1589 "isis priority <0-127>",
1590 "IS-IS commands\n"
1591 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001592 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001593{
jardineb5d44e2003-12-23 08:09:43 +00001594 int prio;
Josh Bailey3f045a02012-03-24 08:35:20 -07001595 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1596 if (!circuit)
1597 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001598
1599 prio = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001600 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1601 {
1602 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1603 prio, VTY_NEWLINE);
1604 return CMD_ERR_AMBIGUOUS;
1605 }
jardineb5d44e2003-12-23 08:09:43 +00001606
Josh Bailey3f045a02012-03-24 08:35:20 -07001607 circuit->priority[0] = prio;
1608 circuit->priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001609
jardineb5d44e2003-12-23 08:09:43 +00001610 return CMD_SUCCESS;
1611}
1612
1613DEFUN (no_isis_priority,
1614 no_isis_priority_cmd,
1615 "no isis priority",
1616 NO_STR
1617 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001618 "Set priority for Designated Router election\n")
jardineb5d44e2003-12-23 08:09:43 +00001619{
Josh Bailey3f045a02012-03-24 08:35:20 -07001620 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1621 if (!circuit)
1622 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001623
Josh Bailey3f045a02012-03-24 08:35:20 -07001624 circuit->priority[0] = DEFAULT_PRIORITY;
1625 circuit->priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001626
jardineb5d44e2003-12-23 08:09:43 +00001627 return CMD_SUCCESS;
1628}
1629
1630ALIAS (no_isis_priority,
1631 no_isis_priority_arg_cmd,
1632 "no isis priority <0-127>",
1633 NO_STR
1634 "IS-IS commands\n"
1635 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001636 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001637
1638DEFUN (isis_priority_l1,
1639 isis_priority_l1_cmd,
hassof390d2c2004-09-10 20:48:21 +00001640 "isis priority <0-127> level-1",
jardineb5d44e2003-12-23 08:09:43 +00001641 "IS-IS commands\n"
1642 "Set priority for Designated Router election\n"
1643 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001644 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001645{
jardineb5d44e2003-12-23 08:09:43 +00001646 int prio;
Josh Bailey3f045a02012-03-24 08:35:20 -07001647 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1648 if (!circuit)
1649 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001650
1651 prio = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001652 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1653 {
1654 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1655 prio, VTY_NEWLINE);
1656 return CMD_ERR_AMBIGUOUS;
1657 }
jardineb5d44e2003-12-23 08:09:43 +00001658
Josh Bailey3f045a02012-03-24 08:35:20 -07001659 circuit->priority[0] = prio;
hassof390d2c2004-09-10 20:48:21 +00001660
jardineb5d44e2003-12-23 08:09:43 +00001661 return CMD_SUCCESS;
1662}
1663
1664DEFUN (no_isis_priority_l1,
1665 no_isis_priority_l1_cmd,
1666 "no isis priority level-1",
1667 NO_STR
1668 "IS-IS commands\n"
1669 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001670 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001671{
Josh Bailey3f045a02012-03-24 08:35:20 -07001672 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1673 if (!circuit)
1674 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001675
Josh Bailey3f045a02012-03-24 08:35:20 -07001676 circuit->priority[0] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001677
jardineb5d44e2003-12-23 08:09:43 +00001678 return CMD_SUCCESS;
1679}
1680
1681ALIAS (no_isis_priority_l1,
1682 no_isis_priority_l1_arg_cmd,
1683 "no isis priority <0-127> level-1",
1684 NO_STR
1685 "IS-IS commands\n"
1686 "Set priority for Designated Router election\n"
1687 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001688 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001689
1690DEFUN (isis_priority_l2,
1691 isis_priority_l2_cmd,
hassof390d2c2004-09-10 20:48:21 +00001692 "isis priority <0-127> level-2",
jardineb5d44e2003-12-23 08:09:43 +00001693 "IS-IS commands\n"
1694 "Set priority for Designated Router election\n"
1695 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001696 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001697{
jardineb5d44e2003-12-23 08:09:43 +00001698 int prio;
Josh Bailey3f045a02012-03-24 08:35:20 -07001699 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1700 if (!circuit)
1701 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001702
1703 prio = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001704 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1705 {
1706 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1707 prio, VTY_NEWLINE);
1708 return CMD_ERR_AMBIGUOUS;
1709 }
jardineb5d44e2003-12-23 08:09:43 +00001710
Josh Bailey3f045a02012-03-24 08:35:20 -07001711 circuit->priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001712
jardineb5d44e2003-12-23 08:09:43 +00001713 return CMD_SUCCESS;
1714}
1715
1716DEFUN (no_isis_priority_l2,
1717 no_isis_priority_l2_cmd,
1718 "no isis priority level-2",
1719 NO_STR
1720 "IS-IS commands\n"
1721 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001722 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001723{
Josh Bailey3f045a02012-03-24 08:35:20 -07001724 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1725 if (!circuit)
1726 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001727
Josh Bailey3f045a02012-03-24 08:35:20 -07001728 circuit->priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001729
jardineb5d44e2003-12-23 08:09:43 +00001730 return CMD_SUCCESS;
1731}
1732
1733ALIAS (no_isis_priority_l2,
1734 no_isis_priority_l2_arg_cmd,
1735 "no isis priority <0-127> level-2",
1736 NO_STR
1737 "IS-IS commands\n"
1738 "Set priority for Designated Router election\n"
1739 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001740 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001741
1742/* Metric command */
Josh Bailey3f045a02012-03-24 08:35:20 -07001743DEFUN (isis_metric,
jardineb5d44e2003-12-23 08:09:43 +00001744 isis_metric_cmd,
hassof21fb272005-09-26 17:05:55 +00001745 "isis metric <0-16777215>",
jardineb5d44e2003-12-23 08:09:43 +00001746 "IS-IS commands\n"
1747 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001748 "Default metric value\n")
jardineb5d44e2003-12-23 08:09:43 +00001749{
jardineb5d44e2003-12-23 08:09:43 +00001750 int met;
Josh Bailey3f045a02012-03-24 08:35:20 -07001751 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1752 if (!circuit)
1753 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001754
1755 met = atoi (argv[0]);
1756
Josh Bailey3f045a02012-03-24 08:35:20 -07001757 /* RFC3787 section 5.1 */
1758 if (circuit->area && circuit->area->oldmetric == 1 &&
1759 met > MAX_NARROW_LINK_METRIC)
1760 {
1761 vty_out (vty, "Invalid metric %d - should be <0-63> "
1762 "when narrow metric type enabled%s",
1763 met, VTY_NEWLINE);
1764 return CMD_ERR_AMBIGUOUS;
1765 }
1766
1767 /* RFC4444 */
1768 if (circuit->area && circuit->area->newmetric == 1 &&
1769 met > MAX_WIDE_LINK_METRIC)
1770 {
1771 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1772 "when wide metric type enabled%s",
1773 met, VTY_NEWLINE);
1774 return CMD_ERR_AMBIGUOUS;
1775 }
1776
hassof21fb272005-09-26 17:05:55 +00001777 circuit->te_metric[0] = met;
1778 circuit->te_metric[1] = met;
1779
jardineb5d44e2003-12-23 08:09:43 +00001780 circuit->metrics[0].metric_default = met;
1781 circuit->metrics[1].metric_default = met;
1782
Josh Bailey3f045a02012-03-24 08:35:20 -07001783 if (circuit->area)
1784 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
1785
jardineb5d44e2003-12-23 08:09:43 +00001786 return CMD_SUCCESS;
1787}
1788
1789DEFUN (no_isis_metric,
1790 no_isis_metric_cmd,
1791 "no isis metric",
1792 NO_STR
1793 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001794 "Set default metric for circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001795{
Josh Bailey3f045a02012-03-24 08:35:20 -07001796 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1797 if (!circuit)
1798 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001799
Josh Bailey3f045a02012-03-24 08:35:20 -07001800 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
1801 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
1802 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
1803 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
jardineb5d44e2003-12-23 08:09:43 +00001804
Josh Bailey3f045a02012-03-24 08:35:20 -07001805 if (circuit->area)
1806 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
jardineb5d44e2003-12-23 08:09:43 +00001807
1808 return CMD_SUCCESS;
1809}
1810
1811ALIAS (no_isis_metric,
1812 no_isis_metric_arg_cmd,
hassof21fb272005-09-26 17:05:55 +00001813 "no isis metric <0-16777215>",
jardineb5d44e2003-12-23 08:09:43 +00001814 NO_STR
1815 "IS-IS commands\n"
1816 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001817 "Default metric value\n")
1818
Josh Bailey3f045a02012-03-24 08:35:20 -07001819DEFUN (isis_metric_l1,
1820 isis_metric_l1_cmd,
1821 "isis metric <0-16777215> level-1",
1822 "IS-IS commands\n"
1823 "Set default metric for circuit\n"
1824 "Default metric value\n"
1825 "Specify metric for level-1 routing\n")
1826{
1827 int met;
1828 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1829 if (!circuit)
1830 return CMD_ERR_NO_MATCH;
1831
1832 met = atoi (argv[0]);
1833
1834 /* RFC3787 section 5.1 */
1835 if (circuit->area && circuit->area->oldmetric == 1 &&
1836 met > MAX_NARROW_LINK_METRIC)
1837 {
1838 vty_out (vty, "Invalid metric %d - should be <0-63> "
1839 "when narrow metric type enabled%s",
1840 met, VTY_NEWLINE);
1841 return CMD_ERR_AMBIGUOUS;
1842 }
1843
1844 /* RFC4444 */
1845 if (circuit->area && circuit->area->newmetric == 1 &&
1846 met > MAX_WIDE_LINK_METRIC)
1847 {
1848 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1849 "when wide metric type enabled%s",
1850 met, VTY_NEWLINE);
1851 return CMD_ERR_AMBIGUOUS;
1852 }
1853
1854 circuit->te_metric[0] = met;
1855 circuit->metrics[0].metric_default = met;
1856
1857 if (circuit->area)
1858 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
1859
1860 return CMD_SUCCESS;
1861}
1862
1863DEFUN (no_isis_metric_l1,
1864 no_isis_metric_l1_cmd,
1865 "no isis metric level-1",
1866 NO_STR
1867 "IS-IS commands\n"
1868 "Set default metric for circuit\n"
1869 "Specify metric for level-1 routing\n")
1870{
1871 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1872 if (!circuit)
1873 return CMD_ERR_NO_MATCH;
1874
1875 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
1876 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
1877
1878 if (circuit->area)
1879 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
1880
1881 return CMD_SUCCESS;
1882}
1883
1884ALIAS (no_isis_metric_l1,
1885 no_isis_metric_l1_arg_cmd,
1886 "no isis metric <0-16777215> level-1",
1887 NO_STR
1888 "IS-IS commands\n"
1889 "Set default metric for circuit\n"
1890 "Default metric value\n"
1891 "Specify metric for level-1 routing\n")
1892
1893DEFUN (isis_metric_l2,
1894 isis_metric_l2_cmd,
1895 "isis metric <0-16777215> level-2",
1896 "IS-IS commands\n"
1897 "Set default metric for circuit\n"
1898 "Default metric value\n"
1899 "Specify metric for level-2 routing\n")
1900{
1901 int met;
1902 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1903 if (!circuit)
1904 return CMD_ERR_NO_MATCH;
1905
1906 met = atoi (argv[0]);
1907
1908 /* RFC3787 section 5.1 */
1909 if (circuit->area && circuit->area->oldmetric == 1 &&
1910 met > MAX_NARROW_LINK_METRIC)
1911 {
1912 vty_out (vty, "Invalid metric %d - should be <0-63> "
1913 "when narrow metric type enabled%s",
1914 met, VTY_NEWLINE);
1915 return CMD_ERR_AMBIGUOUS;
1916 }
1917
1918 /* RFC4444 */
1919 if (circuit->area && circuit->area->newmetric == 1 &&
1920 met > MAX_WIDE_LINK_METRIC)
1921 {
1922 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1923 "when wide metric type enabled%s",
1924 met, VTY_NEWLINE);
1925 return CMD_ERR_AMBIGUOUS;
1926 }
1927
1928 circuit->te_metric[1] = met;
1929 circuit->metrics[1].metric_default = met;
1930
1931 if (circuit->area)
1932 lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
1933
1934 return CMD_SUCCESS;
1935}
1936
1937DEFUN (no_isis_metric_l2,
1938 no_isis_metric_l2_cmd,
1939 "no isis metric level-2",
1940 NO_STR
1941 "IS-IS commands\n"
1942 "Set default metric for circuit\n"
1943 "Specify metric for level-2 routing\n")
1944{
1945 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1946 if (!circuit)
1947 return CMD_ERR_NO_MATCH;
1948
1949 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
1950 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
1951
1952 if (circuit->area)
1953 lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
1954
1955 return CMD_SUCCESS;
1956}
1957
1958ALIAS (no_isis_metric_l2,
1959 no_isis_metric_l2_arg_cmd,
1960 "no isis metric <0-16777215> level-2",
1961 NO_STR
1962 "IS-IS commands\n"
1963 "Set default metric for circuit\n"
1964 "Default metric value\n"
1965 "Specify metric for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001966/* end of metrics */
Josh Bailey3f045a02012-03-24 08:35:20 -07001967
hassof21fb272005-09-26 17:05:55 +00001968DEFUN (isis_hello_interval,
jardineb5d44e2003-12-23 08:09:43 +00001969 isis_hello_interval_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001970 "isis hello-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00001971 "IS-IS commands\n"
1972 "Set Hello interval\n"
1973 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001974 "Holdtime 1 seconds, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001975{
jardineb5d44e2003-12-23 08:09:43 +00001976 int interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07001977 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1978 if (!circuit)
1979 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001980
Josh Bailey3f045a02012-03-24 08:35:20 -07001981 interval = atoi (argv[0]);
1982 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00001983 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001984 vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s",
1985 interval, VTY_NEWLINE);
1986 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001987 }
jardineb5d44e2003-12-23 08:09:43 +00001988
hassof390d2c2004-09-10 20:48:21 +00001989 circuit->hello_interval[0] = (u_int16_t) interval;
1990 circuit->hello_interval[1] = (u_int16_t) interval;
1991
jardineb5d44e2003-12-23 08:09:43 +00001992 return CMD_SUCCESS;
1993}
1994
1995DEFUN (no_isis_hello_interval,
1996 no_isis_hello_interval_cmd,
1997 "no isis hello-interval",
1998 NO_STR
1999 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00002000 "Set Hello interval\n")
jardineb5d44e2003-12-23 08:09:43 +00002001{
Josh Bailey3f045a02012-03-24 08:35:20 -07002002 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2003 if (!circuit)
2004 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002005
Josh Bailey3f045a02012-03-24 08:35:20 -07002006 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
2007 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002008
jardineb5d44e2003-12-23 08:09:43 +00002009 return CMD_SUCCESS;
2010}
2011
2012ALIAS (no_isis_hello_interval,
2013 no_isis_hello_interval_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002014 "no isis hello-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00002015 NO_STR
2016 "IS-IS commands\n"
2017 "Set Hello interval\n"
2018 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00002019 "Holdtime 1 second, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00002020
2021DEFUN (isis_hello_interval_l1,
2022 isis_hello_interval_l1_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002023 "isis hello-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002024 "IS-IS commands\n"
2025 "Set Hello interval\n"
2026 "Hello interval value\n"
2027 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002028 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002029{
jardineb5d44e2003-12-23 08:09:43 +00002030 long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002031 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2032 if (!circuit)
2033 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002034
Josh Bailey3f045a02012-03-24 08:35:20 -07002035 interval = atoi (argv[0]);
2036 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002037 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002038 vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
2039 interval, VTY_NEWLINE);
2040 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00002041 }
jardineb5d44e2003-12-23 08:09:43 +00002042
hassof390d2c2004-09-10 20:48:21 +00002043 circuit->hello_interval[0] = (u_int16_t) interval;
2044
jardineb5d44e2003-12-23 08:09:43 +00002045 return CMD_SUCCESS;
2046}
2047
2048DEFUN (no_isis_hello_interval_l1,
2049 no_isis_hello_interval_l1_cmd,
2050 "no isis hello-interval level-1",
2051 NO_STR
2052 "IS-IS commands\n"
2053 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00002054 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002055{
Josh Bailey3f045a02012-03-24 08:35:20 -07002056 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2057 if (!circuit)
2058 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002059
Josh Bailey3f045a02012-03-24 08:35:20 -07002060 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002061
jardineb5d44e2003-12-23 08:09:43 +00002062 return CMD_SUCCESS;
2063}
2064
2065ALIAS (no_isis_hello_interval_l1,
2066 no_isis_hello_interval_l1_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002067 "no isis hello-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002068 NO_STR
2069 "IS-IS commands\n"
2070 "Set Hello interval\n"
2071 "Hello interval value\n"
2072 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002073 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002074
2075DEFUN (isis_hello_interval_l2,
2076 isis_hello_interval_l2_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002077 "isis hello-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002078 "IS-IS commands\n"
2079 "Set Hello interval\n"
2080 "Hello interval value\n"
2081 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002082 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002083{
jardineb5d44e2003-12-23 08:09:43 +00002084 long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002085 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2086 if (!circuit)
2087 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002088
Josh Bailey3f045a02012-03-24 08:35:20 -07002089 interval = atoi (argv[0]);
2090 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002091 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002092 vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
2093 interval, VTY_NEWLINE);
2094 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00002095 }
jardineb5d44e2003-12-23 08:09:43 +00002096
hassof390d2c2004-09-10 20:48:21 +00002097 circuit->hello_interval[1] = (u_int16_t) interval;
2098
jardineb5d44e2003-12-23 08:09:43 +00002099 return CMD_SUCCESS;
2100}
2101
2102DEFUN (no_isis_hello_interval_l2,
2103 no_isis_hello_interval_l2_cmd,
2104 "no isis hello-interval level-2",
2105 NO_STR
2106 "IS-IS commands\n"
2107 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00002108 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002109{
Josh Bailey3f045a02012-03-24 08:35:20 -07002110 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2111 if (!circuit)
2112 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002113
Josh Bailey3f045a02012-03-24 08:35:20 -07002114 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002115
jardineb5d44e2003-12-23 08:09:43 +00002116 return CMD_SUCCESS;
2117}
2118
2119ALIAS (no_isis_hello_interval_l2,
2120 no_isis_hello_interval_l2_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002121 "no isis hello-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002122 NO_STR
2123 "IS-IS commands\n"
2124 "Set Hello interval\n"
2125 "Hello interval value\n"
2126 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002127 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002128
2129DEFUN (isis_hello_multiplier,
2130 isis_hello_multiplier_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002131 "isis hello-multiplier <2-100>",
jardineb5d44e2003-12-23 08:09:43 +00002132 "IS-IS commands\n"
2133 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002134 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00002135{
jardineb5d44e2003-12-23 08:09:43 +00002136 int mult;
Josh Bailey3f045a02012-03-24 08:35:20 -07002137 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2138 if (!circuit)
2139 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002140
2141 mult = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002142 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2143 {
2144 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2145 mult, VTY_NEWLINE);
2146 return CMD_ERR_AMBIGUOUS;
2147 }
jardineb5d44e2003-12-23 08:09:43 +00002148
hassof390d2c2004-09-10 20:48:21 +00002149 circuit->hello_multiplier[0] = (u_int16_t) mult;
2150 circuit->hello_multiplier[1] = (u_int16_t) mult;
2151
jardineb5d44e2003-12-23 08:09:43 +00002152 return CMD_SUCCESS;
2153}
2154
2155DEFUN (no_isis_hello_multiplier,
2156 no_isis_hello_multiplier_cmd,
2157 "no isis hello-multiplier",
2158 NO_STR
2159 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00002160 "Set multiplier for Hello holding time\n")
jardineb5d44e2003-12-23 08:09:43 +00002161{
Josh Bailey3f045a02012-03-24 08:35:20 -07002162 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2163 if (!circuit)
2164 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002165
Josh Bailey3f045a02012-03-24 08:35:20 -07002166 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
2167 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
jardineb5d44e2003-12-23 08:09:43 +00002168
2169 return CMD_SUCCESS;
2170}
2171
2172ALIAS (no_isis_hello_multiplier,
2173 no_isis_hello_multiplier_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002174 "no isis hello-multiplier <2-100>",
jardineb5d44e2003-12-23 08:09:43 +00002175 NO_STR
2176 "IS-IS commands\n"
2177 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002178 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00002179
2180DEFUN (isis_hello_multiplier_l1,
2181 isis_hello_multiplier_l1_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002182 "isis hello-multiplier <2-100> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002183 "IS-IS commands\n"
2184 "Set multiplier for Hello holding time\n"
2185 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002186 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002187{
jardineb5d44e2003-12-23 08:09:43 +00002188 int mult;
Josh Bailey3f045a02012-03-24 08:35:20 -07002189 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2190 if (!circuit)
2191 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002192
2193 mult = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002194 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2195 {
2196 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2197 mult, VTY_NEWLINE);
2198 return CMD_ERR_AMBIGUOUS;
2199 }
jardineb5d44e2003-12-23 08:09:43 +00002200
hassof390d2c2004-09-10 20:48:21 +00002201 circuit->hello_multiplier[0] = (u_int16_t) mult;
2202
jardineb5d44e2003-12-23 08:09:43 +00002203 return CMD_SUCCESS;
2204}
2205
2206DEFUN (no_isis_hello_multiplier_l1,
2207 no_isis_hello_multiplier_l1_cmd,
2208 "no isis hello-multiplier level-1",
2209 NO_STR
2210 "IS-IS commands\n"
2211 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002212 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002213{
Josh Bailey3f045a02012-03-24 08:35:20 -07002214 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2215 if (!circuit)
2216 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002217
Josh Bailey3f045a02012-03-24 08:35:20 -07002218 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
jardineb5d44e2003-12-23 08:09:43 +00002219
2220 return CMD_SUCCESS;
2221}
2222
2223ALIAS (no_isis_hello_multiplier_l1,
2224 no_isis_hello_multiplier_l1_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002225 "no isis hello-multiplier <2-100> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002226 NO_STR
2227 "IS-IS commands\n"
2228 "Set multiplier for Hello holding time\n"
2229 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002230 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002231
2232DEFUN (isis_hello_multiplier_l2,
2233 isis_hello_multiplier_l2_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002234 "isis hello-multiplier <2-100> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002235 "IS-IS commands\n"
2236 "Set multiplier for Hello holding time\n"
2237 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002238 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002239{
jardineb5d44e2003-12-23 08:09:43 +00002240 int mult;
Josh Bailey3f045a02012-03-24 08:35:20 -07002241 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2242 if (!circuit)
2243 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002244
2245 mult = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002246 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2247 {
2248 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2249 mult, VTY_NEWLINE);
2250 return CMD_ERR_AMBIGUOUS;
2251 }
jardineb5d44e2003-12-23 08:09:43 +00002252
hassof390d2c2004-09-10 20:48:21 +00002253 circuit->hello_multiplier[1] = (u_int16_t) mult;
2254
jardineb5d44e2003-12-23 08:09:43 +00002255 return CMD_SUCCESS;
2256}
2257
2258DEFUN (no_isis_hello_multiplier_l2,
2259 no_isis_hello_multiplier_l2_cmd,
2260 "no isis hello-multiplier level-2",
2261 NO_STR
2262 "IS-IS commands\n"
2263 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002264 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002265{
Josh Bailey3f045a02012-03-24 08:35:20 -07002266 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2267 if (!circuit)
2268 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002269
Josh Bailey3f045a02012-03-24 08:35:20 -07002270 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
jardineb5d44e2003-12-23 08:09:43 +00002271
2272 return CMD_SUCCESS;
2273}
2274
2275ALIAS (no_isis_hello_multiplier_l2,
2276 no_isis_hello_multiplier_l2_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002277 "no isis hello-multiplier <2-100> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002278 NO_STR
2279 "IS-IS commands\n"
2280 "Set multiplier for Hello holding time\n"
2281 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002282 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002283
Josh Bailey3f045a02012-03-24 08:35:20 -07002284DEFUN (isis_hello_padding,
2285 isis_hello_padding_cmd,
jardineb5d44e2003-12-23 08:09:43 +00002286 "isis hello padding",
2287 "IS-IS commands\n"
2288 "Add padding to IS-IS hello packets\n"
2289 "Pad hello packets\n"
2290 "<cr>\n")
2291{
Josh Bailey3f045a02012-03-24 08:35:20 -07002292 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2293 if (!circuit)
2294 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002295
Josh Bailey3f045a02012-03-24 08:35:20 -07002296 circuit->pad_hellos = 1;
hassof390d2c2004-09-10 20:48:21 +00002297
jardineb5d44e2003-12-23 08:09:43 +00002298 return CMD_SUCCESS;
2299}
2300
Josh Bailey3f045a02012-03-24 08:35:20 -07002301DEFUN (no_isis_hello_padding,
2302 no_isis_hello_padding_cmd,
jardineb5d44e2003-12-23 08:09:43 +00002303 "no isis hello padding",
2304 NO_STR
2305 "IS-IS commands\n"
2306 "Add padding to IS-IS hello packets\n"
2307 "Pad hello packets\n"
2308 "<cr>\n")
2309{
Josh Bailey3f045a02012-03-24 08:35:20 -07002310 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2311 if (!circuit)
2312 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002313
Josh Bailey3f045a02012-03-24 08:35:20 -07002314 circuit->pad_hellos = 0;
hassof390d2c2004-09-10 20:48:21 +00002315
jardineb5d44e2003-12-23 08:09:43 +00002316 return CMD_SUCCESS;
2317}
2318
2319DEFUN (csnp_interval,
2320 csnp_interval_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002321 "isis csnp-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00002322 "IS-IS commands\n"
2323 "Set CSNP interval in seconds\n"
2324 "CSNP interval value\n")
2325{
jardineb5d44e2003-12-23 08:09:43 +00002326 unsigned long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002327 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2328 if (!circuit)
2329 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002330
jardineb5d44e2003-12-23 08:09:43 +00002331 interval = atol (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002332 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2333 {
2334 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2335 interval, VTY_NEWLINE);
2336 return CMD_ERR_AMBIGUOUS;
2337 }
jardineb5d44e2003-12-23 08:09:43 +00002338
hassof390d2c2004-09-10 20:48:21 +00002339 circuit->csnp_interval[0] = (u_int16_t) interval;
2340 circuit->csnp_interval[1] = (u_int16_t) interval;
2341
jardineb5d44e2003-12-23 08:09:43 +00002342 return CMD_SUCCESS;
2343}
2344
2345DEFUN (no_csnp_interval,
2346 no_csnp_interval_cmd,
2347 "no isis csnp-interval",
2348 NO_STR
2349 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00002350 "Set CSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002351{
Josh Bailey3f045a02012-03-24 08:35:20 -07002352 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2353 if (!circuit)
2354 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002355
Josh Bailey3f045a02012-03-24 08:35:20 -07002356 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
2357 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002358
jardineb5d44e2003-12-23 08:09:43 +00002359 return CMD_SUCCESS;
2360}
2361
2362ALIAS (no_csnp_interval,
2363 no_csnp_interval_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002364 "no isis csnp-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00002365 NO_STR
2366 "IS-IS commands\n"
2367 "Set CSNP interval in seconds\n"
2368 "CSNP interval value\n")
2369
jardineb5d44e2003-12-23 08:09:43 +00002370DEFUN (csnp_interval_l1,
2371 csnp_interval_l1_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002372 "isis csnp-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002373 "IS-IS commands\n"
2374 "Set CSNP interval in seconds\n"
2375 "CSNP interval value\n"
2376 "Specify interval for level-1 CSNPs\n")
2377{
jardineb5d44e2003-12-23 08:09:43 +00002378 unsigned long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002379 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2380 if (!circuit)
2381 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002382
jardineb5d44e2003-12-23 08:09:43 +00002383 interval = atol (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002384 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2385 {
2386 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2387 interval, VTY_NEWLINE);
2388 return CMD_ERR_AMBIGUOUS;
2389 }
hassof390d2c2004-09-10 20:48:21 +00002390
2391 circuit->csnp_interval[0] = (u_int16_t) interval;
2392
jardineb5d44e2003-12-23 08:09:43 +00002393 return CMD_SUCCESS;
2394}
2395
2396DEFUN (no_csnp_interval_l1,
2397 no_csnp_interval_l1_cmd,
2398 "no isis csnp-interval level-1",
2399 NO_STR
2400 "IS-IS commands\n"
2401 "Set CSNP interval in seconds\n"
2402 "Specify interval for level-1 CSNPs\n")
2403{
Josh Bailey3f045a02012-03-24 08:35:20 -07002404 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2405 if (!circuit)
2406 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002407
Josh Bailey3f045a02012-03-24 08:35:20 -07002408 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002409
jardineb5d44e2003-12-23 08:09:43 +00002410 return CMD_SUCCESS;
2411}
2412
2413ALIAS (no_csnp_interval_l1,
2414 no_csnp_interval_l1_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002415 "no isis csnp-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002416 NO_STR
2417 "IS-IS commands\n"
2418 "Set CSNP interval in seconds\n"
2419 "CSNP interval value\n"
2420 "Specify interval for level-1 CSNPs\n")
2421
jardineb5d44e2003-12-23 08:09:43 +00002422DEFUN (csnp_interval_l2,
2423 csnp_interval_l2_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002424 "isis csnp-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002425 "IS-IS commands\n"
2426 "Set CSNP interval in seconds\n"
2427 "CSNP interval value\n"
2428 "Specify interval for level-2 CSNPs\n")
2429{
jardineb5d44e2003-12-23 08:09:43 +00002430 unsigned long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002431 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2432 if (!circuit)
2433 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002434
jardineb5d44e2003-12-23 08:09:43 +00002435 interval = atol (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002436 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2437 {
2438 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2439 interval, VTY_NEWLINE);
2440 return CMD_ERR_AMBIGUOUS;
2441 }
hassof390d2c2004-09-10 20:48:21 +00002442
2443 circuit->csnp_interval[1] = (u_int16_t) interval;
2444
jardineb5d44e2003-12-23 08:09:43 +00002445 return CMD_SUCCESS;
2446}
2447
2448DEFUN (no_csnp_interval_l2,
2449 no_csnp_interval_l2_cmd,
2450 "no isis csnp-interval level-2",
2451 NO_STR
2452 "IS-IS commands\n"
2453 "Set CSNP interval in seconds\n"
2454 "Specify interval for level-2 CSNPs\n")
2455{
Josh Bailey3f045a02012-03-24 08:35:20 -07002456 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2457 if (!circuit)
2458 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002459
Josh Bailey3f045a02012-03-24 08:35:20 -07002460 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002461
jardineb5d44e2003-12-23 08:09:43 +00002462 return CMD_SUCCESS;
2463}
2464
2465ALIAS (no_csnp_interval_l2,
2466 no_csnp_interval_l2_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002467 "no isis csnp-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002468 NO_STR
2469 "IS-IS commands\n"
2470 "Set CSNP interval in seconds\n"
2471 "CSNP interval value\n"
2472 "Specify interval for level-2 CSNPs\n")
2473
Josh Bailey3f045a02012-03-24 08:35:20 -07002474DEFUN (psnp_interval,
2475 psnp_interval_cmd,
2476 "isis psnp-interval <1-120>",
2477 "IS-IS commands\n"
2478 "Set PSNP interval in seconds\n"
2479 "PSNP interval value\n")
jardineb5d44e2003-12-23 08:09:43 +00002480{
Josh Bailey3f045a02012-03-24 08:35:20 -07002481 unsigned long interval;
2482 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2483 if (!circuit)
2484 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002485
Josh Bailey3f045a02012-03-24 08:35:20 -07002486 interval = atol (argv[0]);
2487 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002488 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002489 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2490 interval, VTY_NEWLINE);
2491 return CMD_ERR_AMBIGUOUS;
jardineb5d44e2003-12-23 08:09:43 +00002492 }
jardineb5d44e2003-12-23 08:09:43 +00002493
Josh Bailey3f045a02012-03-24 08:35:20 -07002494 circuit->psnp_interval[0] = (u_int16_t) interval;
2495 circuit->psnp_interval[1] = (u_int16_t) interval;
jardineb5d44e2003-12-23 08:09:43 +00002496
2497 return CMD_SUCCESS;
2498}
2499
Josh Bailey3f045a02012-03-24 08:35:20 -07002500DEFUN (no_psnp_interval,
2501 no_psnp_interval_cmd,
2502 "no isis psnp-interval",
jardineb5d44e2003-12-23 08:09:43 +00002503 NO_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002504 "IS-IS commands\n"
2505 "Set PSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002506{
Josh Bailey3f045a02012-03-24 08:35:20 -07002507 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2508 if (!circuit)
2509 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002510
Josh Bailey3f045a02012-03-24 08:35:20 -07002511 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
2512 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
jardineb5d44e2003-12-23 08:09:43 +00002513
2514 return CMD_SUCCESS;
2515}
jardineb5d44e2003-12-23 08:09:43 +00002516
Josh Bailey3f045a02012-03-24 08:35:20 -07002517ALIAS (no_psnp_interval,
2518 no_psnp_interval_arg_cmd,
2519 "no isis psnp-interval <1-120>",
2520 NO_STR
2521 "IS-IS commands\n"
2522 "Set PSNP interval in seconds\n"
2523 "PSNP interval value\n")
2524
2525DEFUN (psnp_interval_l1,
2526 psnp_interval_l1_cmd,
2527 "isis psnp-interval <1-120> level-1",
2528 "IS-IS commands\n"
2529 "Set PSNP interval in seconds\n"
2530 "PSNP interval value\n"
2531 "Specify interval for level-1 PSNPs\n")
2532{
2533 unsigned long interval;
2534 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2535 if (!circuit)
2536 return CMD_ERR_NO_MATCH;
2537
2538 interval = atol (argv[0]);
2539 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2540 {
2541 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2542 interval, VTY_NEWLINE);
2543 return CMD_ERR_AMBIGUOUS;
2544 }
2545
2546 circuit->psnp_interval[0] = (u_int16_t) interval;
2547
2548 return CMD_SUCCESS;
2549}
2550
2551DEFUN (no_psnp_interval_l1,
2552 no_psnp_interval_l1_cmd,
2553 "no isis psnp-interval level-1",
2554 NO_STR
2555 "IS-IS commands\n"
2556 "Set PSNP interval in seconds\n"
2557 "Specify interval for level-1 PSNPs\n")
2558{
2559 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2560 if (!circuit)
2561 return CMD_ERR_NO_MATCH;
2562
2563 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
2564
2565 return CMD_SUCCESS;
2566}
2567
2568ALIAS (no_psnp_interval_l1,
2569 no_psnp_interval_l1_arg_cmd,
2570 "no isis psnp-interval <1-120> level-1",
2571 NO_STR
2572 "IS-IS commands\n"
2573 "Set PSNP interval in seconds\n"
2574 "PSNP interval value\n"
2575 "Specify interval for level-1 PSNPs\n")
2576
2577DEFUN (psnp_interval_l2,
2578 psnp_interval_l2_cmd,
2579 "isis psnp-interval <1-120> level-2",
2580 "IS-IS commands\n"
2581 "Set PSNP interval in seconds\n"
2582 "PSNP interval value\n"
2583 "Specify interval for level-2 PSNPs\n")
2584{
2585 unsigned long interval;
2586 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2587 if (!circuit)
2588 return CMD_ERR_NO_MATCH;
2589
2590 interval = atol (argv[0]);
2591 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2592 {
2593 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2594 interval, VTY_NEWLINE);
2595 return CMD_ERR_AMBIGUOUS;
2596 }
2597
2598 circuit->psnp_interval[1] = (u_int16_t) interval;
2599
2600 return CMD_SUCCESS;
2601}
2602
2603DEFUN (no_psnp_interval_l2,
2604 no_psnp_interval_l2_cmd,
2605 "no isis psnp-interval level-2",
2606 NO_STR
2607 "IS-IS commands\n"
2608 "Set PSNP interval in seconds\n"
2609 "Specify interval for level-2 PSNPs\n")
2610{
2611 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2612 if (!circuit)
2613 return CMD_ERR_NO_MATCH;
2614
2615 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
2616
2617 return CMD_SUCCESS;
2618}
2619
2620ALIAS (no_psnp_interval_l2,
2621 no_psnp_interval_l2_arg_cmd,
2622 "no isis psnp-interval <1-120> level-2",
2623 NO_STR
2624 "IS-IS commands\n"
2625 "Set PSNP interval in seconds\n"
2626 "PSNP interval value\n"
2627 "Specify interval for level-2 PSNPs\n")
2628
2629struct cmd_node interface_node = {
jardineb5d44e2003-12-23 08:09:43 +00002630 INTERFACE_NODE,
2631 "%s(config-if)# ",
2632 1,
2633};
2634
Josh Bailey3f045a02012-03-24 08:35:20 -07002635DEFUN (isis_network,
2636 isis_network_cmd,
2637 "isis network point-to-point",
2638 "IS-IS commands\n"
2639 "Set network type\n"
2640 "point-to-point network type\n")
2641{
2642 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2643 if (!circuit)
2644 return CMD_ERR_NO_MATCH;
2645
2646 /* RFC5309 section 4 */
2647 if (circuit->circ_type == CIRCUIT_T_P2P)
2648 return CMD_SUCCESS;
2649
2650 if (circuit->state != C_STATE_UP)
2651 {
2652 circuit->circ_type = CIRCUIT_T_P2P;
2653 circuit->circ_type_config = CIRCUIT_T_P2P;
2654 }
2655 else
2656 {
2657 struct isis_area *area = circuit->area;
2658 if (!if_is_broadcast (circuit->interface))
2659 {
2660 vty_out (vty, "isis network point-to-point "
2661 "is valid only on broadcast interfaces%s",
2662 VTY_NEWLINE);
2663 return CMD_ERR_AMBIGUOUS;
2664 }
2665
2666 isis_csm_state_change (ISIS_DISABLE, circuit, area);
2667 circuit->circ_type = CIRCUIT_T_P2P;
2668 circuit->circ_type_config = CIRCUIT_T_P2P;
2669 isis_csm_state_change (ISIS_ENABLE, circuit, area);
2670 }
2671
2672 return CMD_SUCCESS;
2673}
2674
2675DEFUN (no_isis_network,
2676 no_isis_network_cmd,
2677 "no isis network point-to-point",
2678 NO_STR
2679 "IS-IS commands\n"
2680 "Set network type for circuit\n"
2681 "point-to-point network type\n")
2682{
2683 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2684 if (!circuit)
2685 return CMD_ERR_NO_MATCH;
2686
2687 /* RFC5309 section 4 */
2688 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
2689 return CMD_SUCCESS;
2690
2691 if (circuit->state != C_STATE_UP)
2692 {
2693 circuit->circ_type = CIRCUIT_T_BROADCAST;
2694 circuit->circ_type_config = CIRCUIT_T_BROADCAST;
2695 }
2696 else
2697 {
2698 struct isis_area *area = circuit->area;
2699 if (circuit->interface &&
2700 !if_is_broadcast (circuit->interface))
2701 {
2702 vty_out (vty, "no isis network point-to-point "
2703 "is valid only on broadcast interfaces%s",
2704 VTY_NEWLINE);
2705 return CMD_ERR_AMBIGUOUS;
2706 }
2707
2708 isis_csm_state_change (ISIS_DISABLE, circuit, area);
2709 circuit->circ_type = CIRCUIT_T_BROADCAST;
2710 circuit->circ_type_config = CIRCUIT_T_BROADCAST;
2711 isis_csm_state_change (ISIS_ENABLE, circuit, area);
2712 }
2713
2714 return CMD_SUCCESS;
2715}
2716
jardineb5d44e2003-12-23 08:09:43 +00002717int
2718isis_if_new_hook (struct interface *ifp)
2719{
jardineb5d44e2003-12-23 08:09:43 +00002720 return 0;
2721}
2722
2723int
2724isis_if_delete_hook (struct interface *ifp)
2725{
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002726 struct isis_circuit *circuit;
2727 /* Clean up the circuit data */
2728 if (ifp && ifp->info)
2729 {
2730 circuit = ifp->info;
2731 isis_csm_state_change (IF_DOWN_FROM_Z, circuit, circuit->area);
2732 isis_csm_state_change (ISIS_DISABLE, circuit, circuit->area);
2733 }
2734
jardineb5d44e2003-12-23 08:09:43 +00002735 return 0;
2736}
2737
jardineb5d44e2003-12-23 08:09:43 +00002738void
2739isis_circuit_init ()
2740{
jardineb5d44e2003-12-23 08:09:43 +00002741 /* Initialize Zebra interface data structure */
jardineb5d44e2003-12-23 08:09:43 +00002742 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2743 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2744
2745 /* Install interface node */
2746 install_node (&interface_node, isis_interface_config_write);
2747 install_element (CONFIG_NODE, &interface_cmd);
Subbaiah Venkatae38e0df2012-03-27 23:48:05 -07002748 install_element (CONFIG_NODE, &no_interface_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002749
2750 install_default (INTERFACE_NODE);
2751 install_element (INTERFACE_NODE, &interface_desc_cmd);
2752 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2753
2754 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2755 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2756
Josh Bailey3f045a02012-03-24 08:35:20 -07002757 install_element (INTERFACE_NODE, &isis_passive_cmd);
2758 install_element (INTERFACE_NODE, &no_isis_passive_cmd);
2759
jardineb5d44e2003-12-23 08:09:43 +00002760 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2761 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2762
Josh Bailey3f045a02012-03-24 08:35:20 -07002763 install_element (INTERFACE_NODE, &isis_passwd_clear_cmd);
2764 install_element (INTERFACE_NODE, &isis_passwd_md5_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002765 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2766
2767 install_element (INTERFACE_NODE, &isis_priority_cmd);
2768 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2769 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2770 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2771 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2772 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2773 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2774 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2775 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2776
2777 install_element (INTERFACE_NODE, &isis_metric_cmd);
2778 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2779 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07002780 install_element (INTERFACE_NODE, &isis_metric_l1_cmd);
2781 install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd);
2782 install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd);
2783 install_element (INTERFACE_NODE, &isis_metric_l2_cmd);
2784 install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd);
2785 install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002786
2787 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2788 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2789 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2790 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2791 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2792 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2793 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2794 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2795 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2796
2797 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2798 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2799 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2800 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2801 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2802 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2803 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2804 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2805 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2806
Josh Bailey3f045a02012-03-24 08:35:20 -07002807 install_element (INTERFACE_NODE, &isis_hello_padding_cmd);
2808 install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd);
2809
jardineb5d44e2003-12-23 08:09:43 +00002810 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2811 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2812 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2813 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2814 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2815 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2816 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2817 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2818 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2819
Josh Bailey3f045a02012-03-24 08:35:20 -07002820 install_element (INTERFACE_NODE, &psnp_interval_cmd);
2821 install_element (INTERFACE_NODE, &no_psnp_interval_cmd);
2822 install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd);
2823 install_element (INTERFACE_NODE, &psnp_interval_l1_cmd);
2824 install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd);
2825 install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd);
2826 install_element (INTERFACE_NODE, &psnp_interval_l2_cmd);
2827 install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd);
2828 install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd);
2829
2830 install_element (INTERFACE_NODE, &isis_network_cmd);
2831 install_element (INTERFACE_NODE, &no_isis_network_cmd);
2832
jardineb5d44e2003-12-23 08:09:43 +00002833#ifdef HAVE_IPV6
2834 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2835 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002836#endif
jardineb5d44e2003-12-23 08:09:43 +00002837}