blob: cb439e87743f5afe4be70abd78343cde200f7d73 [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 }
330 }
331#ifdef HAVE_IPV6
332 if (connected->address->family == AF_INET6)
333 {
334 ipv6 = prefix_ipv6_new ();
335 ipv6->prefixlen = connected->address->prefixlen;
336 ipv6->prefix = connected->address->u.prefix6;
337
338 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
339 {
paul1eb8ef22005-04-07 07:30:20 +0000340 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
hassof891f442004-09-14 13:54:30 +0000341 {
hassof891f442004-09-14 13:54:30 +0000342 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
343 break;
344 }
345 if (ip6)
346 {
347 listnode_delete (circuit->ipv6_link, ip6);
348 found = 1;
349 }
350 }
351 else
352 {
paul1eb8ef22005-04-07 07:30:20 +0000353 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
hassof891f442004-09-14 13:54:30 +0000354 {
hassof891f442004-09-14 13:54:30 +0000355 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
356 break;
357 }
358 if (ip6)
359 {
360 listnode_delete (circuit->ipv6_non_link, ip6);
361 found = 1;
362 }
363 }
364
365 if (!found)
366 {
hassof7c43dc2004-09-26 16:24:14 +0000367 prefix2str (connected->address, (char *)buf, BUFSIZ);
Josh Bailey3f045a02012-03-24 08:35:20 -0700368 zlog_warn ("Nonexitant ip address %s removal attempt from \
369 circuit %d", buf, circuit->circuit_id);
hassof891f442004-09-14 13:54:30 +0000370 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700371 else if (circuit->area)
372 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
hassof891f442004-09-14 13:54:30 +0000373 }
374#endif /* HAVE_IPV6 */
375 return;
jardineb5d44e2003-12-23 08:09:43 +0000376}
377
Josh Bailey3f045a02012-03-24 08:35:20 -0700378static u_char
379isis_circuit_id_gen (struct interface *ifp)
380{
381 u_char id = 0;
382 char ifname[16];
383 unsigned int i;
384 int start = -1, end = -1;
385
386 /*
387 * Get a stable circuit id from ifname. This makes
388 * the ifindex from flapping when netdevs are created
389 * and deleted on the fly. Note that this circuit id
390 * is used in pseudo lsps so it is better to be stable.
391 * The following code works on any reasonanle ifname
392 * like: eth1 or trk-1.1 etc.
393 */
394 for (i = 0; i < strlen (ifp->name); i++)
395 {
396 if (isdigit(ifp->name[i]))
397 {
398 if (start < 0)
399 {
400 start = i;
401 end = i + 1;
402 }
403 else
404 {
405 end = i + 1;
406 }
407 }
408 else if (start >= 0)
409 break;
410 }
411
412 if ((start >= 0) && (end >= start) && (end - start) < 16)
413 {
414 memset (ifname, 0, 16);
415 strncpy (ifname, &ifp->name[start], end - start);
416 id = (u_char)atoi(ifname);
417 }
418
419 /* Try to be unique. */
420 if (!id)
421 id = (u_char)((ifp->ifindex & 0xff) | 0x80);
422
423 return id;
424}
425
jardineb5d44e2003-12-23 08:09:43 +0000426void
427isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
428{
paul1eb8ef22005-04-07 07:30:20 +0000429 struct listnode *node, *nnode;
jardineb5d44e2003-12-23 08:09:43 +0000430 struct connected *conn;
431
Josh Bailey3f045a02012-03-24 08:35:20 -0700432 circuit->circuit_id = isis_circuit_id_gen (ifp);
hassof390d2c2004-09-10 20:48:21 +0000433
Josh Bailey3f045a02012-03-24 08:35:20 -0700434 isis_circuit_if_bind (circuit, ifp);
jardineb5d44e2003-12-23 08:09:43 +0000435 /* isis_circuit_update_addrs (circuit, ifp); */
436
hassof390d2c2004-09-10 20:48:21 +0000437 if (if_is_broadcast (ifp))
438 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700439 if (circuit->circ_type_config == CIRCUIT_T_P2P)
440 circuit->circ_type = CIRCUIT_T_P2P;
hassof390d2c2004-09-10 20:48:21 +0000441 else
Josh Bailey3f045a02012-03-24 08:35:20 -0700442 circuit->circ_type = CIRCUIT_T_BROADCAST;
hassof390d2c2004-09-10 20:48:21 +0000443 }
444 else if (if_is_pointopoint (ifp))
445 {
446 circuit->circ_type = CIRCUIT_T_P2P;
447 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700448 else if (if_is_loopback (ifp))
449 {
450 circuit->circ_type = CIRCUIT_T_LOOPBACK;
451 circuit->is_passive = 1;
452 }
hassof390d2c2004-09-10 20:48:21 +0000453 else
454 {
hassoc89c05d2005-09-04 21:36:36 +0000455 /* It's normal in case of loopback etc. */
456 if (isis->debugs & DEBUG_EVENTS)
Josh Bailey3f045a02012-03-24 08:35:20 -0700457 zlog_debug ("isis_circuit_if_add: unsupported media");
458 circuit->circ_type = CIRCUIT_T_UNKNOWN;
hassof390d2c2004-09-10 20:48:21 +0000459 }
460
Josh Bailey3f045a02012-03-24 08:35:20 -0700461 circuit->ip_addrs = list_new ();
462#ifdef HAVE_IPV6
463 circuit->ipv6_link = list_new ();
464 circuit->ipv6_non_link = list_new ();
465#endif /* HAVE_IPV6 */
466
paul1eb8ef22005-04-07 07:30:20 +0000467 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
468 isis_circuit_add_addr (circuit, conn);
jardineb5d44e2003-12-23 08:09:43 +0000469
470 return;
471}
472
473void
Josh Bailey3f045a02012-03-24 08:35:20 -0700474isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000475{
Josh Bailey3f045a02012-03-24 08:35:20 -0700476 struct listnode *node, *nnode;
477 struct connected *conn;
hassof390d2c2004-09-10 20:48:21 +0000478
Josh Bailey3f045a02012-03-24 08:35:20 -0700479 assert (circuit->interface == ifp);
480
481 /* destroy addresses */
482 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
483 isis_circuit_del_addr (circuit, conn);
484
485 if (circuit->ip_addrs)
hassof390d2c2004-09-10 20:48:21 +0000486 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700487 assert (listcount(circuit->ip_addrs) == 0);
488 list_delete (circuit->ip_addrs);
489 circuit->ip_addrs = NULL;
hassof390d2c2004-09-10 20:48:21 +0000490 }
jardineb5d44e2003-12-23 08:09:43 +0000491
Josh Bailey3f045a02012-03-24 08:35:20 -0700492#ifdef HAVE_IPV6
493 if (circuit->ipv6_link)
hassof390d2c2004-09-10 20:48:21 +0000494 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700495 assert (listcount(circuit->ipv6_link) == 0);
496 list_delete (circuit->ipv6_link);
497 circuit->ipv6_link = NULL;
jardineb5d44e2003-12-23 08:09:43 +0000498 }
jardineb5d44e2003-12-23 08:09:43 +0000499
Josh Bailey3f045a02012-03-24 08:35:20 -0700500 if (circuit->ipv6_non_link)
hassof390d2c2004-09-10 20:48:21 +0000501 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700502 assert (listcount(circuit->ipv6_non_link) == 0);
503 list_delete (circuit->ipv6_non_link);
504 circuit->ipv6_non_link = NULL;
hassof390d2c2004-09-10 20:48:21 +0000505 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700506#endif /* HAVE_IPV6 */
507
508 circuit->circ_type = CIRCUIT_T_UNKNOWN;
509 circuit->circuit_id = 0;
jardineb5d44e2003-12-23 08:09:43 +0000510
jardineb5d44e2003-12-23 08:09:43 +0000511 return;
512}
513
514void
Josh Bailey3f045a02012-03-24 08:35:20 -0700515isis_circuit_if_bind (struct isis_circuit *circuit, struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000516{
Josh Bailey3f045a02012-03-24 08:35:20 -0700517 assert (circuit != NULL);
518 assert (ifp != NULL);
519 if (circuit->interface)
520 assert (circuit->interface == ifp);
521 else
522 circuit->interface = ifp;
523 if (ifp->info)
524 assert (ifp->info == circuit);
525 else
526 ifp->info = circuit;
527}
528
529void
530isis_circuit_if_unbind (struct isis_circuit *circuit, struct interface *ifp)
531{
532 assert (circuit != NULL);
533 assert (ifp != NULL);
534 assert (circuit->interface == ifp);
535 assert (ifp->info == circuit);
jardineb5d44e2003-12-23 08:09:43 +0000536 circuit->interface = NULL;
Josh Bailey3f045a02012-03-24 08:35:20 -0700537 ifp->info = NULL;
jardineb5d44e2003-12-23 08:09:43 +0000538}
539
Josh Bailey3f045a02012-03-24 08:35:20 -0700540static void
541isis_circuit_update_all_srmflags (struct isis_circuit *circuit, int is_set)
542{
543 struct isis_area *area;
544 struct isis_lsp *lsp;
545 dnode_t *dnode, *dnode_next;
546 int level;
547
548 assert (circuit);
549 area = circuit->area;
550 assert (area);
551 for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++)
552 {
553 if (level & circuit->is_type)
554 {
555 if (area->lspdb[level - 1] &&
556 dict_count (area->lspdb[level - 1]) > 0)
557 {
558 for (dnode = dict_first (area->lspdb[level - 1]);
559 dnode != NULL; dnode = dnode_next)
560 {
561 dnode_next = dict_next (area->lspdb[level - 1], dnode);
562 lsp = dnode_get (dnode);
563 if (is_set)
564 {
565 ISIS_SET_FLAG (lsp->SRMflags, circuit);
566 }
567 else
568 {
569 ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
570 }
571 }
572 }
573 }
574 }
575}
576
577int
jardineb5d44e2003-12-23 08:09:43 +0000578isis_circuit_up (struct isis_circuit *circuit)
579{
Josh Bailey3f045a02012-03-24 08:35:20 -0700580 int retv;
581
582 /* Set the flags for all the lsps of the circuit. */
583 isis_circuit_update_all_srmflags (circuit, 1);
584
585 if (circuit->state == C_STATE_UP)
586 return ISIS_OK;
587
588 if (circuit->is_passive)
589 return ISIS_OK;
jardineb5d44e2003-12-23 08:09:43 +0000590
hassof390d2c2004-09-10 20:48:21 +0000591 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
592 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700593 /*
594 * Get the Hardware Address
595 */
596#ifdef HAVE_STRUCT_SOCKADDR_DL
597#ifndef SUNOS_5
598 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
599 zlog_warn ("unsupported link layer");
600 else
601 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
602 ETH_ALEN);
603#endif
604#else
605 if (circuit->interface->hw_addr_len != ETH_ALEN)
606 {
607 zlog_warn ("unsupported link layer");
608 }
609 else
610 {
611 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
612 }
613#ifdef EXTREME_DEGUG
614 zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
615 circuit->interface->ifindex, ISO_MTU (circuit),
616 snpa_print (circuit->u.bc.snpa));
617#endif /* EXTREME_DEBUG */
618#endif /* HAVE_STRUCT_SOCKADDR_DL */
619
620 circuit->u.bc.adjdb[0] = list_new ();
621 circuit->u.bc.adjdb[1] = list_new ();
622
hassof390d2c2004-09-10 20:48:21 +0000623 if (circuit->area->min_bcast_mtu == 0 ||
Josh Bailey3f045a02012-03-24 08:35:20 -0700624 ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
625 circuit->area->min_bcast_mtu = ISO_MTU (circuit);
hassof390d2c2004-09-10 20:48:21 +0000626 /*
627 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
628 */
jardineb5d44e2003-12-23 08:09:43 +0000629
hassof390d2c2004-09-10 20:48:21 +0000630 /* initilizing the hello sending threads
631 * for a broadcast IF
632 */
jardineb5d44e2003-12-23 08:09:43 +0000633
hassof390d2c2004-09-10 20:48:21 +0000634 /* 8.4.1 a) commence sending of IIH PDUs */
635
Josh Bailey3f045a02012-03-24 08:35:20 -0700636 if (circuit->is_type & IS_LEVEL_1)
637 {
638 thread_add_event (master, send_lan_l1_hello, circuit, 0);
639 circuit->u.bc.lan_neighs[0] = list_new ();
640 }
hassof390d2c2004-09-10 20:48:21 +0000641
Josh Bailey3f045a02012-03-24 08:35:20 -0700642 if (circuit->is_type & IS_LEVEL_2)
643 {
644 thread_add_event (master, send_lan_l2_hello, circuit, 0);
645 circuit->u.bc.lan_neighs[1] = list_new ();
646 }
hassof390d2c2004-09-10 20:48:21 +0000647
648 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
649 /* 8.4.1 c) FIXME: listen for ESH PDUs */
650
651 /* 8.4.1 d) */
652 /* dr election will commence in... */
Josh Bailey3f045a02012-03-24 08:35:20 -0700653 if (circuit->is_type & IS_LEVEL_1)
654 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
655 circuit, 2 * circuit->hello_interval[0]);
656 if (circuit->is_type & IS_LEVEL_2)
657 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
658 circuit, 2 * circuit->hello_interval[1]);
jardineb5d44e2003-12-23 08:09:43 +0000659 }
hassof390d2c2004-09-10 20:48:21 +0000660 else
661 {
662 /* initializing the hello send threads
663 * for a ptp IF
664 */
Josh Bailey3f045a02012-03-24 08:35:20 -0700665 circuit->u.p2p.neighbor = NULL;
hassof390d2c2004-09-10 20:48:21 +0000666 thread_add_event (master, send_p2p_hello, circuit, 0);
jardineb5d44e2003-12-23 08:09:43 +0000667 }
668
jardineb5d44e2003-12-23 08:09:43 +0000669 /* initializing PSNP timers */
Josh Bailey3f045a02012-03-24 08:35:20 -0700670 if (circuit->is_type & IS_LEVEL_1)
671 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
672 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
673
674 if (circuit->is_type & IS_LEVEL_2)
675 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
676 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
677
678 /* unified init for circuits; ignore warnings below this level */
679 retv = isis_sock_init (circuit);
680 if (retv != ISIS_OK)
hassof390d2c2004-09-10 20:48:21 +0000681 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700682 isis_circuit_down (circuit);
683 return retv;
hassof390d2c2004-09-10 20:48:21 +0000684 }
685
Josh Bailey3f045a02012-03-24 08:35:20 -0700686 /* initialize the circuit streams after opening connection */
jardineb5d44e2003-12-23 08:09:43 +0000687 if (circuit->rcv_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000688 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000689
690 if (circuit->snd_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000691 circuit->snd_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000692
jardineb5d44e2003-12-23 08:09:43 +0000693#ifdef GNU_LINUX
hassof390d2c2004-09-10 20:48:21 +0000694 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
Josh Bailey3f045a02012-03-24 08:35:20 -0700695 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000696#else
hassof390d2c2004-09-10 20:48:21 +0000697 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
Josh Bailey3f045a02012-03-24 08:35:20 -0700698 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000699#endif
Josh Bailey3f045a02012-03-24 08:35:20 -0700700
701 circuit->lsp_queue = list_new ();
702 circuit->lsp_queue_last_cleared = time (NULL);
703
704 return ISIS_OK;
jardineb5d44e2003-12-23 08:09:43 +0000705}
706
707void
708isis_circuit_down (struct isis_circuit *circuit)
709{
Josh Bailey3f045a02012-03-24 08:35:20 -0700710 if (circuit->state != C_STATE_UP)
711 return;
712
713 /* Clear the flags for all the lsps of the circuit. */
714 isis_circuit_update_all_srmflags (circuit, 0);
715
hassof390d2c2004-09-10 20:48:21 +0000716 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
717 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700718 /* destroy neighbour lists */
719 if (circuit->u.bc.lan_neighs[0])
720 {
721 list_delete (circuit->u.bc.lan_neighs[0]);
722 circuit->u.bc.lan_neighs[0] = NULL;
723 }
724 if (circuit->u.bc.lan_neighs[1])
725 {
726 list_delete (circuit->u.bc.lan_neighs[1]);
727 circuit->u.bc.lan_neighs[1] = NULL;
728 }
729 /* destroy adjacency databases */
730 if (circuit->u.bc.adjdb[0])
731 {
732 circuit->u.bc.adjdb[0]->del = isis_delete_adj;
733 list_delete (circuit->u.bc.adjdb[0]);
734 circuit->u.bc.adjdb[0] = NULL;
735 }
736 if (circuit->u.bc.adjdb[1])
737 {
738 circuit->u.bc.adjdb[1]->del = isis_delete_adj;
739 list_delete (circuit->u.bc.adjdb[1]);
740 circuit->u.bc.adjdb[1] = NULL;
741 }
742 if (circuit->u.bc.is_dr[0])
743 {
744 isis_dr_resign (circuit, 1);
745 circuit->u.bc.is_dr[0] = 0;
746 }
747 memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1);
748 if (circuit->u.bc.is_dr[1])
749 {
750 isis_dr_resign (circuit, 2);
751 circuit->u.bc.is_dr[1] = 0;
752 }
753 memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1);
754 memset (circuit->u.bc.snpa, 0, ETH_ALEN);
755
hassof390d2c2004-09-10 20:48:21 +0000756 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
757 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
hassof891f442004-09-14 13:54:30 +0000758 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
759 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
Josh Bailey3f045a02012-03-24 08:35:20 -0700760 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[0]);
761 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[1]);
hassof390d2c2004-09-10 20:48:21 +0000762 }
763 else if (circuit->circ_type == CIRCUIT_T_P2P)
764 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700765 isis_delete_adj (circuit->u.p2p.neighbor);
766 circuit->u.p2p.neighbor = NULL;
hassof390d2c2004-09-10 20:48:21 +0000767 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
768 }
Josh Bailey3f045a02012-03-24 08:35:20 -0700769
770 /* Cancel all active threads */
771 THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
772 THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
773 THREAD_TIMER_OFF (circuit->t_send_psnp[0]);
774 THREAD_TIMER_OFF (circuit->t_send_psnp[1]);
775 THREAD_OFF (circuit->t_read);
776
777 if (circuit->lsp_queue)
778 {
779 circuit->lsp_queue->del = NULL;
780 list_delete (circuit->lsp_queue);
781 circuit->lsp_queue = NULL;
782 }
783
784 /* send one gratuitous hello to spead up convergence */
785 if (circuit->is_type & IS_LEVEL_1)
786 send_hello (circuit, IS_LEVEL_1);
787 if (circuit->is_type & IS_LEVEL_2)
788 send_hello (circuit, IS_LEVEL_2);
789
790 circuit->upadjcount[0] = 0;
791 circuit->upadjcount[1] = 0;
792
jardineb5d44e2003-12-23 08:09:43 +0000793 /* close the socket */
Josh Bailey3f045a02012-03-24 08:35:20 -0700794 if (circuit->fd)
795 {
796 close (circuit->fd);
797 circuit->fd = 0;
798 }
799
800 if (circuit->rcv_stream != NULL)
801 {
802 stream_free (circuit->rcv_stream);
803 circuit->rcv_stream = NULL;
804 }
805
806 if (circuit->snd_stream != NULL)
807 {
808 stream_free (circuit->snd_stream);
809 circuit->snd_stream = NULL;
810 }
811
812 thread_cancel_event (master, circuit);
jardineb5d44e2003-12-23 08:09:43 +0000813
814 return;
815}
816
817void
818circuit_update_nlpids (struct isis_circuit *circuit)
819{
820 circuit->nlpids.count = 0;
hassof390d2c2004-09-10 20:48:21 +0000821
822 if (circuit->ip_router)
823 {
824 circuit->nlpids.nlpids[0] = NLPID_IP;
825 circuit->nlpids.count++;
826 }
jardineb5d44e2003-12-23 08:09:43 +0000827#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000828 if (circuit->ipv6_router)
829 {
830 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
831 circuit->nlpids.count++;
832 }
jardineb5d44e2003-12-23 08:09:43 +0000833#endif /* HAVE_IPV6 */
834 return;
835}
836
Josh Bailey3f045a02012-03-24 08:35:20 -0700837void
838isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty,
839 char detail)
840{
841 if (detail == ISIS_UI_LEVEL_BRIEF)
842 {
843 vty_out (vty, " %-12s", circuit->interface->name);
844 vty_out (vty, "0x%-7x", circuit->circuit_id);
845 vty_out (vty, "%-9s", circuit_state2string (circuit->state));
846 vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type));
847 vty_out (vty, "%-9s", circuit_t2string (circuit->is_type));
848 vty_out (vty, "%s", VTY_NEWLINE);
849 }
850
851 if (detail == ISIS_UI_LEVEL_DETAIL)
852 {
853 vty_out (vty, " Interface: %s", circuit->interface->name);
854 vty_out (vty, ", State: %s", circuit_state2string (circuit->state));
855 if (circuit->is_passive)
856 vty_out (vty, ", Passive");
857 else
858 vty_out (vty, ", Active");
859 vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id);
860 vty_out (vty, "%s", VTY_NEWLINE);
861 vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type));
862 vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type));
863 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
864 vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa));
865 vty_out (vty, "%s", VTY_NEWLINE);
866 if (circuit->is_type & IS_LEVEL_1)
867 {
868 vty_out (vty, " Level-1 Information:%s", VTY_NEWLINE);
869 if (circuit->area->newmetric)
870 vty_out (vty, " Metric: %d", circuit->te_metric[0]);
871 else
872 vty_out (vty, " Metric: %d",
873 circuit->metrics[0].metric_default);
874 if (!circuit->is_passive)
875 {
876 vty_out (vty, ", Active neighbors: %u%s",
877 circuit->upadjcount[0], VTY_NEWLINE);
878 vty_out (vty, " Hello interval: %u, "
879 "Holddown count: %u %s%s",
880 circuit->hello_interval[0],
881 circuit->hello_multiplier[0],
882 (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
883 VTY_NEWLINE);
884 vty_out (vty, " CNSP interval: %u, "
885 "PSNP interval: %u%s",
886 circuit->csnp_interval[0],
887 circuit->psnp_interval[0], VTY_NEWLINE);
888 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
889 vty_out (vty, " LAN Priority: %u, %s%s",
890 circuit->priority[0],
891 (circuit->u.bc.is_dr[0] ? \
892 "is DIS" : "is not DIS"), VTY_NEWLINE);
893 }
894 else
895 {
896 vty_out (vty, "%s", VTY_NEWLINE);
897 }
898 }
899 if (circuit->is_type & IS_LEVEL_2)
900 {
901 vty_out (vty, " Level-2 Information:%s", VTY_NEWLINE);
902 if (circuit->area->newmetric)
903 vty_out (vty, " Metric: %d", circuit->te_metric[1]);
904 else
905 vty_out (vty, " Metric: %d",
906 circuit->metrics[1].metric_default);
907 if (!circuit->is_passive)
908 {
909 vty_out (vty, ", Active neighbors: %u%s",
910 circuit->upadjcount[1], VTY_NEWLINE);
911 vty_out (vty, " Hello interval: %u, "
912 "Holddown count: %u %s%s",
913 circuit->hello_interval[1],
914 circuit->hello_multiplier[1],
915 (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
916 VTY_NEWLINE);
917 vty_out (vty, " CNSP interval: %u, "
918 "PSNP interval: %u%s",
919 circuit->csnp_interval[1],
920 circuit->psnp_interval[1], VTY_NEWLINE);
921 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
922 vty_out (vty, " LAN Priority: %u, %s%s",
923 circuit->priority[1],
924 (circuit->u.bc.is_dr[1] ? \
925 "is DIS" : "is not DIS"), VTY_NEWLINE);
926 }
927 else
928 {
929 vty_out (vty, "%s", VTY_NEWLINE);
930 }
931 }
932 if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0)
933 {
934 struct listnode *node;
935 struct prefix *ip_addr;
936 u_char buf[BUFSIZ];
937 vty_out (vty, " IP Prefix(es):%s", VTY_NEWLINE);
938 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr))
939 {
940 prefix2str (ip_addr, (char*)buf, BUFSIZ),
941 vty_out (vty, " %s%s", buf, VTY_NEWLINE);
942 }
943 }
944 vty_out (vty, "%s", VTY_NEWLINE);
945 }
946 return;
947}
948
jardineb5d44e2003-12-23 08:09:43 +0000949int
hassof390d2c2004-09-10 20:48:21 +0000950isis_interface_config_write (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000951{
jardineb5d44e2003-12-23 08:09:43 +0000952 int write = 0;
hasso3fdb2dd2005-09-28 18:45:54 +0000953 struct listnode *node, *node2;
jardineb5d44e2003-12-23 08:09:43 +0000954 struct interface *ifp;
955 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -0700956 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +0000957 int i;
jardineb5d44e2003-12-23 08:09:43 +0000958
hasso3fdb2dd2005-09-28 18:45:54 +0000959 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
jardineb5d44e2003-12-23 08:09:43 +0000960 {
Josh Bailey3f045a02012-03-24 08:35:20 -0700961 /* IF name */
962 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
963 write++;
964 /* IF desc */
965 if (ifp->desc)
966 {
967 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
968 write++;
969 }
970 /* ISIS Circuit */
971 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
972 {
973 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
974 if (circuit == NULL)
975 continue;
976 if (circuit->ip_router)
977 {
978 vty_out (vty, " ip router isis %s%s", area->area_tag,
979 VTY_NEWLINE);
980 write++;
981 }
982 if (circuit->is_passive)
983 {
984 vty_out (vty, " isis passive%s", VTY_NEWLINE);
985 write++;
986 }
987 if (circuit->circ_type_config == CIRCUIT_T_P2P)
988 {
989 vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE);
990 write++;
991 }
jardineb5d44e2003-12-23 08:09:43 +0000992#ifdef HAVE_IPV6
Josh Bailey3f045a02012-03-24 08:35:20 -0700993 if (circuit->ipv6_router)
994 {
995 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
996 VTY_NEWLINE);
997 write++;
998 }
jardineb5d44e2003-12-23 08:09:43 +0000999#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00001000
Josh Bailey3f045a02012-03-24 08:35:20 -07001001 /* ISIS - circuit type */
1002 if (circuit->is_type == IS_LEVEL_1)
1003 {
1004 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
1005 write++;
1006 }
1007 else
1008 {
1009 if (circuit->is_type == IS_LEVEL_2)
1010 {
1011 vty_out (vty, " isis circuit-type level-2-only%s",
1012 VTY_NEWLINE);
1013 write++;
1014 }
1015 }
jardineb5d44e2003-12-23 08:09:43 +00001016
Josh Bailey3f045a02012-03-24 08:35:20 -07001017 /* ISIS - CSNP interval */
1018 if (circuit->csnp_interval[0] == circuit->csnp_interval[1])
1019 {
1020 if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL)
1021 {
1022 vty_out (vty, " isis csnp-interval %d%s",
1023 circuit->csnp_interval[0], VTY_NEWLINE);
1024 write++;
1025 }
1026 }
1027 else
1028 {
1029 for (i = 0; i < 2; i++)
1030 {
1031 if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL)
1032 {
1033 vty_out (vty, " isis csnp-interval %d level-%d%s",
1034 circuit->csnp_interval[i], i + 1, VTY_NEWLINE);
1035 write++;
1036 }
1037 }
1038 }
jardineb5d44e2003-12-23 08:09:43 +00001039
Josh Bailey3f045a02012-03-24 08:35:20 -07001040 /* ISIS - PSNP interval */
1041 if (circuit->psnp_interval[0] == circuit->psnp_interval[1])
1042 {
1043 if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL)
1044 {
1045 vty_out (vty, " isis psnp-interval %d%s",
1046 circuit->psnp_interval[0], VTY_NEWLINE);
1047 write++;
1048 }
1049 }
1050 else
1051 {
1052 for (i = 0; i < 2; i++)
1053 {
1054 if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL)
1055 {
1056 vty_out (vty, " isis psnp-interval %d level-%d%s",
1057 circuit->psnp_interval[i], i + 1, VTY_NEWLINE);
1058 write++;
1059 }
1060 }
1061 }
jardineb5d44e2003-12-23 08:09:43 +00001062
Josh Bailey3f045a02012-03-24 08:35:20 -07001063 /* ISIS - Hello padding - Defaults to true so only display if false */
1064 if (circuit->pad_hellos == 0)
1065 {
1066 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
1067 write++;
1068 }
jardineb5d44e2003-12-23 08:09:43 +00001069
Josh Bailey3f045a02012-03-24 08:35:20 -07001070 /* ISIS - Hello interval */
1071 if (circuit->hello_interval[0] == circuit->hello_interval[1])
1072 {
1073 if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL)
1074 {
1075 vty_out (vty, " isis hello-interval %d%s",
1076 circuit->hello_interval[0], VTY_NEWLINE);
1077 write++;
1078 }
1079 }
1080 else
1081 {
1082 for (i = 0; i < 2; i++)
1083 {
1084 if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL)
1085 {
1086 vty_out (vty, " isis hello-interval %d level-%d%s",
1087 circuit->hello_interval[i], i + 1, VTY_NEWLINE);
1088 write++;
1089 }
1090 }
1091 }
jardineb5d44e2003-12-23 08:09:43 +00001092
Josh Bailey3f045a02012-03-24 08:35:20 -07001093 /* ISIS - Hello Multiplier */
1094 if (circuit->hello_multiplier[0] == circuit->hello_multiplier[1])
1095 {
1096 if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER)
1097 {
1098 vty_out (vty, " isis hello-multiplier %d%s",
1099 circuit->hello_multiplier[0], VTY_NEWLINE);
1100 write++;
1101 }
1102 }
1103 else
1104 {
1105 for (i = 0; i < 2; i++)
1106 {
1107 if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER)
1108 {
1109 vty_out (vty, " isis hello-multiplier %d level-%d%s",
1110 circuit->hello_multiplier[i], i + 1,
1111 VTY_NEWLINE);
1112 write++;
1113 }
1114 }
1115 }
1116
1117 /* ISIS - Priority */
1118 if (circuit->priority[0] == circuit->priority[1])
1119 {
1120 if (circuit->priority[0] != DEFAULT_PRIORITY)
1121 {
1122 vty_out (vty, " isis priority %d%s",
1123 circuit->priority[0], VTY_NEWLINE);
1124 write++;
1125 }
1126 }
1127 else
1128 {
1129 for (i = 0; i < 2; i++)
1130 {
1131 if (circuit->priority[i] != DEFAULT_PRIORITY)
1132 {
1133 vty_out (vty, " isis priority %d level-%d%s",
1134 circuit->priority[i], i + 1, VTY_NEWLINE);
1135 write++;
1136 }
1137 }
1138 }
1139
1140 /* ISIS - Metric */
1141 if (circuit->te_metric[0] == circuit->te_metric[1])
1142 {
1143 if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC)
1144 {
1145 vty_out (vty, " isis metric %d%s", circuit->te_metric[0],
1146 VTY_NEWLINE);
1147 write++;
1148 }
1149 }
1150 else
1151 {
1152 for (i = 0; i < 2; i++)
1153 {
1154 if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC)
1155 {
1156 vty_out (vty, " isis metric %d level-%d%s",
1157 circuit->te_metric[i], i + 1, VTY_NEWLINE);
1158 write++;
1159 }
1160 }
1161 }
1162 if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
1163 {
1164 vty_out (vty, " isis password md5 %s%s", circuit->passwd.passwd,
1165 VTY_NEWLINE);
1166 write++;
1167 }
1168 else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
1169 {
1170 vty_out (vty, " isis password clear %s%s", circuit->passwd.passwd,
1171 VTY_NEWLINE);
1172 write++;
1173 }
1174 }
1175 vty_out (vty, "!%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +00001176 }
hassof390d2c2004-09-10 20:48:21 +00001177
jardineb5d44e2003-12-23 08:09:43 +00001178 return write;
1179}
jardineb5d44e2003-12-23 08:09:43 +00001180
1181DEFUN (ip_router_isis,
1182 ip_router_isis_cmd,
1183 "ip router isis WORD",
1184 "Interface Internet Protocol config commands\n"
1185 "IP router interface commands\n"
1186 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +00001187 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +00001188{
Josh Bailey3f045a02012-03-24 08:35:20 -07001189 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +00001190 struct interface *ifp;
1191 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00001192
1193 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001194 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00001195
Josh Bailey3f045a02012-03-24 08:35:20 -07001196 /* Prevent more than one area per circuit */
1197 circuit = circuit_scan_by_ifp (ifp);
1198 if (circuit)
hassof390d2c2004-09-10 20:48:21 +00001199 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001200 if (circuit->ip_router == 1)
1201 {
1202 if (strcmp (circuit->area->area_tag, argv[0]))
1203 {
1204 vty_out (vty, "ISIS circuit is already defined on %s%s",
1205 circuit->area->area_tag, VTY_NEWLINE);
1206 return CMD_ERR_NOTHING_TODO;
1207 }
1208 return CMD_SUCCESS;
1209 }
jardineb5d44e2003-12-23 08:09:43 +00001210 }
hassof390d2c2004-09-10 20:48:21 +00001211
Josh Bailey3f045a02012-03-24 08:35:20 -07001212 if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
hassof390d2c2004-09-10 20:48:21 +00001213 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001214 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1215 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001216 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001217 area = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001218
Josh Bailey3f045a02012-03-24 08:35:20 -07001219 circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
1220 isis_circuit_if_bind (circuit, ifp);
jardineb5d44e2003-12-23 08:09:43 +00001221
Josh Bailey3f045a02012-03-24 08:35:20 -07001222 circuit->ip_router = 1;
jardineb5d44e2003-12-23 08:09:43 +00001223 area->ip_circuits++;
Josh Bailey3f045a02012-03-24 08:35:20 -07001224 circuit_update_nlpids (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001225
1226 vty->node = INTERFACE_NODE;
Josh Bailey3f045a02012-03-24 08:35:20 -07001227 vty->index = ifp;
hassof390d2c2004-09-10 20:48:21 +00001228
jardineb5d44e2003-12-23 08:09:43 +00001229 return CMD_SUCCESS;
1230}
1231
1232DEFUN (no_ip_router_isis,
1233 no_ip_router_isis_cmd,
1234 "no ip router isis WORD",
1235 NO_STR
1236 "Interface Internet Protocol config commands\n"
1237 "IP router interface commands\n"
1238 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +00001239 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +00001240{
jardineb5d44e2003-12-23 08:09:43 +00001241 struct interface *ifp;
1242 struct isis_area *area;
Josh Bailey3f045a02012-03-24 08:35:20 -07001243 struct isis_circuit *circuit;
jardineb5d44e2003-12-23 08:09:43 +00001244
hassof390d2c2004-09-10 20:48:21 +00001245 ifp = (struct interface *) vty->index;
Josh Bailey3f045a02012-03-24 08:35:20 -07001246 if (!ifp)
1247 {
1248 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1249 return CMD_ERR_NO_MATCH;
1250 }
hassof390d2c2004-09-10 20:48:21 +00001251
jardineb5d44e2003-12-23 08:09:43 +00001252 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001253 if (!area)
1254 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001255 vty_out (vty, "Can't find ISIS instance %s%s",
1256 argv[0], VTY_NEWLINE);
1257 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001258 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001259
1260 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +00001261 if (!circuit)
1262 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001263 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1264 ifp->name, VTY_NEWLINE);
1265 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001266 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001267
jardineb5d44e2003-12-23 08:09:43 +00001268 circuit->ip_router = 0;
1269 area->ip_circuits--;
1270#ifdef HAVE_IPV6
1271 if (circuit->ipv6_router == 0)
1272#endif
1273 isis_csm_state_change (ISIS_DISABLE, circuit, area);
hassof390d2c2004-09-10 20:48:21 +00001274
jardineb5d44e2003-12-23 08:09:43 +00001275 return CMD_SUCCESS;
1276}
1277
Josh Bailey3f045a02012-03-24 08:35:20 -07001278#ifdef HAVE_IPV6
1279DEFUN (ipv6_router_isis,
1280 ipv6_router_isis_cmd,
1281 "ipv6 router isis WORD",
1282 "IPv6 interface subcommands\n"
1283 "IPv6 Router interface commands\n"
1284 "IS-IS Routing for IPv6\n"
1285 "Routing process tag\n")
1286{
1287 struct isis_circuit *circuit;
1288 struct interface *ifp;
1289 struct isis_area *area;
1290
1291 ifp = (struct interface *) vty->index;
1292 assert (ifp);
1293
1294 /* Prevent more than one area per circuit */
1295 circuit = circuit_scan_by_ifp (ifp);
1296 if (circuit)
1297 {
1298 if (circuit->ipv6_router == 1)
1299 {
1300 if (strcmp (circuit->area->area_tag, argv[0]))
1301 {
1302 vty_out (vty, "ISIS circuit is already defined for IPv6 on %s%s",
1303 circuit->area->area_tag, VTY_NEWLINE);
1304 return CMD_ERR_NOTHING_TODO;
1305 }
1306 return CMD_SUCCESS;
1307 }
1308 }
1309
1310 if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
1311 {
1312 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1313 return CMD_ERR_NO_MATCH;
1314 }
1315 area = vty->index;
1316
1317 circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
1318 isis_circuit_if_bind (circuit, ifp);
1319
1320 circuit->ipv6_router = 1;
1321 area->ipv6_circuits++;
1322 circuit_update_nlpids (circuit);
1323
1324 vty->node = INTERFACE_NODE;
1325 vty->index = ifp;
1326
1327 return CMD_SUCCESS;
1328}
1329
1330DEFUN (no_ipv6_router_isis,
1331 no_ipv6_router_isis_cmd,
1332 "no ipv6 router isis WORD",
1333 NO_STR
1334 "IPv6 interface subcommands\n"
1335 "IPv6 Router interface commands\n"
1336 "IS-IS Routing for IPv6\n"
1337 "Routing process tag\n")
1338{
1339 struct interface *ifp;
1340 struct isis_area *area;
1341 struct listnode *node;
1342 struct isis_circuit *circuit;
1343
1344 ifp = (struct interface *) vty->index;
1345 if (!ifp)
1346 {
1347 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1348 return CMD_ERR_NO_MATCH;
1349 }
1350
1351 area = isis_area_lookup (argv[0]);
1352 if (!area)
1353 {
1354 vty_out (vty, "Can't find ISIS instance %s%s",
1355 argv[0], VTY_NEWLINE);
1356 return CMD_ERR_NO_MATCH;
1357 }
1358
1359 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
1360 if (!circuit)
1361 {
1362 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1363 ifp->name, VTY_NEWLINE);
1364 return CMD_ERR_NO_MATCH;
1365 }
1366
1367 circuit->ipv6_router = 0;
1368 area->ipv6_circuits--;
1369 if (circuit->ip_router == 0)
1370 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1371
1372 return CMD_SUCCESS;
1373}
1374#endif /* HAVE_IPV6 */
1375
1376DEFUN (isis_passive,
1377 isis_passive_cmd,
1378 "isis passive",
1379 "IS-IS commands\n"
1380 "Configure the passive mode for interface\n")
1381{
1382 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1383 if (!circuit)
1384 return CMD_ERR_NO_MATCH;
1385
1386 if (circuit->is_passive == 1)
1387 return CMD_SUCCESS;
1388
1389 if (circuit->state != C_STATE_UP)
1390 {
1391 circuit->is_passive = 1;
1392 }
1393 else
1394 {
1395 struct isis_area *area = circuit->area;
1396 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1397 circuit->is_passive = 1;
1398 isis_csm_state_change (ISIS_ENABLE, circuit, area);
1399 }
1400
1401 return CMD_SUCCESS;
1402}
1403
1404DEFUN (no_isis_passive,
1405 no_isis_passive_cmd,
1406 "no isis passive",
1407 NO_STR
1408 "IS-IS commands\n"
1409 "Configure the passive mode for interface\n")
1410{
1411 struct interface *ifp;
1412 struct isis_circuit *circuit;
1413
1414 ifp = (struct interface *) vty->index;
1415 if (!ifp)
1416 {
1417 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1418 return CMD_ERR_NO_MATCH;
1419 }
1420
1421 /* FIXME: what is wrong with circuit = ifp->info ? */
1422 circuit = circuit_scan_by_ifp (ifp);
1423 if (!circuit)
1424 {
1425 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1426 ifp->name, VTY_NEWLINE);
1427 return CMD_ERR_NO_MATCH;
1428 }
1429
1430 if (if_is_loopback(ifp))
1431 {
1432 vty_out (vty, "Can't set no passive for loopback interface%s",
1433 VTY_NEWLINE);
1434 return CMD_ERR_AMBIGUOUS;
1435 }
1436
1437 if (circuit->is_passive == 0)
1438 return CMD_SUCCESS;
1439
1440 if (circuit->state != C_STATE_UP)
1441 {
1442 circuit->is_passive = 0;
1443 }
1444 else
1445 {
1446 struct isis_area *area = circuit->area;
1447 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1448 circuit->is_passive = 0;
1449 isis_csm_state_change (ISIS_ENABLE, circuit, area);
1450 }
1451
1452 return CMD_SUCCESS;
1453}
1454
jardineb5d44e2003-12-23 08:09:43 +00001455DEFUN (isis_circuit_type,
1456 isis_circuit_type_cmd,
1457 "isis circuit-type (level-1|level-1-2|level-2-only)",
1458 "IS-IS commands\n"
1459 "Configure circuit type for interface\n"
1460 "Level-1 only adjacencies are formed\n"
1461 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +00001462 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +00001463{
Josh Bailey3f045a02012-03-24 08:35:20 -07001464 int circuit_type;
1465 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1466 if (!circuit)
1467 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001468
Josh Bailey3f045a02012-03-24 08:35:20 -07001469 circuit_type = string2circuit_t (argv[0]);
1470 if (!circuit_type)
hassof390d2c2004-09-10 20:48:21 +00001471 {
1472 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001473 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001474 }
1475
Josh Bailey3f045a02012-03-24 08:35:20 -07001476 if (circuit->state == C_STATE_UP &&
1477 circuit->area->is_type != IS_LEVEL_1_AND_2 &&
1478 circuit->area->is_type != circuit_type)
hassof390d2c2004-09-10 20:48:21 +00001479 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001480 vty_out (vty, "Invalid circuit level for area %s.%s",
1481 circuit->area->area_tag, VTY_NEWLINE);
1482 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001483 }
Josh Bailey3f045a02012-03-24 08:35:20 -07001484 isis_event_circuit_type_change (circuit, circuit_type);
hassof390d2c2004-09-10 20:48:21 +00001485
jardineb5d44e2003-12-23 08:09:43 +00001486 return CMD_SUCCESS;
1487}
1488
1489DEFUN (no_isis_circuit_type,
1490 no_isis_circuit_type_cmd,
1491 "no isis circuit-type (level-1|level-1-2|level-2-only)",
1492 NO_STR
1493 "IS-IS commands\n"
1494 "Configure circuit type for interface\n"
1495 "Level-1 only adjacencies are formed\n"
1496 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +00001497 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +00001498{
Josh Bailey3f045a02012-03-24 08:35:20 -07001499 int circuit_type;
1500 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1501 if (!circuit)
1502 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001503
jardineb5d44e2003-12-23 08:09:43 +00001504 /*
Josh Bailey3f045a02012-03-24 08:35:20 -07001505 * Set the circuits level to its default value
jardineb5d44e2003-12-23 08:09:43 +00001506 */
Josh Bailey3f045a02012-03-24 08:35:20 -07001507 if (circuit->state == C_STATE_UP)
1508 circuit_type = circuit->area->is_type;
1509 else
1510 circuit_type = IS_LEVEL_1_AND_2;
1511 isis_event_circuit_type_change (circuit, circuit_type);
hassof390d2c2004-09-10 20:48:21 +00001512
jardineb5d44e2003-12-23 08:09:43 +00001513 return CMD_SUCCESS;
1514}
1515
Josh Bailey3f045a02012-03-24 08:35:20 -07001516DEFUN (isis_passwd_md5,
1517 isis_passwd_md5_cmd,
1518 "isis password md5 WORD",
jardineb5d44e2003-12-23 08:09:43 +00001519 "IS-IS commands\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001520 "Configure the authentication password for a circuit\n"
1521 "Authentication type\n"
1522 "Circuit password\n")
jardineb5d44e2003-12-23 08:09:43 +00001523{
jardineb5d44e2003-12-23 08:09:43 +00001524 int len;
Josh Bailey3f045a02012-03-24 08:35:20 -07001525 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1526 if (!circuit)
1527 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001528
jardineb5d44e2003-12-23 08:09:43 +00001529 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001530 if (len > 254)
1531 {
1532 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
Josh Bailey3f045a02012-03-24 08:35:20 -07001533 return CMD_ERR_AMBIGUOUS;
1534 }
1535 circuit->passwd.len = len;
1536 circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1537 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
1538
1539 return CMD_SUCCESS;
1540}
1541
1542DEFUN (isis_passwd_clear,
1543 isis_passwd_clear_cmd,
1544 "isis password clear WORD",
1545 "IS-IS commands\n"
1546 "Configure the authentication password for a circuit\n"
1547 "Authentication type\n"
1548 "Circuit password\n")
1549{
1550 int len;
1551 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1552 if (!circuit)
1553 return CMD_ERR_NO_MATCH;
1554
1555 len = strlen (argv[0]);
1556 if (len > 254)
1557 {
1558 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1559 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001560 }
jardineb5d44e2003-12-23 08:09:43 +00001561 circuit->passwd.len = len;
1562 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001563 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001564
jardineb5d44e2003-12-23 08:09:43 +00001565 return CMD_SUCCESS;
1566}
1567
1568DEFUN (no_isis_passwd,
1569 no_isis_passwd_cmd,
1570 "no isis password",
1571 NO_STR
1572 "IS-IS commands\n"
Josh Bailey3f045a02012-03-24 08:35:20 -07001573 "Configure the authentication password for a circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001574{
Josh Bailey3f045a02012-03-24 08:35:20 -07001575 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1576 if (!circuit)
1577 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001578
jardineb5d44e2003-12-23 08:09:43 +00001579 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
hassof390d2c2004-09-10 20:48:21 +00001580
jardineb5d44e2003-12-23 08:09:43 +00001581 return CMD_SUCCESS;
1582}
1583
jardineb5d44e2003-12-23 08:09:43 +00001584DEFUN (isis_priority,
1585 isis_priority_cmd,
1586 "isis priority <0-127>",
1587 "IS-IS commands\n"
1588 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001589 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001590{
jardineb5d44e2003-12-23 08:09:43 +00001591 int prio;
Josh Bailey3f045a02012-03-24 08:35:20 -07001592 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1593 if (!circuit)
1594 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001595
1596 prio = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001597 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1598 {
1599 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1600 prio, VTY_NEWLINE);
1601 return CMD_ERR_AMBIGUOUS;
1602 }
jardineb5d44e2003-12-23 08:09:43 +00001603
Josh Bailey3f045a02012-03-24 08:35:20 -07001604 circuit->priority[0] = prio;
1605 circuit->priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001606
jardineb5d44e2003-12-23 08:09:43 +00001607 return CMD_SUCCESS;
1608}
1609
1610DEFUN (no_isis_priority,
1611 no_isis_priority_cmd,
1612 "no isis priority",
1613 NO_STR
1614 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001615 "Set priority for Designated Router election\n")
jardineb5d44e2003-12-23 08:09:43 +00001616{
Josh Bailey3f045a02012-03-24 08:35:20 -07001617 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1618 if (!circuit)
1619 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001620
Josh Bailey3f045a02012-03-24 08:35:20 -07001621 circuit->priority[0] = DEFAULT_PRIORITY;
1622 circuit->priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001623
jardineb5d44e2003-12-23 08:09:43 +00001624 return CMD_SUCCESS;
1625}
1626
1627ALIAS (no_isis_priority,
1628 no_isis_priority_arg_cmd,
1629 "no isis priority <0-127>",
1630 NO_STR
1631 "IS-IS commands\n"
1632 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001633 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001634
1635DEFUN (isis_priority_l1,
1636 isis_priority_l1_cmd,
hassof390d2c2004-09-10 20:48:21 +00001637 "isis priority <0-127> level-1",
jardineb5d44e2003-12-23 08:09:43 +00001638 "IS-IS commands\n"
1639 "Set priority for Designated Router election\n"
1640 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001641 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001642{
jardineb5d44e2003-12-23 08:09:43 +00001643 int prio;
Josh Bailey3f045a02012-03-24 08:35:20 -07001644 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1645 if (!circuit)
1646 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001647
1648 prio = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001649 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1650 {
1651 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1652 prio, VTY_NEWLINE);
1653 return CMD_ERR_AMBIGUOUS;
1654 }
jardineb5d44e2003-12-23 08:09:43 +00001655
Josh Bailey3f045a02012-03-24 08:35:20 -07001656 circuit->priority[0] = prio;
hassof390d2c2004-09-10 20:48:21 +00001657
jardineb5d44e2003-12-23 08:09:43 +00001658 return CMD_SUCCESS;
1659}
1660
1661DEFUN (no_isis_priority_l1,
1662 no_isis_priority_l1_cmd,
1663 "no isis priority level-1",
1664 NO_STR
1665 "IS-IS commands\n"
1666 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001667 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001668{
Josh Bailey3f045a02012-03-24 08:35:20 -07001669 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1670 if (!circuit)
1671 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001672
Josh Bailey3f045a02012-03-24 08:35:20 -07001673 circuit->priority[0] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001674
jardineb5d44e2003-12-23 08:09:43 +00001675 return CMD_SUCCESS;
1676}
1677
1678ALIAS (no_isis_priority_l1,
1679 no_isis_priority_l1_arg_cmd,
1680 "no isis priority <0-127> level-1",
1681 NO_STR
1682 "IS-IS commands\n"
1683 "Set priority for Designated Router election\n"
1684 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001685 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001686
1687DEFUN (isis_priority_l2,
1688 isis_priority_l2_cmd,
hassof390d2c2004-09-10 20:48:21 +00001689 "isis priority <0-127> level-2",
jardineb5d44e2003-12-23 08:09:43 +00001690 "IS-IS commands\n"
1691 "Set priority for Designated Router election\n"
1692 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001693 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001694{
jardineb5d44e2003-12-23 08:09:43 +00001695 int prio;
Josh Bailey3f045a02012-03-24 08:35:20 -07001696 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1697 if (!circuit)
1698 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001699
1700 prio = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07001701 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1702 {
1703 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1704 prio, VTY_NEWLINE);
1705 return CMD_ERR_AMBIGUOUS;
1706 }
jardineb5d44e2003-12-23 08:09:43 +00001707
Josh Bailey3f045a02012-03-24 08:35:20 -07001708 circuit->priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001709
jardineb5d44e2003-12-23 08:09:43 +00001710 return CMD_SUCCESS;
1711}
1712
1713DEFUN (no_isis_priority_l2,
1714 no_isis_priority_l2_cmd,
1715 "no isis priority level-2",
1716 NO_STR
1717 "IS-IS commands\n"
1718 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001719 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001720{
Josh Bailey3f045a02012-03-24 08:35:20 -07001721 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1722 if (!circuit)
1723 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00001724
Josh Bailey3f045a02012-03-24 08:35:20 -07001725 circuit->priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001726
jardineb5d44e2003-12-23 08:09:43 +00001727 return CMD_SUCCESS;
1728}
1729
1730ALIAS (no_isis_priority_l2,
1731 no_isis_priority_l2_arg_cmd,
1732 "no isis priority <0-127> level-2",
1733 NO_STR
1734 "IS-IS commands\n"
1735 "Set priority for Designated Router election\n"
1736 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001737 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001738
1739/* Metric command */
Josh Bailey3f045a02012-03-24 08:35:20 -07001740DEFUN (isis_metric,
jardineb5d44e2003-12-23 08:09:43 +00001741 isis_metric_cmd,
hassof21fb272005-09-26 17:05:55 +00001742 "isis metric <0-16777215>",
jardineb5d44e2003-12-23 08:09:43 +00001743 "IS-IS commands\n"
1744 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001745 "Default metric value\n")
jardineb5d44e2003-12-23 08:09:43 +00001746{
jardineb5d44e2003-12-23 08:09:43 +00001747 int met;
Josh Bailey3f045a02012-03-24 08:35:20 -07001748 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1749 if (!circuit)
1750 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001751
1752 met = atoi (argv[0]);
1753
Josh Bailey3f045a02012-03-24 08:35:20 -07001754 /* RFC3787 section 5.1 */
1755 if (circuit->area && circuit->area->oldmetric == 1 &&
1756 met > MAX_NARROW_LINK_METRIC)
1757 {
1758 vty_out (vty, "Invalid metric %d - should be <0-63> "
1759 "when narrow metric type enabled%s",
1760 met, VTY_NEWLINE);
1761 return CMD_ERR_AMBIGUOUS;
1762 }
1763
1764 /* RFC4444 */
1765 if (circuit->area && circuit->area->newmetric == 1 &&
1766 met > MAX_WIDE_LINK_METRIC)
1767 {
1768 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1769 "when wide metric type enabled%s",
1770 met, VTY_NEWLINE);
1771 return CMD_ERR_AMBIGUOUS;
1772 }
1773
hassof21fb272005-09-26 17:05:55 +00001774 circuit->te_metric[0] = met;
1775 circuit->te_metric[1] = met;
1776
jardineb5d44e2003-12-23 08:09:43 +00001777 circuit->metrics[0].metric_default = met;
1778 circuit->metrics[1].metric_default = met;
1779
Josh Bailey3f045a02012-03-24 08:35:20 -07001780 if (circuit->area)
1781 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
1782
jardineb5d44e2003-12-23 08:09:43 +00001783 return CMD_SUCCESS;
1784}
1785
1786DEFUN (no_isis_metric,
1787 no_isis_metric_cmd,
1788 "no isis metric",
1789 NO_STR
1790 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001791 "Set default metric for circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001792{
Josh Bailey3f045a02012-03-24 08:35:20 -07001793 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1794 if (!circuit)
1795 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001796
Josh Bailey3f045a02012-03-24 08:35:20 -07001797 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
1798 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
1799 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
1800 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
jardineb5d44e2003-12-23 08:09:43 +00001801
Josh Bailey3f045a02012-03-24 08:35:20 -07001802 if (circuit->area)
1803 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
jardineb5d44e2003-12-23 08:09:43 +00001804
1805 return CMD_SUCCESS;
1806}
1807
1808ALIAS (no_isis_metric,
1809 no_isis_metric_arg_cmd,
hassof21fb272005-09-26 17:05:55 +00001810 "no isis metric <0-16777215>",
jardineb5d44e2003-12-23 08:09:43 +00001811 NO_STR
1812 "IS-IS commands\n"
1813 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001814 "Default metric value\n")
1815
Josh Bailey3f045a02012-03-24 08:35:20 -07001816DEFUN (isis_metric_l1,
1817 isis_metric_l1_cmd,
1818 "isis metric <0-16777215> level-1",
1819 "IS-IS commands\n"
1820 "Set default metric for circuit\n"
1821 "Default metric value\n"
1822 "Specify metric for level-1 routing\n")
1823{
1824 int met;
1825 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1826 if (!circuit)
1827 return CMD_ERR_NO_MATCH;
1828
1829 met = atoi (argv[0]);
1830
1831 /* RFC3787 section 5.1 */
1832 if (circuit->area && circuit->area->oldmetric == 1 &&
1833 met > MAX_NARROW_LINK_METRIC)
1834 {
1835 vty_out (vty, "Invalid metric %d - should be <0-63> "
1836 "when narrow metric type enabled%s",
1837 met, VTY_NEWLINE);
1838 return CMD_ERR_AMBIGUOUS;
1839 }
1840
1841 /* RFC4444 */
1842 if (circuit->area && circuit->area->newmetric == 1 &&
1843 met > MAX_WIDE_LINK_METRIC)
1844 {
1845 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1846 "when wide metric type enabled%s",
1847 met, VTY_NEWLINE);
1848 return CMD_ERR_AMBIGUOUS;
1849 }
1850
1851 circuit->te_metric[0] = met;
1852 circuit->metrics[0].metric_default = met;
1853
1854 if (circuit->area)
1855 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
1856
1857 return CMD_SUCCESS;
1858}
1859
1860DEFUN (no_isis_metric_l1,
1861 no_isis_metric_l1_cmd,
1862 "no isis metric level-1",
1863 NO_STR
1864 "IS-IS commands\n"
1865 "Set default metric for circuit\n"
1866 "Specify metric for level-1 routing\n")
1867{
1868 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1869 if (!circuit)
1870 return CMD_ERR_NO_MATCH;
1871
1872 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
1873 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
1874
1875 if (circuit->area)
1876 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
1877
1878 return CMD_SUCCESS;
1879}
1880
1881ALIAS (no_isis_metric_l1,
1882 no_isis_metric_l1_arg_cmd,
1883 "no isis metric <0-16777215> level-1",
1884 NO_STR
1885 "IS-IS commands\n"
1886 "Set default metric for circuit\n"
1887 "Default metric value\n"
1888 "Specify metric for level-1 routing\n")
1889
1890DEFUN (isis_metric_l2,
1891 isis_metric_l2_cmd,
1892 "isis metric <0-16777215> level-2",
1893 "IS-IS commands\n"
1894 "Set default metric for circuit\n"
1895 "Default metric value\n"
1896 "Specify metric for level-2 routing\n")
1897{
1898 int met;
1899 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1900 if (!circuit)
1901 return CMD_ERR_NO_MATCH;
1902
1903 met = atoi (argv[0]);
1904
1905 /* RFC3787 section 5.1 */
1906 if (circuit->area && circuit->area->oldmetric == 1 &&
1907 met > MAX_NARROW_LINK_METRIC)
1908 {
1909 vty_out (vty, "Invalid metric %d - should be <0-63> "
1910 "when narrow metric type enabled%s",
1911 met, VTY_NEWLINE);
1912 return CMD_ERR_AMBIGUOUS;
1913 }
1914
1915 /* RFC4444 */
1916 if (circuit->area && circuit->area->newmetric == 1 &&
1917 met > MAX_WIDE_LINK_METRIC)
1918 {
1919 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1920 "when wide metric type enabled%s",
1921 met, VTY_NEWLINE);
1922 return CMD_ERR_AMBIGUOUS;
1923 }
1924
1925 circuit->te_metric[1] = met;
1926 circuit->metrics[1].metric_default = met;
1927
1928 if (circuit->area)
1929 lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
1930
1931 return CMD_SUCCESS;
1932}
1933
1934DEFUN (no_isis_metric_l2,
1935 no_isis_metric_l2_cmd,
1936 "no isis metric level-2",
1937 NO_STR
1938 "IS-IS commands\n"
1939 "Set default metric for circuit\n"
1940 "Specify metric for level-2 routing\n")
1941{
1942 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1943 if (!circuit)
1944 return CMD_ERR_NO_MATCH;
1945
1946 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
1947 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
1948
1949 if (circuit->area)
1950 lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
1951
1952 return CMD_SUCCESS;
1953}
1954
1955ALIAS (no_isis_metric_l2,
1956 no_isis_metric_l2_arg_cmd,
1957 "no isis metric <0-16777215> level-2",
1958 NO_STR
1959 "IS-IS commands\n"
1960 "Set default metric for circuit\n"
1961 "Default metric value\n"
1962 "Specify metric for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001963/* end of metrics */
Josh Bailey3f045a02012-03-24 08:35:20 -07001964
hassof21fb272005-09-26 17:05:55 +00001965DEFUN (isis_hello_interval,
jardineb5d44e2003-12-23 08:09:43 +00001966 isis_hello_interval_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07001967 "isis hello-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00001968 "IS-IS commands\n"
1969 "Set Hello interval\n"
1970 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001971 "Holdtime 1 seconds, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001972{
jardineb5d44e2003-12-23 08:09:43 +00001973 int interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07001974 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1975 if (!circuit)
1976 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00001977
Josh Bailey3f045a02012-03-24 08:35:20 -07001978 interval = atoi (argv[0]);
1979 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00001980 {
Josh Bailey3f045a02012-03-24 08:35:20 -07001981 vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s",
1982 interval, VTY_NEWLINE);
1983 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00001984 }
jardineb5d44e2003-12-23 08:09:43 +00001985
hassof390d2c2004-09-10 20:48:21 +00001986 circuit->hello_interval[0] = (u_int16_t) interval;
1987 circuit->hello_interval[1] = (u_int16_t) interval;
1988
jardineb5d44e2003-12-23 08:09:43 +00001989 return CMD_SUCCESS;
1990}
1991
1992DEFUN (no_isis_hello_interval,
1993 no_isis_hello_interval_cmd,
1994 "no isis hello-interval",
1995 NO_STR
1996 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001997 "Set Hello interval\n")
jardineb5d44e2003-12-23 08:09:43 +00001998{
Josh Bailey3f045a02012-03-24 08:35:20 -07001999 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2000 if (!circuit)
2001 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002002
Josh Bailey3f045a02012-03-24 08:35:20 -07002003 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
2004 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002005
jardineb5d44e2003-12-23 08:09:43 +00002006 return CMD_SUCCESS;
2007}
2008
2009ALIAS (no_isis_hello_interval,
2010 no_isis_hello_interval_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002011 "no isis hello-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00002012 NO_STR
2013 "IS-IS commands\n"
2014 "Set Hello interval\n"
2015 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00002016 "Holdtime 1 second, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00002017
2018DEFUN (isis_hello_interval_l1,
2019 isis_hello_interval_l1_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002020 "isis hello-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002021 "IS-IS commands\n"
2022 "Set Hello interval\n"
2023 "Hello interval value\n"
2024 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002025 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002026{
jardineb5d44e2003-12-23 08:09:43 +00002027 long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002028 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2029 if (!circuit)
2030 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002031
Josh Bailey3f045a02012-03-24 08:35:20 -07002032 interval = atoi (argv[0]);
2033 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002034 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002035 vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
2036 interval, VTY_NEWLINE);
2037 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00002038 }
jardineb5d44e2003-12-23 08:09:43 +00002039
hassof390d2c2004-09-10 20:48:21 +00002040 circuit->hello_interval[0] = (u_int16_t) interval;
2041
jardineb5d44e2003-12-23 08:09:43 +00002042 return CMD_SUCCESS;
2043}
2044
2045DEFUN (no_isis_hello_interval_l1,
2046 no_isis_hello_interval_l1_cmd,
2047 "no isis hello-interval level-1",
2048 NO_STR
2049 "IS-IS commands\n"
2050 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00002051 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002052{
Josh Bailey3f045a02012-03-24 08:35:20 -07002053 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2054 if (!circuit)
2055 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002056
Josh Bailey3f045a02012-03-24 08:35:20 -07002057 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002058
jardineb5d44e2003-12-23 08:09:43 +00002059 return CMD_SUCCESS;
2060}
2061
2062ALIAS (no_isis_hello_interval_l1,
2063 no_isis_hello_interval_l1_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002064 "no isis hello-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002065 NO_STR
2066 "IS-IS commands\n"
2067 "Set Hello interval\n"
2068 "Hello interval value\n"
2069 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002070 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002071
2072DEFUN (isis_hello_interval_l2,
2073 isis_hello_interval_l2_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002074 "isis hello-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002075 "IS-IS commands\n"
2076 "Set Hello interval\n"
2077 "Hello interval value\n"
2078 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002079 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002080{
jardineb5d44e2003-12-23 08:09:43 +00002081 long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002082 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2083 if (!circuit)
2084 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002085
Josh Bailey3f045a02012-03-24 08:35:20 -07002086 interval = atoi (argv[0]);
2087 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002088 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002089 vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
2090 interval, VTY_NEWLINE);
2091 return CMD_ERR_AMBIGUOUS;
hassof390d2c2004-09-10 20:48:21 +00002092 }
jardineb5d44e2003-12-23 08:09:43 +00002093
hassof390d2c2004-09-10 20:48:21 +00002094 circuit->hello_interval[1] = (u_int16_t) interval;
2095
jardineb5d44e2003-12-23 08:09:43 +00002096 return CMD_SUCCESS;
2097}
2098
2099DEFUN (no_isis_hello_interval_l2,
2100 no_isis_hello_interval_l2_cmd,
2101 "no isis hello-interval level-2",
2102 NO_STR
2103 "IS-IS commands\n"
2104 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00002105 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002106{
Josh Bailey3f045a02012-03-24 08:35:20 -07002107 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2108 if (!circuit)
2109 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002110
Josh Bailey3f045a02012-03-24 08:35:20 -07002111 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002112
jardineb5d44e2003-12-23 08:09:43 +00002113 return CMD_SUCCESS;
2114}
2115
2116ALIAS (no_isis_hello_interval_l2,
2117 no_isis_hello_interval_l2_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002118 "no isis hello-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002119 NO_STR
2120 "IS-IS commands\n"
2121 "Set Hello interval\n"
2122 "Hello interval value\n"
2123 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00002124 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002125
2126DEFUN (isis_hello_multiplier,
2127 isis_hello_multiplier_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002128 "isis hello-multiplier <2-100>",
jardineb5d44e2003-12-23 08:09:43 +00002129 "IS-IS commands\n"
2130 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002131 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00002132{
jardineb5d44e2003-12-23 08:09:43 +00002133 int mult;
Josh Bailey3f045a02012-03-24 08:35:20 -07002134 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2135 if (!circuit)
2136 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002137
2138 mult = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002139 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2140 {
2141 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2142 mult, VTY_NEWLINE);
2143 return CMD_ERR_AMBIGUOUS;
2144 }
jardineb5d44e2003-12-23 08:09:43 +00002145
hassof390d2c2004-09-10 20:48:21 +00002146 circuit->hello_multiplier[0] = (u_int16_t) mult;
2147 circuit->hello_multiplier[1] = (u_int16_t) mult;
2148
jardineb5d44e2003-12-23 08:09:43 +00002149 return CMD_SUCCESS;
2150}
2151
2152DEFUN (no_isis_hello_multiplier,
2153 no_isis_hello_multiplier_cmd,
2154 "no isis hello-multiplier",
2155 NO_STR
2156 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00002157 "Set multiplier for Hello holding time\n")
jardineb5d44e2003-12-23 08:09:43 +00002158{
Josh Bailey3f045a02012-03-24 08:35:20 -07002159 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2160 if (!circuit)
2161 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002162
Josh Bailey3f045a02012-03-24 08:35:20 -07002163 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
2164 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
jardineb5d44e2003-12-23 08:09:43 +00002165
2166 return CMD_SUCCESS;
2167}
2168
2169ALIAS (no_isis_hello_multiplier,
2170 no_isis_hello_multiplier_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002171 "no isis hello-multiplier <2-100>",
jardineb5d44e2003-12-23 08:09:43 +00002172 NO_STR
2173 "IS-IS commands\n"
2174 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002175 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00002176
2177DEFUN (isis_hello_multiplier_l1,
2178 isis_hello_multiplier_l1_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002179 "isis hello-multiplier <2-100> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002180 "IS-IS commands\n"
2181 "Set multiplier for Hello holding time\n"
2182 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002183 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002184{
jardineb5d44e2003-12-23 08:09:43 +00002185 int mult;
Josh Bailey3f045a02012-03-24 08:35:20 -07002186 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2187 if (!circuit)
2188 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002189
2190 mult = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002191 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2192 {
2193 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2194 mult, VTY_NEWLINE);
2195 return CMD_ERR_AMBIGUOUS;
2196 }
jardineb5d44e2003-12-23 08:09:43 +00002197
hassof390d2c2004-09-10 20:48:21 +00002198 circuit->hello_multiplier[0] = (u_int16_t) mult;
2199
jardineb5d44e2003-12-23 08:09:43 +00002200 return CMD_SUCCESS;
2201}
2202
2203DEFUN (no_isis_hello_multiplier_l1,
2204 no_isis_hello_multiplier_l1_cmd,
2205 "no isis hello-multiplier level-1",
2206 NO_STR
2207 "IS-IS commands\n"
2208 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002209 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002210{
Josh Bailey3f045a02012-03-24 08:35:20 -07002211 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2212 if (!circuit)
2213 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002214
Josh Bailey3f045a02012-03-24 08:35:20 -07002215 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
jardineb5d44e2003-12-23 08:09:43 +00002216
2217 return CMD_SUCCESS;
2218}
2219
2220ALIAS (no_isis_hello_multiplier_l1,
2221 no_isis_hello_multiplier_l1_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002222 "no isis hello-multiplier <2-100> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002223 NO_STR
2224 "IS-IS commands\n"
2225 "Set multiplier for Hello holding time\n"
2226 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002227 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002228
2229DEFUN (isis_hello_multiplier_l2,
2230 isis_hello_multiplier_l2_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002231 "isis hello-multiplier <2-100> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002232 "IS-IS commands\n"
2233 "Set multiplier for Hello holding time\n"
2234 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002235 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002236{
jardineb5d44e2003-12-23 08:09:43 +00002237 int mult;
Josh Bailey3f045a02012-03-24 08:35:20 -07002238 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2239 if (!circuit)
2240 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002241
2242 mult = atoi (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002243 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2244 {
2245 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2246 mult, VTY_NEWLINE);
2247 return CMD_ERR_AMBIGUOUS;
2248 }
jardineb5d44e2003-12-23 08:09:43 +00002249
hassof390d2c2004-09-10 20:48:21 +00002250 circuit->hello_multiplier[1] = (u_int16_t) mult;
2251
jardineb5d44e2003-12-23 08:09:43 +00002252 return CMD_SUCCESS;
2253}
2254
2255DEFUN (no_isis_hello_multiplier_l2,
2256 no_isis_hello_multiplier_l2_cmd,
2257 "no isis hello-multiplier level-2",
2258 NO_STR
2259 "IS-IS commands\n"
2260 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00002261 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002262{
Josh Bailey3f045a02012-03-24 08:35:20 -07002263 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2264 if (!circuit)
2265 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002266
Josh Bailey3f045a02012-03-24 08:35:20 -07002267 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
jardineb5d44e2003-12-23 08:09:43 +00002268
2269 return CMD_SUCCESS;
2270}
2271
2272ALIAS (no_isis_hello_multiplier_l2,
2273 no_isis_hello_multiplier_l2_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002274 "no isis hello-multiplier <2-100> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002275 NO_STR
2276 "IS-IS commands\n"
2277 "Set multiplier for Hello holding time\n"
2278 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00002279 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00002280
Josh Bailey3f045a02012-03-24 08:35:20 -07002281DEFUN (isis_hello_padding,
2282 isis_hello_padding_cmd,
jardineb5d44e2003-12-23 08:09:43 +00002283 "isis hello padding",
2284 "IS-IS commands\n"
2285 "Add padding to IS-IS hello packets\n"
2286 "Pad hello packets\n"
2287 "<cr>\n")
2288{
Josh Bailey3f045a02012-03-24 08:35:20 -07002289 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2290 if (!circuit)
2291 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002292
Josh Bailey3f045a02012-03-24 08:35:20 -07002293 circuit->pad_hellos = 1;
hassof390d2c2004-09-10 20:48:21 +00002294
jardineb5d44e2003-12-23 08:09:43 +00002295 return CMD_SUCCESS;
2296}
2297
Josh Bailey3f045a02012-03-24 08:35:20 -07002298DEFUN (no_isis_hello_padding,
2299 no_isis_hello_padding_cmd,
jardineb5d44e2003-12-23 08:09:43 +00002300 "no isis hello padding",
2301 NO_STR
2302 "IS-IS commands\n"
2303 "Add padding to IS-IS hello packets\n"
2304 "Pad hello packets\n"
2305 "<cr>\n")
2306{
Josh Bailey3f045a02012-03-24 08:35:20 -07002307 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2308 if (!circuit)
2309 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002310
Josh Bailey3f045a02012-03-24 08:35:20 -07002311 circuit->pad_hellos = 0;
hassof390d2c2004-09-10 20:48:21 +00002312
jardineb5d44e2003-12-23 08:09:43 +00002313 return CMD_SUCCESS;
2314}
2315
2316DEFUN (csnp_interval,
2317 csnp_interval_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002318 "isis csnp-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00002319 "IS-IS commands\n"
2320 "Set CSNP interval in seconds\n"
2321 "CSNP interval value\n")
2322{
jardineb5d44e2003-12-23 08:09:43 +00002323 unsigned long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002324 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2325 if (!circuit)
2326 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002327
jardineb5d44e2003-12-23 08:09:43 +00002328 interval = atol (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002329 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2330 {
2331 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2332 interval, VTY_NEWLINE);
2333 return CMD_ERR_AMBIGUOUS;
2334 }
jardineb5d44e2003-12-23 08:09:43 +00002335
hassof390d2c2004-09-10 20:48:21 +00002336 circuit->csnp_interval[0] = (u_int16_t) interval;
2337 circuit->csnp_interval[1] = (u_int16_t) interval;
2338
jardineb5d44e2003-12-23 08:09:43 +00002339 return CMD_SUCCESS;
2340}
2341
2342DEFUN (no_csnp_interval,
2343 no_csnp_interval_cmd,
2344 "no isis csnp-interval",
2345 NO_STR
2346 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00002347 "Set CSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002348{
Josh Bailey3f045a02012-03-24 08:35:20 -07002349 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2350 if (!circuit)
2351 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002352
Josh Bailey3f045a02012-03-24 08:35:20 -07002353 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
2354 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002355
jardineb5d44e2003-12-23 08:09:43 +00002356 return CMD_SUCCESS;
2357}
2358
2359ALIAS (no_csnp_interval,
2360 no_csnp_interval_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002361 "no isis csnp-interval <1-600>",
jardineb5d44e2003-12-23 08:09:43 +00002362 NO_STR
2363 "IS-IS commands\n"
2364 "Set CSNP interval in seconds\n"
2365 "CSNP interval value\n")
2366
jardineb5d44e2003-12-23 08:09:43 +00002367DEFUN (csnp_interval_l1,
2368 csnp_interval_l1_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002369 "isis csnp-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002370 "IS-IS commands\n"
2371 "Set CSNP interval in seconds\n"
2372 "CSNP interval value\n"
2373 "Specify interval for level-1 CSNPs\n")
2374{
jardineb5d44e2003-12-23 08:09:43 +00002375 unsigned long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002376 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2377 if (!circuit)
2378 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002379
jardineb5d44e2003-12-23 08:09:43 +00002380 interval = atol (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002381 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2382 {
2383 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2384 interval, VTY_NEWLINE);
2385 return CMD_ERR_AMBIGUOUS;
2386 }
hassof390d2c2004-09-10 20:48:21 +00002387
2388 circuit->csnp_interval[0] = (u_int16_t) interval;
2389
jardineb5d44e2003-12-23 08:09:43 +00002390 return CMD_SUCCESS;
2391}
2392
2393DEFUN (no_csnp_interval_l1,
2394 no_csnp_interval_l1_cmd,
2395 "no isis csnp-interval level-1",
2396 NO_STR
2397 "IS-IS commands\n"
2398 "Set CSNP interval in seconds\n"
2399 "Specify interval for level-1 CSNPs\n")
2400{
Josh Bailey3f045a02012-03-24 08:35:20 -07002401 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2402 if (!circuit)
2403 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002404
Josh Bailey3f045a02012-03-24 08:35:20 -07002405 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002406
jardineb5d44e2003-12-23 08:09:43 +00002407 return CMD_SUCCESS;
2408}
2409
2410ALIAS (no_csnp_interval_l1,
2411 no_csnp_interval_l1_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002412 "no isis csnp-interval <1-600> level-1",
jardineb5d44e2003-12-23 08:09:43 +00002413 NO_STR
2414 "IS-IS commands\n"
2415 "Set CSNP interval in seconds\n"
2416 "CSNP interval value\n"
2417 "Specify interval for level-1 CSNPs\n")
2418
jardineb5d44e2003-12-23 08:09:43 +00002419DEFUN (csnp_interval_l2,
2420 csnp_interval_l2_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002421 "isis csnp-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002422 "IS-IS commands\n"
2423 "Set CSNP interval in seconds\n"
2424 "CSNP interval value\n"
2425 "Specify interval for level-2 CSNPs\n")
2426{
jardineb5d44e2003-12-23 08:09:43 +00002427 unsigned long interval;
Josh Bailey3f045a02012-03-24 08:35:20 -07002428 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2429 if (!circuit)
2430 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002431
jardineb5d44e2003-12-23 08:09:43 +00002432 interval = atol (argv[0]);
Josh Bailey3f045a02012-03-24 08:35:20 -07002433 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2434 {
2435 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2436 interval, VTY_NEWLINE);
2437 return CMD_ERR_AMBIGUOUS;
2438 }
hassof390d2c2004-09-10 20:48:21 +00002439
2440 circuit->csnp_interval[1] = (u_int16_t) interval;
2441
jardineb5d44e2003-12-23 08:09:43 +00002442 return CMD_SUCCESS;
2443}
2444
2445DEFUN (no_csnp_interval_l2,
2446 no_csnp_interval_l2_cmd,
2447 "no isis csnp-interval level-2",
2448 NO_STR
2449 "IS-IS commands\n"
2450 "Set CSNP interval in seconds\n"
2451 "Specify interval for level-2 CSNPs\n")
2452{
Josh Bailey3f045a02012-03-24 08:35:20 -07002453 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2454 if (!circuit)
2455 return CMD_ERR_NO_MATCH;
jardineb5d44e2003-12-23 08:09:43 +00002456
Josh Bailey3f045a02012-03-24 08:35:20 -07002457 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002458
jardineb5d44e2003-12-23 08:09:43 +00002459 return CMD_SUCCESS;
2460}
2461
2462ALIAS (no_csnp_interval_l2,
2463 no_csnp_interval_l2_arg_cmd,
Josh Bailey3f045a02012-03-24 08:35:20 -07002464 "no isis csnp-interval <1-600> level-2",
jardineb5d44e2003-12-23 08:09:43 +00002465 NO_STR
2466 "IS-IS commands\n"
2467 "Set CSNP interval in seconds\n"
2468 "CSNP interval value\n"
2469 "Specify interval for level-2 CSNPs\n")
2470
Josh Bailey3f045a02012-03-24 08:35:20 -07002471DEFUN (psnp_interval,
2472 psnp_interval_cmd,
2473 "isis psnp-interval <1-120>",
2474 "IS-IS commands\n"
2475 "Set PSNP interval in seconds\n"
2476 "PSNP interval value\n")
jardineb5d44e2003-12-23 08:09:43 +00002477{
Josh Bailey3f045a02012-03-24 08:35:20 -07002478 unsigned long interval;
2479 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2480 if (!circuit)
2481 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002482
Josh Bailey3f045a02012-03-24 08:35:20 -07002483 interval = atol (argv[0]);
2484 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
hassof390d2c2004-09-10 20:48:21 +00002485 {
Josh Bailey3f045a02012-03-24 08:35:20 -07002486 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2487 interval, VTY_NEWLINE);
2488 return CMD_ERR_AMBIGUOUS;
jardineb5d44e2003-12-23 08:09:43 +00002489 }
jardineb5d44e2003-12-23 08:09:43 +00002490
Josh Bailey3f045a02012-03-24 08:35:20 -07002491 circuit->psnp_interval[0] = (u_int16_t) interval;
2492 circuit->psnp_interval[1] = (u_int16_t) interval;
jardineb5d44e2003-12-23 08:09:43 +00002493
2494 return CMD_SUCCESS;
2495}
2496
Josh Bailey3f045a02012-03-24 08:35:20 -07002497DEFUN (no_psnp_interval,
2498 no_psnp_interval_cmd,
2499 "no isis psnp-interval",
jardineb5d44e2003-12-23 08:09:43 +00002500 NO_STR
Josh Bailey3f045a02012-03-24 08:35:20 -07002501 "IS-IS commands\n"
2502 "Set PSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00002503{
Josh Bailey3f045a02012-03-24 08:35:20 -07002504 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2505 if (!circuit)
2506 return CMD_ERR_NO_MATCH;
hassof390d2c2004-09-10 20:48:21 +00002507
Josh Bailey3f045a02012-03-24 08:35:20 -07002508 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
2509 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
jardineb5d44e2003-12-23 08:09:43 +00002510
2511 return CMD_SUCCESS;
2512}
jardineb5d44e2003-12-23 08:09:43 +00002513
Josh Bailey3f045a02012-03-24 08:35:20 -07002514ALIAS (no_psnp_interval,
2515 no_psnp_interval_arg_cmd,
2516 "no isis psnp-interval <1-120>",
2517 NO_STR
2518 "IS-IS commands\n"
2519 "Set PSNP interval in seconds\n"
2520 "PSNP interval value\n")
2521
2522DEFUN (psnp_interval_l1,
2523 psnp_interval_l1_cmd,
2524 "isis psnp-interval <1-120> level-1",
2525 "IS-IS commands\n"
2526 "Set PSNP interval in seconds\n"
2527 "PSNP interval value\n"
2528 "Specify interval for level-1 PSNPs\n")
2529{
2530 unsigned long interval;
2531 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2532 if (!circuit)
2533 return CMD_ERR_NO_MATCH;
2534
2535 interval = atol (argv[0]);
2536 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2537 {
2538 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2539 interval, VTY_NEWLINE);
2540 return CMD_ERR_AMBIGUOUS;
2541 }
2542
2543 circuit->psnp_interval[0] = (u_int16_t) interval;
2544
2545 return CMD_SUCCESS;
2546}
2547
2548DEFUN (no_psnp_interval_l1,
2549 no_psnp_interval_l1_cmd,
2550 "no isis psnp-interval level-1",
2551 NO_STR
2552 "IS-IS commands\n"
2553 "Set PSNP interval in seconds\n"
2554 "Specify interval for level-1 PSNPs\n")
2555{
2556 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2557 if (!circuit)
2558 return CMD_ERR_NO_MATCH;
2559
2560 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
2561
2562 return CMD_SUCCESS;
2563}
2564
2565ALIAS (no_psnp_interval_l1,
2566 no_psnp_interval_l1_arg_cmd,
2567 "no isis psnp-interval <1-120> level-1",
2568 NO_STR
2569 "IS-IS commands\n"
2570 "Set PSNP interval in seconds\n"
2571 "PSNP interval value\n"
2572 "Specify interval for level-1 PSNPs\n")
2573
2574DEFUN (psnp_interval_l2,
2575 psnp_interval_l2_cmd,
2576 "isis psnp-interval <1-120> level-2",
2577 "IS-IS commands\n"
2578 "Set PSNP interval in seconds\n"
2579 "PSNP interval value\n"
2580 "Specify interval for level-2 PSNPs\n")
2581{
2582 unsigned long interval;
2583 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2584 if (!circuit)
2585 return CMD_ERR_NO_MATCH;
2586
2587 interval = atol (argv[0]);
2588 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2589 {
2590 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2591 interval, VTY_NEWLINE);
2592 return CMD_ERR_AMBIGUOUS;
2593 }
2594
2595 circuit->psnp_interval[1] = (u_int16_t) interval;
2596
2597 return CMD_SUCCESS;
2598}
2599
2600DEFUN (no_psnp_interval_l2,
2601 no_psnp_interval_l2_cmd,
2602 "no isis psnp-interval level-2",
2603 NO_STR
2604 "IS-IS commands\n"
2605 "Set PSNP interval in seconds\n"
2606 "Specify interval for level-2 PSNPs\n")
2607{
2608 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2609 if (!circuit)
2610 return CMD_ERR_NO_MATCH;
2611
2612 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
2613
2614 return CMD_SUCCESS;
2615}
2616
2617ALIAS (no_psnp_interval_l2,
2618 no_psnp_interval_l2_arg_cmd,
2619 "no isis psnp-interval <1-120> level-2",
2620 NO_STR
2621 "IS-IS commands\n"
2622 "Set PSNP interval in seconds\n"
2623 "PSNP interval value\n"
2624 "Specify interval for level-2 PSNPs\n")
2625
2626struct cmd_node interface_node = {
jardineb5d44e2003-12-23 08:09:43 +00002627 INTERFACE_NODE,
2628 "%s(config-if)# ",
2629 1,
2630};
2631
Josh Bailey3f045a02012-03-24 08:35:20 -07002632DEFUN (isis_network,
2633 isis_network_cmd,
2634 "isis network point-to-point",
2635 "IS-IS commands\n"
2636 "Set network type\n"
2637 "point-to-point network type\n")
2638{
2639 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2640 if (!circuit)
2641 return CMD_ERR_NO_MATCH;
2642
2643 /* RFC5309 section 4 */
2644 if (circuit->circ_type == CIRCUIT_T_P2P)
2645 return CMD_SUCCESS;
2646
2647 if (circuit->state != C_STATE_UP)
2648 {
2649 circuit->circ_type = CIRCUIT_T_P2P;
2650 circuit->circ_type_config = CIRCUIT_T_P2P;
2651 }
2652 else
2653 {
2654 struct isis_area *area = circuit->area;
2655 if (!if_is_broadcast (circuit->interface))
2656 {
2657 vty_out (vty, "isis network point-to-point "
2658 "is valid only on broadcast interfaces%s",
2659 VTY_NEWLINE);
2660 return CMD_ERR_AMBIGUOUS;
2661 }
2662
2663 isis_csm_state_change (ISIS_DISABLE, circuit, area);
2664 circuit->circ_type = CIRCUIT_T_P2P;
2665 circuit->circ_type_config = CIRCUIT_T_P2P;
2666 isis_csm_state_change (ISIS_ENABLE, circuit, area);
2667 }
2668
2669 return CMD_SUCCESS;
2670}
2671
2672DEFUN (no_isis_network,
2673 no_isis_network_cmd,
2674 "no isis network point-to-point",
2675 NO_STR
2676 "IS-IS commands\n"
2677 "Set network type for circuit\n"
2678 "point-to-point network type\n")
2679{
2680 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2681 if (!circuit)
2682 return CMD_ERR_NO_MATCH;
2683
2684 /* RFC5309 section 4 */
2685 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
2686 return CMD_SUCCESS;
2687
2688 if (circuit->state != C_STATE_UP)
2689 {
2690 circuit->circ_type = CIRCUIT_T_BROADCAST;
2691 circuit->circ_type_config = CIRCUIT_T_BROADCAST;
2692 }
2693 else
2694 {
2695 struct isis_area *area = circuit->area;
2696 if (circuit->interface &&
2697 !if_is_broadcast (circuit->interface))
2698 {
2699 vty_out (vty, "no isis network point-to-point "
2700 "is valid only on broadcast interfaces%s",
2701 VTY_NEWLINE);
2702 return CMD_ERR_AMBIGUOUS;
2703 }
2704
2705 isis_csm_state_change (ISIS_DISABLE, circuit, area);
2706 circuit->circ_type = CIRCUIT_T_BROADCAST;
2707 circuit->circ_type_config = CIRCUIT_T_BROADCAST;
2708 isis_csm_state_change (ISIS_ENABLE, circuit, area);
2709 }
2710
2711 return CMD_SUCCESS;
2712}
2713
jardineb5d44e2003-12-23 08:09:43 +00002714int
2715isis_if_new_hook (struct interface *ifp)
2716{
jardineb5d44e2003-12-23 08:09:43 +00002717 return 0;
2718}
2719
2720int
2721isis_if_delete_hook (struct interface *ifp)
2722{
jardineb5d44e2003-12-23 08:09:43 +00002723 return 0;
2724}
2725
jardineb5d44e2003-12-23 08:09:43 +00002726void
2727isis_circuit_init ()
2728{
jardineb5d44e2003-12-23 08:09:43 +00002729 /* Initialize Zebra interface data structure */
2730 if_init ();
2731 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2732 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2733
2734 /* Install interface node */
2735 install_node (&interface_node, isis_interface_config_write);
2736 install_element (CONFIG_NODE, &interface_cmd);
2737
2738 install_default (INTERFACE_NODE);
2739 install_element (INTERFACE_NODE, &interface_desc_cmd);
2740 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2741
2742 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2743 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2744
Josh Bailey3f045a02012-03-24 08:35:20 -07002745 install_element (INTERFACE_NODE, &isis_passive_cmd);
2746 install_element (INTERFACE_NODE, &no_isis_passive_cmd);
2747
jardineb5d44e2003-12-23 08:09:43 +00002748 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2749 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2750
Josh Bailey3f045a02012-03-24 08:35:20 -07002751 install_element (INTERFACE_NODE, &isis_passwd_clear_cmd);
2752 install_element (INTERFACE_NODE, &isis_passwd_md5_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002753 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2754
2755 install_element (INTERFACE_NODE, &isis_priority_cmd);
2756 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2757 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2758 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2759 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2760 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2761 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2762 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2763 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2764
2765 install_element (INTERFACE_NODE, &isis_metric_cmd);
2766 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2767 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
Josh Bailey3f045a02012-03-24 08:35:20 -07002768 install_element (INTERFACE_NODE, &isis_metric_l1_cmd);
2769 install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd);
2770 install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd);
2771 install_element (INTERFACE_NODE, &isis_metric_l2_cmd);
2772 install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd);
2773 install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002774
2775 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2776 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2777 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2778 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2779 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2780 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2781 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2782 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2783 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2784
2785 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2786 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2787 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2788 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2789 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2790 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2791 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2792 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2793 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2794
Josh Bailey3f045a02012-03-24 08:35:20 -07002795 install_element (INTERFACE_NODE, &isis_hello_padding_cmd);
2796 install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd);
2797
jardineb5d44e2003-12-23 08:09:43 +00002798 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2799 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2800 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2801 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2802 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2803 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2804 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2805 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2806 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2807
Josh Bailey3f045a02012-03-24 08:35:20 -07002808 install_element (INTERFACE_NODE, &psnp_interval_cmd);
2809 install_element (INTERFACE_NODE, &no_psnp_interval_cmd);
2810 install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd);
2811 install_element (INTERFACE_NODE, &psnp_interval_l1_cmd);
2812 install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd);
2813 install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd);
2814 install_element (INTERFACE_NODE, &psnp_interval_l2_cmd);
2815 install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd);
2816 install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd);
2817
2818 install_element (INTERFACE_NODE, &isis_network_cmd);
2819 install_element (INTERFACE_NODE, &no_isis_network_cmd);
2820
jardineb5d44e2003-12-23 08:09:43 +00002821#ifdef HAVE_IPV6
2822 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2823 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
jardineb5d44e2003-12-23 08:09:43 +00002824#endif
jardineb5d44e2003-12-23 08:09:43 +00002825}