blob: eb83e98696dbaeb6a88759d905c30572bebed6a1 [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,
534 circuit,
535 2 * circuit->hello_multiplier[0] *
536 circuit->hello_interval[0]);
537 if (circuit->circuit_is_type & IS_LEVEL_2)
538 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
539 circuit,
540 2 * circuit->hello_multiplier[1] *
541 circuit->hello_interval[1]);
jardineb5d44e2003-12-23 08:09:43 +0000542 }
hassof390d2c2004-09-10 20:48:21 +0000543 else
544 {
545 /* initializing the hello send threads
546 * for a ptp IF
547 */
548 thread_add_event (master, send_p2p_hello, circuit, 0);
jardineb5d44e2003-12-23 08:09:43 +0000549
jardineb5d44e2003-12-23 08:09:43 +0000550 }
551
jardineb5d44e2003-12-23 08:09:43 +0000552 /* initializing PSNP timers */
hassof390d2c2004-09-10 20:48:21 +0000553 if (circuit->circuit_is_type & IS_LEVEL_1)
554 {
555 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
556 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
557 }
558
559 if (circuit->circuit_is_type & IS_LEVEL_2)
560 {
561 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
562 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
563 }
564
jardineb5d44e2003-12-23 08:09:43 +0000565 /* initialize the circuit streams */
566 if (circuit->rcv_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000567 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000568
569 if (circuit->snd_stream == NULL)
hassof390d2c2004-09-10 20:48:21 +0000570 circuit->snd_stream = stream_new (ISO_MTU (circuit));
jardineb5d44e2003-12-23 08:09:43 +0000571
572 /* unified init for circuits */
573 isis_sock_init (circuit);
574
575#ifdef GNU_LINUX
hassof390d2c2004-09-10 20:48:21 +0000576 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
577 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000578#else
hassof390d2c2004-09-10 20:48:21 +0000579 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
580 circuit->fd);
jardineb5d44e2003-12-23 08:09:43 +0000581#endif
582 return;
583}
584
585void
586isis_circuit_down (struct isis_circuit *circuit)
587{
hassof390d2c2004-09-10 20:48:21 +0000588 /* Cancel all active threads -- FIXME: wrong place */
hassod70f99e2004-02-11 20:26:31 +0000589 /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
hassof390d2c2004-09-10 20:48:21 +0000590 THREAD_OFF (circuit->t_read);
591 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
592 {
593 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
594 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
hassof891f442004-09-14 13:54:30 +0000595 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
596 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
hassof390d2c2004-09-10 20:48:21 +0000597 }
598 else if (circuit->circ_type == CIRCUIT_T_P2P)
599 {
600 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
601 }
jardineb5d44e2003-12-23 08:09:43 +0000602 /* close the socket */
603 close (circuit->fd);
604
605 return;
606}
607
608void
609circuit_update_nlpids (struct isis_circuit *circuit)
610{
611 circuit->nlpids.count = 0;
hassof390d2c2004-09-10 20:48:21 +0000612
613 if (circuit->ip_router)
614 {
615 circuit->nlpids.nlpids[0] = NLPID_IP;
616 circuit->nlpids.count++;
617 }
jardineb5d44e2003-12-23 08:09:43 +0000618#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000619 if (circuit->ipv6_router)
620 {
621 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
622 circuit->nlpids.count++;
623 }
jardineb5d44e2003-12-23 08:09:43 +0000624#endif /* HAVE_IPV6 */
625 return;
626}
627
628int
hassof390d2c2004-09-10 20:48:21 +0000629isis_interface_config_write (struct vty *vty)
jardineb5d44e2003-12-23 08:09:43 +0000630{
631
632 int write = 0;
633 listnode node;
634 listnode node2;
635 listnode node3;
636 struct interface *ifp;
637 struct isis_area *area;
638 struct isis_circuit *c;
639 struct prefix_ipv4 *ip;
640 int i;
641#ifdef HAVE_IPV6
642 struct prefix_ipv6 *ipv6;
643#endif /*HAVE_IPV6 */
644
645 char buf[BUFSIZ];
646
jardineb5d44e2003-12-23 08:09:43 +0000647 LIST_LOOP (iflist, ifp, node)
648 {
649 /* IF name */
hassof390d2c2004-09-10 20:48:21 +0000650 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000651 write++;
652 /* IF desc */
hassof390d2c2004-09-10 20:48:21 +0000653 if (ifp->desc)
654 {
655 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
656 write++;
657 }
jardineb5d44e2003-12-23 08:09:43 +0000658 /* ISIS Circuit */
659 LIST_LOOP (isis->area_list, area, node2)
660 {
661 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000662 if (c)
663 {
664 if (c->ip_router)
665 {
666 vty_out (vty, " ip router isis %s%s", area->area_tag,
667 VTY_NEWLINE);
668 write++;
669 }
jardineb5d44e2003-12-23 08:09:43 +0000670#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000671 if (c->ipv6_router)
672 {
673 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
674 VTY_NEWLINE);
675 write++;
676 }
jardineb5d44e2003-12-23 08:09:43 +0000677#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000678
hassof390d2c2004-09-10 20:48:21 +0000679 /* ISIS - circuit type */
680 if (c->circuit_is_type == IS_LEVEL_1)
681 {
682 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
683 write++;
684 }
685 else
686 {
687 if (c->circuit_is_type == IS_LEVEL_2)
688 {
689 vty_out (vty, " isis circuit-type level-2-only%s",
690 VTY_NEWLINE);
691 write++;
692 }
693 }
jardineb5d44e2003-12-23 08:09:43 +0000694
hassof390d2c2004-09-10 20:48:21 +0000695 /* ISIS - CSNP interval - FIXME: compare to cisco */
696 if (c->csnp_interval[0] == c->csnp_interval[1])
697 {
698 if (c->csnp_interval[0] != CSNP_INTERVAL)
699 {
700 vty_out (vty, " isis csnp-interval %d%s",
701 c->csnp_interval[0], VTY_NEWLINE);
702 write++;
703 }
704 }
705 else
706 {
707 for (i = 0; i < 2; i++)
708 {
709 if (c->csnp_interval[1] != CSNP_INTERVAL)
710 {
711 vty_out (vty, " isis csnp-interval %d level-%d%s",
712 c->csnp_interval[1], i + 1, VTY_NEWLINE);
713 write++;
714 }
715 }
716 }
jardineb5d44e2003-12-23 08:09:43 +0000717
hassof390d2c2004-09-10 20:48:21 +0000718 /* ISIS - Hello padding - Defaults to true so only display if false */
719 if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
720 {
721 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
722 write++;
723 }
jardineb5d44e2003-12-23 08:09:43 +0000724
hassof390d2c2004-09-10 20:48:21 +0000725 /* ISIS - Hello interval - FIXME: compare to cisco */
726 if (c->hello_interval[0] == c->hello_interval[1])
727 {
728 if (c->hello_interval[0] != HELLO_INTERVAL)
729 {
730 vty_out (vty, " isis hello-interval %d%s",
731 c->hello_interval[0], VTY_NEWLINE);
732 write++;
733 }
734 }
735 else
736 {
737 for (i = 0; i < 2; i++)
738 {
739 if (c->hello_interval[i] != HELLO_INTERVAL)
740 {
741 if (c->hello_interval[i] == HELLO_MINIMAL)
742 {
743 vty_out (vty,
744 " isis hello-interval minimal level-%d%s",
745 i + 1, VTY_NEWLINE);
746 }
747 else
748 {
749 vty_out (vty, " isis hello-interval %d level-%d%s",
750 c->hello_interval[i], i + 1, VTY_NEWLINE);
751 }
752 write++;
753 }
754 }
755 }
jardineb5d44e2003-12-23 08:09:43 +0000756
hassof390d2c2004-09-10 20:48:21 +0000757 /* ISIS - Hello Multiplier */
758 if (c->hello_multiplier[0] == c->hello_multiplier[1])
759 {
760 if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
761 {
762 vty_out (vty, " isis hello-multiplier %d%s",
763 c->hello_multiplier[0], VTY_NEWLINE);
764 write++;
765 }
766 }
767 else
768 {
769 for (i = 0; i < 2; i++)
770 {
771 if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
772 {
773 vty_out (vty, " isis hello-multiplier %d level-%d%s",
774 c->hello_multiplier[i], i + 1, VTY_NEWLINE);
775 write++;
776 }
777 }
778 }
779 /* ISIS - Priority */
780 if (c->circ_type == CIRCUIT_T_BROADCAST)
781 {
782 if (c->u.bc.priority[0] == c->u.bc.priority[1])
783 {
784 if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
785 {
786 vty_out (vty, " isis priority %d%s",
787 c->u.bc.priority[0], VTY_NEWLINE);
788 write++;
789 }
790 }
791 else
792 {
793 for (i = 0; i < 2; i++)
794 {
795 if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
796 {
797 vty_out (vty, " isis priority %d level-%d%s",
798 c->u.bc.priority[i], i + 1, VTY_NEWLINE);
799 write++;
800 }
801 }
802 }
803 }
804 /* ISIS - Metric */
805 if (c->metrics[0].metric_default == c->metrics[1].metric_default)
806 {
807 if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS)
808 {
809 vty_out (vty, " isis metric %d%s",
810 c->metrics[0].metric_default, VTY_NEWLINE);
811 write++;
812 }
813 }
814 else
815 {
816 for (i = 0; i < 2; i++)
817 {
818 if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS)
819 {
820 vty_out (vty, " isis metric %d level-%d%s",
821 c->metrics[i].metric_default, i + 1,
822 VTY_NEWLINE);
823 write++;
824 }
825 }
826 }
jardineb5d44e2003-12-23 08:09:43 +0000827
hassof390d2c2004-09-10 20:48:21 +0000828 }
jardineb5d44e2003-12-23 08:09:43 +0000829 }
hassof390d2c2004-09-10 20:48:21 +0000830 vty_out (vty, "!%s", VTY_NEWLINE);
jardineb5d44e2003-12-23 08:09:43 +0000831 }
hassof390d2c2004-09-10 20:48:21 +0000832
jardineb5d44e2003-12-23 08:09:43 +0000833 return write;
834}
jardineb5d44e2003-12-23 08:09:43 +0000835
836DEFUN (ip_router_isis,
837 ip_router_isis_cmd,
838 "ip router isis WORD",
839 "Interface Internet Protocol config commands\n"
840 "IP router interface commands\n"
841 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000842 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000843{
844 struct isis_circuit *c;
845 struct interface *ifp;
846 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +0000847
848 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000849 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000850
jardineb5d44e2003-12-23 08:09:43 +0000851 area = isis_area_lookup (argv[0]);
852
853 /* Prevent more than one circuit per interface */
854 if (area)
855 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +0000856 else
857 c = NULL;
858 if (c && (ifp->info != NULL))
859 {
jardineb5d44e2003-12-23 08:09:43 +0000860#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000861 if (c->ipv6_router == 0)
862 {
jardineb5d44e2003-12-23 08:09:43 +0000863#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000864 vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
865 return CMD_WARNING;
jardineb5d44e2003-12-23 08:09:43 +0000866#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000867 }
868#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000869 }
hassof390d2c2004-09-10 20:48:21 +0000870
jardineb5d44e2003-12-23 08:09:43 +0000871 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +0000872 if (!area)
873 {
874 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
875 return CMD_WARNING;
876 }
jardineb5d44e2003-12-23 08:09:43 +0000877
hassof390d2c2004-09-10 20:48:21 +0000878 if (!c)
879 {
880 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
881 c = isis_csm_state_change (ISIS_ENABLE, c, area);
882 c->interface = ifp; /* this is automatic */
883 ifp->info = c; /* hardly related to the FSM */
884 }
jardineb5d44e2003-12-23 08:09:43 +0000885
hassof390d2c2004-09-10 20:48:21 +0000886 if (!c)
jardineb5d44e2003-12-23 08:09:43 +0000887 return CMD_WARNING;
888
889 c->ip_router = 1;
890 area->ip_circuits++;
891 circuit_update_nlpids (c);
892
893 vty->node = INTERFACE_NODE;
hassof390d2c2004-09-10 20:48:21 +0000894
jardineb5d44e2003-12-23 08:09:43 +0000895 return CMD_SUCCESS;
896}
897
898DEFUN (no_ip_router_isis,
899 no_ip_router_isis_cmd,
900 "no ip router isis WORD",
901 NO_STR
902 "Interface Internet Protocol config commands\n"
903 "IP router interface commands\n"
904 "IS-IS Routing for IP\n"
hassof390d2c2004-09-10 20:48:21 +0000905 "Routing process tag\n")
jardineb5d44e2003-12-23 08:09:43 +0000906{
907 struct isis_circuit *circuit = NULL;
908 struct interface *ifp;
909 struct isis_area *area;
910 struct listnode *node;
911
hassof390d2c2004-09-10 20:48:21 +0000912 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000913 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +0000914
jardineb5d44e2003-12-23 08:09:43 +0000915 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +0000916 if (!area)
917 {
918 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
919 return CMD_WARNING;
920 }
jardineb5d44e2003-12-23 08:09:43 +0000921 LIST_LOOP (area->circuit_list, circuit, node)
922 if (circuit->interface == ifp)
923 break;
hassof390d2c2004-09-10 20:48:21 +0000924 if (!circuit)
925 {
926 vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
927 return CMD_WARNING;
928 }
jardineb5d44e2003-12-23 08:09:43 +0000929 circuit->ip_router = 0;
930 area->ip_circuits--;
931#ifdef HAVE_IPV6
932 if (circuit->ipv6_router == 0)
933#endif
934 isis_csm_state_change (ISIS_DISABLE, circuit, area);
hassof390d2c2004-09-10 20:48:21 +0000935
jardineb5d44e2003-12-23 08:09:43 +0000936 return CMD_SUCCESS;
937}
938
939DEFUN (isis_circuit_type,
940 isis_circuit_type_cmd,
941 "isis circuit-type (level-1|level-1-2|level-2-only)",
942 "IS-IS commands\n"
943 "Configure circuit type for interface\n"
944 "Level-1 only adjacencies are formed\n"
945 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000946 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000947{
948 struct isis_circuit *circuit;
949 struct interface *ifp;
950 int circuit_t;
951 int is_type;
hassof390d2c2004-09-10 20:48:21 +0000952
953 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +0000954 circuit = ifp->info;
955 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +0000956 if (circuit == NULL)
957 {
958 return CMD_WARNING;
959 }
jardineb5d44e2003-12-23 08:09:43 +0000960
hasso13c48f72004-09-10 21:19:13 +0000961 /* XXX what to do when ip_router_isis is not executed */
962 if (circuit->area == NULL)
963 return CMD_WARNING;
964
jardineb5d44e2003-12-23 08:09:43 +0000965 assert (circuit);
966
967 circuit_t = string2circuit_t (argv[0]);
968
hassof390d2c2004-09-10 20:48:21 +0000969 if (!circuit_t)
970 {
971 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
972 return CMD_SUCCESS;
973 }
974
jardineb5d44e2003-12-23 08:09:43 +0000975 is_type = circuit->area->is_type;
976 if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
hassof390d2c2004-09-10 20:48:21 +0000977 isis_event_circuit_type_change (circuit, circuit_t);
978 else
979 {
980 vty_out (vty, "invalid circuit level for area %s.%s",
981 circuit->area->area_tag, VTY_NEWLINE);
982 }
983
jardineb5d44e2003-12-23 08:09:43 +0000984 return CMD_SUCCESS;
985}
986
987DEFUN (no_isis_circuit_type,
988 no_isis_circuit_type_cmd,
989 "no isis circuit-type (level-1|level-1-2|level-2-only)",
990 NO_STR
991 "IS-IS commands\n"
992 "Configure circuit type for interface\n"
993 "Level-1 only adjacencies are formed\n"
994 "Level-1-2 adjacencies are formed\n"
hassof390d2c2004-09-10 20:48:21 +0000995 "Level-2 only adjacencies are formed\n")
jardineb5d44e2003-12-23 08:09:43 +0000996{
997 struct isis_circuit *circuit;
998 struct interface *ifp;
jardineb5d44e2003-12-23 08:09:43 +0000999
hassof390d2c2004-09-10 20:48:21 +00001000 ifp = vty->index;
1001 circuit = ifp->info;
1002 if (circuit == NULL)
1003 {
1004 return CMD_WARNING;
1005 }
1006
1007 assert (circuit);
1008
jardineb5d44e2003-12-23 08:09:43 +00001009 /*
1010 * Set the circuits level to its default value which is that of the area
1011 */
1012 isis_event_circuit_type_change (circuit, circuit->area->is_type);
hassof390d2c2004-09-10 20:48:21 +00001013
jardineb5d44e2003-12-23 08:09:43 +00001014 return CMD_SUCCESS;
1015}
1016
1017DEFUN (isis_passwd,
1018 isis_passwd_cmd,
1019 "isis password WORD",
1020 "IS-IS commands\n"
1021 "Configure the authentication password for interface\n"
1022 "Password\n")
1023{
1024 struct isis_circuit *circuit;
1025 struct interface *ifp;
1026 int len;
hassof390d2c2004-09-10 20:48:21 +00001027
1028 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001029 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001030 if (circuit == NULL)
1031 {
1032 return CMD_WARNING;
1033 }
1034
jardineb5d44e2003-12-23 08:09:43 +00001035 len = strlen (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001036 if (len > 254)
1037 {
1038 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1039 return CMD_WARNING;
1040 }
jardineb5d44e2003-12-23 08:09:43 +00001041 circuit->passwd.len = len;
1042 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
1043 strncpy (circuit->passwd.passwd, argv[0], 255);
hassof390d2c2004-09-10 20:48:21 +00001044
jardineb5d44e2003-12-23 08:09:43 +00001045 return CMD_SUCCESS;
1046}
1047
1048DEFUN (no_isis_passwd,
1049 no_isis_passwd_cmd,
1050 "no isis password",
1051 NO_STR
1052 "IS-IS commands\n"
1053 "Configure the authentication password for interface\n")
1054{
1055 struct isis_circuit *circuit;
1056 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001057
1058 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001059 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001060 if (circuit == NULL)
1061 {
1062 return CMD_WARNING;
1063 }
1064
jardineb5d44e2003-12-23 08:09:43 +00001065 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
hassof390d2c2004-09-10 20:48:21 +00001066
jardineb5d44e2003-12-23 08:09:43 +00001067 return CMD_SUCCESS;
1068}
1069
1070
1071DEFUN (isis_priority,
1072 isis_priority_cmd,
1073 "isis priority <0-127>",
1074 "IS-IS commands\n"
1075 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001076 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001077{
1078 struct isis_circuit *circuit;
1079 struct interface *ifp;
1080 int prio;
hassof390d2c2004-09-10 20:48:21 +00001081
1082 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001083 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001084 if (circuit == NULL)
1085 {
1086 return CMD_WARNING;
1087 }
jardineb5d44e2003-12-23 08:09:43 +00001088 assert (circuit);
1089
1090 prio = atoi (argv[0]);
1091
1092 circuit->u.bc.priority[0] = prio;
1093 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001094
jardineb5d44e2003-12-23 08:09:43 +00001095 return CMD_SUCCESS;
1096}
1097
1098DEFUN (no_isis_priority,
1099 no_isis_priority_cmd,
1100 "no isis priority",
1101 NO_STR
1102 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001103 "Set priority for Designated Router election\n")
jardineb5d44e2003-12-23 08:09:43 +00001104{
1105 struct isis_circuit *circuit;
1106 struct interface *ifp;
1107
hassof390d2c2004-09-10 20:48:21 +00001108 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001109 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001110 if (circuit == NULL)
1111 {
1112 return CMD_WARNING;
1113 }
jardineb5d44e2003-12-23 08:09:43 +00001114 assert (circuit);
1115
1116 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
1117 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001118
jardineb5d44e2003-12-23 08:09:43 +00001119 return CMD_SUCCESS;
1120}
1121
1122ALIAS (no_isis_priority,
1123 no_isis_priority_arg_cmd,
1124 "no isis priority <0-127>",
1125 NO_STR
1126 "IS-IS commands\n"
1127 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001128 "Priority value\n")
jardineb5d44e2003-12-23 08:09:43 +00001129
1130DEFUN (isis_priority_l1,
1131 isis_priority_l1_cmd,
hassof390d2c2004-09-10 20:48:21 +00001132 "isis priority <0-127> level-1",
jardineb5d44e2003-12-23 08:09:43 +00001133 "IS-IS commands\n"
1134 "Set priority for Designated Router election\n"
1135 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001136 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001137{
1138 struct isis_circuit *circuit;
1139 struct interface *ifp;
1140 int prio;
hassof390d2c2004-09-10 20:48:21 +00001141
1142 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001143 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001144 if (circuit == NULL)
1145 {
1146 return CMD_WARNING;
1147 }
jardineb5d44e2003-12-23 08:09:43 +00001148 assert (circuit);
1149
1150 prio = atoi (argv[0]);
1151
1152 circuit->u.bc.priority[0] = prio;
hassof390d2c2004-09-10 20:48:21 +00001153
jardineb5d44e2003-12-23 08:09:43 +00001154 return CMD_SUCCESS;
1155}
1156
1157DEFUN (no_isis_priority_l1,
1158 no_isis_priority_l1_cmd,
1159 "no isis priority level-1",
1160 NO_STR
1161 "IS-IS commands\n"
1162 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001163 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001164{
1165 struct isis_circuit *circuit;
1166 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001167
1168 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001169 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001170 if (circuit == NULL)
1171 {
1172 return CMD_WARNING;
1173 }
jardineb5d44e2003-12-23 08:09:43 +00001174 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001175
jardineb5d44e2003-12-23 08:09:43 +00001176 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001177
jardineb5d44e2003-12-23 08:09:43 +00001178 return CMD_SUCCESS;
1179}
1180
1181ALIAS (no_isis_priority_l1,
1182 no_isis_priority_l1_arg_cmd,
1183 "no isis priority <0-127> level-1",
1184 NO_STR
1185 "IS-IS commands\n"
1186 "Set priority for Designated Router election\n"
1187 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001188 "Specify priority for level-1 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001189
1190DEFUN (isis_priority_l2,
1191 isis_priority_l2_cmd,
hassof390d2c2004-09-10 20:48:21 +00001192 "isis priority <0-127> level-2",
jardineb5d44e2003-12-23 08:09:43 +00001193 "IS-IS commands\n"
1194 "Set priority for Designated Router election\n"
1195 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001196 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001197{
1198 struct isis_circuit *circuit;
1199 struct interface *ifp;
1200 int prio;
hassof390d2c2004-09-10 20:48:21 +00001201
1202 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001203 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001204 if (circuit == NULL)
1205 {
1206 return CMD_WARNING;
1207 }
jardineb5d44e2003-12-23 08:09:43 +00001208 assert (circuit);
1209
1210 prio = atoi (argv[0]);
1211
1212 circuit->u.bc.priority[1] = prio;
hassof390d2c2004-09-10 20:48:21 +00001213
jardineb5d44e2003-12-23 08:09:43 +00001214 return CMD_SUCCESS;
1215}
1216
1217DEFUN (no_isis_priority_l2,
1218 no_isis_priority_l2_cmd,
1219 "no isis priority level-2",
1220 NO_STR
1221 "IS-IS commands\n"
1222 "Set priority for Designated Router election\n"
hassof390d2c2004-09-10 20:48:21 +00001223 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001224{
1225 struct isis_circuit *circuit;
1226 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001227
1228 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001229 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001230 if (circuit == NULL)
1231 {
1232 return CMD_WARNING;
1233 }
jardineb5d44e2003-12-23 08:09:43 +00001234 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001235
jardineb5d44e2003-12-23 08:09:43 +00001236 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
hassof390d2c2004-09-10 20:48:21 +00001237
jardineb5d44e2003-12-23 08:09:43 +00001238 return CMD_SUCCESS;
1239}
1240
1241ALIAS (no_isis_priority_l2,
1242 no_isis_priority_l2_arg_cmd,
1243 "no isis priority <0-127> level-2",
1244 NO_STR
1245 "IS-IS commands\n"
1246 "Set priority for Designated Router election\n"
1247 "Priority value\n"
hassof390d2c2004-09-10 20:48:21 +00001248 "Specify priority for level-2 routing\n")
jardineb5d44e2003-12-23 08:09:43 +00001249
1250/* Metric command */
hassof390d2c2004-09-10 20:48:21 +00001251 DEFUN (isis_metric,
jardineb5d44e2003-12-23 08:09:43 +00001252 isis_metric_cmd,
1253 "isis metric <0-63>",
1254 "IS-IS commands\n"
1255 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001256 "Default metric value\n")
jardineb5d44e2003-12-23 08:09:43 +00001257{
1258 struct isis_circuit *circuit;
1259 struct interface *ifp;
1260 int met;
1261
hassof390d2c2004-09-10 20:48:21 +00001262 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001263 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001264 if (circuit == NULL)
1265 {
1266 return CMD_WARNING;
1267 }
jardineb5d44e2003-12-23 08:09:43 +00001268 assert (circuit);
1269
1270 met = atoi (argv[0]);
1271
1272 circuit->metrics[0].metric_default = met;
1273 circuit->metrics[1].metric_default = met;
1274
1275 return CMD_SUCCESS;
1276}
1277
1278DEFUN (no_isis_metric,
1279 no_isis_metric_cmd,
1280 "no isis metric",
1281 NO_STR
1282 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001283 "Set default metric for circuit\n")
jardineb5d44e2003-12-23 08:09:43 +00001284{
1285 struct isis_circuit *circuit;
1286 struct interface *ifp;
1287
hassof390d2c2004-09-10 20:48:21 +00001288 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001289 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001290 if (circuit == NULL)
1291 {
1292 return CMD_WARNING;
1293 }
jardineb5d44e2003-12-23 08:09:43 +00001294 assert (circuit);
1295
1296 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
1297 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS;
1298
1299 return CMD_SUCCESS;
1300}
1301
1302ALIAS (no_isis_metric,
1303 no_isis_metric_arg_cmd,
1304 "no isis metric <0-127>",
1305 NO_STR
1306 "IS-IS commands\n"
1307 "Set default metric for circuit\n"
hassof390d2c2004-09-10 20:48:21 +00001308 "Default metric value\n")
1309
jardineb5d44e2003-12-23 08:09:43 +00001310/* end of metrics */
hassof390d2c2004-09-10 20:48:21 +00001311 DEFUN (isis_hello_interval,
jardineb5d44e2003-12-23 08:09:43 +00001312 isis_hello_interval_cmd,
1313 "isis hello-interval (<1-65535>|minimal)",
1314 "IS-IS commands\n"
1315 "Set Hello interval\n"
1316 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001317 "Holdtime 1 seconds, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001318{
1319 struct isis_circuit *circuit;
1320 struct interface *ifp;
1321 int interval;
1322 char c;
1323
hassof390d2c2004-09-10 20:48:21 +00001324 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001325 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001326 if (circuit == NULL)
1327 {
1328 return CMD_WARNING;
1329 }
1330 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001331 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001332 if (isdigit ((int) c))
1333 {
1334 interval = atoi (argv[0]);
1335 }
1336 else
1337 interval = HELLO_MINIMAL; /* FIXME: should be calculated */
jardineb5d44e2003-12-23 08:09:43 +00001338
hassof390d2c2004-09-10 20:48:21 +00001339 circuit->hello_interval[0] = (u_int16_t) interval;
1340 circuit->hello_interval[1] = (u_int16_t) interval;
1341
jardineb5d44e2003-12-23 08:09:43 +00001342 return CMD_SUCCESS;
1343}
1344
1345DEFUN (no_isis_hello_interval,
1346 no_isis_hello_interval_cmd,
1347 "no isis hello-interval",
1348 NO_STR
1349 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001350 "Set Hello interval\n")
jardineb5d44e2003-12-23 08:09:43 +00001351{
1352 struct isis_circuit *circuit;
1353 struct interface *ifp;
1354
hassof390d2c2004-09-10 20:48:21 +00001355 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001356 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001357 if (circuit == NULL)
1358 {
1359 return CMD_WARNING;
1360 }
jardineb5d44e2003-12-23 08:09:43 +00001361 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001362
hassof390d2c2004-09-10 20:48:21 +00001363
1364 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
jardineb5d44e2003-12-23 08:09:43 +00001365 circuit->hello_interval[1] = HELLO_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001366
jardineb5d44e2003-12-23 08:09:43 +00001367 return CMD_SUCCESS;
1368}
1369
1370ALIAS (no_isis_hello_interval,
1371 no_isis_hello_interval_arg_cmd,
1372 "no isis hello-interval (<1-65535>|minimal)",
1373 NO_STR
1374 "IS-IS commands\n"
1375 "Set Hello interval\n"
1376 "Hello interval value\n"
hassof390d2c2004-09-10 20:48:21 +00001377 "Holdtime 1 second, interval depends on multiplier\n")
jardineb5d44e2003-12-23 08:09:43 +00001378
1379DEFUN (isis_hello_interval_l1,
1380 isis_hello_interval_l1_cmd,
1381 "isis hello-interval (<1-65535>|minimal) level-1",
1382 "IS-IS commands\n"
1383 "Set Hello interval\n"
1384 "Hello interval value\n"
1385 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001386 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001387{
1388 struct isis_circuit *circuit;
1389 struct interface *ifp;
1390 long interval;
1391 char c;
1392
hassof390d2c2004-09-10 20:48:21 +00001393 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001394 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001395 if (circuit == NULL)
1396 {
1397 return CMD_WARNING;
1398 }
jardineb5d44e2003-12-23 08:09:43 +00001399 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001400
jardineb5d44e2003-12-23 08:09:43 +00001401 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001402 if (isdigit ((int) c))
1403 {
1404 interval = atoi (argv[0]);
1405 }
1406 else
jardineb5d44e2003-12-23 08:09:43 +00001407 interval = HELLO_MINIMAL;
1408
hassof390d2c2004-09-10 20:48:21 +00001409 circuit->hello_interval[0] = (u_int16_t) interval;
1410
jardineb5d44e2003-12-23 08:09:43 +00001411 return CMD_SUCCESS;
1412}
1413
1414DEFUN (no_isis_hello_interval_l1,
1415 no_isis_hello_interval_l1_cmd,
1416 "no isis hello-interval level-1",
1417 NO_STR
1418 "IS-IS commands\n"
1419 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001420 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001421{
1422 struct isis_circuit *circuit;
1423 struct interface *ifp;
1424
hassof390d2c2004-09-10 20:48:21 +00001425 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001426 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001427 if (circuit == NULL)
1428 {
1429 return CMD_WARNING;
1430 }
jardineb5d44e2003-12-23 08:09:43 +00001431 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001432
hassof390d2c2004-09-10 20:48:21 +00001433
1434 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
1435
jardineb5d44e2003-12-23 08:09:43 +00001436 return CMD_SUCCESS;
1437}
1438
1439ALIAS (no_isis_hello_interval_l1,
1440 no_isis_hello_interval_l1_arg_cmd,
1441 "no isis hello-interval (<1-65535>|minimal) level-1",
1442 NO_STR
1443 "IS-IS commands\n"
1444 "Set Hello interval\n"
1445 "Hello interval value\n"
1446 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001447 "Specify hello-interval for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001448
1449DEFUN (isis_hello_interval_l2,
1450 isis_hello_interval_l2_cmd,
1451 "isis hello-interval (<1-65535>|minimal) level-2",
1452 "IS-IS commands\n"
1453 "Set Hello interval\n"
1454 "Hello interval value\n"
1455 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001456 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001457{
1458 struct isis_circuit *circuit;
1459 struct interface *ifp;
1460 long interval;
1461 char c;
1462
hassof390d2c2004-09-10 20:48:21 +00001463 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001464 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001465 if (circuit == NULL)
1466 {
1467 return CMD_WARNING;
1468 }
jardineb5d44e2003-12-23 08:09:43 +00001469 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001470
jardineb5d44e2003-12-23 08:09:43 +00001471 c = *argv[0];
hassof390d2c2004-09-10 20:48:21 +00001472 if (isdigit ((int) c))
1473 {
1474 interval = atoi (argv[0]);
1475 }
1476 else
jardineb5d44e2003-12-23 08:09:43 +00001477 interval = HELLO_MINIMAL;
1478
hassof390d2c2004-09-10 20:48:21 +00001479 circuit->hello_interval[1] = (u_int16_t) interval;
1480
jardineb5d44e2003-12-23 08:09:43 +00001481 return CMD_SUCCESS;
1482}
1483
1484DEFUN (no_isis_hello_interval_l2,
1485 no_isis_hello_interval_l2_cmd,
1486 "no isis hello-interval level-2",
1487 NO_STR
1488 "IS-IS commands\n"
1489 "Set Hello interval\n"
hassof390d2c2004-09-10 20:48:21 +00001490 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001491{
1492 struct isis_circuit *circuit;
1493 struct interface *ifp;
1494
hassof390d2c2004-09-10 20:48:21 +00001495 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001496 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001497 if (circuit == NULL)
1498 {
1499 return CMD_WARNING;
1500 }
jardineb5d44e2003-12-23 08:09:43 +00001501 assert (circuit);
jardineb5d44e2003-12-23 08:09:43 +00001502
hassof390d2c2004-09-10 20:48:21 +00001503
1504 circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
1505
jardineb5d44e2003-12-23 08:09:43 +00001506 return CMD_SUCCESS;
1507}
1508
1509ALIAS (no_isis_hello_interval_l2,
1510 no_isis_hello_interval_l2_arg_cmd,
1511 "no isis hello-interval (<1-65535>|minimal) level-2",
1512 NO_STR
1513 "IS-IS commands\n"
1514 "Set Hello interval\n"
1515 "Hello interval value\n"
1516 "Holdtime 1 second, interval depends on multiplier\n"
hassof390d2c2004-09-10 20:48:21 +00001517 "Specify hello-interval for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001518
1519DEFUN (isis_hello_multiplier,
1520 isis_hello_multiplier_cmd,
1521 "isis hello-multiplier <3-1000>",
1522 "IS-IS commands\n"
1523 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001524 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001525{
1526 struct isis_circuit *circuit;
1527 struct interface *ifp;
1528 int mult;
hassof390d2c2004-09-10 20:48:21 +00001529
1530 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001531 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001532 if (circuit == NULL)
1533 {
1534 return CMD_WARNING;
1535 }
jardineb5d44e2003-12-23 08:09:43 +00001536 assert (circuit);
1537
1538 mult = atoi (argv[0]);
1539
hassof390d2c2004-09-10 20:48:21 +00001540 circuit->hello_multiplier[0] = (u_int16_t) mult;
1541 circuit->hello_multiplier[1] = (u_int16_t) mult;
1542
jardineb5d44e2003-12-23 08:09:43 +00001543 return CMD_SUCCESS;
1544}
1545
1546DEFUN (no_isis_hello_multiplier,
1547 no_isis_hello_multiplier_cmd,
1548 "no isis hello-multiplier",
1549 NO_STR
1550 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001551 "Set multiplier for Hello holding time\n")
jardineb5d44e2003-12-23 08:09:43 +00001552{
1553 struct isis_circuit *circuit;
1554 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001555
1556 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001557 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001558 if (circuit == NULL)
1559 {
1560 return CMD_WARNING;
1561 }
jardineb5d44e2003-12-23 08:09:43 +00001562 assert (circuit);
1563
1564 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1565 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1566
1567 return CMD_SUCCESS;
1568}
1569
1570ALIAS (no_isis_hello_multiplier,
1571 no_isis_hello_multiplier_arg_cmd,
1572 "no isis hello-multiplier <3-1000>",
1573 NO_STR
1574 "IS-IS commands\n"
1575 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001576 "Hello multiplier value\n")
jardineb5d44e2003-12-23 08:09:43 +00001577
1578DEFUN (isis_hello_multiplier_l1,
1579 isis_hello_multiplier_l1_cmd,
1580 "isis hello-multiplier <3-1000> level-1",
1581 "IS-IS commands\n"
1582 "Set multiplier for Hello holding time\n"
1583 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001584 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001585{
1586 struct isis_circuit *circuit;
1587 struct interface *ifp;
1588 int mult;
hassof390d2c2004-09-10 20:48:21 +00001589
1590 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001591 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001592 if (circuit == NULL)
1593 {
1594 return CMD_WARNING;
1595 }
jardineb5d44e2003-12-23 08:09:43 +00001596 assert (circuit);
1597
1598 mult = atoi (argv[0]);
1599
hassof390d2c2004-09-10 20:48:21 +00001600 circuit->hello_multiplier[0] = (u_int16_t) mult;
1601
jardineb5d44e2003-12-23 08:09:43 +00001602 return CMD_SUCCESS;
1603}
1604
1605DEFUN (no_isis_hello_multiplier_l1,
1606 no_isis_hello_multiplier_l1_cmd,
1607 "no isis hello-multiplier level-1",
1608 NO_STR
1609 "IS-IS commands\n"
1610 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001611 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001612{
1613 struct isis_circuit *circuit;
1614 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001615
1616 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001617 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001618 if (circuit == NULL)
1619 {
1620 return CMD_WARNING;
1621 }
jardineb5d44e2003-12-23 08:09:43 +00001622 assert (circuit);
1623
1624 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1625
1626 return CMD_SUCCESS;
1627}
1628
1629ALIAS (no_isis_hello_multiplier_l1,
1630 no_isis_hello_multiplier_l1_arg_cmd,
1631 "no isis hello-multiplier <3-1000> level-1",
1632 NO_STR
1633 "IS-IS commands\n"
1634 "Set multiplier for Hello holding time\n"
1635 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001636 "Specify hello multiplier for level-1 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001637
1638DEFUN (isis_hello_multiplier_l2,
1639 isis_hello_multiplier_l2_cmd,
1640 "isis hello-multiplier <3-1000> level-2",
1641 "IS-IS commands\n"
1642 "Set multiplier for Hello holding time\n"
1643 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001644 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001645{
1646 struct isis_circuit *circuit;
1647 struct interface *ifp;
1648 int mult;
hassof390d2c2004-09-10 20:48:21 +00001649
1650 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001651 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001652 if (circuit == NULL)
1653 {
1654 return CMD_WARNING;
1655 }
jardineb5d44e2003-12-23 08:09:43 +00001656 assert (circuit);
1657
1658 mult = atoi (argv[0]);
1659
hassof390d2c2004-09-10 20:48:21 +00001660 circuit->hello_multiplier[1] = (u_int16_t) mult;
1661
jardineb5d44e2003-12-23 08:09:43 +00001662 return CMD_SUCCESS;
1663}
1664
1665DEFUN (no_isis_hello_multiplier_l2,
1666 no_isis_hello_multiplier_l2_cmd,
1667 "no isis hello-multiplier level-2",
1668 NO_STR
1669 "IS-IS commands\n"
1670 "Set multiplier for Hello holding time\n"
hassof390d2c2004-09-10 20:48:21 +00001671 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001672{
1673 struct isis_circuit *circuit;
1674 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +00001675
1676 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001677 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001678 if (circuit == NULL)
1679 {
1680 return CMD_WARNING;
1681 }
jardineb5d44e2003-12-23 08:09:43 +00001682 assert (circuit);
1683
1684 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1685
1686 return CMD_SUCCESS;
1687}
1688
1689ALIAS (no_isis_hello_multiplier_l2,
1690 no_isis_hello_multiplier_l2_arg_cmd,
1691 "no isis hello-multiplier <3-1000> level-2",
1692 NO_STR
1693 "IS-IS commands\n"
1694 "Set multiplier for Hello holding time\n"
1695 "Hello multiplier value\n"
hassof390d2c2004-09-10 20:48:21 +00001696 "Specify hello multiplier for level-2 IIHs\n")
jardineb5d44e2003-12-23 08:09:43 +00001697
1698DEFUN (isis_hello,
1699 isis_hello_cmd,
1700 "isis hello padding",
1701 "IS-IS commands\n"
1702 "Add padding to IS-IS hello packets\n"
1703 "Pad hello packets\n"
1704 "<cr>\n")
1705{
1706 struct interface *ifp;
1707 struct isis_circuit *circuit;
hassof390d2c2004-09-10 20:48:21 +00001708
1709 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001710 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001711 if (circuit == NULL)
1712 {
1713 return CMD_WARNING;
1714 }
jardineb5d44e2003-12-23 08:09:43 +00001715 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001716
jardineb5d44e2003-12-23 08:09:43 +00001717 circuit->u.bc.pad_hellos = 1;
hassof390d2c2004-09-10 20:48:21 +00001718
jardineb5d44e2003-12-23 08:09:43 +00001719 return CMD_SUCCESS;
1720}
1721
hasso54301ce2004-01-27 10:07:34 +00001722#if 0
jardineb5d44e2003-12-23 08:09:43 +00001723DEFUN (ip_address,
1724 ip_address_cmd,
1725 "ip address A.B.C.D/A",
1726 "Interface Internet Protocol config commands\n"
hassof390d2c2004-09-10 20:48:21 +00001727 "Set the IP address of an interface\n" "IP address (e.g. 10.0.0.1/8\n")
jardineb5d44e2003-12-23 08:09:43 +00001728{
1729 struct interface *ifp;
1730 struct isis_circuit *circuit;
1731 struct prefix_ipv4 *ipv4, *ip;
1732 struct listnode *node;
1733 int ret, found = 1;
1734
hassof390d2c2004-09-10 20:48:21 +00001735 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001736 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001737 if (circuit == NULL)
1738 {
1739 return CMD_WARNING;
1740 }
jardineb5d44e2003-12-23 08:09:43 +00001741
1742 assert (circuit);
1743#ifdef HAVE_IPV6
1744 zlog_info ("ip_address_cmd circuit %d", circuit->interface->ifindex);
1745#endif /* HAVE_IPV6 */
1746
1747 ipv4 = prefix_ipv4_new ();
jardineb5d44e2003-12-23 08:09:43 +00001748
hassof390d2c2004-09-10 20:48:21 +00001749 ret = str2prefix_ipv4 (argv[0], ipv4);
1750 if (ret <= 0)
1751 {
1752 zlog_warn ("ip_address_cmd(): malformed address");
1753 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
1754 return CMD_WARNING;
1755 }
1756
1757 if (!circuit->ip_addrs)
1758 circuit->ip_addrs = list_new ();
1759 else
1760 {
1761 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
1762 {
1763 ip = getdata (node);
1764 if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
1765 found = 1;
1766 }
1767 if (found)
1768 {
1769 prefix_ipv4_free (ipv4);
1770 return CMD_SUCCESS;
1771 }
1772 }
1773
1774
jardineb5d44e2003-12-23 08:09:43 +00001775 listnode_add (circuit->ip_addrs, ipv4);
hassof390d2c2004-09-10 20:48:21 +00001776#ifdef EXTREME_DEBUG
1777 zlog_info ("added IP address %s to circuit %d", argv[0],
jardineb5d44e2003-12-23 08:09:43 +00001778 circuit->interface->ifindex);
1779#endif /* EXTREME_DEBUG */
1780 return CMD_SUCCESS;
1781}
1782
1783DEFUN (no_ip_address,
1784 no_ip_address_cmd,
1785 "no ip address A.B.C.D/A",
1786 NO_STR
1787 "Interface Internet Protocol config commands\n"
1788 "Set the IP address of an interface\n"
1789 "IP address (e.g. 10.0.0.1/8\n")
1790{
1791 struct interface *ifp;
1792 struct isis_circuit *circuit;
1793 struct prefix_ipv4 ipv4, *ip = NULL;
1794 struct listnode *node;
1795 int ret;
1796
hassof390d2c2004-09-10 20:48:21 +00001797 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001798 circuit = ifp->info;
1799 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00001800 if (circuit == NULL)
1801 {
1802 return CMD_WARNING;
1803 }
jardineb5d44e2003-12-23 08:09:43 +00001804 assert (circuit);
1805
hassof390d2c2004-09-10 20:48:21 +00001806 if (!circuit->ip_addrs || circuit->ip_addrs->count == 0)
1807 {
1808 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
1809 return CMD_WARNING;
1810 }
jardineb5d44e2003-12-23 08:09:43 +00001811 ret = str2prefix_ipv4 (argv[0], &ipv4);
hassof390d2c2004-09-10 20:48:21 +00001812 if (ret <= 0)
1813 {
1814 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
1815 return CMD_WARNING;
1816 }
1817
1818 for (node = listhead (circuit->ip_addrs); node; nextnode (node))
1819 {
1820 ip = getdata (node);
1821 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
1822 break;
1823 }
1824
1825 if (ip)
1826 {
1827 listnode_delete (circuit->ip_addrs, ip);
1828 }
1829 else
1830 {
1831 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
1832 }
1833
jardineb5d44e2003-12-23 08:09:43 +00001834 return CMD_SUCCESS;
1835}
hasso54301ce2004-01-27 10:07:34 +00001836#endif
jardineb5d44e2003-12-23 08:09:43 +00001837
1838DEFUN (no_isis_hello,
1839 no_isis_hello_cmd,
1840 "no isis hello padding",
1841 NO_STR
1842 "IS-IS commands\n"
1843 "Add padding to IS-IS hello packets\n"
1844 "Pad hello packets\n"
1845 "<cr>\n")
1846{
1847 struct isis_circuit *circuit;
1848 struct interface *ifp;
1849
hassof390d2c2004-09-10 20:48:21 +00001850 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001851 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001852 if (circuit == NULL)
1853 {
1854 return CMD_WARNING;
1855 }
jardineb5d44e2003-12-23 08:09:43 +00001856 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001857
jardineb5d44e2003-12-23 08:09:43 +00001858 circuit->u.bc.pad_hellos = 0;
hassof390d2c2004-09-10 20:48:21 +00001859
jardineb5d44e2003-12-23 08:09:43 +00001860 return CMD_SUCCESS;
1861}
1862
1863DEFUN (csnp_interval,
1864 csnp_interval_cmd,
1865 "isis csnp-interval <0-65535>",
1866 "IS-IS commands\n"
1867 "Set CSNP interval in seconds\n"
1868 "CSNP interval value\n")
1869{
1870 struct isis_circuit *circuit;
1871 struct interface *ifp;
1872 unsigned long interval;
1873
hassof390d2c2004-09-10 20:48:21 +00001874 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001875 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001876 if (circuit == NULL)
1877 {
1878 return CMD_WARNING;
1879 }
jardineb5d44e2003-12-23 08:09:43 +00001880 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001881
jardineb5d44e2003-12-23 08:09:43 +00001882 interval = atol (argv[0]);
1883
hassof390d2c2004-09-10 20:48:21 +00001884 circuit->csnp_interval[0] = (u_int16_t) interval;
1885 circuit->csnp_interval[1] = (u_int16_t) interval;
1886
jardineb5d44e2003-12-23 08:09:43 +00001887 return CMD_SUCCESS;
1888}
1889
1890DEFUN (no_csnp_interval,
1891 no_csnp_interval_cmd,
1892 "no isis csnp-interval",
1893 NO_STR
1894 "IS-IS commands\n"
hassof390d2c2004-09-10 20:48:21 +00001895 "Set CSNP interval in seconds\n")
jardineb5d44e2003-12-23 08:09:43 +00001896{
1897 struct isis_circuit *circuit;
1898 struct interface *ifp;
1899
hassof390d2c2004-09-10 20:48:21 +00001900 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001901 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001902 if (circuit == NULL)
1903 {
1904 return CMD_WARNING;
1905 }
jardineb5d44e2003-12-23 08:09:43 +00001906 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001907
jardineb5d44e2003-12-23 08:09:43 +00001908 circuit->csnp_interval[0] = CSNP_INTERVAL;
1909 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001910
jardineb5d44e2003-12-23 08:09:43 +00001911 return CMD_SUCCESS;
1912}
1913
1914ALIAS (no_csnp_interval,
1915 no_csnp_interval_arg_cmd,
1916 "no isis csnp-interval <0-65535>",
1917 NO_STR
1918 "IS-IS commands\n"
1919 "Set CSNP interval in seconds\n"
1920 "CSNP interval value\n")
1921
jardineb5d44e2003-12-23 08:09:43 +00001922DEFUN (csnp_interval_l1,
1923 csnp_interval_l1_cmd,
1924 "isis csnp-interval <0-65535> level-1",
1925 "IS-IS commands\n"
1926 "Set CSNP interval in seconds\n"
1927 "CSNP interval value\n"
1928 "Specify interval for level-1 CSNPs\n")
1929{
1930 struct isis_circuit *circuit;
1931 struct interface *ifp;
1932 unsigned long interval;
1933
hassof390d2c2004-09-10 20:48:21 +00001934 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001935 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001936 if (circuit == NULL)
1937 {
1938 return CMD_WARNING;
1939 }
jardineb5d44e2003-12-23 08:09:43 +00001940 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001941
jardineb5d44e2003-12-23 08:09:43 +00001942 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00001943
1944 circuit->csnp_interval[0] = (u_int16_t) interval;
1945
jardineb5d44e2003-12-23 08:09:43 +00001946 return CMD_SUCCESS;
1947}
1948
1949DEFUN (no_csnp_interval_l1,
1950 no_csnp_interval_l1_cmd,
1951 "no isis csnp-interval level-1",
1952 NO_STR
1953 "IS-IS commands\n"
1954 "Set CSNP interval in seconds\n"
1955 "Specify interval for level-1 CSNPs\n")
1956{
1957 struct isis_circuit *circuit;
1958 struct interface *ifp;
1959
hassof390d2c2004-09-10 20:48:21 +00001960 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001961 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001962 if (circuit == NULL)
1963 {
1964 return CMD_WARNING;
1965 }
jardineb5d44e2003-12-23 08:09:43 +00001966 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00001967
jardineb5d44e2003-12-23 08:09:43 +00001968 circuit->csnp_interval[0] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00001969
jardineb5d44e2003-12-23 08:09:43 +00001970 return CMD_SUCCESS;
1971}
1972
1973ALIAS (no_csnp_interval_l1,
1974 no_csnp_interval_l1_arg_cmd,
1975 "no isis csnp-interval <0-65535> level-1",
1976 NO_STR
1977 "IS-IS commands\n"
1978 "Set CSNP interval in seconds\n"
1979 "CSNP interval value\n"
1980 "Specify interval for level-1 CSNPs\n")
1981
jardineb5d44e2003-12-23 08:09:43 +00001982DEFUN (csnp_interval_l2,
1983 csnp_interval_l2_cmd,
1984 "isis csnp-interval <0-65535> level-2",
1985 "IS-IS commands\n"
1986 "Set CSNP interval in seconds\n"
1987 "CSNP interval value\n"
1988 "Specify interval for level-2 CSNPs\n")
1989{
1990 struct isis_circuit *circuit;
1991 struct interface *ifp;
1992 unsigned long interval;
1993
hassof390d2c2004-09-10 20:48:21 +00001994 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00001995 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00001996 if (circuit == NULL)
1997 {
1998 return CMD_WARNING;
1999 }
jardineb5d44e2003-12-23 08:09:43 +00002000 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00002001
jardineb5d44e2003-12-23 08:09:43 +00002002 interval = atol (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002003
2004 circuit->csnp_interval[1] = (u_int16_t) interval;
2005
jardineb5d44e2003-12-23 08:09:43 +00002006 return CMD_SUCCESS;
2007}
2008
2009DEFUN (no_csnp_interval_l2,
2010 no_csnp_interval_l2_cmd,
2011 "no isis csnp-interval level-2",
2012 NO_STR
2013 "IS-IS commands\n"
2014 "Set CSNP interval in seconds\n"
2015 "Specify interval for level-2 CSNPs\n")
2016{
2017 struct isis_circuit *circuit;
2018 struct interface *ifp;
2019
hassof390d2c2004-09-10 20:48:21 +00002020 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002021 circuit = ifp->info;
hassof390d2c2004-09-10 20:48:21 +00002022 if (circuit == NULL)
2023 {
2024 return CMD_WARNING;
2025 }
jardineb5d44e2003-12-23 08:09:43 +00002026 assert (circuit);
hassof390d2c2004-09-10 20:48:21 +00002027
jardineb5d44e2003-12-23 08:09:43 +00002028 circuit->csnp_interval[1] = CSNP_INTERVAL;
hassof390d2c2004-09-10 20:48:21 +00002029
jardineb5d44e2003-12-23 08:09:43 +00002030 return CMD_SUCCESS;
2031}
2032
2033ALIAS (no_csnp_interval_l2,
2034 no_csnp_interval_l2_arg_cmd,
2035 "no isis csnp-interval <0-65535> level-2",
2036 NO_STR
2037 "IS-IS commands\n"
2038 "Set CSNP interval in seconds\n"
2039 "CSNP interval value\n"
2040 "Specify interval for level-2 CSNPs\n")
2041
jardineb5d44e2003-12-23 08:09:43 +00002042#ifdef HAVE_IPV6
2043DEFUN (ipv6_router_isis,
2044 ipv6_router_isis_cmd,
2045 "ipv6 router isis WORD",
2046 "IPv6 interface subcommands\n"
2047 "IPv6 Router interface commands\n"
2048 "IS-IS Routing for IPv6\n"
2049 "Routing process tag\n")
2050{
2051 struct isis_circuit *c;
2052 struct interface *ifp;
2053 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002054
2055 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002056 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002057
jardineb5d44e2003-12-23 08:09:43 +00002058 area = isis_area_lookup (argv[0]);
2059
2060 /* Prevent more than one circuit per interface */
2061 if (area)
2062 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
hassof390d2c2004-09-10 20:48:21 +00002063 else
2064 c = NULL;
2065
2066 if (c && (ifp->info != NULL))
2067 {
2068 if (c->ipv6_router == 1)
2069 {
2070 vty_out (vty, "ISIS circuit is already defined for IPv6%s",
2071 VTY_NEWLINE);
2072 return CMD_WARNING;
2073 }
jardineb5d44e2003-12-23 08:09:43 +00002074 }
jardineb5d44e2003-12-23 08:09:43 +00002075
2076 /* this is here for ciscopability */
hassof390d2c2004-09-10 20:48:21 +00002077 if (!area)
2078 {
2079 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2080 return CMD_WARNING;
2081 }
jardineb5d44e2003-12-23 08:09:43 +00002082
hassof390d2c2004-09-10 20:48:21 +00002083 if (!c)
2084 {
2085 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
2086 c = isis_csm_state_change (ISIS_ENABLE, c, area);
2087 c->interface = ifp;
2088 ifp->info = c;
2089 }
jardineb5d44e2003-12-23 08:09:43 +00002090
hassof390d2c2004-09-10 20:48:21 +00002091 if (!c)
jardineb5d44e2003-12-23 08:09:43 +00002092 return CMD_WARNING;
2093
2094 c->ipv6_router = 1;
2095 area->ipv6_circuits++;
2096 circuit_update_nlpids (c);
2097
2098 vty->node = INTERFACE_NODE;
2099
2100 return CMD_SUCCESS;
2101}
2102
2103DEFUN (no_ipv6_router_isis,
2104 no_ipv6_router_isis_cmd,
2105 "no ipv6 router isis WORD",
2106 NO_STR
2107 "IPv6 interface subcommands\n"
2108 "IPv6 Router interface commands\n"
2109 "IS-IS Routing for IPv6\n"
2110 "Routing process tag\n")
2111{
2112 struct isis_circuit *c;
2113 struct interface *ifp;
2114 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +00002115
2116 ifp = (struct interface *) vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002117 /* UGLY - will remove l8r
2118 if (circuit == NULL) {
hassof390d2c2004-09-10 20:48:21 +00002119 return CMD_WARNING;
2120 } */
jardineb5d44e2003-12-23 08:09:43 +00002121 assert (ifp);
hassof390d2c2004-09-10 20:48:21 +00002122
jardineb5d44e2003-12-23 08:09:43 +00002123 area = isis_area_lookup (argv[0]);
hassof390d2c2004-09-10 20:48:21 +00002124 if (!area)
2125 {
2126 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2127 return CMD_WARNING;
2128 }
2129
jardineb5d44e2003-12-23 08:09:43 +00002130 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
2131 if (!c)
2132 return CMD_WARNING;
2133
2134 c->ipv6_router = 0;
2135 area->ipv6_circuits--;
2136 if (c->ip_router == 0)
2137 isis_csm_state_change (ISIS_DISABLE, c, area);
2138
2139 return CMD_SUCCESS;
2140}
2141
hassof390d2c2004-09-10 20:48:21 +00002142#if 0 /* Guess we don't really need these */
jardineb5d44e2003-12-23 08:09:43 +00002143
2144DEFUN (ipv6_address,
2145 ipv6_address_cmd,
2146 "ipv6 address X:X::X:X/M",
2147 "Interface Internet Protocol config commands\n"
2148 "Set the IP address of an interface\n"
2149 "IPv6 address (e.g. 3ffe:506::1/48)\n")
2150{
2151 struct interface *ifp;
2152 struct isis_circuit *circuit;
2153 struct prefix_ipv6 *ipv6, *ip6;
2154 struct listnode *node;
2155 int ret, found = 1;
2156
hassof390d2c2004-09-10 20:48:21 +00002157 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002158 circuit = ifp->info;
2159 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00002160 if (circuit == NULL)
2161 {
2162 return CMD_WARNING;
2163 }
jardineb5d44e2003-12-23 08:09:43 +00002164 assert (circuit);
2165#ifdef EXTREME_DEBUG
2166 zlog_info ("ipv6_address_cmd circuit %d", circuit->idx);
2167#endif /* EXTREME_DEBUG */
jardineb5d44e2003-12-23 08:09:43 +00002168
hassof390d2c2004-09-10 20:48:21 +00002169 if (circuit == NULL)
2170 {
2171 zlog_warn ("ipv6_address_cmd(): no circuit");
2172 return CMD_WARNING;
2173 }
2174
2175
2176 ipv6 = prefix_ipv6_new ();
2177
2178 ret = str2prefix_ipv6 (argv[0], ipv6);
2179 if (ret <= 0)
2180 {
2181 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
2182 return CMD_WARNING;
2183 }
2184
2185 if (!circuit->ipv6_addrs)
2186 circuit->ipv6_addrs = list_new ();
2187 else
2188 {
2189 for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
2190 {
2191 ip6 = getdata (node);
2192 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
2193 found = 1;
2194 }
2195 if (found)
2196 {
2197 prefix_ipv6_free (ipv6);
2198 return CMD_SUCCESS;
2199 }
2200 }
2201
2202
jardineb5d44e2003-12-23 08:09:43 +00002203 listnode_add (circuit->ipv6_addrs, ipv6);
2204#ifdef EXTREME_DEBUG
2205 zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx);
2206#endif /* EXTREME_DEBUG */
2207
2208 return CMD_SUCCESS;
2209}
2210
2211DEFUN (no_ipv6_address,
2212 no_ipv6_address_cmd,
hassof390d2c2004-09-10 20:48:21 +00002213 "no ipv6 address X:X::X:X/M",
jardineb5d44e2003-12-23 08:09:43 +00002214 NO_STR
2215 "Interface Internet Protocol config commands\n"
2216 "Set the IP address of an interface\n"
2217 "IPv6 address (e.g. 3ffe:506::1/48)\n")
2218{
2219 struct interface *ifp;
2220 struct isis_circuit *circuit;
2221 struct prefix_ipv6 ipv6, *ip6 = NULL;
2222 struct listnode *node;
2223 int ret;
2224
hassof390d2c2004-09-10 20:48:21 +00002225 ifp = vty->index;
jardineb5d44e2003-12-23 08:09:43 +00002226 circuit = ifp->info;
2227 /* UGLY - will remove l8r */
hassof390d2c2004-09-10 20:48:21 +00002228 if (circuit == NULL)
2229 {
2230 return CMD_WARNING;
2231 }
jardineb5d44e2003-12-23 08:09:43 +00002232 assert (circuit);
2233
hassof390d2c2004-09-10 20:48:21 +00002234 if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0)
2235 {
2236 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
2237 return CMD_WARNING;
2238 }
jardineb5d44e2003-12-23 08:09:43 +00002239 ret = str2prefix_ipv6 (argv[0], &ipv6);
hassof390d2c2004-09-10 20:48:21 +00002240 if (ret <= 0)
2241 {
2242 vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
2243 return CMD_WARNING;
2244 }
2245
2246 for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
2247 {
2248 ip6 = getdata (node);
2249 if (prefix_same ((struct prefix *) ip6, (struct prefix *) &ipv6))
2250 break;
2251 }
2252
2253 if (ip6)
2254 {
2255 listnode_delete (circuit->ipv6_addrs, ip6);
2256 }
2257 else
2258 {
2259 vty_out (vty, "Invalid address %s", VTY_NEWLINE);
2260 }
2261
jardineb5d44e2003-12-23 08:09:43 +00002262 return CMD_SUCCESS;
2263}
2264#endif /* 0 */
hassof390d2c2004-09-10 20:48:21 +00002265#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +00002266
hassof390d2c2004-09-10 20:48:21 +00002267struct cmd_node interface_node = {
jardineb5d44e2003-12-23 08:09:43 +00002268 INTERFACE_NODE,
2269 "%s(config-if)# ",
2270 1,
2271};
2272
jardineb5d44e2003-12-23 08:09:43 +00002273int
2274isis_if_new_hook (struct interface *ifp)
2275{
2276/* FIXME: Discuss if the circuit should be created here
2277 ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */
2278 ifp->info = NULL;
2279 return 0;
2280}
2281
2282int
2283isis_if_delete_hook (struct interface *ifp)
2284{
2285/* FIXME: Discuss if the circuit should be created here
2286 XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/
2287 ifp->info = NULL;
2288 return 0;
2289}
2290
jardineb5d44e2003-12-23 08:09:43 +00002291void
2292isis_circuit_init ()
2293{
jardineb5d44e2003-12-23 08:09:43 +00002294 /* Initialize Zebra interface data structure */
2295 if_init ();
2296 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2297 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2298
2299 /* Install interface node */
2300 install_node (&interface_node, isis_interface_config_write);
2301 install_element (CONFIG_NODE, &interface_cmd);
2302
2303 install_default (INTERFACE_NODE);
2304 install_element (INTERFACE_NODE, &interface_desc_cmd);
2305 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2306
2307 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2308 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2309
2310 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2311 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2312
2313 install_element (INTERFACE_NODE, &isis_passwd_cmd);
2314 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2315
2316 install_element (INTERFACE_NODE, &isis_priority_cmd);
2317 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2318 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2319 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2320 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2321 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2322 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2323 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2324 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2325
2326 install_element (INTERFACE_NODE, &isis_metric_cmd);
2327 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2328 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
2329
2330 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2331 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2332 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2333 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2334 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2335 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2336 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2337 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2338 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2339
2340 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2341 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2342 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2343 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2344 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2345 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2346 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2347 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2348 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2349
2350 install_element (INTERFACE_NODE, &isis_hello_cmd);
2351 install_element (INTERFACE_NODE, &no_isis_hello_cmd);
hasso38a61c72004-01-27 13:40:14 +00002352#if 0
jardineb5d44e2003-12-23 08:09:43 +00002353 install_element (INTERFACE_NODE, &ip_address_cmd);
2354 install_element (INTERFACE_NODE, &no_ip_address_cmd);
hasso38a61c72004-01-27 13:40:14 +00002355#endif
jardineb5d44e2003-12-23 08:09:43 +00002356 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2357 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2358 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2359 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2360 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2361 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2362 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2363 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2364 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2365
2366#ifdef HAVE_IPV6
2367 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2368 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
2369#if 0
2370 install_element (INTERFACE_NODE, &ipv6_address_cmd);
2371 install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
2372#endif
2373#endif
jardineb5d44e2003-12-23 08:09:43 +00002374}