blob: 4f66346d7dedf858046bdeb26503272bb7879c22 [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);
hassof891f442004-09-14 13:54:30 +0000244 isis_event_int_reach_change (circuit);
245
jardineb5d44e2003-12-23 08:09:43 +0000246#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000247 prefix2str (connected->address, buf, BUFSIZ);
hassof390d2c2004-09-10 20:48:21 +0000248 zlog_info ("Added IP address %s to circuit %d", buf,
249 circuit->circuit_id);
250#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +0000251 }
hassof390d2c2004-09-10 20:48:21 +0000252#ifdef HAVE_IPV6
hassof891f442004-09-14 13:54:30 +0000253 if (connected->address->family == AF_INET6)
hassof390d2c2004-09-10 20:48:21 +0000254 {
255 ipv6 = prefix_ipv6_new ();
hassof891f442004-09-14 13:54:30 +0000256 ipv6->prefixlen = connected->address->prefixlen;
257 ipv6->prefix = connected->address->u.prefix6;
258
hassof390d2c2004-09-10 20:48:21 +0000259 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
hassof891f442004-09-14 13:54:30 +0000260 listnode_add (circuit->ipv6_link, ipv6);
hassof390d2c2004-09-10 20:48:21 +0000261 else
hassof891f442004-09-14 13:54:30 +0000262 listnode_add (circuit->ipv6_non_link, ipv6);
263
264 isis_event_int_reach_change(circuit);
265
jardineb5d44e2003-12-23 08:09:43 +0000266#ifdef EXTREME_DEBUG
hassof891f442004-09-14 13:54:30 +0000267 prefix2str (connected->address, buf, BUFSIZ);
hassof390d2c2004-09-10 20:48:21 +0000268 zlog_info ("Added IPv6 address %s to circuit %d", buf,
269 circuit->circuit_id);
270#endif /* EXTREME_DEBUG */
271 }
jardineb5d44e2003-12-23 08:09:43 +0000272#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000273 return;
274}
275
276void
277isis_circuit_del_addr (struct isis_circuit *circuit,
hassof390d2c2004-09-10 20:48:21 +0000278 struct connected *connected)
jardineb5d44e2003-12-23 08:09:43 +0000279{
hassof891f442004-09-14 13:54:30 +0000280 struct prefix_ipv4 *ipv4, *ip = NULL;
281 struct listnode *node;
282 int found = 0;
283 u_char buf[BUFSIZ];
284#ifdef HAVE_IPV6
285 struct prefix_ipv6 *ipv6, *ip6 = NULL;
286#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000287
hassof891f442004-09-14 13:54:30 +0000288 memset (&buf, 0, BUFSIZ);
289 if (connected->address->family == AF_INET)
290 {
291 ipv4 = prefix_ipv4_new ();
292 ipv4->prefixlen = connected->address->prefixlen;
293 ipv4->prefix = connected->address->u.prefix4;
294
295 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
296 {
297 ip = getdata (node);
298 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
299 break;
300 }
301
302 if (ip)
303 {
304 listnode_delete (circuit->ip_addrs, ip);
305 isis_event_int_reach_change (circuit);
306 }
307 else
308 {
309 prefix2str (connected->address, buf, BUFSIZ);
310 zlog_warn("Nonexitant ip address %s removal attempt from circuit \
311 %d", buf, circuit->circuit_id);
312 }
313 }
314#ifdef HAVE_IPV6
315 if (connected->address->family == AF_INET6)
316 {
317 ipv6 = prefix_ipv6_new ();
318 ipv6->prefixlen = connected->address->prefixlen;
319 ipv6->prefix = connected->address->u.prefix6;
320
321 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
322 {
323 for (node = listhead (circuit->ipv6_link); node; nextnode (node))
324 {
325 ip6 = getdata (node);
326 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
327 break;
328 }
329 if (ip6)
330 {
331 listnode_delete (circuit->ipv6_link, ip6);
332 found = 1;
333 }
334 }
335 else
336 {
337 for (node = listhead (circuit->ipv6_non_link); node; nextnode (node))
338 {
339 ip6 = getdata (node);
340 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
341 break;
342 }
343 if (ip6)
344 {
345 listnode_delete (circuit->ipv6_non_link, ip6);
346 found = 1;
347 }
348 }
349
350 if (!found)
351 {
352 prefix2str (connected->address, buf, BUFSIZ);
353 zlog_warn("Nonexitant ip address %s removal attempt from \
354 circuit %d", buf, circuit->circuit_id);
355 }
356 else
357 isis_event_int_reach_change (circuit);
358 }
359#endif /* HAVE_IPV6 */
360 return;
jardineb5d44e2003-12-23 08:09:43 +0000361}
362
363void
364isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
365{
366 struct listnode *node;
367 struct connected *conn;
368
369 circuit->interface = ifp;
370 ifp->info = circuit;
hassof390d2c2004-09-10 20:48:21 +0000371
372 circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
jardineb5d44e2003-12-23 08:09:43 +0000373
374 /* isis_circuit_update_addrs (circuit, ifp); */
375
hassof390d2c2004-09-10 20:48:21 +0000376 if (if_is_broadcast (ifp))
377 {
378 circuit->circ_type = CIRCUIT_T_BROADCAST;
379 /*
380 * Get the Hardware Address
381 */
jardineb5d44e2003-12-23 08:09:43 +0000382#ifdef HAVE_SOCKADDR_DL
hassof390d2c2004-09-10 20:48:21 +0000383 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
384 zlog_warn ("unsupported link layer");
385 else
386 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
387 ETH_ALEN);
jardineb5d44e2003-12-23 08:09:43 +0000388#else
hassof390d2c2004-09-10 20:48:21 +0000389 if (circuit->interface->hw_addr_len != ETH_ALEN)
390 {
391 zlog_warn ("unsupported link layer");
392 }
393 else
394 {
395 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
396 }
jardineb5d44e2003-12-23 08:09:43 +0000397#ifdef EXTREME_DEGUG
hassof390d2c2004-09-10 20:48:21 +0000398 zlog_info ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
399 circuit->interface->ifindex, ISO_MTU (circuit),
400 snpa_print (circuit->u.bc.snpa));
jardineb5d44e2003-12-23 08:09:43 +0000401
402#endif /* EXTREME_DEBUG */
hassof390d2c2004-09-10 20:48:21 +0000403#endif /* HAVE_SOCKADDR_DL */
404 }
405 else if (if_is_pointopoint (ifp))
406 {
407 circuit->circ_type = CIRCUIT_T_P2P;
408 }
409 else
410 {
411 zlog_warn ("isis_circuit_if_add: unsupported media");
412 }
413
414 for (node = ifp->connected ? listhead (ifp->connected) : NULL; node;
415 nextnode (node))
416 {
417 conn = getdata (node);
418 isis_circuit_add_addr (circuit, conn);
419 }
jardineb5d44e2003-12-23 08:09:43 +0000420
421 return;
422}
423
424void
hassof390d2c2004-09-10 20:48:21 +0000425isis_circuit_update_params (struct isis_circuit *circuit,
426 struct interface *ifp)
jardineb5d44e2003-12-23 08:09:43 +0000427{
428 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +0000429
430 if (circuit->circuit_id != ifp->ifindex)
431 {
432 zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
433 ifp->ifindex);
434 circuit->circuit_id = ifp->ifindex % 255;
435 }
jardineb5d44e2003-12-23 08:09:43 +0000436
437 /* FIXME: Why is this needed? shouldn't we compare to the area's mtu */
438 /* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig)
439 The areas MTU is the minimum of mtu's of circuits in the area
440 now we can't catch the change
441 if (circuit->mtu != ifp->mtu) {
442 zlog_warn ("changing circuit mtu %d->%d", circuit->mtu,
443 ifp->mtu);
444 circuit->mtu = ifp->mtu;
445 }
hassof390d2c2004-09-10 20:48:21 +0000446 */
jardineb5d44e2003-12-23 08:09:43 +0000447 /*
448 * Get the Hardware Address
449 */
450#ifdef HAVE_SOCKADDR_DL
451 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
jardineb5d44e2003-12-23 08:09:43 +0000452 zlog_warn ("unsupported link layer");
hassof390d2c2004-09-10 20:48:21 +0000453 else
454 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN);
455#else
456 if (circuit->interface->hw_addr_len != ETH_ALEN)
457 {
458 zlog_warn ("unsupported link layer");
jardineb5d44e2003-12-23 08:09:43 +0000459 }
hassof390d2c2004-09-10 20:48:21 +0000460 else
461 {
462 if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN))
463 {
464 zlog_warn ("changing circuit snpa %s->%s",
465 snpa_print (circuit->u.bc.snpa),
466 snpa_print (circuit->interface->hw_addr));
467 }
468 }
469#endif
jardineb5d44e2003-12-23 08:09:43 +0000470
hassof390d2c2004-09-10 20:48:21 +0000471 if (if_is_broadcast (ifp))
472 {
473 circuit->circ_type = CIRCUIT_T_BROADCAST;
474 }
475 else if (if_is_pointopoint (ifp))
476 {
477 circuit->circ_type = CIRCUIT_T_P2P;
478 }
479 else
480 {
481 zlog_warn ("isis_circuit_update_params: unsupported media");
482 }
jardineb5d44e2003-12-23 08:09:43 +0000483
jardineb5d44e2003-12-23 08:09:43 +0000484 return;
485}
486
487void
hassof390d2c2004-09-10 20:48:21 +0000488isis_circuit_if_del (struct isis_circuit *circuit)
jardineb5d44e2003-12-23 08:09:43 +0000489{
490 circuit->interface->info = NULL;
491 circuit->interface = NULL;
hassof390d2c2004-09-10 20:48:21 +0000492
jardineb5d44e2003-12-23 08:09:43 +0000493 return;
494}
495
496void
497isis_circuit_up (struct isis_circuit *circuit)
498{
jardineb5d44e2003-12-23 08:09:43 +0000499
hassof390d2c2004-09-10 20:48:21 +0000500 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
501 {
502 if (circuit->area->min_bcast_mtu == 0 ||
503 ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
504 circuit->area->min_bcast_mtu = ISO_MTU (circuit);
505 /*
506 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
507 */
jardineb5d44e2003-12-23 08:09:43 +0000508
hassof390d2c2004-09-10 20:48:21 +0000509 /* initilizing the hello sending threads
510 * for a broadcast IF
511 */
jardineb5d44e2003-12-23 08:09:43 +0000512
hassof390d2c2004-09-10 20:48:21 +0000513 /* 8.4.1 a) commence sending of IIH PDUs */
514
515 if (circuit->circuit_is_type & IS_LEVEL_1)
516 {
517 thread_add_event (master, send_lan_l1_hello, circuit, 0);
518 circuit->u.bc.lan_neighs[0] = list_new ();
519 }
520
521 if (circuit->circuit_is_type & IS_LEVEL_2)
522 {
523 thread_add_event (master, send_lan_l2_hello, circuit, 0);
524 circuit->u.bc.lan_neighs[1] = list_new ();
525 }
526
527 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
528 /* 8.4.1 c) FIXME: listen for ESH PDUs */
529
530 /* 8.4.1 d) */
531 /* dr election will commence in... */
532 if (circuit->circuit_is_type & IS_LEVEL_1)
533 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
hassobf731012004-09-17 07:59:57 +0000534 circuit, 2 * circuit->hello_interval[0]);
hassof390d2c2004-09-10 20:48:21 +0000535 if (circuit->circuit_is_type & IS_LEVEL_2)
536 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
hassobf731012004-09-17 07:59:57 +0000537 circuit, 2 * circuit->hello_interval[1]);
jardineb5d44e2003-12-23 08:09:43 +0000538 }
hassof390d2c2004-09-10 20:48:21 +0000539 else
540 {
541 /* initializing the hello send threads
542 * for a ptp IF
543 */
544 thread_add_event (master, send_p2p_hello, circuit, 0);
jardineb5d44e2003-12-23 08:09:43 +0000545
jardineb5d44e2003-12-23 08:09:43 +0000546 }
547
jardineb5d44e2003-12-23 08:09:43 +0000548 /* initializing PSNP timers */
hassof390d2c2004-09-10 20:48:21 +0000549 if (circuit->circuit_is_type & IS_LEVEL_1)
550 {
551 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
552 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
553 }
554
555 if (circuit->circuit_is_type & IS_LEVEL_2)
556 {
557 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
558 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
559 }
560
jardineb5d44e2003-12-23 08:09:43 +0000561 /* initialize the circuit streams */
562 if (circuit->rcv_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000563 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000564
565 if (circuit->snd_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000566 circuit->snd_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000567
568 /* unified init for circuits */
569 isis_sock_init (circuit);
570
571#ifdef GNU_LINUX
hassof390d2c2004-09-10 20:48:21 +0000572 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
573 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000574#else
hassof390d2c2004-09-10 20:48:21 +0000575 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
576 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000577#endif
578 return;
579}
580
581void
582isis_circuit_down (struct isis_circuit *circuit)
583{
hassof390d2c2004-09-10 20:48:21 +0000584 /* Cancel all active threads -- FIXME: wrong place */
hassod70f99e2004-02-11 20:26:31 +0000585 /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
hassof390d2c2004-09-10 20:48:21 +0000586 THREAD_OFF (circuit->t_read);
587 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
588 {
589 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
590 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
hassof891f442004-09-14 13:54:30 +0000591 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
592 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
hassof390d2c2004-09-10 20:48:21 +0000593 }
594 else if (circuit->circ_type == CIRCUIT_T_P2P)
595 {
596 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
597 }
jardineb5d44e2003-12-23 08:09:43 +0000598 /* close the socket */
599 close (circuit->fd);
600
601 return;
602}
603
604void
605circuit_update_nlpids (struct isis_circuit *circuit)
606{
607 circuit->nlpids.count = 0;
hassof390d2c2004-09-10 20:48:21 +0000608
609 if (circuit->ip_router)
610 {
611 circuit->nlpids.nlpids[0] = NLPID_IP;
612 circuit->nlpids.count++;
613 }
jardineb5d44e2003-12-23 08:09:43 +0000614#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000615 if (circuit->ipv6_router)
616 {
617 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
618 circuit->nlpids.count++;
619 }
jardineb5d44e2003-12-23 08:09:43 +0000620#endif /* HAVE_IPV6 */
621 return;
622}
623
624int
hassof390d2c2004-09-10 20:48:21 +0000625isis_interface_config_write (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000626{
627
628 int write = 0;
629 listnode node;
630 listnode node2;
631 listnode node3;
632 struct interface *ifp;
633 struct isis_area *area;
634 struct isis_circuit *c;
635 struct prefix_ipv4 *ip;
636 int i;
637#ifdef HAVE_IPV6
638 struct prefix_ipv6 *ipv6;
639#endif /*HAVE_IPV6 */
640
641 char buf[BUFSIZ];
642
jardineb5d44e2003-12-23 08:09:43 +0000643 LIST_LOOP (iflist, ifp, node)
644 {
645 /* IF name */
hassof390d2c2004-09-10 20:48:21 +0000646 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000647 write++;
648 /* IF desc */
hassof390d2c2004-09-10 20:48:21 +0000649 if (ifp->desc)
650 {
651 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
652 write++;
653 }
jardineb5d44e2003-12-23 08:09:43 +0000654 /* ISIS Circuit */
655 LIST_LOOP (isis->area_list, area, node2)
656 {
657 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000658 if (c)
659 {
660 if (c->ip_router)
661 {
662 vty_out (vty, " ip router isis %s%s", area->area_tag,
663 VTY_NEWLINE);
664 write++;
665 }
jardineb5d44e2003-12-23 08:09:43 +0000666#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000667 if (c->ipv6_router)
668 {
669 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
670 VTY_NEWLINE);
671 write++;
672 }
jardineb5d44e2003-12-23 08:09:43 +0000673#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000674
hassof390d2c2004-09-10 20:48:21 +0000675 /* ISIS - circuit type */
676 if (c->circuit_is_type == IS_LEVEL_1)
677 {
678 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
679 write++;
680 }
681 else
682 {
683 if (c->circuit_is_type == IS_LEVEL_2)
684 {
685 vty_out (vty, " isis circuit-type level-2-only%s",
686 VTY_NEWLINE);
687 write++;
688 }
689 }
jardineb5d44e2003-12-23 08:09:43 +0000690
hassof390d2c2004-09-10 20:48:21 +0000691 /* ISIS - CSNP interval - FIXME: compare to cisco */
692 if (c->csnp_interval[0] == c->csnp_interval[1])
693 {
694 if (c->csnp_interval[0] != CSNP_INTERVAL)
695 {
696 vty_out (vty, " isis csnp-interval %d%s",
697 c->csnp_interval[0], VTY_NEWLINE);
698 write++;
699 }
700 }
701 else
702 {
703 for (i = 0; i < 2; i++)
704 {
705 if (c->csnp_interval[1] != CSNP_INTERVAL)
706 {
707 vty_out (vty, " isis csnp-interval %d level-%d%s",
708 c->csnp_interval[1], i + 1, VTY_NEWLINE);
709 write++;
710 }
711 }
712 }
jardineb5d44e2003-12-23 08:09:43 +0000713
hassof390d2c2004-09-10 20:48:21 +0000714 /* ISIS - Hello padding - Defaults to true so only display if false */
715 if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
716 {
717 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
718 write++;
719 }
jardineb5d44e2003-12-23 08:09:43 +0000720
hassof390d2c2004-09-10 20:48:21 +0000721 /* ISIS - Hello interval - FIXME: compare to cisco */
722 if (c->hello_interval[0] == c->hello_interval[1])
723 {
724 if (c->hello_interval[0] != HELLO_INTERVAL)
725 {
726 vty_out (vty, " isis hello-interval %d%s",
727 c->hello_interval[0], VTY_NEWLINE);
728 write++;
729 }
730 }
731 else
732 {
733 for (i = 0; i < 2; i++)
734 {
735 if (c->hello_interval[i] != HELLO_INTERVAL)
736 {
737 if (c->hello_interval[i] == HELLO_MINIMAL)
738 {
739 vty_out (vty,
740 " isis hello-interval minimal level-%d%s",
741 i + 1, VTY_NEWLINE);
742 }
743 else
744 {
745 vty_out (vty, " isis hello-interval %d level-%d%s",
746 c->hello_interval[i], i + 1, VTY_NEWLINE);
747 }
748 write++;
749 }
750 }
751 }
jardineb5d44e2003-12-23 08:09:43 +0000752
hassof390d2c2004-09-10 20:48:21 +0000753 /* ISIS - Hello Multiplier */
754 if (c->hello_multiplier[0] == c->hello_multiplier[1])
755 {
756 if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
757 {
758 vty_out (vty, " isis hello-multiplier %d%s",
759 c->hello_multiplier[0], VTY_NEWLINE);
760 write++;
761 }
762 }
763 else
764 {
765 for (i = 0; i < 2; i++)
766 {
767 if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
768 {
769 vty_out (vty, " isis hello-multiplier %d level-%d%s",
770 c->hello_multiplier[i], i + 1, VTY_NEWLINE);
771 write++;
772 }
773 }
774 }
775 /* ISIS - Priority */
776 if (c->circ_type == CIRCUIT_T_BROADCAST)
777 {
778 if (c->u.bc.priority[0] == c->u.bc.priority[1])
779 {
780 if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
781 {
782 vty_out (vty, " isis priority %d%s",
783 c->u.bc.priority[0], VTY_NEWLINE);
784 write++;
785 }
786 }
787 else
788 {
789 for (i = 0; i < 2; i++)
790 {
791 if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
792 {
793 vty_out (vty, " isis priority %d level-%d%s",
794 c->u.bc.priority[i], i + 1, VTY_NEWLINE);
795 write++;
796 }
797 }
798 }
799 }
800 /* ISIS - Metric */
801 if (c->metrics[0].metric_default == c->metrics[1].metric_default)
802 {
803 if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS)
804 {
805 vty_out (vty, " isis metric %d%s",
806 c->metrics[0].metric_default, VTY_NEWLINE);
807 write++;
808 }
809 }
810 else
811 {
812 for (i = 0; i < 2; i++)
813 {
814 if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS)
815 {
816 vty_out (vty, " isis metric %d level-%d%s",
817 c->metrics[i].metric_default, i + 1,
818 VTY_NEWLINE);
819 write++;
820 }
821 }
822 }
jardineb5d44e2003-12-23 08:09:43 +0000823
hassof390d2c2004-09-10 20:48:21 +0000824 }
jardineb5d44e2003-12-23 08:09:43 +0000825 }
hassof390d2c2004-09-10 20:48:21 +0000826 vty_out (vty, "!%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000827 }
hassof390d2c2004-09-10 20:48:21 +0000828
jardineb5d44e2003-12-23 08:09:43 +0000829 return write;
830}
jardineb5d44e2003-12-23 08:09:43 +0000831
832DEFUN (ip_router_isis,
833 ip_router_isis_cmd,
834 "ip router isis WORD",
835 "Interface Internet Protocol config commands\n"
836 "IP router interface commands\n"
837 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000838 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000839{
840 struct isis_circuit *c;
841 struct interface *ifp;
842 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000843
844 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000845 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000846
jardineb5d44e2003-12-23 08:09:43 +0000847 area = isis_area_lookup (argv[0]);
848
849 /* Prevent more than one circuit per interface */
850 if (area)
851 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000852 else
853 c = NULL;
854 if (c && (ifp->info != NULL))
855 {
jardineb5d44e2003-12-23 08:09:43 +0000856#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000857 if (c->ipv6_router == 0)
858 {
jardineb5d44e2003-12-23 08:09:43 +0000859#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000860 vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
861 return CMD_WARNING;
jardineb5d44e2003-12-23 08:09:43 +0000862#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000863 }
864#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000865 }
hassof390d2c2004-09-10 20:48:21 +0000866
jardineb5d44e2003-12-23 08:09:43 +0000867 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +0000868 if (!area)
869 {
870 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
871 return CMD_WARNING;
872 }
jardineb5d44e2003-12-23 08:09:43 +0000873
hassof390d2c2004-09-10 20:48:21 +0000874 if (!c)
875 {
876 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
877 c = isis_csm_state_change (ISIS_ENABLE, c, area);
878 c->interface = ifp; /* this is automatic */
879 ifp->info = c; /* hardly related to the FSM */
880 }
jardineb5d44e2003-12-23 08:09:43 +0000881
hassof390d2c2004-09-10 20:48:21 +0000882 if (!c)
jardineb5d44e2003-12-23 08:09:43 +0000883 return CMD_WARNING;
884
885 c->ip_router = 1;
886 area->ip_circuits++;
887 circuit_update_nlpids (c);
888
889 vty->node = INTERFACE_NODE;
hassof390d2c2004-09-10 20:48:21 +0000890
jardineb5d44e2003-12-23 08:09:43 +0000891 return CMD_SUCCESS;
892}
893
894DEFUN (no_ip_router_isis,
895 no_ip_router_isis_cmd,
896 "no ip router isis WORD",
897 NO_STR
898 "Interface Internet Protocol config commands\n"
899 "IP router interface commands\n"
900 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000901 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000902{
903 struct isis_circuit *circuit = NULL;
904 struct interface *ifp;
905 struct isis_area *area;
906 struct listnode *node;
907
hassof390d2c2004-09-10 20:48:21 +0000908 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000909 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000910
jardineb5d44e2003-12-23 08:09:43 +0000911 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +0000912 if (!area)
913 {
914 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
915 return CMD_WARNING;
916 }
jardineb5d44e2003-12-23 08:09:43 +0000917 LIST_LOOP (area->circuit_list, circuit, node)
918 if (circuit->interface == ifp)
919 break;
hassof390d2c2004-09-10 20:48:21 +0000920 if (!circuit)
921 {
922 vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
923 return CMD_WARNING;
924 }
jardineb5d44e2003-12-23 08:09:43 +0000925 circuit->ip_router = 0;
926 area->ip_circuits--;
927#ifdef HAVE_IPV6
928 if (circuit->ipv6_router == 0)
929#endif
930 isis_csm_state_change (ISIS_DISABLE, circuit, area);
hassof390d2c2004-09-10 20:48:21 +0000931
jardineb5d44e2003-12-23 08:09:43 +0000932 return CMD_SUCCESS;
933}
934
935DEFUN (isis_circuit_type,
936 isis_circuit_type_cmd,
937 "isis circuit-type (level-1|level-1-2|level-2-only)",
938 "IS-IS commands\n"
939 "Configure circuit type for interface\n"
940 "Level-1 only adjacencies are formed\n"
941 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000942 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000943{
944 struct isis_circuit *circuit;
945 struct interface *ifp;
946 int circuit_t;
947 int is_type;
hassof390d2c2004-09-10 20:48:21 +0000948
949 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000950 circuit = ifp->info;
951 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +0000952 if (circuit == NULL)
953 {
954 return CMD_WARNING;
955 }
jardineb5d44e2003-12-23 08:09:43 +0000956
hasso13c48f72004-09-10 21:19:13 +0000957 /* XXX what to do when ip_router_isis is not executed */
958 if (circuit->area == NULL)
959 return CMD_WARNING;
960
jardineb5d44e2003-12-23 08:09:43 +0000961 assert (circuit);
962
963 circuit_t = string2circuit_t (argv[0]);
964
hassof390d2c2004-09-10 20:48:21 +0000965 if (!circuit_t)
966 {
967 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
968 return CMD_SUCCESS;
969 }
970
jardineb5d44e2003-12-23 08:09:43 +0000971 is_type = circuit->area->is_type;
972 if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
hassof390d2c2004-09-10 20:48:21 +0000973 isis_event_circuit_type_change (circuit, circuit_t);
974 else
975 {
976 vty_out (vty, "invalid circuit level for area %s.%s",
977 circuit->area->area_tag, VTY_NEWLINE);
978 }
979
jardineb5d44e2003-12-23 08:09:43 +0000980 return CMD_SUCCESS;
981}
982
983DEFUN (no_isis_circuit_type,
984 no_isis_circuit_type_cmd,
985 "no isis circuit-type (level-1|level-1-2|level-2-only)",
986 NO_STR
987 "IS-IS commands\n"
988 "Configure circuit type for interface\n"
989 "Level-1 only adjacencies are formed\n"
990 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000991 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000992{
993 struct isis_circuit *circuit;
994 struct interface *ifp;
jardineb5d44e2003-12-23 08:09:43 +0000995
hassof390d2c2004-09-10 20:48:21 +0000996 ifp = vty->index;
997 circuit = ifp->info;
998 if (circuit == NULL)
999 {
1000 return CMD_WARNING;
1001 }
1002
1003 assert (circuit);
1004
jardineb5d44e2003-12-23 08:09:43 +00001005 /*
1006 * Set the circuits level to its default value which is that of the area
1007 */
1008 isis_event_circuit_type_change (circuit, circuit->area->is_type);
hassof390d2c2004-09-10 20:48:21 +00001009
jardineb5d44e2003-12-23 08:09:43 +00001010 return CMD_SUCCESS;
1011}
1012
1013DEFUN (isis_passwd,
1014 isis_passwd_cmd,
1015 "isis password WORD",
1016 "IS-IS commands\n"
1017 "Configure the authentication password for interface\n"
1018 "Password\n")
1019{
1020 struct isis_circuit *circuit;
1021 struct interface *ifp;
1022 int len;
hassof390d2c2004-09-10 20:48:21 +00001023
1024 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001025 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001026 if (circuit == NULL)
1027 {
1028 return CMD_WARNING;
1029 }
1030
jardineb5d44e2003-12-23 08:09:43 +00001031 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001032 if (len > 254)
1033 {
1034 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1035 return CMD_WARNING;
1036 }
jardineb5d44e2003-12-23 08:09:43 +00001037 circuit->passwd.len = len;
1038 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
1039 strncpy (circuit->passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001040
jardineb5d44e2003-12-23 08:09:43 +00001041 return CMD_SUCCESS;
1042}
1043
1044DEFUN (no_isis_passwd,
1045 no_isis_passwd_cmd,
1046 "no isis password",
1047 NO_STR
1048 "IS-IS commands\n"
1049 "Configure the authentication password for interface\n")
1050{
1051 struct isis_circuit *circuit;
1052 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001053
1054 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001055 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001056 if (circuit == NULL)
1057 {
1058 return CMD_WARNING;
1059 }
1060
jardineb5d44e2003-12-23 08:09:43 +00001061 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
hassof390d2c2004-09-10 20:48:21 +00001062
jardineb5d44e2003-12-23 08:09:43 +00001063 return CMD_SUCCESS;
1064}
1065
1066
1067DEFUN (isis_priority,
1068 isis_priority_cmd,
1069 "isis priority <0-127>",
1070 "IS-IS commands\n"
1071 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001072 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001073{
1074 struct isis_circuit *circuit;
1075 struct interface *ifp;
1076 int prio;
hassof390d2c2004-09-10 20:48:21 +00001077
1078 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001079 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001080 if (circuit == NULL)
1081 {
1082 return CMD_WARNING;
1083 }
jardineb5d44e2003-12-23 08:09:43 +00001084 assert (circuit);
1085
1086 prio = atoi (argv[0]);
1087
1088 circuit->u.bc.priority[0] = prio;
1089 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001090
jardineb5d44e2003-12-23 08:09:43 +00001091 return CMD_SUCCESS;
1092}
1093
1094DEFUN (no_isis_priority,
1095 no_isis_priority_cmd,
1096 "no isis priority",
1097 NO_STR
1098 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001099 "Set priority for Designated Router election\n")
jardineb5d44e2003-12-23 08:09:43 +00001100{
1101 struct isis_circuit *circuit;
1102 struct interface *ifp;
1103
hassof390d2c2004-09-10 20:48:21 +00001104 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001105 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001106 if (circuit == NULL)
1107 {
1108 return CMD_WARNING;
1109 }
jardineb5d44e2003-12-23 08:09:43 +00001110 assert (circuit);
1111
1112 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
1113 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001114
jardineb5d44e2003-12-23 08:09:43 +00001115 return CMD_SUCCESS;
1116}
1117
1118ALIAS (no_isis_priority,
1119 no_isis_priority_arg_cmd,
1120 "no isis priority <0-127>",
1121 NO_STR
1122 "IS-IS commands\n"
1123 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001124 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001125
1126DEFUN (isis_priority_l1,
1127 isis_priority_l1_cmd,
hassof390d2c2004-09-10 20:48:21 +00001128 "isis priority <0-127> level-1",
jardineb5d44e2003-12-23 08:09:43 +00001129 "IS-IS commands\n"
1130 "Set priority for Designated Router election\n"
1131 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001132 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001133{
1134 struct isis_circuit *circuit;
1135 struct interface *ifp;
1136 int prio;
hassof390d2c2004-09-10 20:48:21 +00001137
1138 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001139 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001140 if (circuit == NULL)
1141 {
1142 return CMD_WARNING;
1143 }
jardineb5d44e2003-12-23 08:09:43 +00001144 assert (circuit);
1145
1146 prio = atoi (argv[0]);
1147
1148 circuit->u.bc.priority[0] = prio;
hassof390d2c2004-09-10 20:48:21 +00001149
jardineb5d44e2003-12-23 08:09:43 +00001150 return CMD_SUCCESS;
1151}
1152
1153DEFUN (no_isis_priority_l1,
1154 no_isis_priority_l1_cmd,
1155 "no isis priority level-1",
1156 NO_STR
1157 "IS-IS commands\n"
1158 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001159 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001160{
1161 struct isis_circuit *circuit;
1162 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001163
1164 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001165 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001166 if (circuit == NULL)
1167 {
1168 return CMD_WARNING;
1169 }
jardineb5d44e2003-12-23 08:09:43 +00001170 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001171
jardineb5d44e2003-12-23 08:09:43 +00001172 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001173
jardineb5d44e2003-12-23 08:09:43 +00001174 return CMD_SUCCESS;
1175}
1176
1177ALIAS (no_isis_priority_l1,
1178 no_isis_priority_l1_arg_cmd,
1179 "no isis priority <0-127> level-1",
1180 NO_STR
1181 "IS-IS commands\n"
1182 "Set priority for Designated Router election\n"
1183 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001184 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001185
1186DEFUN (isis_priority_l2,
1187 isis_priority_l2_cmd,
hassof390d2c2004-09-10 20:48:21 +00001188 "isis priority <0-127> level-2",
jardineb5d44e2003-12-23 08:09:43 +00001189 "IS-IS commands\n"
1190 "Set priority for Designated Router election\n"
1191 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001192 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001193{
1194 struct isis_circuit *circuit;
1195 struct interface *ifp;
1196 int prio;
hassof390d2c2004-09-10 20:48:21 +00001197
1198 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001199 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001200 if (circuit == NULL)
1201 {
1202 return CMD_WARNING;
1203 }
jardineb5d44e2003-12-23 08:09:43 +00001204 assert (circuit);
1205
1206 prio = atoi (argv[0]);
1207
1208 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001209
jardineb5d44e2003-12-23 08:09:43 +00001210 return CMD_SUCCESS;
1211}
1212
1213DEFUN (no_isis_priority_l2,
1214 no_isis_priority_l2_cmd,
1215 "no isis priority level-2",
1216 NO_STR
1217 "IS-IS commands\n"
1218 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001219 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001220{
1221 struct isis_circuit *circuit;
1222 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001223
1224 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001225 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001226 if (circuit == NULL)
1227 {
1228 return CMD_WARNING;
1229 }
jardineb5d44e2003-12-23 08:09:43 +00001230 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001231
jardineb5d44e2003-12-23 08:09:43 +00001232 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001233
jardineb5d44e2003-12-23 08:09:43 +00001234 return CMD_SUCCESS;
1235}
1236
1237ALIAS (no_isis_priority_l2,
1238 no_isis_priority_l2_arg_cmd,
1239 "no isis priority <0-127> level-2",
1240 NO_STR
1241 "IS-IS commands\n"
1242 "Set priority for Designated Router election\n"
1243 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001244 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001245
1246/* Metric command */
hassof390d2c2004-09-10 20:48:21 +00001247 DEFUN (isis_metric,
jardineb5d44e2003-12-23 08:09:43 +00001248 isis_metric_cmd,
1249 "isis metric <0-63>",
1250 "IS-IS commands\n"
1251 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001252 "Default metric value\n")
jardineb5d44e2003-12-23 08:09:43 +00001253{
1254 struct isis_circuit *circuit;
1255 struct interface *ifp;
1256 int met;
1257
hassof390d2c2004-09-10 20:48:21 +00001258 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001259 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001260 if (circuit == NULL)
1261 {
1262 return CMD_WARNING;
1263 }
jardineb5d44e2003-12-23 08:09:43 +00001264 assert (circuit);
1265
1266 met = atoi (argv[0]);
1267
1268 circuit->metrics[0].metric_default = met;
1269 circuit->metrics[1].metric_default = met;
1270
1271 return CMD_SUCCESS;
1272}
1273
1274DEFUN (no_isis_metric,
1275 no_isis_metric_cmd,
1276 "no isis metric",
1277 NO_STR
1278 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001279 "Set default metric for circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001280{
1281 struct isis_circuit *circuit;
1282 struct interface *ifp;
1283
hassof390d2c2004-09-10 20:48:21 +00001284 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001285 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001286 if (circuit == NULL)
1287 {
1288 return CMD_WARNING;
1289 }
jardineb5d44e2003-12-23 08:09:43 +00001290 assert (circuit);
1291
1292 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
1293 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS;
1294
1295 return CMD_SUCCESS;
1296}
1297
1298ALIAS (no_isis_metric,
1299 no_isis_metric_arg_cmd,
1300 "no isis metric <0-127>",
1301 NO_STR
1302 "IS-IS commands\n"
1303 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001304 "Default metric value\n")
1305
jardineb5d44e2003-12-23 08:09:43 +00001306/* end of metrics */
hassof390d2c2004-09-10 20:48:21 +00001307 DEFUN (isis_hello_interval,
jardineb5d44e2003-12-23 08:09:43 +00001308 isis_hello_interval_cmd,
1309 "isis hello-interval (<1-65535>|minimal)",
1310 "IS-IS commands\n"
1311 "Set Hello interval\n"
1312 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001313 "Holdtime 1 seconds, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001314{
1315 struct isis_circuit *circuit;
1316 struct interface *ifp;
1317 int interval;
1318 char c;
1319
hassof390d2c2004-09-10 20:48:21 +00001320 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001321 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001322 if (circuit == NULL)
1323 {
1324 return CMD_WARNING;
1325 }
1326 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001327 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001328 if (isdigit ((int) c))
1329 {
1330 interval = atoi (argv[0]);
1331 }
1332 else
1333 interval = HELLO_MINIMAL; /* FIXME: should be calculated */
jardineb5d44e2003-12-23 08:09:43 +00001334
hassof390d2c2004-09-10 20:48:21 +00001335 circuit->hello_interval[0] = (u_int16_t) interval;
1336 circuit->hello_interval[1] = (u_int16_t) interval;
1337
jardineb5d44e2003-12-23 08:09:43 +00001338 return CMD_SUCCESS;
1339}
1340
1341DEFUN (no_isis_hello_interval,
1342 no_isis_hello_interval_cmd,
1343 "no isis hello-interval",
1344 NO_STR
1345 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001346 "Set Hello interval\n")
jardineb5d44e2003-12-23 08:09:43 +00001347{
1348 struct isis_circuit *circuit;
1349 struct interface *ifp;
1350
hassof390d2c2004-09-10 20:48:21 +00001351 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001352 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001353 if (circuit == NULL)
1354 {
1355 return CMD_WARNING;
1356 }
jardineb5d44e2003-12-23 08:09:43 +00001357 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001358
hassof390d2c2004-09-10 20:48:21 +00001359
1360 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
jardineb5d44e2003-12-23 08:09:43 +00001361 circuit->hello_interval[1] = HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001362
jardineb5d44e2003-12-23 08:09:43 +00001363 return CMD_SUCCESS;
1364}
1365
1366ALIAS (no_isis_hello_interval,
1367 no_isis_hello_interval_arg_cmd,
1368 "no isis hello-interval (<1-65535>|minimal)",
1369 NO_STR
1370 "IS-IS commands\n"
1371 "Set Hello interval\n"
1372 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001373 "Holdtime 1 second, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001374
1375DEFUN (isis_hello_interval_l1,
1376 isis_hello_interval_l1_cmd,
1377 "isis hello-interval (<1-65535>|minimal) level-1",
1378 "IS-IS commands\n"
1379 "Set Hello interval\n"
1380 "Hello interval value\n"
1381 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001382 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001383{
1384 struct isis_circuit *circuit;
1385 struct interface *ifp;
1386 long interval;
1387 char c;
1388
hassof390d2c2004-09-10 20:48:21 +00001389 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001390 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001391 if (circuit == NULL)
1392 {
1393 return CMD_WARNING;
1394 }
jardineb5d44e2003-12-23 08:09:43 +00001395 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001396
jardineb5d44e2003-12-23 08:09:43 +00001397 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001398 if (isdigit ((int) c))
1399 {
1400 interval = atoi (argv[0]);
1401 }
1402 else
jardineb5d44e2003-12-23 08:09:43 +00001403 interval = HELLO_MINIMAL;
1404
hassof390d2c2004-09-10 20:48:21 +00001405 circuit->hello_interval[0] = (u_int16_t) interval;
1406
jardineb5d44e2003-12-23 08:09:43 +00001407 return CMD_SUCCESS;
1408}
1409
1410DEFUN (no_isis_hello_interval_l1,
1411 no_isis_hello_interval_l1_cmd,
1412 "no isis hello-interval level-1",
1413 NO_STR
1414 "IS-IS commands\n"
1415 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001416 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001417{
1418 struct isis_circuit *circuit;
1419 struct interface *ifp;
1420
hassof390d2c2004-09-10 20:48:21 +00001421 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001422 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001423 if (circuit == NULL)
1424 {
1425 return CMD_WARNING;
1426 }
jardineb5d44e2003-12-23 08:09:43 +00001427 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001428
hassof390d2c2004-09-10 20:48:21 +00001429
1430 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
1431
jardineb5d44e2003-12-23 08:09:43 +00001432 return CMD_SUCCESS;
1433}
1434
1435ALIAS (no_isis_hello_interval_l1,
1436 no_isis_hello_interval_l1_arg_cmd,
1437 "no isis hello-interval (<1-65535>|minimal) level-1",
1438 NO_STR
1439 "IS-IS commands\n"
1440 "Set Hello interval\n"
1441 "Hello interval value\n"
1442 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001443 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001444
1445DEFUN (isis_hello_interval_l2,
1446 isis_hello_interval_l2_cmd,
1447 "isis hello-interval (<1-65535>|minimal) level-2",
1448 "IS-IS commands\n"
1449 "Set Hello interval\n"
1450 "Hello interval value\n"
1451 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001452 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001453{
1454 struct isis_circuit *circuit;
1455 struct interface *ifp;
1456 long interval;
1457 char c;
1458
hassof390d2c2004-09-10 20:48:21 +00001459 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001460 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001461 if (circuit == NULL)
1462 {
1463 return CMD_WARNING;
1464 }
jardineb5d44e2003-12-23 08:09:43 +00001465 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001466
jardineb5d44e2003-12-23 08:09:43 +00001467 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001468 if (isdigit ((int) c))
1469 {
1470 interval = atoi (argv[0]);
1471 }
1472 else
jardineb5d44e2003-12-23 08:09:43 +00001473 interval = HELLO_MINIMAL;
1474
hassof390d2c2004-09-10 20:48:21 +00001475 circuit->hello_interval[1] = (u_int16_t) interval;
1476
jardineb5d44e2003-12-23 08:09:43 +00001477 return CMD_SUCCESS;
1478}
1479
1480DEFUN (no_isis_hello_interval_l2,
1481 no_isis_hello_interval_l2_cmd,
1482 "no isis hello-interval level-2",
1483 NO_STR
1484 "IS-IS commands\n"
1485 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001486 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001487{
1488 struct isis_circuit *circuit;
1489 struct interface *ifp;
1490
hassof390d2c2004-09-10 20:48:21 +00001491 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001492 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001493 if (circuit == NULL)
1494 {
1495 return CMD_WARNING;
1496 }
jardineb5d44e2003-12-23 08:09:43 +00001497 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001498
hassof390d2c2004-09-10 20:48:21 +00001499
1500 circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
1501
jardineb5d44e2003-12-23 08:09:43 +00001502 return CMD_SUCCESS;
1503}
1504
1505ALIAS (no_isis_hello_interval_l2,
1506 no_isis_hello_interval_l2_arg_cmd,
1507 "no isis hello-interval (<1-65535>|minimal) level-2",
1508 NO_STR
1509 "IS-IS commands\n"
1510 "Set Hello interval\n"
1511 "Hello interval value\n"
1512 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001513 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001514
1515DEFUN (isis_hello_multiplier,
1516 isis_hello_multiplier_cmd,
1517 "isis hello-multiplier <3-1000>",
1518 "IS-IS commands\n"
1519 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001520 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001521{
1522 struct isis_circuit *circuit;
1523 struct interface *ifp;
1524 int mult;
hassof390d2c2004-09-10 20:48:21 +00001525
1526 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001527 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001528 if (circuit == NULL)
1529 {
1530 return CMD_WARNING;
1531 }
jardineb5d44e2003-12-23 08:09:43 +00001532 assert (circuit);
1533
1534 mult = atoi (argv[0]);
1535
hassof390d2c2004-09-10 20:48:21 +00001536 circuit->hello_multiplier[0] = (u_int16_t) mult;
1537 circuit->hello_multiplier[1] = (u_int16_t) mult;
1538
jardineb5d44e2003-12-23 08:09:43 +00001539 return CMD_SUCCESS;
1540}
1541
1542DEFUN (no_isis_hello_multiplier,
1543 no_isis_hello_multiplier_cmd,
1544 "no isis hello-multiplier",
1545 NO_STR
1546 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001547 "Set multiplier for Hello holding time\n")
jardineb5d44e2003-12-23 08:09:43 +00001548{
1549 struct isis_circuit *circuit;
1550 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001551
1552 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001553 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001554 if (circuit == NULL)
1555 {
1556 return CMD_WARNING;
1557 }
jardineb5d44e2003-12-23 08:09:43 +00001558 assert (circuit);
1559
1560 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1561 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1562
1563 return CMD_SUCCESS;
1564}
1565
1566ALIAS (no_isis_hello_multiplier,
1567 no_isis_hello_multiplier_arg_cmd,
1568 "no isis hello-multiplier <3-1000>",
1569 NO_STR
1570 "IS-IS commands\n"
1571 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001572 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001573
1574DEFUN (isis_hello_multiplier_l1,
1575 isis_hello_multiplier_l1_cmd,
1576 "isis hello-multiplier <3-1000> level-1",
1577 "IS-IS commands\n"
1578 "Set multiplier for Hello holding time\n"
1579 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001580 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001581{
1582 struct isis_circuit *circuit;
1583 struct interface *ifp;
1584 int mult;
hassof390d2c2004-09-10 20:48:21 +00001585
1586 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001587 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001588 if (circuit == NULL)
1589 {
1590 return CMD_WARNING;
1591 }
jardineb5d44e2003-12-23 08:09:43 +00001592 assert (circuit);
1593
1594 mult = atoi (argv[0]);
1595
hassof390d2c2004-09-10 20:48:21 +00001596 circuit->hello_multiplier[0] = (u_int16_t) mult;
1597
jardineb5d44e2003-12-23 08:09:43 +00001598 return CMD_SUCCESS;
1599}
1600
1601DEFUN (no_isis_hello_multiplier_l1,
1602 no_isis_hello_multiplier_l1_cmd,
1603 "no isis hello-multiplier level-1",
1604 NO_STR
1605 "IS-IS commands\n"
1606 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001607 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001608{
1609 struct isis_circuit *circuit;
1610 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001611
1612 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001613 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001614 if (circuit == NULL)
1615 {
1616 return CMD_WARNING;
1617 }
jardineb5d44e2003-12-23 08:09:43 +00001618 assert (circuit);
1619
1620 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1621
1622 return CMD_SUCCESS;
1623}
1624
1625ALIAS (no_isis_hello_multiplier_l1,
1626 no_isis_hello_multiplier_l1_arg_cmd,
1627 "no isis hello-multiplier <3-1000> level-1",
1628 NO_STR
1629 "IS-IS commands\n"
1630 "Set multiplier for Hello holding time\n"
1631 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001632 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001633
1634DEFUN (isis_hello_multiplier_l2,
1635 isis_hello_multiplier_l2_cmd,
1636 "isis hello-multiplier <3-1000> level-2",
1637 "IS-IS commands\n"
1638 "Set multiplier for Hello holding time\n"
1639 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001640 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001641{
1642 struct isis_circuit *circuit;
1643 struct interface *ifp;
1644 int mult;
hassof390d2c2004-09-10 20:48:21 +00001645
1646 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001647 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001648 if (circuit == NULL)
1649 {
1650 return CMD_WARNING;
1651 }
jardineb5d44e2003-12-23 08:09:43 +00001652 assert (circuit);
1653
1654 mult = atoi (argv[0]);
1655
hassof390d2c2004-09-10 20:48:21 +00001656 circuit->hello_multiplier[1] = (u_int16_t) mult;
1657
jardineb5d44e2003-12-23 08:09:43 +00001658 return CMD_SUCCESS;
1659}
1660
1661DEFUN (no_isis_hello_multiplier_l2,
1662 no_isis_hello_multiplier_l2_cmd,
1663 "no isis hello-multiplier level-2",
1664 NO_STR
1665 "IS-IS commands\n"
1666 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001667 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001668{
1669 struct isis_circuit *circuit;
1670 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001671
1672 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001673 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001674 if (circuit == NULL)
1675 {
1676 return CMD_WARNING;
1677 }
jardineb5d44e2003-12-23 08:09:43 +00001678 assert (circuit);
1679
1680 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1681
1682 return CMD_SUCCESS;
1683}
1684
1685ALIAS (no_isis_hello_multiplier_l2,
1686 no_isis_hello_multiplier_l2_arg_cmd,
1687 "no isis hello-multiplier <3-1000> level-2",
1688 NO_STR
1689 "IS-IS commands\n"
1690 "Set multiplier for Hello holding time\n"
1691 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001692 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001693
1694DEFUN (isis_hello,
1695 isis_hello_cmd,
1696 "isis hello padding",
1697 "IS-IS commands\n"
1698 "Add padding to IS-IS hello packets\n"
1699 "Pad hello packets\n"
1700 "<cr>\n")
1701{
1702 struct interface *ifp;
1703 struct isis_circuit *circuit;
hassof390d2c2004-09-10 20:48:21 +00001704
1705 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001706 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001707 if (circuit == NULL)
1708 {
1709 return CMD_WARNING;
1710 }
jardineb5d44e2003-12-23 08:09:43 +00001711 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001712
jardineb5d44e2003-12-23 08:09:43 +00001713 circuit->u.bc.pad_hellos = 1;
hassof390d2c2004-09-10 20:48:21 +00001714
jardineb5d44e2003-12-23 08:09:43 +00001715 return CMD_SUCCESS;
1716}
1717
hasso54301ce2004-01-27 10:07:34 +00001718#if 0
jardineb5d44e2003-12-23 08:09:43 +00001719DEFUN (ip_address,
1720 ip_address_cmd,
1721 "ip address A.B.C.D/A",
1722 "Interface Internet Protocol config commands\n"
hassof390d2c2004-09-10 20:48:21 +00001723 "Set the IP address of an interface\n" "IP address (e.g. 10.0.0.1/8\n")
jardineb5d44e2003-12-23 08:09:43 +00001724{
1725 struct interface *ifp;
1726 struct isis_circuit *circuit;
1727 struct prefix_ipv4 *ipv4, *ip;
1728 struct listnode *node;
1729 int ret, found = 1;
1730
hassof390d2c2004-09-10 20:48:21 +00001731 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001732 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001733 if (circuit == NULL)
1734 {
1735 return CMD_WARNING;
1736 }
jardineb5d44e2003-12-23 08:09:43 +00001737
1738 assert (circuit);
1739#ifdef HAVE_IPV6
1740 zlog_info ("ip_address_cmd circuit %d", circuit->interface->ifindex);
1741#endif /* HAVE_IPV6 */
1742
1743 ipv4 = prefix_ipv4_new ();
jardineb5d44e2003-12-23 08:09:43 +00001744
hassof390d2c2004-09-10 20:48:21 +00001745 ret = str2prefix_ipv4 (argv[0], ipv4);
1746 if (ret <= 0)
1747 {
1748 zlog_warn ("ip_address_cmd(): malformed address");
1749 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
1750 return CMD_WARNING;
1751 }
1752
1753 if (!circuit->ip_addrs)
1754 circuit->ip_addrs = list_new ();
1755 else
1756 {
1757 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
1758 {
1759 ip = getdata (node);
1760 if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
1761 found = 1;
1762 }
1763 if (found)
1764 {
1765 prefix_ipv4_free (ipv4);
1766 return CMD_SUCCESS;
1767 }
1768 }
1769
1770
jardineb5d44e2003-12-23 08:09:43 +00001771 listnode_add (circuit->ip_addrs, ipv4);
hassof390d2c2004-09-10 20:48:21 +00001772#ifdef EXTREME_DEBUG
1773 zlog_info ("added IP address %s to circuit %d", argv[0],
jardineb5d44e2003-12-23 08:09:43 +00001774 circuit->interface->ifindex);
1775#endif /* EXTREME_DEBUG */
1776 return CMD_SUCCESS;
1777}
1778
1779DEFUN (no_ip_address,
1780 no_ip_address_cmd,
1781 "no ip address A.B.C.D/A",
1782 NO_STR
1783 "Interface Internet Protocol config commands\n"
1784 "Set the IP address of an interface\n"
1785 "IP address (e.g. 10.0.0.1/8\n")
1786{
1787 struct interface *ifp;
1788 struct isis_circuit *circuit;
1789 struct prefix_ipv4 ipv4, *ip = NULL;
1790 struct listnode *node;
1791 int ret;
1792
hassof390d2c2004-09-10 20:48:21 +00001793 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001794 circuit = ifp->info;
1795 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00001796 if (circuit == NULL)
1797 {
1798 return CMD_WARNING;
1799 }
jardineb5d44e2003-12-23 08:09:43 +00001800 assert (circuit);
1801
hassof390d2c2004-09-10 20:48:21 +00001802 if (!circuit->ip_addrs || circuit->ip_addrs->count == 0)
1803 {
1804 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
1805 return CMD_WARNING;
1806 }
jardineb5d44e2003-12-23 08:09:43 +00001807 ret = str2prefix_ipv4 (argv[0], &ipv4);
hassof390d2c2004-09-10 20:48:21 +00001808 if (ret <= 0)
1809 {
1810 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
1811 return CMD_WARNING;
1812 }
1813
1814 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
1815 {
1816 ip = getdata (node);
1817 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
1818 break;
1819 }
1820
1821 if (ip)
1822 {
1823 listnode_delete (circuit->ip_addrs, ip);
1824 }
1825 else
1826 {
1827 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
1828 }
1829
jardineb5d44e2003-12-23 08:09:43 +00001830 return CMD_SUCCESS;
1831}
hasso54301ce2004-01-27 10:07:34 +00001832#endif
jardineb5d44e2003-12-23 08:09:43 +00001833
1834DEFUN (no_isis_hello,
1835 no_isis_hello_cmd,
1836 "no isis hello padding",
1837 NO_STR
1838 "IS-IS commands\n"
1839 "Add padding to IS-IS hello packets\n"
1840 "Pad hello packets\n"
1841 "<cr>\n")
1842{
1843 struct isis_circuit *circuit;
1844 struct interface *ifp;
1845
hassof390d2c2004-09-10 20:48:21 +00001846 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001847 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001848 if (circuit == NULL)
1849 {
1850 return CMD_WARNING;
1851 }
jardineb5d44e2003-12-23 08:09:43 +00001852 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001853
jardineb5d44e2003-12-23 08:09:43 +00001854 circuit->u.bc.pad_hellos = 0;
hassof390d2c2004-09-10 20:48:21 +00001855
jardineb5d44e2003-12-23 08:09:43 +00001856 return CMD_SUCCESS;
1857}
1858
1859DEFUN (csnp_interval,
1860 csnp_interval_cmd,
1861 "isis csnp-interval <0-65535>",
1862 "IS-IS commands\n"
1863 "Set CSNP interval in seconds\n"
1864 "CSNP interval value\n")
1865{
1866 struct isis_circuit *circuit;
1867 struct interface *ifp;
1868 unsigned long interval;
1869
hassof390d2c2004-09-10 20:48:21 +00001870 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001871 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001872 if (circuit == NULL)
1873 {
1874 return CMD_WARNING;
1875 }
jardineb5d44e2003-12-23 08:09:43 +00001876 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001877
jardineb5d44e2003-12-23 08:09:43 +00001878 interval = atol (argv[0]);
1879
hassof390d2c2004-09-10 20:48:21 +00001880 circuit->csnp_interval[0] = (u_int16_t) interval;
1881 circuit->csnp_interval[1] = (u_int16_t) interval;
1882
jardineb5d44e2003-12-23 08:09:43 +00001883 return CMD_SUCCESS;
1884}
1885
1886DEFUN (no_csnp_interval,
1887 no_csnp_interval_cmd,
1888 "no isis csnp-interval",
1889 NO_STR
1890 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001891 "Set CSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001892{
1893 struct isis_circuit *circuit;
1894 struct interface *ifp;
1895
hassof390d2c2004-09-10 20:48:21 +00001896 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001897 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001898 if (circuit == NULL)
1899 {
1900 return CMD_WARNING;
1901 }
jardineb5d44e2003-12-23 08:09:43 +00001902 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001903
jardineb5d44e2003-12-23 08:09:43 +00001904 circuit->csnp_interval[0] = CSNP_INTERVAL;
1905 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001906
jardineb5d44e2003-12-23 08:09:43 +00001907 return CMD_SUCCESS;
1908}
1909
1910ALIAS (no_csnp_interval,
1911 no_csnp_interval_arg_cmd,
1912 "no isis csnp-interval <0-65535>",
1913 NO_STR
1914 "IS-IS commands\n"
1915 "Set CSNP interval in seconds\n"
1916 "CSNP interval value\n")
1917
jardineb5d44e2003-12-23 08:09:43 +00001918DEFUN (csnp_interval_l1,
1919 csnp_interval_l1_cmd,
1920 "isis csnp-interval <0-65535> level-1",
1921 "IS-IS commands\n"
1922 "Set CSNP interval in seconds\n"
1923 "CSNP interval value\n"
1924 "Specify interval for level-1 CSNPs\n")
1925{
1926 struct isis_circuit *circuit;
1927 struct interface *ifp;
1928 unsigned long interval;
1929
hassof390d2c2004-09-10 20:48:21 +00001930 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001931 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001932 if (circuit == NULL)
1933 {
1934 return CMD_WARNING;
1935 }
jardineb5d44e2003-12-23 08:09:43 +00001936 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001937
jardineb5d44e2003-12-23 08:09:43 +00001938 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001939
1940 circuit->csnp_interval[0] = (u_int16_t) interval;
1941
jardineb5d44e2003-12-23 08:09:43 +00001942 return CMD_SUCCESS;
1943}
1944
1945DEFUN (no_csnp_interval_l1,
1946 no_csnp_interval_l1_cmd,
1947 "no isis csnp-interval level-1",
1948 NO_STR
1949 "IS-IS commands\n"
1950 "Set CSNP interval in seconds\n"
1951 "Specify interval for level-1 CSNPs\n")
1952{
1953 struct isis_circuit *circuit;
1954 struct interface *ifp;
1955
hassof390d2c2004-09-10 20:48:21 +00001956 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001957 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001958 if (circuit == NULL)
1959 {
1960 return CMD_WARNING;
1961 }
jardineb5d44e2003-12-23 08:09:43 +00001962 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001963
jardineb5d44e2003-12-23 08:09:43 +00001964 circuit->csnp_interval[0] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001965
jardineb5d44e2003-12-23 08:09:43 +00001966 return CMD_SUCCESS;
1967}
1968
1969ALIAS (no_csnp_interval_l1,
1970 no_csnp_interval_l1_arg_cmd,
1971 "no isis csnp-interval <0-65535> level-1",
1972 NO_STR
1973 "IS-IS commands\n"
1974 "Set CSNP interval in seconds\n"
1975 "CSNP interval value\n"
1976 "Specify interval for level-1 CSNPs\n")
1977
jardineb5d44e2003-12-23 08:09:43 +00001978DEFUN (csnp_interval_l2,
1979 csnp_interval_l2_cmd,
1980 "isis csnp-interval <0-65535> level-2",
1981 "IS-IS commands\n"
1982 "Set CSNP interval in seconds\n"
1983 "CSNP interval value\n"
1984 "Specify interval for level-2 CSNPs\n")
1985{
1986 struct isis_circuit *circuit;
1987 struct interface *ifp;
1988 unsigned long interval;
1989
hassof390d2c2004-09-10 20:48:21 +00001990 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001991 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001992 if (circuit == NULL)
1993 {
1994 return CMD_WARNING;
1995 }
jardineb5d44e2003-12-23 08:09:43 +00001996 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001997
jardineb5d44e2003-12-23 08:09:43 +00001998 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001999
2000 circuit->csnp_interval[1] = (u_int16_t) interval;
2001
jardineb5d44e2003-12-23 08:09:43 +00002002 return CMD_SUCCESS;
2003}
2004
2005DEFUN (no_csnp_interval_l2,
2006 no_csnp_interval_l2_cmd,
2007 "no isis csnp-interval level-2",
2008 NO_STR
2009 "IS-IS commands\n"
2010 "Set CSNP interval in seconds\n"
2011 "Specify interval for level-2 CSNPs\n")
2012{
2013 struct isis_circuit *circuit;
2014 struct interface *ifp;
2015
hassof390d2c2004-09-10 20:48:21 +00002016 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002017 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00002018 if (circuit == NULL)
2019 {
2020 return CMD_WARNING;
2021 }
jardineb5d44e2003-12-23 08:09:43 +00002022 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00002023
jardineb5d44e2003-12-23 08:09:43 +00002024 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002025
jardineb5d44e2003-12-23 08:09:43 +00002026 return CMD_SUCCESS;
2027}
2028
2029ALIAS (no_csnp_interval_l2,
2030 no_csnp_interval_l2_arg_cmd,
2031 "no isis csnp-interval <0-65535> level-2",
2032 NO_STR
2033 "IS-IS commands\n"
2034 "Set CSNP interval in seconds\n"
2035 "CSNP interval value\n"
2036 "Specify interval for level-2 CSNPs\n")
2037
jardineb5d44e2003-12-23 08:09:43 +00002038#ifdef HAVE_IPV6
2039DEFUN (ipv6_router_isis,
2040 ipv6_router_isis_cmd,
2041 "ipv6 router isis WORD",
2042 "IPv6 interface subcommands\n"
2043 "IPv6 Router interface commands\n"
2044 "IS-IS Routing for IPv6\n"
2045 "Routing process tag\n")
2046{
2047 struct isis_circuit *c;
2048 struct interface *ifp;
2049 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002050
2051 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002052 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002053
jardineb5d44e2003-12-23 08:09:43 +00002054 area = isis_area_lookup (argv[0]);
2055
2056 /* Prevent more than one circuit per interface */
2057 if (area)
2058 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +00002059 else
2060 c = NULL;
2061
2062 if (c && (ifp->info != NULL))
2063 {
2064 if (c->ipv6_router == 1)
2065 {
2066 vty_out (vty, "ISIS circuit is already defined for IPv6%s",
2067 VTY_NEWLINE);
2068 return CMD_WARNING;
2069 }
jardineb5d44e2003-12-23 08:09:43 +00002070 }
jardineb5d44e2003-12-23 08:09:43 +00002071
2072 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +00002073 if (!area)
2074 {
2075 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2076 return CMD_WARNING;
2077 }
jardineb5d44e2003-12-23 08:09:43 +00002078
hassof390d2c2004-09-10 20:48:21 +00002079 if (!c)
2080 {
2081 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
2082 c = isis_csm_state_change (ISIS_ENABLE, c, area);
2083 c->interface = ifp;
2084 ifp->info = c;
2085 }
jardineb5d44e2003-12-23 08:09:43 +00002086
hassof390d2c2004-09-10 20:48:21 +00002087 if (!c)
jardineb5d44e2003-12-23 08:09:43 +00002088 return CMD_WARNING;
2089
2090 c->ipv6_router = 1;
2091 area->ipv6_circuits++;
2092 circuit_update_nlpids (c);
2093
2094 vty->node = INTERFACE_NODE;
2095
2096 return CMD_SUCCESS;
2097}
2098
2099DEFUN (no_ipv6_router_isis,
2100 no_ipv6_router_isis_cmd,
2101 "no ipv6 router isis WORD",
2102 NO_STR
2103 "IPv6 interface subcommands\n"
2104 "IPv6 Router interface commands\n"
2105 "IS-IS Routing for IPv6\n"
2106 "Routing process tag\n")
2107{
2108 struct isis_circuit *c;
2109 struct interface *ifp;
2110 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002111
2112 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002113 /* UGLY - will remove l8r
2114 if (circuit == NULL) {
hassof390d2c2004-09-10 20:48:21 +00002115 return CMD_WARNING;
2116 } */
jardineb5d44e2003-12-23 08:09:43 +00002117 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002118
jardineb5d44e2003-12-23 08:09:43 +00002119 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002120 if (!area)
2121 {
2122 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2123 return CMD_WARNING;
2124 }
2125
jardineb5d44e2003-12-23 08:09:43 +00002126 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
2127 if (!c)
2128 return CMD_WARNING;
2129
2130 c->ipv6_router = 0;
2131 area->ipv6_circuits--;
2132 if (c->ip_router == 0)
2133 isis_csm_state_change (ISIS_DISABLE, c, area);
2134
2135 return CMD_SUCCESS;
2136}
2137
hassof390d2c2004-09-10 20:48:21 +00002138#if 0 /* Guess we don't really need these */
jardineb5d44e2003-12-23 08:09:43 +00002139
2140DEFUN (ipv6_address,
2141 ipv6_address_cmd,
2142 "ipv6 address X:X::X:X/M",
2143 "Interface Internet Protocol config commands\n"
2144 "Set the IP address of an interface\n"
2145 "IPv6 address (e.g. 3ffe:506::1/48)\n")
2146{
2147 struct interface *ifp;
2148 struct isis_circuit *circuit;
2149 struct prefix_ipv6 *ipv6, *ip6;
2150 struct listnode *node;
2151 int ret, found = 1;
2152
hassof390d2c2004-09-10 20:48:21 +00002153 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002154 circuit = ifp->info;
2155 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00002156 if (circuit == NULL)
2157 {
2158 return CMD_WARNING;
2159 }
jardineb5d44e2003-12-23 08:09:43 +00002160 assert (circuit);
2161#ifdef EXTREME_DEBUG
2162 zlog_info ("ipv6_address_cmd circuit %d", circuit->idx);
2163#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +00002164
hassof390d2c2004-09-10 20:48:21 +00002165 if (circuit == NULL)
2166 {
2167 zlog_warn ("ipv6_address_cmd(): no circuit");
2168 return CMD_WARNING;
2169 }
2170
2171
2172 ipv6 = prefix_ipv6_new ();
2173
2174 ret = str2prefix_ipv6 (argv[0], ipv6);
2175 if (ret <= 0)
2176 {
2177 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
2178 return CMD_WARNING;
2179 }
2180
2181 if (!circuit->ipv6_addrs)
2182 circuit->ipv6_addrs = list_new ();
2183 else
2184 {
2185 for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
2186 {
2187 ip6 = getdata (node);
2188 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
2189 found = 1;
2190 }
2191 if (found)
2192 {
2193 prefix_ipv6_free (ipv6);
2194 return CMD_SUCCESS;
2195 }
2196 }
2197
2198
jardineb5d44e2003-12-23 08:09:43 +00002199 listnode_add (circuit->ipv6_addrs, ipv6);
2200#ifdef EXTREME_DEBUG
2201 zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx);
2202#endif /* EXTREME_DEBUG */
2203
2204 return CMD_SUCCESS;
2205}
2206
2207DEFUN (no_ipv6_address,
2208 no_ipv6_address_cmd,
hassof390d2c2004-09-10 20:48:21 +00002209 "no ipv6 address X:X::X:X/M",
jardineb5d44e2003-12-23 08:09:43 +00002210 NO_STR
2211 "Interface Internet Protocol config commands\n"
2212 "Set the IP address of an interface\n"
2213 "IPv6 address (e.g. 3ffe:506::1/48)\n")
2214{
2215 struct interface *ifp;
2216 struct isis_circuit *circuit;
2217 struct prefix_ipv6 ipv6, *ip6 = NULL;
2218 struct listnode *node;
2219 int ret;
2220
hassof390d2c2004-09-10 20:48:21 +00002221 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002222 circuit = ifp->info;
2223 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00002224 if (circuit == NULL)
2225 {
2226 return CMD_WARNING;
2227 }
jardineb5d44e2003-12-23 08:09:43 +00002228 assert (circuit);
2229
hassof390d2c2004-09-10 20:48:21 +00002230 if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0)
2231 {
2232 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
2233 return CMD_WARNING;
2234 }
jardineb5d44e2003-12-23 08:09:43 +00002235 ret = str2prefix_ipv6 (argv[0], &ipv6);
hassof390d2c2004-09-10 20:48:21 +00002236 if (ret <= 0)
2237 {
2238 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
2239 return CMD_WARNING;
2240 }
2241
2242 for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
2243 {
2244 ip6 = getdata (node);
2245 if (prefix_same ((struct prefix *) ip6, (struct prefix *) &ipv6))
2246 break;
2247 }
2248
2249 if (ip6)
2250 {
2251 listnode_delete (circuit->ipv6_addrs, ip6);
2252 }
2253 else
2254 {
2255 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
2256 }
2257
jardineb5d44e2003-12-23 08:09:43 +00002258 return CMD_SUCCESS;
2259}
2260#endif /* 0 */
hassof390d2c2004-09-10 20:48:21 +00002261#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00002262
hassof390d2c2004-09-10 20:48:21 +00002263struct cmd_node interface_node = {
jardineb5d44e2003-12-23 08:09:43 +00002264 INTERFACE_NODE,
2265 "%s(config-if)# ",
2266 1,
2267};
2268
jardineb5d44e2003-12-23 08:09:43 +00002269int
2270isis_if_new_hook (struct interface *ifp)
2271{
2272/* FIXME: Discuss if the circuit should be created here
2273 ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */
2274 ifp->info = NULL;
2275 return 0;
2276}
2277
2278int
2279isis_if_delete_hook (struct interface *ifp)
2280{
2281/* FIXME: Discuss if the circuit should be created here
2282 XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/
2283 ifp->info = NULL;
2284 return 0;
2285}
2286
jardineb5d44e2003-12-23 08:09:43 +00002287void
2288isis_circuit_init ()
2289{
jardineb5d44e2003-12-23 08:09:43 +00002290 /* Initialize Zebra interface data structure */
2291 if_init ();
2292 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2293 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2294
2295 /* Install interface node */
2296 install_node (&interface_node, isis_interface_config_write);
2297 install_element (CONFIG_NODE, &interface_cmd);
2298
2299 install_default (INTERFACE_NODE);
2300 install_element (INTERFACE_NODE, &interface_desc_cmd);
2301 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2302
2303 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2304 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2305
2306 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2307 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2308
2309 install_element (INTERFACE_NODE, &isis_passwd_cmd);
2310 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2311
2312 install_element (INTERFACE_NODE, &isis_priority_cmd);
2313 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2314 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2315 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2316 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2317 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2318 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2319 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2320 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2321
2322 install_element (INTERFACE_NODE, &isis_metric_cmd);
2323 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2324 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
2325
2326 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2327 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2328 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2329 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2330 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2331 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2332 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2333 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2334 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2335
2336 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2337 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2338 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2339 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2340 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2341 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2342 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2343 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2344 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2345
2346 install_element (INTERFACE_NODE, &isis_hello_cmd);
2347 install_element (INTERFACE_NODE, &no_isis_hello_cmd);
hasso38a61c72004-01-27 13:40:14 +00002348#if 0
jardineb5d44e2003-12-23 08:09:43 +00002349 install_element (INTERFACE_NODE, &ip_address_cmd);
2350 install_element (INTERFACE_NODE, &no_ip_address_cmd);
hasso38a61c72004-01-27 13:40:14 +00002351#endif
jardineb5d44e2003-12-23 08:09:43 +00002352 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2353 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2354 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2355 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2356 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2357 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2358 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2359 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2360 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2361
2362#ifdef HAVE_IPV6
2363 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2364 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
2365#if 0
2366 install_element (INTERFACE_NODE, &ipv6_address_cmd);
2367 install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
2368#endif
2369#endif
jardineb5d44e2003-12-23 08:09:43 +00002370}