blob: 3669cf437fa5367e1214c756038ca65687cc3d1f [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 */
22#include <stdlib.h>
23#include <stdio.h>
24#include <ctype.h>
25#include <zebra.h>
hasso37da8c02004-05-19 11:38:40 +000026#ifdef GNU_LINUX
jardineb5d44e2003-12-23 08:09:43 +000027#include <net/ethernet.h>
hasso37da8c02004-05-19 11:38:40 +000028#else
29#include <netinet/if_ether.h>
30#endif
jardineb5d44e2003-12-23 08:09:43 +000031
32#include "log.h"
33#include "memory.h"
34#include "if.h"
35#include "linklist.h"
36#include "command.h"
37#include "thread.h"
38#include "hash.h"
39#include "prefix.h"
40#include "stream.h"
41
42#include "isisd/dict.h"
43#include "isisd/include-netbsd/iso.h"
44#include "isisd/isis_constants.h"
45#include "isisd/isis_common.h"
46#include "isisd/isis_circuit.h"
47#include "isisd/isis_tlv.h"
48#include "isisd/isis_lsp.h"
49#include "isisd/isis_pdu.h"
50#include "isisd/isis_network.h"
51#include "isisd/isis_misc.h"
52#include "isisd/isis_constants.h"
53#include "isisd/isis_adjacency.h"
54#include "isisd/isis_dr.h"
55#include "isisd/isis_flags.h"
56#include "isisd/isisd.h"
57#include "isisd/isis_csm.h"
58#include "isisd/isis_events.h"
59
60extern struct thread_master *master;
61extern struct isis *isis;
62
63struct isis_circuit *
64isis_circuit_new ()
65{
66 struct isis_circuit *circuit;
67 int i;
68
69 circuit = XMALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
hassof390d2c2004-09-10 20:48:21 +000070 if (circuit)
71 {
72 memset (circuit, 0, sizeof (struct isis_circuit));
73 /* set default metrics for circuit */
74 for (i = 0; i < 2; i++)
75 {
76 circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS;
77 circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
78 circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
79 circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
80 }
jardineb5d44e2003-12-23 08:09:43 +000081 }
hassof390d2c2004-09-10 20:48:21 +000082 else
83 {
84 zlog_err ("Can't malloc isis circuit");
85 return NULL;
86 }
87
jardineb5d44e2003-12-23 08:09:43 +000088 return circuit;
89}
90
jardineb5d44e2003-12-23 08:09:43 +000091void
92isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
93{
94 int i;
95 circuit->area = area;
96 /*
97 * The level for the circuit is same as for the area, unless configured
98 * otherwise.
99 */
100 circuit->circuit_is_type = area->is_type;
101 /*
102 * Default values
103 */
hassof390d2c2004-09-10 20:48:21 +0000104 for (i = 0; i < 2; i++)
105 {
106 circuit->hello_interval[i] = HELLO_INTERVAL;
107 circuit->hello_multiplier[i] = HELLO_MULTIPLIER;
108 circuit->csnp_interval[i] = CSNP_INTERVAL;
109 circuit->psnp_interval[i] = PSNP_INTERVAL;
110 circuit->u.bc.priority[i] = DEFAULT_PRIORITY;
111 }
112 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
113 {
114 circuit->u.bc.adjdb[0] = list_new ();
115 circuit->u.bc.adjdb[1] = list_new ();
116 circuit->u.bc.pad_hellos = 1;
117 }
jardineb5d44e2003-12-23 08:09:43 +0000118 circuit->lsp_interval = LSP_INTERVAL;
119
120 /*
121 * Add the circuit into area
122 */
123 listnode_add (area->circuit_list, circuit);
124
125 circuit->idx = flags_get_index (&area->flags);
126 circuit->lsp_queue = list_new ();
127
128 return;
129}
130
hassof390d2c2004-09-10 20:48:21 +0000131void
jardineb5d44e2003-12-23 08:09:43 +0000132isis_circuit_deconfigure (struct isis_circuit *circuit,
hassof390d2c2004-09-10 20:48:21 +0000133 struct isis_area *area)
jardineb5d44e2003-12-23 08:09:43 +0000134{
hassof390d2c2004-09-10 20:48:21 +0000135
jardineb5d44e2003-12-23 08:09:43 +0000136 /* Remove circuit from area */
137 listnode_delete (area->circuit_list, circuit);
138 /* Free the index of SRM and SSN flags */
139 flags_free_index (&area->flags, circuit->idx);
140
141 return;
142}
143
144struct isis_circuit *
145circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
146{
147 struct isis_circuit *circuit = NULL;
148 struct listnode *node;
hassof390d2c2004-09-10 20:48:21 +0000149
jardineb5d44e2003-12-23 08:09:43 +0000150 if (!list)
151 return NULL;
hassof390d2c2004-09-10 20:48:21 +0000152
153 for (node = listhead (list); node; nextnode (node))
154 {
155 circuit = getdata (node);
156 if (circuit->interface == ifp)
157 return circuit;
158 }
159
jardineb5d44e2003-12-23 08:09:43 +0000160 return NULL;
161}
162
163struct isis_circuit *
164circuit_scan_by_ifp (struct interface *ifp)
165{
166 struct isis_area *area;
167 struct listnode *node;
168 struct isis_circuit *circuit;
169
170 if (!isis->area_list)
171 return NULL;
172
hassof390d2c2004-09-10 20:48:21 +0000173 for (node = listhead (isis->area_list); node; nextnode (node))
174 {
175 area = getdata (node);
176 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
177 if (circuit)
178 return circuit;
179 }
180
jardineb5d44e2003-12-23 08:09:43 +0000181 return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
182}
183
184void
185isis_circuit_del (struct isis_circuit *circuit)
186{
187
188 if (!circuit)
189 return;
190
hassof390d2c2004-09-10 20:48:21 +0000191 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
192 {
193 /* destroy adjacency databases */
194 list_delete (circuit->u.bc.adjdb[0]);
195 list_delete (circuit->u.bc.adjdb[1]);
196 /* destroy neighbour lists */
197 if (circuit->u.bc.lan_neighs[0])
198 list_delete (circuit->u.bc.lan_neighs[0]);
199 if (circuit->u.bc.lan_neighs[1])
200 list_delete (circuit->u.bc.lan_neighs[1]);
201 /* destroy addresses */
202 }
jardineb5d44e2003-12-23 08:09:43 +0000203 if (circuit->ip_addrs)
204 list_delete (circuit->ip_addrs);
205#ifdef HAVE_IPV6
206 if (circuit->ipv6_link)
207 list_delete (circuit->ipv6_link);
208 if (circuit->ipv6_non_link)
209 list_delete (circuit->ipv6_non_link);
210#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000211
jardineb5d44e2003-12-23 08:09:43 +0000212 /* and lastly the circuit itself */
213 XFREE (MTYPE_ISIS_CIRCUIT, circuit);
214
215 return;
216}
217
218void
hassof891f442004-09-14 13:54:30 +0000219isis_circuit_add_addr (struct isis_circuit *circuit,
220 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000221{
222 struct prefix_ipv4 *ipv4;
hassof390d2c2004-09-10 20:48:21 +0000223 u_char buf[BUFSIZ];
jardineb5d44e2003-12-23 08:09:43 +0000224#ifdef HAVE_IPV6
225 struct prefix_ipv6 *ipv6;
226#endif /* HAVE_IPV6 */
hassof891f442004-09-14 13:54:30 +0000227
hassof390d2c2004-09-10 20:48:21 +0000228 if (!circuit->ip_addrs)
hassof891f442004-09-14 13:54:30 +0000229 circuit->ip_addrs = list_new ();
jardineb5d44e2003-12-23 08:09:43 +0000230#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000231 if (!circuit->ipv6_link)
hassof891f442004-09-14 13:54:30 +0000232 circuit->ipv6_link = list_new ();
hassof390d2c2004-09-10 20:48:21 +0000233 if (!circuit->ipv6_non_link)
hassof891f442004-09-14 13:54:30 +0000234 circuit->ipv6_non_link = list_new ();
jardineb5d44e2003-12-23 08:09:43 +0000235#endif /* HAVE_IPV6 */
236
237 memset (&buf, 0, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000238 if (connected->address->family == AF_INET)
hassof390d2c2004-09-10 20:48:21 +0000239 {
240 ipv4 = prefix_ipv4_new ();
hassof891f442004-09-14 13:54:30 +0000241 ipv4->prefixlen = connected->address->prefixlen;
242 ipv4->prefix = connected->address->u.prefix4;
hassof390d2c2004-09-10 20:48:21 +0000243 listnode_add (circuit->ip_addrs, ipv4);
hasso0dae85e2004-09-26 19:53:47 +0000244 if (circuit->area)
245 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000246
jardineb5d44e2003-12-23 08:09:43 +0000247#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000248 prefix2str (connected->address, buf, BUFSIZ);
hassof390d2c2004-09-10 20:48:21 +0000249 zlog_info ("Added IP address %s to circuit %d", buf,
250 circuit->circuit_id);
251#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +0000252 }
hassof390d2c2004-09-10 20:48:21 +0000253#ifdef HAVE_IPV6
hassof891f442004-09-14 13:54:30 +0000254 if (connected->address->family == AF_INET6)
hassof390d2c2004-09-10 20:48:21 +0000255 {
256 ipv6 = prefix_ipv6_new ();
hassof891f442004-09-14 13:54:30 +0000257 ipv6->prefixlen = connected->address->prefixlen;
258 ipv6->prefix = connected->address->u.prefix6;
259
hassof390d2c2004-09-10 20:48:21 +0000260 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
hassof891f442004-09-14 13:54:30 +0000261 listnode_add (circuit->ipv6_link, ipv6);
hassof390d2c2004-09-10 20:48:21 +0000262 else
hassof891f442004-09-14 13:54:30 +0000263 listnode_add (circuit->ipv6_non_link, ipv6);
hasso0dae85e2004-09-26 19:53:47 +0000264 if (circuit->area)
265 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000266
jardineb5d44e2003-12-23 08:09:43 +0000267#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000268 prefix2str (connected->address, buf, BUFSIZ);
hassof390d2c2004-09-10 20:48:21 +0000269 zlog_info ("Added IPv6 address %s to circuit %d", buf,
270 circuit->circuit_id);
271#endif /* EXTREME_DEBUG */
272 }
jardineb5d44e2003-12-23 08:09:43 +0000273#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000274 return;
275}
276
277void
278isis_circuit_del_addr (struct isis_circuit *circuit,
hassof390d2c2004-09-10 20:48:21 +0000279 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000280{
hassof891f442004-09-14 13:54:30 +0000281 struct prefix_ipv4 *ipv4, *ip = NULL;
282 struct listnode *node;
283 int found = 0;
284 u_char buf[BUFSIZ];
285#ifdef HAVE_IPV6
286 struct prefix_ipv6 *ipv6, *ip6 = NULL;
287#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000288
hassof891f442004-09-14 13:54:30 +0000289 memset (&buf, 0, BUFSIZ);
290 if (connected->address->family == AF_INET)
291 {
292 ipv4 = prefix_ipv4_new ();
293 ipv4->prefixlen = connected->address->prefixlen;
294 ipv4->prefix = connected->address->u.prefix4;
295
296 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
297 {
298 ip = getdata (node);
299 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
300 break;
301 }
302
303 if (ip)
304 {
305 listnode_delete (circuit->ip_addrs, ip);
hasso0dae85e2004-09-26 19:53:47 +0000306 if (circuit->area)
307 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000308 }
309 else
310 {
hassof7c43dc2004-09-26 16:24:14 +0000311 prefix2str (connected->address, (char *)buf, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000312 zlog_warn("Nonexitant ip address %s removal attempt from circuit \
313 %d", buf, circuit->circuit_id);
314 }
315 }
316#ifdef HAVE_IPV6
317 if (connected->address->family == AF_INET6)
318 {
319 ipv6 = prefix_ipv6_new ();
320 ipv6->prefixlen = connected->address->prefixlen;
321 ipv6->prefix = connected->address->u.prefix6;
322
323 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
324 {
325 for (node = listhead (circuit->ipv6_link); node; nextnode (node))
326 {
327 ip6 = getdata (node);
328 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
329 break;
330 }
331 if (ip6)
332 {
333 listnode_delete (circuit->ipv6_link, ip6);
334 found = 1;
335 }
336 }
337 else
338 {
339 for (node = listhead (circuit->ipv6_non_link); node; nextnode (node))
340 {
341 ip6 = getdata (node);
342 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
343 break;
344 }
345 if (ip6)
346 {
347 listnode_delete (circuit->ipv6_non_link, ip6);
348 found = 1;
349 }
350 }
351
352 if (!found)
353 {
hassof7c43dc2004-09-26 16:24:14 +0000354 prefix2str (connected->address, (char *)buf, BUFSIZ);
hassof891f442004-09-14 13:54:30 +0000355 zlog_warn("Nonexitant ip address %s removal attempt from \
356 circuit %d", buf, circuit->circuit_id);
357 }
358 else
hasso0dae85e2004-09-26 19:53:47 +0000359 if (circuit->area)
360 lsp_regenerate_schedule (circuit->area);
hassof891f442004-09-14 13:54:30 +0000361 }
362#endif /* HAVE_IPV6 */
363 return;
jardineb5d44e2003-12-23 08:09:43 +0000364}
365
366void
367isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
368{
369 struct listnode *node;
370 struct connected *conn;
371
372 circuit->interface = ifp;
373 ifp->info = circuit;
hassof390d2c2004-09-10 20:48:21 +0000374
375 circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
jardineb5d44e2003-12-23 08:09:43 +0000376
377 /* isis_circuit_update_addrs (circuit, ifp); */
378
hassof390d2c2004-09-10 20:48:21 +0000379 if (if_is_broadcast (ifp))
380 {
381 circuit->circ_type = CIRCUIT_T_BROADCAST;
382 /*
383 * Get the Hardware Address
384 */
jardineb5d44e2003-12-23 08:09:43 +0000385#ifdef HAVE_SOCKADDR_DL
hassof390d2c2004-09-10 20:48:21 +0000386 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
387 zlog_warn ("unsupported link layer");
388 else
389 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
390 ETH_ALEN);
jardineb5d44e2003-12-23 08:09:43 +0000391#else
hassof390d2c2004-09-10 20:48:21 +0000392 if (circuit->interface->hw_addr_len != ETH_ALEN)
393 {
394 zlog_warn ("unsupported link layer");
395 }
396 else
397 {
398 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
399 }
jardineb5d44e2003-12-23 08:09:43 +0000400#ifdef EXTREME_DEGUG
hassof390d2c2004-09-10 20:48:21 +0000401 zlog_info ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
402 circuit->interface->ifindex, ISO_MTU (circuit),
403 snpa_print (circuit->u.bc.snpa));
jardineb5d44e2003-12-23 08:09:43 +0000404
405#endif /* EXTREME_DEBUG */
hassof390d2c2004-09-10 20:48:21 +0000406#endif /* HAVE_SOCKADDR_DL */
407 }
408 else if (if_is_pointopoint (ifp))
409 {
410 circuit->circ_type = CIRCUIT_T_P2P;
411 }
412 else
413 {
414 zlog_warn ("isis_circuit_if_add: unsupported media");
415 }
416
417 for (node = ifp->connected ? listhead (ifp->connected) : NULL; node;
418 nextnode (node))
419 {
420 conn = getdata (node);
421 isis_circuit_add_addr (circuit, conn);
422 }
jardineb5d44e2003-12-23 08:09:43 +0000423
424 return;
425}
426
427void
hassof390d2c2004-09-10 20:48:21 +0000428isis_circuit_update_params (struct isis_circuit *circuit,
429 struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000430{
431 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +0000432
433 if (circuit->circuit_id != ifp->ifindex)
434 {
435 zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
436 ifp->ifindex);
437 circuit->circuit_id = ifp->ifindex % 255;
438 }
jardineb5d44e2003-12-23 08:09:43 +0000439
440 /* FIXME: Why is this needed? shouldn't we compare to the area's mtu */
441 /* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig)
442 The areas MTU is the minimum of mtu's of circuits in the area
443 now we can't catch the change
444 if (circuit->mtu != ifp->mtu) {
445 zlog_warn ("changing circuit mtu %d->%d", circuit->mtu,
446 ifp->mtu);
447 circuit->mtu = ifp->mtu;
448 }
hassof390d2c2004-09-10 20:48:21 +0000449 */
jardineb5d44e2003-12-23 08:09:43 +0000450 /*
451 * Get the Hardware Address
452 */
453#ifdef HAVE_SOCKADDR_DL
454 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
jardineb5d44e2003-12-23 08:09:43 +0000455 zlog_warn ("unsupported link layer");
hassof390d2c2004-09-10 20:48:21 +0000456 else
457 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN);
458#else
459 if (circuit->interface->hw_addr_len != ETH_ALEN)
460 {
461 zlog_warn ("unsupported link layer");
jardineb5d44e2003-12-23 08:09:43 +0000462 }
hassof390d2c2004-09-10 20:48:21 +0000463 else
464 {
465 if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN))
466 {
467 zlog_warn ("changing circuit snpa %s->%s",
468 snpa_print (circuit->u.bc.snpa),
469 snpa_print (circuit->interface->hw_addr));
470 }
471 }
472#endif
jardineb5d44e2003-12-23 08:09:43 +0000473
hassof390d2c2004-09-10 20:48:21 +0000474 if (if_is_broadcast (ifp))
475 {
476 circuit->circ_type = CIRCUIT_T_BROADCAST;
477 }
478 else if (if_is_pointopoint (ifp))
479 {
480 circuit->circ_type = CIRCUIT_T_P2P;
481 }
482 else
483 {
484 zlog_warn ("isis_circuit_update_params: unsupported media");
485 }
jardineb5d44e2003-12-23 08:09:43 +0000486
jardineb5d44e2003-12-23 08:09:43 +0000487 return;
488}
489
490void
hassof390d2c2004-09-10 20:48:21 +0000491isis_circuit_if_del (struct isis_circuit *circuit)
jardineb5d44e2003-12-23 08:09:43 +0000492{
493 circuit->interface->info = NULL;
494 circuit->interface = NULL;
hassof390d2c2004-09-10 20:48:21 +0000495
jardineb5d44e2003-12-23 08:09:43 +0000496 return;
497}
498
499void
500isis_circuit_up (struct isis_circuit *circuit)
501{
jardineb5d44e2003-12-23 08:09:43 +0000502
hassof390d2c2004-09-10 20:48:21 +0000503 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
504 {
505 if (circuit->area->min_bcast_mtu == 0 ||
506 ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
507 circuit->area->min_bcast_mtu = ISO_MTU (circuit);
508 /*
509 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
510 */
jardineb5d44e2003-12-23 08:09:43 +0000511
hassof390d2c2004-09-10 20:48:21 +0000512 /* initilizing the hello sending threads
513 * for a broadcast IF
514 */
jardineb5d44e2003-12-23 08:09:43 +0000515
hassof390d2c2004-09-10 20:48:21 +0000516 /* 8.4.1 a) commence sending of IIH PDUs */
517
518 if (circuit->circuit_is_type & IS_LEVEL_1)
519 {
520 thread_add_event (master, send_lan_l1_hello, circuit, 0);
521 circuit->u.bc.lan_neighs[0] = list_new ();
522 }
523
524 if (circuit->circuit_is_type & IS_LEVEL_2)
525 {
526 thread_add_event (master, send_lan_l2_hello, circuit, 0);
527 circuit->u.bc.lan_neighs[1] = list_new ();
528 }
529
530 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
531 /* 8.4.1 c) FIXME: listen for ESH PDUs */
532
533 /* 8.4.1 d) */
534 /* dr election will commence in... */
535 if (circuit->circuit_is_type & IS_LEVEL_1)
536 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
hassobf731012004-09-17 07:59:57 +0000537 circuit, 2 * circuit->hello_interval[0]);
hassof390d2c2004-09-10 20:48:21 +0000538 if (circuit->circuit_is_type & IS_LEVEL_2)
539 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
hassobf731012004-09-17 07:59:57 +0000540 circuit, 2 * circuit->hello_interval[1]);
jardineb5d44e2003-12-23 08:09:43 +0000541 }
hassof390d2c2004-09-10 20:48:21 +0000542 else
543 {
544 /* initializing the hello send threads
545 * for a ptp IF
546 */
547 thread_add_event (master, send_p2p_hello, circuit, 0);
jardineb5d44e2003-12-23 08:09:43 +0000548
jardineb5d44e2003-12-23 08:09:43 +0000549 }
550
jardineb5d44e2003-12-23 08:09:43 +0000551 /* initializing PSNP timers */
hassof390d2c2004-09-10 20:48:21 +0000552 if (circuit->circuit_is_type & IS_LEVEL_1)
553 {
554 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
555 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
556 }
557
558 if (circuit->circuit_is_type & IS_LEVEL_2)
559 {
560 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
561 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
562 }
563
jardineb5d44e2003-12-23 08:09:43 +0000564 /* initialize the circuit streams */
565 if (circuit->rcv_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000566 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000567
568 if (circuit->snd_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000569 circuit->snd_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000570
571 /* unified init for circuits */
572 isis_sock_init (circuit);
573
574#ifdef GNU_LINUX
hassof390d2c2004-09-10 20:48:21 +0000575 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
576 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000577#else
hassof390d2c2004-09-10 20:48:21 +0000578 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
579 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000580#endif
581 return;
582}
583
584void
585isis_circuit_down (struct isis_circuit *circuit)
586{
hassof390d2c2004-09-10 20:48:21 +0000587 /* Cancel all active threads -- FIXME: wrong place */
hassod70f99e2004-02-11 20:26:31 +0000588 /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
hassof390d2c2004-09-10 20:48:21 +0000589 THREAD_OFF (circuit->t_read);
590 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
591 {
592 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
593 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
hassof891f442004-09-14 13:54:30 +0000594 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
595 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
hassof390d2c2004-09-10 20:48:21 +0000596 }
597 else if (circuit->circ_type == CIRCUIT_T_P2P)
598 {
599 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
600 }
jardineb5d44e2003-12-23 08:09:43 +0000601 /* close the socket */
602 close (circuit->fd);
603
604 return;
605}
606
607void
608circuit_update_nlpids (struct isis_circuit *circuit)
609{
610 circuit->nlpids.count = 0;
hassof390d2c2004-09-10 20:48:21 +0000611
612 if (circuit->ip_router)
613 {
614 circuit->nlpids.nlpids[0] = NLPID_IP;
615 circuit->nlpids.count++;
616 }
jardineb5d44e2003-12-23 08:09:43 +0000617#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000618 if (circuit->ipv6_router)
619 {
620 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
621 circuit->nlpids.count++;
622 }
jardineb5d44e2003-12-23 08:09:43 +0000623#endif /* HAVE_IPV6 */
624 return;
625}
626
627int
hassof390d2c2004-09-10 20:48:21 +0000628isis_interface_config_write (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000629{
630
631 int write = 0;
hasso52dc7ee2004-09-23 19:18:23 +0000632 struct listnode *node;
633 struct listnode *node2;
634 struct listnode *node3;
jardineb5d44e2003-12-23 08:09:43 +0000635 struct interface *ifp;
636 struct isis_area *area;
637 struct isis_circuit *c;
638 struct prefix_ipv4 *ip;
639 int i;
640#ifdef HAVE_IPV6
641 struct prefix_ipv6 *ipv6;
642#endif /*HAVE_IPV6 */
643
644 char buf[BUFSIZ];
645
jardineb5d44e2003-12-23 08:09:43 +0000646 LIST_LOOP (iflist, ifp, node)
647 {
648 /* IF name */
hassof390d2c2004-09-10 20:48:21 +0000649 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000650 write++;
651 /* IF desc */
hassof390d2c2004-09-10 20:48:21 +0000652 if (ifp->desc)
653 {
654 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
655 write++;
656 }
jardineb5d44e2003-12-23 08:09:43 +0000657 /* ISIS Circuit */
658 LIST_LOOP (isis->area_list, area, node2)
659 {
660 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000661 if (c)
662 {
663 if (c->ip_router)
664 {
665 vty_out (vty, " ip router isis %s%s", area->area_tag,
666 VTY_NEWLINE);
667 write++;
668 }
jardineb5d44e2003-12-23 08:09:43 +0000669#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000670 if (c->ipv6_router)
671 {
672 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
673 VTY_NEWLINE);
674 write++;
675 }
jardineb5d44e2003-12-23 08:09:43 +0000676#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000677
hassof390d2c2004-09-10 20:48:21 +0000678 /* ISIS - circuit type */
679 if (c->circuit_is_type == IS_LEVEL_1)
680 {
681 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
682 write++;
683 }
684 else
685 {
686 if (c->circuit_is_type == IS_LEVEL_2)
687 {
688 vty_out (vty, " isis circuit-type level-2-only%s",
689 VTY_NEWLINE);
690 write++;
691 }
692 }
jardineb5d44e2003-12-23 08:09:43 +0000693
hassof390d2c2004-09-10 20:48:21 +0000694 /* ISIS - CSNP interval - FIXME: compare to cisco */
695 if (c->csnp_interval[0] == c->csnp_interval[1])
696 {
697 if (c->csnp_interval[0] != CSNP_INTERVAL)
698 {
699 vty_out (vty, " isis csnp-interval %d%s",
700 c->csnp_interval[0], VTY_NEWLINE);
701 write++;
702 }
703 }
704 else
705 {
706 for (i = 0; i < 2; i++)
707 {
708 if (c->csnp_interval[1] != CSNP_INTERVAL)
709 {
710 vty_out (vty, " isis csnp-interval %d level-%d%s",
711 c->csnp_interval[1], i + 1, VTY_NEWLINE);
712 write++;
713 }
714 }
715 }
jardineb5d44e2003-12-23 08:09:43 +0000716
hassof390d2c2004-09-10 20:48:21 +0000717 /* ISIS - Hello padding - Defaults to true so only display if false */
718 if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
719 {
720 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
721 write++;
722 }
jardineb5d44e2003-12-23 08:09:43 +0000723
hassof390d2c2004-09-10 20:48:21 +0000724 /* ISIS - Hello interval - FIXME: compare to cisco */
725 if (c->hello_interval[0] == c->hello_interval[1])
726 {
727 if (c->hello_interval[0] != HELLO_INTERVAL)
728 {
729 vty_out (vty, " isis hello-interval %d%s",
730 c->hello_interval[0], VTY_NEWLINE);
731 write++;
732 }
733 }
734 else
735 {
736 for (i = 0; i < 2; i++)
737 {
738 if (c->hello_interval[i] != HELLO_INTERVAL)
739 {
740 if (c->hello_interval[i] == HELLO_MINIMAL)
741 {
742 vty_out (vty,
743 " isis hello-interval minimal level-%d%s",
744 i + 1, VTY_NEWLINE);
745 }
746 else
747 {
748 vty_out (vty, " isis hello-interval %d level-%d%s",
749 c->hello_interval[i], i + 1, VTY_NEWLINE);
750 }
751 write++;
752 }
753 }
754 }
jardineb5d44e2003-12-23 08:09:43 +0000755
hassof390d2c2004-09-10 20:48:21 +0000756 /* ISIS - Hello Multiplier */
757 if (c->hello_multiplier[0] == c->hello_multiplier[1])
758 {
759 if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
760 {
761 vty_out (vty, " isis hello-multiplier %d%s",
762 c->hello_multiplier[0], VTY_NEWLINE);
763 write++;
764 }
765 }
766 else
767 {
768 for (i = 0; i < 2; i++)
769 {
770 if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
771 {
772 vty_out (vty, " isis hello-multiplier %d level-%d%s",
773 c->hello_multiplier[i], i + 1, VTY_NEWLINE);
774 write++;
775 }
776 }
777 }
778 /* ISIS - Priority */
779 if (c->circ_type == CIRCUIT_T_BROADCAST)
780 {
781 if (c->u.bc.priority[0] == c->u.bc.priority[1])
782 {
783 if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
784 {
785 vty_out (vty, " isis priority %d%s",
786 c->u.bc.priority[0], VTY_NEWLINE);
787 write++;
788 }
789 }
790 else
791 {
792 for (i = 0; i < 2; i++)
793 {
794 if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
795 {
796 vty_out (vty, " isis priority %d level-%d%s",
797 c->u.bc.priority[i], i + 1, VTY_NEWLINE);
798 write++;
799 }
800 }
801 }
802 }
803 /* ISIS - Metric */
804 if (c->metrics[0].metric_default == c->metrics[1].metric_default)
805 {
806 if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS)
807 {
808 vty_out (vty, " isis metric %d%s",
809 c->metrics[0].metric_default, VTY_NEWLINE);
810 write++;
811 }
812 }
813 else
814 {
815 for (i = 0; i < 2; i++)
816 {
817 if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS)
818 {
819 vty_out (vty, " isis metric %d level-%d%s",
820 c->metrics[i].metric_default, i + 1,
821 VTY_NEWLINE);
822 write++;
823 }
824 }
825 }
jardineb5d44e2003-12-23 08:09:43 +0000826
hassof390d2c2004-09-10 20:48:21 +0000827 }
jardineb5d44e2003-12-23 08:09:43 +0000828 }
hassof390d2c2004-09-10 20:48:21 +0000829 vty_out (vty, "!%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000830 }
hassof390d2c2004-09-10 20:48:21 +0000831
jardineb5d44e2003-12-23 08:09:43 +0000832 return write;
833}
jardineb5d44e2003-12-23 08:09:43 +0000834
835DEFUN (ip_router_isis,
836 ip_router_isis_cmd,
837 "ip router isis WORD",
838 "Interface Internet Protocol config commands\n"
839 "IP router interface commands\n"
840 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000841 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000842{
843 struct isis_circuit *c;
844 struct interface *ifp;
845 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000846
847 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000848 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000849
jardineb5d44e2003-12-23 08:09:43 +0000850 area = isis_area_lookup (argv[0]);
851
852 /* Prevent more than one circuit per interface */
853 if (area)
854 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000855 else
856 c = NULL;
857 if (c && (ifp->info != NULL))
858 {
jardineb5d44e2003-12-23 08:09:43 +0000859#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000860 if (c->ipv6_router == 0)
861 {
jardineb5d44e2003-12-23 08:09:43 +0000862#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000863 vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
864 return CMD_WARNING;
jardineb5d44e2003-12-23 08:09:43 +0000865#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000866 }
867#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000868 }
hassof390d2c2004-09-10 20:48:21 +0000869
jardineb5d44e2003-12-23 08:09:43 +0000870 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +0000871 if (!area)
872 {
873 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
874 return CMD_WARNING;
875 }
jardineb5d44e2003-12-23 08:09:43 +0000876
hassof390d2c2004-09-10 20:48:21 +0000877 if (!c)
878 {
879 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
880 c = isis_csm_state_change (ISIS_ENABLE, c, area);
881 c->interface = ifp; /* this is automatic */
882 ifp->info = c; /* hardly related to the FSM */
883 }
jardineb5d44e2003-12-23 08:09:43 +0000884
hassof390d2c2004-09-10 20:48:21 +0000885 if (!c)
jardineb5d44e2003-12-23 08:09:43 +0000886 return CMD_WARNING;
887
888 c->ip_router = 1;
889 area->ip_circuits++;
890 circuit_update_nlpids (c);
891
892 vty->node = INTERFACE_NODE;
hassof390d2c2004-09-10 20:48:21 +0000893
jardineb5d44e2003-12-23 08:09:43 +0000894 return CMD_SUCCESS;
895}
896
897DEFUN (no_ip_router_isis,
898 no_ip_router_isis_cmd,
899 "no ip router isis WORD",
900 NO_STR
901 "Interface Internet Protocol config commands\n"
902 "IP router interface commands\n"
903 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000904 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000905{
906 struct isis_circuit *circuit = NULL;
907 struct interface *ifp;
908 struct isis_area *area;
909 struct listnode *node;
910
hassof390d2c2004-09-10 20:48:21 +0000911 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000912 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000913
jardineb5d44e2003-12-23 08:09:43 +0000914 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +0000915 if (!area)
916 {
917 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
918 return CMD_WARNING;
919 }
jardineb5d44e2003-12-23 08:09:43 +0000920 LIST_LOOP (area->circuit_list, circuit, node)
921 if (circuit->interface == ifp)
922 break;
hassof390d2c2004-09-10 20:48:21 +0000923 if (!circuit)
924 {
925 vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
926 return CMD_WARNING;
927 }
jardineb5d44e2003-12-23 08:09:43 +0000928 circuit->ip_router = 0;
929 area->ip_circuits--;
930#ifdef HAVE_IPV6
931 if (circuit->ipv6_router == 0)
932#endif
933 isis_csm_state_change (ISIS_DISABLE, circuit, area);
hassof390d2c2004-09-10 20:48:21 +0000934
jardineb5d44e2003-12-23 08:09:43 +0000935 return CMD_SUCCESS;
936}
937
938DEFUN (isis_circuit_type,
939 isis_circuit_type_cmd,
940 "isis circuit-type (level-1|level-1-2|level-2-only)",
941 "IS-IS commands\n"
942 "Configure circuit type for interface\n"
943 "Level-1 only adjacencies are formed\n"
944 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000945 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000946{
947 struct isis_circuit *circuit;
948 struct interface *ifp;
949 int circuit_t;
950 int is_type;
hassof390d2c2004-09-10 20:48:21 +0000951
952 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000953 circuit = ifp->info;
954 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +0000955 if (circuit == NULL)
956 {
957 return CMD_WARNING;
958 }
jardineb5d44e2003-12-23 08:09:43 +0000959
hasso13c48f72004-09-10 21:19:13 +0000960 /* XXX what to do when ip_router_isis is not executed */
961 if (circuit->area == NULL)
962 return CMD_WARNING;
963
jardineb5d44e2003-12-23 08:09:43 +0000964 assert (circuit);
965
hassof7c43dc2004-09-26 16:24:14 +0000966 circuit_t = string2circuit_t ((u_char *)argv[0]);
jardineb5d44e2003-12-23 08:09:43 +0000967
hassof390d2c2004-09-10 20:48:21 +0000968 if (!circuit_t)
969 {
970 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
971 return CMD_SUCCESS;
972 }
973
jardineb5d44e2003-12-23 08:09:43 +0000974 is_type = circuit->area->is_type;
975 if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
hassof390d2c2004-09-10 20:48:21 +0000976 isis_event_circuit_type_change (circuit, circuit_t);
977 else
978 {
979 vty_out (vty, "invalid circuit level for area %s.%s",
980 circuit->area->area_tag, VTY_NEWLINE);
981 }
982
jardineb5d44e2003-12-23 08:09:43 +0000983 return CMD_SUCCESS;
984}
985
986DEFUN (no_isis_circuit_type,
987 no_isis_circuit_type_cmd,
988 "no isis circuit-type (level-1|level-1-2|level-2-only)",
989 NO_STR
990 "IS-IS commands\n"
991 "Configure circuit type for interface\n"
992 "Level-1 only adjacencies are formed\n"
993 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000994 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000995{
996 struct isis_circuit *circuit;
997 struct interface *ifp;
jardineb5d44e2003-12-23 08:09:43 +0000998
hassof390d2c2004-09-10 20:48:21 +0000999 ifp = vty->index;
1000 circuit = ifp->info;
1001 if (circuit == NULL)
1002 {
1003 return CMD_WARNING;
1004 }
1005
1006 assert (circuit);
1007
jardineb5d44e2003-12-23 08:09:43 +00001008 /*
1009 * Set the circuits level to its default value which is that of the area
1010 */
1011 isis_event_circuit_type_change (circuit, circuit->area->is_type);
hassof390d2c2004-09-10 20:48:21 +00001012
jardineb5d44e2003-12-23 08:09:43 +00001013 return CMD_SUCCESS;
1014}
1015
1016DEFUN (isis_passwd,
1017 isis_passwd_cmd,
1018 "isis password WORD",
1019 "IS-IS commands\n"
1020 "Configure the authentication password for interface\n"
1021 "Password\n")
1022{
1023 struct isis_circuit *circuit;
1024 struct interface *ifp;
1025 int len;
hassof390d2c2004-09-10 20:48:21 +00001026
1027 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001028 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001029 if (circuit == NULL)
1030 {
1031 return CMD_WARNING;
1032 }
1033
jardineb5d44e2003-12-23 08:09:43 +00001034 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001035 if (len > 254)
1036 {
1037 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1038 return CMD_WARNING;
1039 }
jardineb5d44e2003-12-23 08:09:43 +00001040 circuit->passwd.len = len;
1041 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
hassof7c43dc2004-09-26 16:24:14 +00001042 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001043
jardineb5d44e2003-12-23 08:09:43 +00001044 return CMD_SUCCESS;
1045}
1046
1047DEFUN (no_isis_passwd,
1048 no_isis_passwd_cmd,
1049 "no isis password",
1050 NO_STR
1051 "IS-IS commands\n"
1052 "Configure the authentication password for interface\n")
1053{
1054 struct isis_circuit *circuit;
1055 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001056
1057 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001058 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001059 if (circuit == NULL)
1060 {
1061 return CMD_WARNING;
1062 }
1063
jardineb5d44e2003-12-23 08:09:43 +00001064 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
hassof390d2c2004-09-10 20:48:21 +00001065
jardineb5d44e2003-12-23 08:09:43 +00001066 return CMD_SUCCESS;
1067}
1068
1069
1070DEFUN (isis_priority,
1071 isis_priority_cmd,
1072 "isis priority <0-127>",
1073 "IS-IS commands\n"
1074 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001075 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001076{
1077 struct isis_circuit *circuit;
1078 struct interface *ifp;
1079 int prio;
hassof390d2c2004-09-10 20:48:21 +00001080
1081 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001082 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001083 if (circuit == NULL)
1084 {
1085 return CMD_WARNING;
1086 }
jardineb5d44e2003-12-23 08:09:43 +00001087 assert (circuit);
1088
1089 prio = atoi (argv[0]);
1090
1091 circuit->u.bc.priority[0] = prio;
1092 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001093
jardineb5d44e2003-12-23 08:09:43 +00001094 return CMD_SUCCESS;
1095}
1096
1097DEFUN (no_isis_priority,
1098 no_isis_priority_cmd,
1099 "no isis priority",
1100 NO_STR
1101 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001102 "Set priority for Designated Router election\n")
jardineb5d44e2003-12-23 08:09:43 +00001103{
1104 struct isis_circuit *circuit;
1105 struct interface *ifp;
1106
hassof390d2c2004-09-10 20:48:21 +00001107 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001108 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001109 if (circuit == NULL)
1110 {
1111 return CMD_WARNING;
1112 }
jardineb5d44e2003-12-23 08:09:43 +00001113 assert (circuit);
1114
1115 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
1116 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001117
jardineb5d44e2003-12-23 08:09:43 +00001118 return CMD_SUCCESS;
1119}
1120
1121ALIAS (no_isis_priority,
1122 no_isis_priority_arg_cmd,
1123 "no isis priority <0-127>",
1124 NO_STR
1125 "IS-IS commands\n"
1126 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001127 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001128
1129DEFUN (isis_priority_l1,
1130 isis_priority_l1_cmd,
hassof390d2c2004-09-10 20:48:21 +00001131 "isis priority <0-127> level-1",
jardineb5d44e2003-12-23 08:09:43 +00001132 "IS-IS commands\n"
1133 "Set priority for Designated Router election\n"
1134 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001135 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001136{
1137 struct isis_circuit *circuit;
1138 struct interface *ifp;
1139 int prio;
hassof390d2c2004-09-10 20:48:21 +00001140
1141 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001142 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001143 if (circuit == NULL)
1144 {
1145 return CMD_WARNING;
1146 }
jardineb5d44e2003-12-23 08:09:43 +00001147 assert (circuit);
1148
1149 prio = atoi (argv[0]);
1150
1151 circuit->u.bc.priority[0] = prio;
hassof390d2c2004-09-10 20:48:21 +00001152
jardineb5d44e2003-12-23 08:09:43 +00001153 return CMD_SUCCESS;
1154}
1155
1156DEFUN (no_isis_priority_l1,
1157 no_isis_priority_l1_cmd,
1158 "no isis priority level-1",
1159 NO_STR
1160 "IS-IS commands\n"
1161 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001162 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001163{
1164 struct isis_circuit *circuit;
1165 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001166
1167 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001168 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001169 if (circuit == NULL)
1170 {
1171 return CMD_WARNING;
1172 }
jardineb5d44e2003-12-23 08:09:43 +00001173 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001174
jardineb5d44e2003-12-23 08:09:43 +00001175 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001176
jardineb5d44e2003-12-23 08:09:43 +00001177 return CMD_SUCCESS;
1178}
1179
1180ALIAS (no_isis_priority_l1,
1181 no_isis_priority_l1_arg_cmd,
1182 "no isis priority <0-127> level-1",
1183 NO_STR
1184 "IS-IS commands\n"
1185 "Set priority for Designated Router election\n"
1186 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001187 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001188
1189DEFUN (isis_priority_l2,
1190 isis_priority_l2_cmd,
hassof390d2c2004-09-10 20:48:21 +00001191 "isis priority <0-127> level-2",
jardineb5d44e2003-12-23 08:09:43 +00001192 "IS-IS commands\n"
1193 "Set priority for Designated Router election\n"
1194 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001195 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001196{
1197 struct isis_circuit *circuit;
1198 struct interface *ifp;
1199 int prio;
hassof390d2c2004-09-10 20:48:21 +00001200
1201 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001202 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001203 if (circuit == NULL)
1204 {
1205 return CMD_WARNING;
1206 }
jardineb5d44e2003-12-23 08:09:43 +00001207 assert (circuit);
1208
1209 prio = atoi (argv[0]);
1210
1211 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001212
jardineb5d44e2003-12-23 08:09:43 +00001213 return CMD_SUCCESS;
1214}
1215
1216DEFUN (no_isis_priority_l2,
1217 no_isis_priority_l2_cmd,
1218 "no isis priority level-2",
1219 NO_STR
1220 "IS-IS commands\n"
1221 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001222 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001223{
1224 struct isis_circuit *circuit;
1225 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001226
1227 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001228 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001229 if (circuit == NULL)
1230 {
1231 return CMD_WARNING;
1232 }
jardineb5d44e2003-12-23 08:09:43 +00001233 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001234
jardineb5d44e2003-12-23 08:09:43 +00001235 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001236
jardineb5d44e2003-12-23 08:09:43 +00001237 return CMD_SUCCESS;
1238}
1239
1240ALIAS (no_isis_priority_l2,
1241 no_isis_priority_l2_arg_cmd,
1242 "no isis priority <0-127> level-2",
1243 NO_STR
1244 "IS-IS commands\n"
1245 "Set priority for Designated Router election\n"
1246 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001247 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001248
1249/* Metric command */
hassof390d2c2004-09-10 20:48:21 +00001250 DEFUN (isis_metric,
jardineb5d44e2003-12-23 08:09:43 +00001251 isis_metric_cmd,
1252 "isis metric <0-63>",
1253 "IS-IS commands\n"
1254 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001255 "Default metric value\n")
jardineb5d44e2003-12-23 08:09:43 +00001256{
1257 struct isis_circuit *circuit;
1258 struct interface *ifp;
1259 int met;
1260
hassof390d2c2004-09-10 20:48:21 +00001261 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001262 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001263 if (circuit == NULL)
1264 {
1265 return CMD_WARNING;
1266 }
jardineb5d44e2003-12-23 08:09:43 +00001267 assert (circuit);
1268
1269 met = atoi (argv[0]);
1270
1271 circuit->metrics[0].metric_default = met;
1272 circuit->metrics[1].metric_default = met;
1273
1274 return CMD_SUCCESS;
1275}
1276
1277DEFUN (no_isis_metric,
1278 no_isis_metric_cmd,
1279 "no isis metric",
1280 NO_STR
1281 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001282 "Set default metric for circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001283{
1284 struct isis_circuit *circuit;
1285 struct interface *ifp;
1286
hassof390d2c2004-09-10 20:48:21 +00001287 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001288 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001289 if (circuit == NULL)
1290 {
1291 return CMD_WARNING;
1292 }
jardineb5d44e2003-12-23 08:09:43 +00001293 assert (circuit);
1294
1295 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
1296 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS;
1297
1298 return CMD_SUCCESS;
1299}
1300
1301ALIAS (no_isis_metric,
1302 no_isis_metric_arg_cmd,
1303 "no isis metric <0-127>",
1304 NO_STR
1305 "IS-IS commands\n"
1306 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001307 "Default metric value\n")
1308
jardineb5d44e2003-12-23 08:09:43 +00001309/* end of metrics */
hassof390d2c2004-09-10 20:48:21 +00001310 DEFUN (isis_hello_interval,
jardineb5d44e2003-12-23 08:09:43 +00001311 isis_hello_interval_cmd,
1312 "isis hello-interval (<1-65535>|minimal)",
1313 "IS-IS commands\n"
1314 "Set Hello interval\n"
1315 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001316 "Holdtime 1 seconds, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001317{
1318 struct isis_circuit *circuit;
1319 struct interface *ifp;
1320 int interval;
1321 char c;
1322
hassof390d2c2004-09-10 20:48:21 +00001323 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001324 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001325 if (circuit == NULL)
1326 {
1327 return CMD_WARNING;
1328 }
1329 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001330 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001331 if (isdigit ((int) c))
1332 {
1333 interval = atoi (argv[0]);
1334 }
1335 else
1336 interval = HELLO_MINIMAL; /* FIXME: should be calculated */
jardineb5d44e2003-12-23 08:09:43 +00001337
hassof390d2c2004-09-10 20:48:21 +00001338 circuit->hello_interval[0] = (u_int16_t) interval;
1339 circuit->hello_interval[1] = (u_int16_t) interval;
1340
jardineb5d44e2003-12-23 08:09:43 +00001341 return CMD_SUCCESS;
1342}
1343
1344DEFUN (no_isis_hello_interval,
1345 no_isis_hello_interval_cmd,
1346 "no isis hello-interval",
1347 NO_STR
1348 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001349 "Set Hello interval\n")
jardineb5d44e2003-12-23 08:09:43 +00001350{
1351 struct isis_circuit *circuit;
1352 struct interface *ifp;
1353
hassof390d2c2004-09-10 20:48:21 +00001354 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001355 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001356 if (circuit == NULL)
1357 {
1358 return CMD_WARNING;
1359 }
jardineb5d44e2003-12-23 08:09:43 +00001360 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001361
hassof390d2c2004-09-10 20:48:21 +00001362
1363 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
jardineb5d44e2003-12-23 08:09:43 +00001364 circuit->hello_interval[1] = HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001365
jardineb5d44e2003-12-23 08:09:43 +00001366 return CMD_SUCCESS;
1367}
1368
1369ALIAS (no_isis_hello_interval,
1370 no_isis_hello_interval_arg_cmd,
1371 "no isis hello-interval (<1-65535>|minimal)",
1372 NO_STR
1373 "IS-IS commands\n"
1374 "Set Hello interval\n"
1375 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001376 "Holdtime 1 second, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001377
1378DEFUN (isis_hello_interval_l1,
1379 isis_hello_interval_l1_cmd,
1380 "isis hello-interval (<1-65535>|minimal) level-1",
1381 "IS-IS commands\n"
1382 "Set Hello interval\n"
1383 "Hello interval value\n"
1384 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001385 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001386{
1387 struct isis_circuit *circuit;
1388 struct interface *ifp;
1389 long interval;
1390 char c;
1391
hassof390d2c2004-09-10 20:48:21 +00001392 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001393 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001394 if (circuit == NULL)
1395 {
1396 return CMD_WARNING;
1397 }
jardineb5d44e2003-12-23 08:09:43 +00001398 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001399
jardineb5d44e2003-12-23 08:09:43 +00001400 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001401 if (isdigit ((int) c))
1402 {
1403 interval = atoi (argv[0]);
1404 }
1405 else
jardineb5d44e2003-12-23 08:09:43 +00001406 interval = HELLO_MINIMAL;
1407
hassof390d2c2004-09-10 20:48:21 +00001408 circuit->hello_interval[0] = (u_int16_t) interval;
1409
jardineb5d44e2003-12-23 08:09:43 +00001410 return CMD_SUCCESS;
1411}
1412
1413DEFUN (no_isis_hello_interval_l1,
1414 no_isis_hello_interval_l1_cmd,
1415 "no isis hello-interval level-1",
1416 NO_STR
1417 "IS-IS commands\n"
1418 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001419 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001420{
1421 struct isis_circuit *circuit;
1422 struct interface *ifp;
1423
hassof390d2c2004-09-10 20:48:21 +00001424 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001425 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001426 if (circuit == NULL)
1427 {
1428 return CMD_WARNING;
1429 }
jardineb5d44e2003-12-23 08:09:43 +00001430 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001431
hassof390d2c2004-09-10 20:48:21 +00001432
1433 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
1434
jardineb5d44e2003-12-23 08:09:43 +00001435 return CMD_SUCCESS;
1436}
1437
1438ALIAS (no_isis_hello_interval_l1,
1439 no_isis_hello_interval_l1_arg_cmd,
1440 "no isis hello-interval (<1-65535>|minimal) level-1",
1441 NO_STR
1442 "IS-IS commands\n"
1443 "Set Hello interval\n"
1444 "Hello interval value\n"
1445 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001446 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001447
1448DEFUN (isis_hello_interval_l2,
1449 isis_hello_interval_l2_cmd,
1450 "isis hello-interval (<1-65535>|minimal) level-2",
1451 "IS-IS commands\n"
1452 "Set Hello interval\n"
1453 "Hello interval value\n"
1454 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001455 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001456{
1457 struct isis_circuit *circuit;
1458 struct interface *ifp;
1459 long interval;
1460 char c;
1461
hassof390d2c2004-09-10 20:48:21 +00001462 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001463 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001464 if (circuit == NULL)
1465 {
1466 return CMD_WARNING;
1467 }
jardineb5d44e2003-12-23 08:09:43 +00001468 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001469
jardineb5d44e2003-12-23 08:09:43 +00001470 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001471 if (isdigit ((int) c))
1472 {
1473 interval = atoi (argv[0]);
1474 }
1475 else
jardineb5d44e2003-12-23 08:09:43 +00001476 interval = HELLO_MINIMAL;
1477
hassof390d2c2004-09-10 20:48:21 +00001478 circuit->hello_interval[1] = (u_int16_t) interval;
1479
jardineb5d44e2003-12-23 08:09:43 +00001480 return CMD_SUCCESS;
1481}
1482
1483DEFUN (no_isis_hello_interval_l2,
1484 no_isis_hello_interval_l2_cmd,
1485 "no isis hello-interval level-2",
1486 NO_STR
1487 "IS-IS commands\n"
1488 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001489 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001490{
1491 struct isis_circuit *circuit;
1492 struct interface *ifp;
1493
hassof390d2c2004-09-10 20:48:21 +00001494 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001495 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001496 if (circuit == NULL)
1497 {
1498 return CMD_WARNING;
1499 }
jardineb5d44e2003-12-23 08:09:43 +00001500 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001501
hassof390d2c2004-09-10 20:48:21 +00001502
1503 circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
1504
jardineb5d44e2003-12-23 08:09:43 +00001505 return CMD_SUCCESS;
1506}
1507
1508ALIAS (no_isis_hello_interval_l2,
1509 no_isis_hello_interval_l2_arg_cmd,
1510 "no isis hello-interval (<1-65535>|minimal) level-2",
1511 NO_STR
1512 "IS-IS commands\n"
1513 "Set Hello interval\n"
1514 "Hello interval value\n"
1515 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001516 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001517
1518DEFUN (isis_hello_multiplier,
1519 isis_hello_multiplier_cmd,
1520 "isis hello-multiplier <3-1000>",
1521 "IS-IS commands\n"
1522 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001523 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001524{
1525 struct isis_circuit *circuit;
1526 struct interface *ifp;
1527 int mult;
hassof390d2c2004-09-10 20:48:21 +00001528
1529 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001530 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001531 if (circuit == NULL)
1532 {
1533 return CMD_WARNING;
1534 }
jardineb5d44e2003-12-23 08:09:43 +00001535 assert (circuit);
1536
1537 mult = atoi (argv[0]);
1538
hassof390d2c2004-09-10 20:48:21 +00001539 circuit->hello_multiplier[0] = (u_int16_t) mult;
1540 circuit->hello_multiplier[1] = (u_int16_t) mult;
1541
jardineb5d44e2003-12-23 08:09:43 +00001542 return CMD_SUCCESS;
1543}
1544
1545DEFUN (no_isis_hello_multiplier,
1546 no_isis_hello_multiplier_cmd,
1547 "no isis hello-multiplier",
1548 NO_STR
1549 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001550 "Set multiplier for Hello holding time\n")
jardineb5d44e2003-12-23 08:09:43 +00001551{
1552 struct isis_circuit *circuit;
1553 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001554
1555 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001556 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001557 if (circuit == NULL)
1558 {
1559 return CMD_WARNING;
1560 }
jardineb5d44e2003-12-23 08:09:43 +00001561 assert (circuit);
1562
1563 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1564 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1565
1566 return CMD_SUCCESS;
1567}
1568
1569ALIAS (no_isis_hello_multiplier,
1570 no_isis_hello_multiplier_arg_cmd,
1571 "no isis hello-multiplier <3-1000>",
1572 NO_STR
1573 "IS-IS commands\n"
1574 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001575 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001576
1577DEFUN (isis_hello_multiplier_l1,
1578 isis_hello_multiplier_l1_cmd,
1579 "isis hello-multiplier <3-1000> level-1",
1580 "IS-IS commands\n"
1581 "Set multiplier for Hello holding time\n"
1582 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001583 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001584{
1585 struct isis_circuit *circuit;
1586 struct interface *ifp;
1587 int mult;
hassof390d2c2004-09-10 20:48:21 +00001588
1589 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001590 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001591 if (circuit == NULL)
1592 {
1593 return CMD_WARNING;
1594 }
jardineb5d44e2003-12-23 08:09:43 +00001595 assert (circuit);
1596
1597 mult = atoi (argv[0]);
1598
hassof390d2c2004-09-10 20:48:21 +00001599 circuit->hello_multiplier[0] = (u_int16_t) mult;
1600
jardineb5d44e2003-12-23 08:09:43 +00001601 return CMD_SUCCESS;
1602}
1603
1604DEFUN (no_isis_hello_multiplier_l1,
1605 no_isis_hello_multiplier_l1_cmd,
1606 "no isis hello-multiplier level-1",
1607 NO_STR
1608 "IS-IS commands\n"
1609 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001610 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001611{
1612 struct isis_circuit *circuit;
1613 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001614
1615 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001616 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001617 if (circuit == NULL)
1618 {
1619 return CMD_WARNING;
1620 }
jardineb5d44e2003-12-23 08:09:43 +00001621 assert (circuit);
1622
1623 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1624
1625 return CMD_SUCCESS;
1626}
1627
1628ALIAS (no_isis_hello_multiplier_l1,
1629 no_isis_hello_multiplier_l1_arg_cmd,
1630 "no isis hello-multiplier <3-1000> level-1",
1631 NO_STR
1632 "IS-IS commands\n"
1633 "Set multiplier for Hello holding time\n"
1634 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001635 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001636
1637DEFUN (isis_hello_multiplier_l2,
1638 isis_hello_multiplier_l2_cmd,
1639 "isis hello-multiplier <3-1000> level-2",
1640 "IS-IS commands\n"
1641 "Set multiplier for Hello holding time\n"
1642 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001643 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001644{
1645 struct isis_circuit *circuit;
1646 struct interface *ifp;
1647 int mult;
hassof390d2c2004-09-10 20:48:21 +00001648
1649 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001650 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001651 if (circuit == NULL)
1652 {
1653 return CMD_WARNING;
1654 }
jardineb5d44e2003-12-23 08:09:43 +00001655 assert (circuit);
1656
1657 mult = atoi (argv[0]);
1658
hassof390d2c2004-09-10 20:48:21 +00001659 circuit->hello_multiplier[1] = (u_int16_t) mult;
1660
jardineb5d44e2003-12-23 08:09:43 +00001661 return CMD_SUCCESS;
1662}
1663
1664DEFUN (no_isis_hello_multiplier_l2,
1665 no_isis_hello_multiplier_l2_cmd,
1666 "no isis hello-multiplier level-2",
1667 NO_STR
1668 "IS-IS commands\n"
1669 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001670 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001671{
1672 struct isis_circuit *circuit;
1673 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001674
1675 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001676 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001677 if (circuit == NULL)
1678 {
1679 return CMD_WARNING;
1680 }
jardineb5d44e2003-12-23 08:09:43 +00001681 assert (circuit);
1682
1683 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1684
1685 return CMD_SUCCESS;
1686}
1687
1688ALIAS (no_isis_hello_multiplier_l2,
1689 no_isis_hello_multiplier_l2_arg_cmd,
1690 "no isis hello-multiplier <3-1000> level-2",
1691 NO_STR
1692 "IS-IS commands\n"
1693 "Set multiplier for Hello holding time\n"
1694 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001695 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001696
1697DEFUN (isis_hello,
1698 isis_hello_cmd,
1699 "isis hello padding",
1700 "IS-IS commands\n"
1701 "Add padding to IS-IS hello packets\n"
1702 "Pad hello packets\n"
1703 "<cr>\n")
1704{
1705 struct interface *ifp;
1706 struct isis_circuit *circuit;
hassof390d2c2004-09-10 20:48:21 +00001707
1708 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001709 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001710 if (circuit == NULL)
1711 {
1712 return CMD_WARNING;
1713 }
jardineb5d44e2003-12-23 08:09:43 +00001714 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001715
jardineb5d44e2003-12-23 08:09:43 +00001716 circuit->u.bc.pad_hellos = 1;
hassof390d2c2004-09-10 20:48:21 +00001717
jardineb5d44e2003-12-23 08:09:43 +00001718 return CMD_SUCCESS;
1719}
1720
hasso54301ce2004-01-27 10:07:34 +00001721#if 0
jardineb5d44e2003-12-23 08:09:43 +00001722DEFUN (ip_address,
1723 ip_address_cmd,
1724 "ip address A.B.C.D/A",
1725 "Interface Internet Protocol config commands\n"
hassof390d2c2004-09-10 20:48:21 +00001726 "Set the IP address of an interface\n" "IP address (e.g. 10.0.0.1/8\n")
jardineb5d44e2003-12-23 08:09:43 +00001727{
1728 struct interface *ifp;
1729 struct isis_circuit *circuit;
1730 struct prefix_ipv4 *ipv4, *ip;
1731 struct listnode *node;
1732 int ret, found = 1;
1733
hassof390d2c2004-09-10 20:48:21 +00001734 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001735 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001736 if (circuit == NULL)
1737 {
1738 return CMD_WARNING;
1739 }
jardineb5d44e2003-12-23 08:09:43 +00001740
1741 assert (circuit);
1742#ifdef HAVE_IPV6
1743 zlog_info ("ip_address_cmd circuit %d", circuit->interface->ifindex);
1744#endif /* HAVE_IPV6 */
1745
1746 ipv4 = prefix_ipv4_new ();
jardineb5d44e2003-12-23 08:09:43 +00001747
hassof390d2c2004-09-10 20:48:21 +00001748 ret = str2prefix_ipv4 (argv[0], ipv4);
1749 if (ret <= 0)
1750 {
1751 zlog_warn ("ip_address_cmd(): malformed address");
1752 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
1753 return CMD_WARNING;
1754 }
1755
1756 if (!circuit->ip_addrs)
1757 circuit->ip_addrs = list_new ();
1758 else
1759 {
1760 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
1761 {
1762 ip = getdata (node);
1763 if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
1764 found = 1;
1765 }
1766 if (found)
1767 {
1768 prefix_ipv4_free (ipv4);
1769 return CMD_SUCCESS;
1770 }
1771 }
1772
1773
jardineb5d44e2003-12-23 08:09:43 +00001774 listnode_add (circuit->ip_addrs, ipv4);
hassof390d2c2004-09-10 20:48:21 +00001775#ifdef EXTREME_DEBUG
1776 zlog_info ("added IP address %s to circuit %d", argv[0],
jardineb5d44e2003-12-23 08:09:43 +00001777 circuit->interface->ifindex);
1778#endif /* EXTREME_DEBUG */
1779 return CMD_SUCCESS;
1780}
1781
1782DEFUN (no_ip_address,
1783 no_ip_address_cmd,
1784 "no ip address A.B.C.D/A",
1785 NO_STR
1786 "Interface Internet Protocol config commands\n"
1787 "Set the IP address of an interface\n"
1788 "IP address (e.g. 10.0.0.1/8\n")
1789{
1790 struct interface *ifp;
1791 struct isis_circuit *circuit;
1792 struct prefix_ipv4 ipv4, *ip = NULL;
1793 struct listnode *node;
1794 int ret;
1795
hassof390d2c2004-09-10 20:48:21 +00001796 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001797 circuit = ifp->info;
1798 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00001799 if (circuit == NULL)
1800 {
1801 return CMD_WARNING;
1802 }
jardineb5d44e2003-12-23 08:09:43 +00001803 assert (circuit);
1804
hassof390d2c2004-09-10 20:48:21 +00001805 if (!circuit->ip_addrs || circuit->ip_addrs->count == 0)
1806 {
1807 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
1808 return CMD_WARNING;
1809 }
jardineb5d44e2003-12-23 08:09:43 +00001810 ret = str2prefix_ipv4 (argv[0], &ipv4);
hassof390d2c2004-09-10 20:48:21 +00001811 if (ret <= 0)
1812 {
1813 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
1814 return CMD_WARNING;
1815 }
1816
1817 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
1818 {
1819 ip = getdata (node);
1820 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
1821 break;
1822 }
1823
1824 if (ip)
1825 {
1826 listnode_delete (circuit->ip_addrs, ip);
1827 }
1828 else
1829 {
1830 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
1831 }
1832
jardineb5d44e2003-12-23 08:09:43 +00001833 return CMD_SUCCESS;
1834}
hasso54301ce2004-01-27 10:07:34 +00001835#endif
jardineb5d44e2003-12-23 08:09:43 +00001836
1837DEFUN (no_isis_hello,
1838 no_isis_hello_cmd,
1839 "no isis hello padding",
1840 NO_STR
1841 "IS-IS commands\n"
1842 "Add padding to IS-IS hello packets\n"
1843 "Pad hello packets\n"
1844 "<cr>\n")
1845{
1846 struct isis_circuit *circuit;
1847 struct interface *ifp;
1848
hassof390d2c2004-09-10 20:48:21 +00001849 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001850 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001851 if (circuit == NULL)
1852 {
1853 return CMD_WARNING;
1854 }
jardineb5d44e2003-12-23 08:09:43 +00001855 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001856
jardineb5d44e2003-12-23 08:09:43 +00001857 circuit->u.bc.pad_hellos = 0;
hassof390d2c2004-09-10 20:48:21 +00001858
jardineb5d44e2003-12-23 08:09:43 +00001859 return CMD_SUCCESS;
1860}
1861
1862DEFUN (csnp_interval,
1863 csnp_interval_cmd,
1864 "isis csnp-interval <0-65535>",
1865 "IS-IS commands\n"
1866 "Set CSNP interval in seconds\n"
1867 "CSNP interval value\n")
1868{
1869 struct isis_circuit *circuit;
1870 struct interface *ifp;
1871 unsigned long interval;
1872
hassof390d2c2004-09-10 20:48:21 +00001873 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001874 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001875 if (circuit == NULL)
1876 {
1877 return CMD_WARNING;
1878 }
jardineb5d44e2003-12-23 08:09:43 +00001879 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001880
jardineb5d44e2003-12-23 08:09:43 +00001881 interval = atol (argv[0]);
1882
hassof390d2c2004-09-10 20:48:21 +00001883 circuit->csnp_interval[0] = (u_int16_t) interval;
1884 circuit->csnp_interval[1] = (u_int16_t) interval;
1885
jardineb5d44e2003-12-23 08:09:43 +00001886 return CMD_SUCCESS;
1887}
1888
1889DEFUN (no_csnp_interval,
1890 no_csnp_interval_cmd,
1891 "no isis csnp-interval",
1892 NO_STR
1893 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001894 "Set CSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001895{
1896 struct isis_circuit *circuit;
1897 struct interface *ifp;
1898
hassof390d2c2004-09-10 20:48:21 +00001899 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001900 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001901 if (circuit == NULL)
1902 {
1903 return CMD_WARNING;
1904 }
jardineb5d44e2003-12-23 08:09:43 +00001905 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001906
jardineb5d44e2003-12-23 08:09:43 +00001907 circuit->csnp_interval[0] = CSNP_INTERVAL;
1908 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001909
jardineb5d44e2003-12-23 08:09:43 +00001910 return CMD_SUCCESS;
1911}
1912
1913ALIAS (no_csnp_interval,
1914 no_csnp_interval_arg_cmd,
1915 "no isis csnp-interval <0-65535>",
1916 NO_STR
1917 "IS-IS commands\n"
1918 "Set CSNP interval in seconds\n"
1919 "CSNP interval value\n")
1920
jardineb5d44e2003-12-23 08:09:43 +00001921DEFUN (csnp_interval_l1,
1922 csnp_interval_l1_cmd,
1923 "isis csnp-interval <0-65535> level-1",
1924 "IS-IS commands\n"
1925 "Set CSNP interval in seconds\n"
1926 "CSNP interval value\n"
1927 "Specify interval for level-1 CSNPs\n")
1928{
1929 struct isis_circuit *circuit;
1930 struct interface *ifp;
1931 unsigned long interval;
1932
hassof390d2c2004-09-10 20:48:21 +00001933 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001934 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001935 if (circuit == NULL)
1936 {
1937 return CMD_WARNING;
1938 }
jardineb5d44e2003-12-23 08:09:43 +00001939 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001940
jardineb5d44e2003-12-23 08:09:43 +00001941 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001942
1943 circuit->csnp_interval[0] = (u_int16_t) interval;
1944
jardineb5d44e2003-12-23 08:09:43 +00001945 return CMD_SUCCESS;
1946}
1947
1948DEFUN (no_csnp_interval_l1,
1949 no_csnp_interval_l1_cmd,
1950 "no isis csnp-interval level-1",
1951 NO_STR
1952 "IS-IS commands\n"
1953 "Set CSNP interval in seconds\n"
1954 "Specify interval for level-1 CSNPs\n")
1955{
1956 struct isis_circuit *circuit;
1957 struct interface *ifp;
1958
hassof390d2c2004-09-10 20:48:21 +00001959 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001960 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001961 if (circuit == NULL)
1962 {
1963 return CMD_WARNING;
1964 }
jardineb5d44e2003-12-23 08:09:43 +00001965 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001966
jardineb5d44e2003-12-23 08:09:43 +00001967 circuit->csnp_interval[0] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001968
jardineb5d44e2003-12-23 08:09:43 +00001969 return CMD_SUCCESS;
1970}
1971
1972ALIAS (no_csnp_interval_l1,
1973 no_csnp_interval_l1_arg_cmd,
1974 "no isis csnp-interval <0-65535> level-1",
1975 NO_STR
1976 "IS-IS commands\n"
1977 "Set CSNP interval in seconds\n"
1978 "CSNP interval value\n"
1979 "Specify interval for level-1 CSNPs\n")
1980
jardineb5d44e2003-12-23 08:09:43 +00001981DEFUN (csnp_interval_l2,
1982 csnp_interval_l2_cmd,
1983 "isis csnp-interval <0-65535> level-2",
1984 "IS-IS commands\n"
1985 "Set CSNP interval in seconds\n"
1986 "CSNP interval value\n"
1987 "Specify interval for level-2 CSNPs\n")
1988{
1989 struct isis_circuit *circuit;
1990 struct interface *ifp;
1991 unsigned long interval;
1992
hassof390d2c2004-09-10 20:48:21 +00001993 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001994 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001995 if (circuit == NULL)
1996 {
1997 return CMD_WARNING;
1998 }
jardineb5d44e2003-12-23 08:09:43 +00001999 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00002000
jardineb5d44e2003-12-23 08:09:43 +00002001 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002002
2003 circuit->csnp_interval[1] = (u_int16_t) interval;
2004
jardineb5d44e2003-12-23 08:09:43 +00002005 return CMD_SUCCESS;
2006}
2007
2008DEFUN (no_csnp_interval_l2,
2009 no_csnp_interval_l2_cmd,
2010 "no isis csnp-interval level-2",
2011 NO_STR
2012 "IS-IS commands\n"
2013 "Set CSNP interval in seconds\n"
2014 "Specify interval for level-2 CSNPs\n")
2015{
2016 struct isis_circuit *circuit;
2017 struct interface *ifp;
2018
hassof390d2c2004-09-10 20:48:21 +00002019 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002020 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00002021 if (circuit == NULL)
2022 {
2023 return CMD_WARNING;
2024 }
jardineb5d44e2003-12-23 08:09:43 +00002025 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00002026
jardineb5d44e2003-12-23 08:09:43 +00002027 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002028
jardineb5d44e2003-12-23 08:09:43 +00002029 return CMD_SUCCESS;
2030}
2031
2032ALIAS (no_csnp_interval_l2,
2033 no_csnp_interval_l2_arg_cmd,
2034 "no isis csnp-interval <0-65535> level-2",
2035 NO_STR
2036 "IS-IS commands\n"
2037 "Set CSNP interval in seconds\n"
2038 "CSNP interval value\n"
2039 "Specify interval for level-2 CSNPs\n")
2040
jardineb5d44e2003-12-23 08:09:43 +00002041#ifdef HAVE_IPV6
2042DEFUN (ipv6_router_isis,
2043 ipv6_router_isis_cmd,
2044 "ipv6 router isis WORD",
2045 "IPv6 interface subcommands\n"
2046 "IPv6 Router interface commands\n"
2047 "IS-IS Routing for IPv6\n"
2048 "Routing process tag\n")
2049{
2050 struct isis_circuit *c;
2051 struct interface *ifp;
2052 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002053
2054 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002055 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002056
jardineb5d44e2003-12-23 08:09:43 +00002057 area = isis_area_lookup (argv[0]);
2058
2059 /* Prevent more than one circuit per interface */
2060 if (area)
2061 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +00002062 else
2063 c = NULL;
2064
2065 if (c && (ifp->info != NULL))
2066 {
2067 if (c->ipv6_router == 1)
2068 {
2069 vty_out (vty, "ISIS circuit is already defined for IPv6%s",
2070 VTY_NEWLINE);
2071 return CMD_WARNING;
2072 }
jardineb5d44e2003-12-23 08:09:43 +00002073 }
jardineb5d44e2003-12-23 08:09:43 +00002074
2075 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +00002076 if (!area)
2077 {
2078 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2079 return CMD_WARNING;
2080 }
jardineb5d44e2003-12-23 08:09:43 +00002081
hassof390d2c2004-09-10 20:48:21 +00002082 if (!c)
2083 {
2084 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
2085 c = isis_csm_state_change (ISIS_ENABLE, c, area);
2086 c->interface = ifp;
2087 ifp->info = c;
2088 }
jardineb5d44e2003-12-23 08:09:43 +00002089
hassof390d2c2004-09-10 20:48:21 +00002090 if (!c)
jardineb5d44e2003-12-23 08:09:43 +00002091 return CMD_WARNING;
2092
2093 c->ipv6_router = 1;
2094 area->ipv6_circuits++;
2095 circuit_update_nlpids (c);
2096
2097 vty->node = INTERFACE_NODE;
2098
2099 return CMD_SUCCESS;
2100}
2101
2102DEFUN (no_ipv6_router_isis,
2103 no_ipv6_router_isis_cmd,
2104 "no ipv6 router isis WORD",
2105 NO_STR
2106 "IPv6 interface subcommands\n"
2107 "IPv6 Router interface commands\n"
2108 "IS-IS Routing for IPv6\n"
2109 "Routing process tag\n")
2110{
2111 struct isis_circuit *c;
2112 struct interface *ifp;
2113 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002114
2115 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002116 /* UGLY - will remove l8r
2117 if (circuit == NULL) {
hassof390d2c2004-09-10 20:48:21 +00002118 return CMD_WARNING;
2119 } */
jardineb5d44e2003-12-23 08:09:43 +00002120 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002121
jardineb5d44e2003-12-23 08:09:43 +00002122 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002123 if (!area)
2124 {
2125 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2126 return CMD_WARNING;
2127 }
2128
jardineb5d44e2003-12-23 08:09:43 +00002129 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
2130 if (!c)
2131 return CMD_WARNING;
2132
2133 c->ipv6_router = 0;
2134 area->ipv6_circuits--;
2135 if (c->ip_router == 0)
2136 isis_csm_state_change (ISIS_DISABLE, c, area);
2137
2138 return CMD_SUCCESS;
2139}
2140
hassof390d2c2004-09-10 20:48:21 +00002141#if 0 /* Guess we don't really need these */
jardineb5d44e2003-12-23 08:09:43 +00002142
2143DEFUN (ipv6_address,
2144 ipv6_address_cmd,
2145 "ipv6 address X:X::X:X/M",
2146 "Interface Internet Protocol config commands\n"
2147 "Set the IP address of an interface\n"
2148 "IPv6 address (e.g. 3ffe:506::1/48)\n")
2149{
2150 struct interface *ifp;
2151 struct isis_circuit *circuit;
2152 struct prefix_ipv6 *ipv6, *ip6;
2153 struct listnode *node;
2154 int ret, found = 1;
2155
hassof390d2c2004-09-10 20:48:21 +00002156 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002157 circuit = ifp->info;
2158 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00002159 if (circuit == NULL)
2160 {
2161 return CMD_WARNING;
2162 }
jardineb5d44e2003-12-23 08:09:43 +00002163 assert (circuit);
2164#ifdef EXTREME_DEBUG
2165 zlog_info ("ipv6_address_cmd circuit %d", circuit->idx);
2166#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +00002167
hassof390d2c2004-09-10 20:48:21 +00002168 if (circuit == NULL)
2169 {
2170 zlog_warn ("ipv6_address_cmd(): no circuit");
2171 return CMD_WARNING;
2172 }
2173
2174
2175 ipv6 = prefix_ipv6_new ();
2176
2177 ret = str2prefix_ipv6 (argv[0], ipv6);
2178 if (ret <= 0)
2179 {
2180 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
2181 return CMD_WARNING;
2182 }
2183
2184 if (!circuit->ipv6_addrs)
2185 circuit->ipv6_addrs = list_new ();
2186 else
2187 {
2188 for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
2189 {
2190 ip6 = getdata (node);
2191 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
2192 found = 1;
2193 }
2194 if (found)
2195 {
2196 prefix_ipv6_free (ipv6);
2197 return CMD_SUCCESS;
2198 }
2199 }
2200
2201
jardineb5d44e2003-12-23 08:09:43 +00002202 listnode_add (circuit->ipv6_addrs, ipv6);
2203#ifdef EXTREME_DEBUG
2204 zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx);
2205#endif /* EXTREME_DEBUG */
2206
2207 return CMD_SUCCESS;
2208}
2209
2210DEFUN (no_ipv6_address,
2211 no_ipv6_address_cmd,
hassof390d2c2004-09-10 20:48:21 +00002212 "no ipv6 address X:X::X:X/M",
jardineb5d44e2003-12-23 08:09:43 +00002213 NO_STR
2214 "Interface Internet Protocol config commands\n"
2215 "Set the IP address of an interface\n"
2216 "IPv6 address (e.g. 3ffe:506::1/48)\n")
2217{
2218 struct interface *ifp;
2219 struct isis_circuit *circuit;
2220 struct prefix_ipv6 ipv6, *ip6 = NULL;
2221 struct listnode *node;
2222 int ret;
2223
hassof390d2c2004-09-10 20:48:21 +00002224 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002225 circuit = ifp->info;
2226 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00002227 if (circuit == NULL)
2228 {
2229 return CMD_WARNING;
2230 }
jardineb5d44e2003-12-23 08:09:43 +00002231 assert (circuit);
2232
hassof390d2c2004-09-10 20:48:21 +00002233 if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0)
2234 {
2235 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
2236 return CMD_WARNING;
2237 }
jardineb5d44e2003-12-23 08:09:43 +00002238 ret = str2prefix_ipv6 (argv[0], &ipv6);
hassof390d2c2004-09-10 20:48:21 +00002239 if (ret <= 0)
2240 {
2241 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
2242 return CMD_WARNING;
2243 }
2244
2245 for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
2246 {
2247 ip6 = getdata (node);
2248 if (prefix_same ((struct prefix *) ip6, (struct prefix *) &ipv6))
2249 break;
2250 }
2251
2252 if (ip6)
2253 {
2254 listnode_delete (circuit->ipv6_addrs, ip6);
2255 }
2256 else
2257 {
2258 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
2259 }
2260
jardineb5d44e2003-12-23 08:09:43 +00002261 return CMD_SUCCESS;
2262}
2263#endif /* 0 */
hassof390d2c2004-09-10 20:48:21 +00002264#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00002265
hassof390d2c2004-09-10 20:48:21 +00002266struct cmd_node interface_node = {
jardineb5d44e2003-12-23 08:09:43 +00002267 INTERFACE_NODE,
2268 "%s(config-if)# ",
2269 1,
2270};
2271
jardineb5d44e2003-12-23 08:09:43 +00002272int
2273isis_if_new_hook (struct interface *ifp)
2274{
2275/* FIXME: Discuss if the circuit should be created here
2276 ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */
2277 ifp->info = NULL;
2278 return 0;
2279}
2280
2281int
2282isis_if_delete_hook (struct interface *ifp)
2283{
2284/* FIXME: Discuss if the circuit should be created here
2285 XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/
2286 ifp->info = NULL;
2287 return 0;
2288}
2289
jardineb5d44e2003-12-23 08:09:43 +00002290void
2291isis_circuit_init ()
2292{
jardineb5d44e2003-12-23 08:09:43 +00002293 /* Initialize Zebra interface data structure */
2294 if_init ();
2295 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2296 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2297
2298 /* Install interface node */
2299 install_node (&interface_node, isis_interface_config_write);
2300 install_element (CONFIG_NODE, &interface_cmd);
2301
2302 install_default (INTERFACE_NODE);
2303 install_element (INTERFACE_NODE, &interface_desc_cmd);
2304 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2305
2306 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2307 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2308
2309 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2310 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2311
2312 install_element (INTERFACE_NODE, &isis_passwd_cmd);
2313 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2314
2315 install_element (INTERFACE_NODE, &isis_priority_cmd);
2316 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2317 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2318 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2319 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2320 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2321 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2322 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2323 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2324
2325 install_element (INTERFACE_NODE, &isis_metric_cmd);
2326 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2327 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
2328
2329 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2330 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2331 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2332 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2333 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2334 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2335 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2336 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2337 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2338
2339 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2340 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2341 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2342 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2343 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2344 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2345 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2346 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2347 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2348
2349 install_element (INTERFACE_NODE, &isis_hello_cmd);
2350 install_element (INTERFACE_NODE, &no_isis_hello_cmd);
hasso38a61c72004-01-27 13:40:14 +00002351#if 0
jardineb5d44e2003-12-23 08:09:43 +00002352 install_element (INTERFACE_NODE, &ip_address_cmd);
2353 install_element (INTERFACE_NODE, &no_ip_address_cmd);
hasso38a61c72004-01-27 13:40:14 +00002354#endif
jardineb5d44e2003-12-23 08:09:43 +00002355 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2356 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2357 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2358 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2359 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2360 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2361 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2362 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2363 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2364
2365#ifdef HAVE_IPV6
2366 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2367 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
2368#if 0
2369 install_element (INTERFACE_NODE, &ipv6_address_cmd);
2370 install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
2371#endif
2372#endif
jardineb5d44e2003-12-23 08:09:43 +00002373}