+ sayonara old_pid!
[jleu-quagga.git] / isisd / isis_circuit.c
blobaf24988e8773c9728a358e4481ae6df70f714daa
1 /*
2 * IS-IS Rout(e)ing protocol - isis_circuit.h
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
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.
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.
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.
22 #include <zebra.h>
23 #ifdef GNU_LINUX
24 #include <net/ethernet.h>
25 #else
26 #include <netinet/if_ether.h>
27 #endif
29 #ifndef ETHER_ADDR_LEN
30 #define ETHER_ADDR_LEN ETHERADDRL
31 #endif
33 #include "log.h"
34 #include "memory.h"
35 #include "if.h"
36 #include "linklist.h"
37 #include "command.h"
38 #include "thread.h"
39 #include "hash.h"
40 #include "prefix.h"
41 #include "stream.h"
43 #include "isisd/dict.h"
44 #include "isisd/include-netbsd/iso.h"
45 #include "isisd/isis_constants.h"
46 #include "isisd/isis_common.h"
47 #include "isisd/isis_circuit.h"
48 #include "isisd/isis_tlv.h"
49 #include "isisd/isis_lsp.h"
50 #include "isisd/isis_pdu.h"
51 #include "isisd/isis_network.h"
52 #include "isisd/isis_misc.h"
53 #include "isisd/isis_constants.h"
54 #include "isisd/isis_adjacency.h"
55 #include "isisd/isis_dr.h"
56 #include "isisd/isis_flags.h"
57 #include "isisd/isisd.h"
58 #include "isisd/isis_csm.h"
59 #include "isisd/isis_events.h"
61 extern struct thread_master *master;
62 extern struct isis *isis;
65 * Prototypes.
67 void isis_circuit_down(struct isis_circuit *);
68 int isis_interface_config_write(struct vty *);
69 int isis_if_new_hook(struct interface *);
70 int isis_if_delete_hook(struct interface *);
72 struct isis_circuit *
73 isis_circuit_new ()
75 struct isis_circuit *circuit;
76 int i;
78 circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
79 if (circuit)
81 /* set default metrics for circuit */
82 for (i = 0; i < 2; i++)
84 circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS;
85 circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
86 circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
87 circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
88 circuit->te_metric[i] = DEFAULT_CIRCUIT_METRICS;
91 else
93 zlog_err ("Can't malloc isis circuit");
94 return NULL;
97 return circuit;
100 void
101 isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
103 int i;
104 circuit->area = area;
106 * The level for the circuit is same as for the area, unless configured
107 * otherwise.
109 circuit->circuit_is_type = area->is_type;
111 * Default values
113 for (i = 0; i < 2; i++)
115 circuit->hello_interval[i] = HELLO_INTERVAL;
116 circuit->hello_multiplier[i] = HELLO_MULTIPLIER;
117 circuit->csnp_interval[i] = CSNP_INTERVAL;
118 circuit->psnp_interval[i] = PSNP_INTERVAL;
119 circuit->u.bc.priority[i] = DEFAULT_PRIORITY;
121 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
123 circuit->u.bc.adjdb[0] = list_new ();
124 circuit->u.bc.adjdb[1] = list_new ();
125 circuit->u.bc.pad_hellos = 1;
127 circuit->lsp_interval = LSP_INTERVAL;
130 * Add the circuit into area
132 listnode_add (area->circuit_list, circuit);
134 circuit->idx = flags_get_index (&area->flags);
135 circuit->lsp_queue = list_new ();
137 return;
140 void
141 isis_circuit_deconfigure (struct isis_circuit *circuit,
142 struct isis_area *area)
145 /* Remove circuit from area */
146 listnode_delete (area->circuit_list, circuit);
147 /* Free the index of SRM and SSN flags */
148 flags_free_index (&area->flags, circuit->idx);
150 return;
153 struct isis_circuit *
154 circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
156 struct isis_circuit *circuit = NULL;
157 struct listnode *node;
159 if (!list)
160 return NULL;
162 for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
163 if (circuit->interface == ifp)
164 return circuit;
166 return NULL;
169 struct isis_circuit *
170 circuit_scan_by_ifp (struct interface *ifp)
172 struct isis_area *area;
173 struct listnode *node;
174 struct isis_circuit *circuit;
176 if (!isis->area_list)
177 return NULL;
179 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
181 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
182 if (circuit)
183 return circuit;
186 return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
189 void
190 isis_circuit_del (struct isis_circuit *circuit)
193 if (!circuit)
194 return;
196 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
198 /* destroy adjacency databases */
199 if (circuit->u.bc.adjdb[0])
200 list_delete (circuit->u.bc.adjdb[0]);
201 if (circuit->u.bc.adjdb[1])
202 list_delete (circuit->u.bc.adjdb[1]);
203 /* destroy neighbour lists */
204 if (circuit->u.bc.lan_neighs[0])
205 list_delete (circuit->u.bc.lan_neighs[0]);
206 if (circuit->u.bc.lan_neighs[1])
207 list_delete (circuit->u.bc.lan_neighs[1]);
208 /* destroy addresses */
210 if (circuit->ip_addrs)
211 list_delete (circuit->ip_addrs);
212 #ifdef HAVE_IPV6
213 if (circuit->ipv6_link)
214 list_delete (circuit->ipv6_link);
215 if (circuit->ipv6_non_link)
216 list_delete (circuit->ipv6_non_link);
217 #endif /* HAVE_IPV6 */
219 /* and lastly the circuit itself */
220 XFREE (MTYPE_ISIS_CIRCUIT, circuit);
222 return;
225 void
226 isis_circuit_add_addr (struct isis_circuit *circuit,
227 struct connected *connected)
229 struct prefix_ipv4 *ipv4;
230 u_char buf[BUFSIZ];
231 #ifdef HAVE_IPV6
232 struct prefix_ipv6 *ipv6;
233 #endif /* HAVE_IPV6 */
235 if (!circuit->ip_addrs)
236 circuit->ip_addrs = list_new ();
237 #ifdef HAVE_IPV6
238 if (!circuit->ipv6_link)
239 circuit->ipv6_link = list_new ();
240 if (!circuit->ipv6_non_link)
241 circuit->ipv6_non_link = list_new ();
242 #endif /* HAVE_IPV6 */
244 memset (&buf, 0, BUFSIZ);
245 if (connected->address->family == AF_INET)
247 ipv4 = prefix_ipv4_new ();
248 ipv4->prefixlen = connected->address->prefixlen;
249 ipv4->prefix = connected->address->u.prefix4;
250 listnode_add (circuit->ip_addrs, ipv4);
251 if (circuit->area)
252 lsp_regenerate_schedule (circuit->area);
254 #ifdef EXTREME_DEBUG
255 prefix2str (connected->address, buf, BUFSIZ);
256 zlog_debug ("Added IP address %s to circuit %d", buf,
257 circuit->circuit_id);
258 #endif /* EXTREME_DEBUG */
260 #ifdef HAVE_IPV6
261 if (connected->address->family == AF_INET6)
263 ipv6 = prefix_ipv6_new ();
264 ipv6->prefixlen = connected->address->prefixlen;
265 ipv6->prefix = connected->address->u.prefix6;
267 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
268 listnode_add (circuit->ipv6_link, ipv6);
269 else
270 listnode_add (circuit->ipv6_non_link, ipv6);
271 if (circuit->area)
272 lsp_regenerate_schedule (circuit->area);
274 #ifdef EXTREME_DEBUG
275 prefix2str (connected->address, buf, BUFSIZ);
276 zlog_debug ("Added IPv6 address %s to circuit %d", buf,
277 circuit->circuit_id);
278 #endif /* EXTREME_DEBUG */
280 #endif /* HAVE_IPV6 */
281 return;
284 void
285 isis_circuit_del_addr (struct isis_circuit *circuit,
286 struct connected *connected)
288 struct prefix_ipv4 *ipv4, *ip = NULL;
289 struct listnode *node;
290 u_char buf[BUFSIZ];
291 #ifdef HAVE_IPV6
292 struct prefix_ipv6 *ipv6, *ip6 = NULL;
293 int found = 0;
294 #endif /* HAVE_IPV6 */
296 memset (&buf, 0, BUFSIZ);
297 if (connected->address->family == AF_INET)
299 ipv4 = prefix_ipv4_new ();
300 ipv4->prefixlen = connected->address->prefixlen;
301 ipv4->prefix = connected->address->u.prefix4;
303 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
304 if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
305 break;
307 if (ip)
309 listnode_delete (circuit->ip_addrs, ip);
310 if (circuit->area)
311 lsp_regenerate_schedule (circuit->area);
313 else
315 prefix2str (connected->address, (char *)buf, BUFSIZ);
316 zlog_warn("Nonexitant ip address %s removal attempt from circuit \
317 %d", buf, circuit->circuit_id);
320 #ifdef HAVE_IPV6
321 if (connected->address->family == AF_INET6)
323 ipv6 = prefix_ipv6_new ();
324 ipv6->prefixlen = connected->address->prefixlen;
325 ipv6->prefix = connected->address->u.prefix6;
327 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
329 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
331 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
332 break;
334 if (ip6)
336 listnode_delete (circuit->ipv6_link, ip6);
337 found = 1;
340 else
342 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
344 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
345 break;
347 if (ip6)
349 listnode_delete (circuit->ipv6_non_link, ip6);
350 found = 1;
354 if (!found)
356 prefix2str (connected->address, (char *)buf, BUFSIZ);
357 zlog_warn("Nonexitant ip address %s removal attempt from \
358 circuit %d", buf, circuit->circuit_id);
360 else
361 if (circuit->area)
362 lsp_regenerate_schedule (circuit->area);
364 #endif /* HAVE_IPV6 */
365 return;
368 void
369 isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
371 struct listnode *node, *nnode;
372 struct connected *conn;
374 circuit->interface = ifp;
375 ifp->info = circuit;
377 circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
379 /* isis_circuit_update_addrs (circuit, ifp); */
381 if (if_is_broadcast (ifp))
383 circuit->circ_type = CIRCUIT_T_BROADCAST;
385 * Get the Hardware Address
387 #ifdef HAVE_STRUCT_SOCKADDR_DL
388 #ifndef SUNOS_5
389 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
390 zlog_warn ("unsupported link layer");
391 else
392 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
393 ETH_ALEN);
394 #endif
395 #else
396 if (circuit->interface->hw_addr_len != ETH_ALEN)
398 zlog_warn ("unsupported link layer");
400 else
402 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
404 #ifdef EXTREME_DEGUG
405 zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
406 circuit->interface->ifindex, ISO_MTU (circuit),
407 snpa_print (circuit->u.bc.snpa));
409 #endif /* EXTREME_DEBUG */
410 #endif /* HAVE_STRUCT_SOCKADDR_DL */
412 else if (if_is_pointopoint (ifp))
414 circuit->circ_type = CIRCUIT_T_P2P;
416 else
418 /* It's normal in case of loopback etc. */
419 if (isis->debugs & DEBUG_EVENTS)
420 zlog_debug ("isis_circuit_if_add: unsupported media");
423 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
424 isis_circuit_add_addr (circuit, conn);
426 return;
429 void
430 isis_circuit_update_params (struct isis_circuit *circuit,
431 struct interface *ifp)
433 assert (circuit);
435 if (circuit->circuit_id != ifp->ifindex)
437 zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
438 ifp->ifindex);
439 circuit->circuit_id = ifp->ifindex % 255;
442 /* FIXME: Why is this needed? shouldn't we compare to the area's mtu */
443 /* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig)
444 The areas MTU is the minimum of mtu's of circuits in the area
445 now we can't catch the change
446 if (circuit->mtu != ifp->mtu) {
447 zlog_warn ("changing circuit mtu %d->%d", circuit->mtu,
448 ifp->mtu);
449 circuit->mtu = ifp->mtu;
453 * Get the Hardware Address
455 #ifdef HAVE_STRUCT_SOCKADDR_DL
456 #ifndef SUNOS_5
457 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
458 zlog_warn ("unsupported link layer");
459 else
460 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN);
461 #endif
462 #else
463 if (circuit->interface->hw_addr_len != ETH_ALEN)
465 zlog_warn ("unsupported link layer");
467 else
469 if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN))
471 zlog_warn ("changing circuit snpa %s->%s",
472 snpa_print (circuit->u.bc.snpa),
473 snpa_print (circuit->interface->hw_addr));
476 #endif
478 if (if_is_broadcast (ifp))
480 circuit->circ_type = CIRCUIT_T_BROADCAST;
482 else if (if_is_pointopoint (ifp))
484 circuit->circ_type = CIRCUIT_T_P2P;
486 else
488 zlog_warn ("isis_circuit_update_params: unsupported media");
491 return;
494 void
495 isis_circuit_if_del (struct isis_circuit *circuit)
497 circuit->interface->info = NULL;
498 circuit->interface = NULL;
500 return;
503 void
504 isis_circuit_up (struct isis_circuit *circuit)
507 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
509 if (circuit->area->min_bcast_mtu == 0 ||
510 ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
511 circuit->area->min_bcast_mtu = ISO_MTU (circuit);
513 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
516 /* initilizing the hello sending threads
517 * for a broadcast IF
520 /* 8.4.1 a) commence sending of IIH PDUs */
522 if (circuit->circuit_is_type & IS_LEVEL_1)
524 thread_add_event (master, send_lan_l1_hello, circuit, 0);
525 circuit->u.bc.lan_neighs[0] = list_new ();
528 if (circuit->circuit_is_type & IS_LEVEL_2)
530 thread_add_event (master, send_lan_l2_hello, circuit, 0);
531 circuit->u.bc.lan_neighs[1] = list_new ();
534 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
535 /* 8.4.1 c) FIXME: listen for ESH PDUs */
537 /* 8.4.1 d) */
538 /* dr election will commence in... */
539 if (circuit->circuit_is_type & IS_LEVEL_1)
540 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
541 circuit, 2 * circuit->hello_interval[0]);
542 if (circuit->circuit_is_type & IS_LEVEL_2)
543 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
544 circuit, 2 * circuit->hello_interval[1]);
546 else
548 /* initializing the hello send threads
549 * for a ptp IF
551 thread_add_event (master, send_p2p_hello, circuit, 0);
555 /* initializing PSNP timers */
556 if (circuit->circuit_is_type & IS_LEVEL_1)
558 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
559 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
562 if (circuit->circuit_is_type & IS_LEVEL_2)
564 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
565 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
568 /* initialize the circuit streams */
569 if (circuit->rcv_stream == NULL)
570 circuit->rcv_stream = stream_new (ISO_MTU (circuit));
572 if (circuit->snd_stream == NULL)
573 circuit->snd_stream = stream_new (ISO_MTU (circuit));
575 /* unified init for circuits */
576 isis_sock_init (circuit);
578 #ifdef GNU_LINUX
579 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
580 circuit->fd);
581 #else
582 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
583 circuit->fd);
584 #endif
585 return;
588 void
589 isis_circuit_down (struct isis_circuit *circuit)
591 /* Cancel all active threads -- FIXME: wrong place */
592 /* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
593 THREAD_OFF (circuit->t_read);
594 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
596 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
597 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
598 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
599 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
601 else if (circuit->circ_type == CIRCUIT_T_P2P)
603 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
605 /* close the socket */
606 close (circuit->fd);
608 return;
611 void
612 circuit_update_nlpids (struct isis_circuit *circuit)
614 circuit->nlpids.count = 0;
616 if (circuit->ip_router)
618 circuit->nlpids.nlpids[0] = NLPID_IP;
619 circuit->nlpids.count++;
621 #ifdef HAVE_IPV6
622 if (circuit->ipv6_router)
624 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
625 circuit->nlpids.count++;
627 #endif /* HAVE_IPV6 */
628 return;
632 isis_interface_config_write (struct vty *vty)
635 int write = 0;
636 struct listnode *node, *node2;
637 struct interface *ifp;
638 struct isis_area *area;
639 struct isis_circuit *c;
640 int i;
642 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
644 /* IF name */
645 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
646 write++;
647 /* IF desc */
648 if (ifp->desc)
650 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
651 write++;
653 /* ISIS Circuit */
654 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
656 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
657 if (c)
659 if (c->ip_router)
661 vty_out (vty, " ip router isis %s%s", area->area_tag,
662 VTY_NEWLINE);
663 write++;
665 #ifdef HAVE_IPV6
666 if (c->ipv6_router)
668 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
669 VTY_NEWLINE);
670 write++;
672 #endif /* HAVE_IPV6 */
674 /* ISIS - circuit type */
675 if (c->circuit_is_type == IS_LEVEL_1)
677 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
678 write++;
680 else
682 if (c->circuit_is_type == IS_LEVEL_2)
684 vty_out (vty, " isis circuit-type level-2-only%s",
685 VTY_NEWLINE);
686 write++;
690 /* ISIS - CSNP interval - FIXME: compare to cisco */
691 if (c->csnp_interval[0] == c->csnp_interval[1])
693 if (c->csnp_interval[0] != CSNP_INTERVAL)
695 vty_out (vty, " isis csnp-interval %d%s",
696 c->csnp_interval[0], VTY_NEWLINE);
697 write++;
700 else
702 for (i = 0; i < 2; i++)
704 if (c->csnp_interval[1] != CSNP_INTERVAL)
706 vty_out (vty, " isis csnp-interval %d level-%d%s",
707 c->csnp_interval[1], i + 1, VTY_NEWLINE);
708 write++;
713 /* ISIS - Hello padding - Defaults to true so only display if false */
714 if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
716 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
717 write++;
720 /* ISIS - Hello interval - FIXME: compare to cisco */
721 if (c->hello_interval[0] == c->hello_interval[1])
723 if (c->hello_interval[0] != HELLO_INTERVAL)
725 vty_out (vty, " isis hello-interval %d%s",
726 c->hello_interval[0], VTY_NEWLINE);
727 write++;
730 else
732 for (i = 0; i < 2; i++)
734 if (c->hello_interval[i] != HELLO_INTERVAL)
736 if (c->hello_interval[i] == HELLO_MINIMAL)
738 vty_out (vty,
739 " isis hello-interval minimal level-%d%s",
740 i + 1, VTY_NEWLINE);
742 else
744 vty_out (vty, " isis hello-interval %d level-%d%s",
745 c->hello_interval[i], i + 1, VTY_NEWLINE);
747 write++;
752 /* ISIS - Hello Multiplier */
753 if (c->hello_multiplier[0] == c->hello_multiplier[1])
755 if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
757 vty_out (vty, " isis hello-multiplier %d%s",
758 c->hello_multiplier[0], VTY_NEWLINE);
759 write++;
762 else
764 for (i = 0; i < 2; i++)
766 if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
768 vty_out (vty, " isis hello-multiplier %d level-%d%s",
769 c->hello_multiplier[i], i + 1, VTY_NEWLINE);
770 write++;
774 /* ISIS - Priority */
775 if (c->circ_type == CIRCUIT_T_BROADCAST)
777 if (c->u.bc.priority[0] == c->u.bc.priority[1])
779 if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
781 vty_out (vty, " isis priority %d%s",
782 c->u.bc.priority[0], VTY_NEWLINE);
783 write++;
786 else
788 for (i = 0; i < 2; i++)
790 if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
792 vty_out (vty, " isis priority %d level-%d%s",
793 c->u.bc.priority[i], i + 1, VTY_NEWLINE);
794 write++;
799 /* ISIS - Metric */
800 if (c->te_metric[0] == c->te_metric[1])
802 if (c->te_metric[0] != DEFAULT_CIRCUIT_METRICS)
804 vty_out (vty, " isis metric %d%s", c->te_metric[0],
805 VTY_NEWLINE);
806 write++;
809 else
811 for (i = 0; i < 2; i++)
813 if (c->te_metric[i] != DEFAULT_CIRCUIT_METRICS)
815 vty_out (vty, " isis metric %d level-%d%s",
816 c->te_metric[i], i + 1, VTY_NEWLINE);
817 write++;
824 vty_out (vty, "!%s", VTY_NEWLINE);
827 return write;
830 DEFUN (ip_router_isis,
831 ip_router_isis_cmd,
832 "ip router isis WORD",
833 "Interface Internet Protocol config commands\n"
834 "IP router interface commands\n"
835 "IS-IS Routing for IP\n"
836 "Routing process tag\n")
838 struct isis_circuit *c;
839 struct interface *ifp;
840 struct isis_area *area;
842 ifp = (struct interface *) vty->index;
843 assert (ifp);
845 area = isis_area_lookup (argv[0]);
847 /* Prevent more than one circuit per interface */
848 if (area)
849 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
850 else
851 c = NULL;
852 if (c && (ifp->info != NULL))
854 #ifdef HAVE_IPV6
855 if (c->ipv6_router == 0)
857 #endif /* HAVE_IPV6 */
858 /* FIXME: Find the way to warn only vty users. */
859 /* vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE); */
860 return CMD_WARNING;
861 #ifdef HAVE_IPV6
863 #endif /* HAVE_IPV6 */
866 /* this is here for ciscopability */
867 if (!area)
869 /* FIXME: Find the way to warn only vty users. */
870 /* vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); */
871 return CMD_WARNING;
874 if (!c)
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 */
882 if (!c)
883 return CMD_WARNING;
885 c->ip_router = 1;
886 area->ip_circuits++;
887 circuit_update_nlpids (c);
889 vty->node = INTERFACE_NODE;
891 return CMD_SUCCESS;
894 DEFUN (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"
901 "Routing process tag\n")
903 struct isis_circuit *circuit = NULL;
904 struct interface *ifp;
905 struct isis_area *area;
906 struct listnode *node;
908 ifp = (struct interface *) vty->index;
909 assert (ifp);
911 area = isis_area_lookup (argv[0]);
912 if (!area)
914 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
915 return CMD_WARNING;
917 for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
918 if (circuit->interface == ifp)
919 break;
920 if (!circuit)
922 vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
923 return CMD_WARNING;
925 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);
932 return CMD_SUCCESS;
935 DEFUN (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"
942 "Level-2 only adjacencies are formed\n")
944 struct isis_circuit *circuit;
945 struct interface *ifp;
946 int circuit_t;
947 int is_type;
949 ifp = vty->index;
950 circuit = ifp->info;
951 /* UGLY - will remove l8r */
952 if (circuit == NULL)
954 return CMD_WARNING;
957 /* XXX what to do when ip_router_isis is not executed */
958 if (circuit->area == NULL)
959 return CMD_WARNING;
961 assert (circuit);
963 circuit_t = string2circuit_t (argv[0]);
965 if (!circuit_t)
967 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
968 return CMD_SUCCESS;
971 is_type = circuit->area->is_type;
972 if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
973 isis_event_circuit_type_change (circuit, circuit_t);
974 else
976 vty_out (vty, "invalid circuit level for area %s.%s",
977 circuit->area->area_tag, VTY_NEWLINE);
980 return CMD_SUCCESS;
983 DEFUN (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"
991 "Level-2 only adjacencies are formed\n")
993 struct isis_circuit *circuit;
994 struct interface *ifp;
996 ifp = vty->index;
997 circuit = ifp->info;
998 if (circuit == NULL)
1000 return CMD_WARNING;
1003 assert (circuit);
1006 * Set the circuits level to its default value which is that of the area
1008 isis_event_circuit_type_change (circuit, circuit->area->is_type);
1010 return CMD_SUCCESS;
1013 DEFUN (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")
1020 struct isis_circuit *circuit;
1021 struct interface *ifp;
1022 int len;
1024 ifp = vty->index;
1025 circuit = ifp->info;
1026 if (circuit == NULL)
1028 return CMD_WARNING;
1031 len = strlen (argv[0]);
1032 if (len > 254)
1034 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1035 return CMD_WARNING;
1037 circuit->passwd.len = len;
1038 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
1039 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
1041 return CMD_SUCCESS;
1044 DEFUN (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")
1051 struct isis_circuit *circuit;
1052 struct interface *ifp;
1054 ifp = vty->index;
1055 circuit = ifp->info;
1056 if (circuit == NULL)
1058 return CMD_WARNING;
1061 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
1063 return CMD_SUCCESS;
1067 DEFUN (isis_priority,
1068 isis_priority_cmd,
1069 "isis priority <0-127>",
1070 "IS-IS commands\n"
1071 "Set priority for Designated Router election\n"
1072 "Priority value\n")
1074 struct isis_circuit *circuit;
1075 struct interface *ifp;
1076 int prio;
1078 ifp = vty->index;
1079 circuit = ifp->info;
1080 if (circuit == NULL)
1082 return CMD_WARNING;
1084 assert (circuit);
1086 prio = atoi (argv[0]);
1088 circuit->u.bc.priority[0] = prio;
1089 circuit->u.bc.priority[1] = prio;
1091 return CMD_SUCCESS;
1094 DEFUN (no_isis_priority,
1095 no_isis_priority_cmd,
1096 "no isis priority",
1097 NO_STR
1098 "IS-IS commands\n"
1099 "Set priority for Designated Router election\n")
1101 struct isis_circuit *circuit;
1102 struct interface *ifp;
1104 ifp = vty->index;
1105 circuit = ifp->info;
1106 if (circuit == NULL)
1108 return CMD_WARNING;
1110 assert (circuit);
1112 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
1113 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
1115 return CMD_SUCCESS;
1118 ALIAS (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"
1124 "Priority value\n")
1126 DEFUN (isis_priority_l1,
1127 isis_priority_l1_cmd,
1128 "isis priority <0-127> level-1",
1129 "IS-IS commands\n"
1130 "Set priority for Designated Router election\n"
1131 "Priority value\n"
1132 "Specify priority for level-1 routing\n")
1134 struct isis_circuit *circuit;
1135 struct interface *ifp;
1136 int prio;
1138 ifp = vty->index;
1139 circuit = ifp->info;
1140 if (circuit == NULL)
1142 return CMD_WARNING;
1144 assert (circuit);
1146 prio = atoi (argv[0]);
1148 circuit->u.bc.priority[0] = prio;
1150 return CMD_SUCCESS;
1153 DEFUN (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"
1159 "Specify priority for level-1 routing\n")
1161 struct isis_circuit *circuit;
1162 struct interface *ifp;
1164 ifp = vty->index;
1165 circuit = ifp->info;
1166 if (circuit == NULL)
1168 return CMD_WARNING;
1170 assert (circuit);
1172 circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
1174 return CMD_SUCCESS;
1177 ALIAS (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"
1184 "Specify priority for level-1 routing\n")
1186 DEFUN (isis_priority_l2,
1187 isis_priority_l2_cmd,
1188 "isis priority <0-127> level-2",
1189 "IS-IS commands\n"
1190 "Set priority for Designated Router election\n"
1191 "Priority value\n"
1192 "Specify priority for level-2 routing\n")
1194 struct isis_circuit *circuit;
1195 struct interface *ifp;
1196 int prio;
1198 ifp = vty->index;
1199 circuit = ifp->info;
1200 if (circuit == NULL)
1202 return CMD_WARNING;
1204 assert (circuit);
1206 prio = atoi (argv[0]);
1208 circuit->u.bc.priority[1] = prio;
1210 return CMD_SUCCESS;
1213 DEFUN (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"
1219 "Specify priority for level-2 routing\n")
1221 struct isis_circuit *circuit;
1222 struct interface *ifp;
1224 ifp = vty->index;
1225 circuit = ifp->info;
1226 if (circuit == NULL)
1228 return CMD_WARNING;
1230 assert (circuit);
1232 circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
1234 return CMD_SUCCESS;
1237 ALIAS (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"
1244 "Specify priority for level-2 routing\n")
1246 /* Metric command */
1247 DEFUN (isis_metric,
1248 isis_metric_cmd,
1249 "isis metric <0-16777215>",
1250 "IS-IS commands\n"
1251 "Set default metric for circuit\n"
1252 "Default metric value\n")
1254 struct isis_circuit *circuit;
1255 struct interface *ifp;
1256 int met;
1258 ifp = vty->index;
1259 circuit = ifp->info;
1260 if (circuit == NULL)
1262 return CMD_WARNING;
1264 assert (circuit);
1266 met = atoi (argv[0]);
1268 circuit->te_metric[0] = met;
1269 circuit->te_metric[1] = met;
1271 if (met > 63)
1272 met = 63;
1274 circuit->metrics[0].metric_default = met;
1275 circuit->metrics[1].metric_default = met;
1277 return CMD_SUCCESS;
1280 DEFUN (no_isis_metric,
1281 no_isis_metric_cmd,
1282 "no isis metric",
1283 NO_STR
1284 "IS-IS commands\n"
1285 "Set default metric for circuit\n")
1287 struct isis_circuit *circuit;
1288 struct interface *ifp;
1290 ifp = vty->index;
1291 circuit = ifp->info;
1292 if (circuit == NULL)
1294 return CMD_WARNING;
1296 assert (circuit);
1298 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRICS;
1299 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRICS;
1300 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
1301 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRICS;
1303 return CMD_SUCCESS;
1306 ALIAS (no_isis_metric,
1307 no_isis_metric_arg_cmd,
1308 "no isis metric <0-16777215>",
1309 NO_STR
1310 "IS-IS commands\n"
1311 "Set default metric for circuit\n"
1312 "Default metric value\n")
1314 /* end of metrics */
1315 DEFUN (isis_hello_interval,
1316 isis_hello_interval_cmd,
1317 "isis hello-interval (<1-65535>|minimal)",
1318 "IS-IS commands\n"
1319 "Set Hello interval\n"
1320 "Hello interval value\n"
1321 "Holdtime 1 seconds, interval depends on multiplier\n")
1323 struct isis_circuit *circuit;
1324 struct interface *ifp;
1325 int interval;
1326 char c;
1328 ifp = vty->index;
1329 circuit = ifp->info;
1330 if (circuit == NULL)
1332 return CMD_WARNING;
1334 assert (circuit);
1335 c = *argv[0];
1336 if (isdigit ((int) c))
1338 interval = atoi (argv[0]);
1340 else
1341 interval = HELLO_MINIMAL; /* FIXME: should be calculated */
1343 circuit->hello_interval[0] = (u_int16_t) interval;
1344 circuit->hello_interval[1] = (u_int16_t) interval;
1346 return CMD_SUCCESS;
1349 DEFUN (no_isis_hello_interval,
1350 no_isis_hello_interval_cmd,
1351 "no isis hello-interval",
1352 NO_STR
1353 "IS-IS commands\n"
1354 "Set Hello interval\n")
1356 struct isis_circuit *circuit;
1357 struct interface *ifp;
1359 ifp = vty->index;
1360 circuit = ifp->info;
1361 if (circuit == NULL)
1363 return CMD_WARNING;
1365 assert (circuit);
1368 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
1369 circuit->hello_interval[1] = HELLO_INTERVAL;
1371 return CMD_SUCCESS;
1374 ALIAS (no_isis_hello_interval,
1375 no_isis_hello_interval_arg_cmd,
1376 "no isis hello-interval (<1-65535>|minimal)",
1377 NO_STR
1378 "IS-IS commands\n"
1379 "Set Hello interval\n"
1380 "Hello interval value\n"
1381 "Holdtime 1 second, interval depends on multiplier\n")
1383 DEFUN (isis_hello_interval_l1,
1384 isis_hello_interval_l1_cmd,
1385 "isis hello-interval (<1-65535>|minimal) level-1",
1386 "IS-IS commands\n"
1387 "Set Hello interval\n"
1388 "Hello interval value\n"
1389 "Holdtime 1 second, interval depends on multiplier\n"
1390 "Specify hello-interval for level-1 IIHs\n")
1392 struct isis_circuit *circuit;
1393 struct interface *ifp;
1394 long interval;
1395 char c;
1397 ifp = vty->index;
1398 circuit = ifp->info;
1399 if (circuit == NULL)
1401 return CMD_WARNING;
1403 assert (circuit);
1405 c = *argv[0];
1406 if (isdigit ((int) c))
1408 interval = atoi (argv[0]);
1410 else
1411 interval = HELLO_MINIMAL;
1413 circuit->hello_interval[0] = (u_int16_t) interval;
1415 return CMD_SUCCESS;
1418 DEFUN (no_isis_hello_interval_l1,
1419 no_isis_hello_interval_l1_cmd,
1420 "no isis hello-interval level-1",
1421 NO_STR
1422 "IS-IS commands\n"
1423 "Set Hello interval\n"
1424 "Specify hello-interval for level-1 IIHs\n")
1426 struct isis_circuit *circuit;
1427 struct interface *ifp;
1429 ifp = vty->index;
1430 circuit = ifp->info;
1431 if (circuit == NULL)
1433 return CMD_WARNING;
1435 assert (circuit);
1438 circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
1440 return CMD_SUCCESS;
1443 ALIAS (no_isis_hello_interval_l1,
1444 no_isis_hello_interval_l1_arg_cmd,
1445 "no isis hello-interval (<1-65535>|minimal) level-1",
1446 NO_STR
1447 "IS-IS commands\n"
1448 "Set Hello interval\n"
1449 "Hello interval value\n"
1450 "Holdtime 1 second, interval depends on multiplier\n"
1451 "Specify hello-interval for level-1 IIHs\n")
1453 DEFUN (isis_hello_interval_l2,
1454 isis_hello_interval_l2_cmd,
1455 "isis hello-interval (<1-65535>|minimal) level-2",
1456 "IS-IS commands\n"
1457 "Set Hello interval\n"
1458 "Hello interval value\n"
1459 "Holdtime 1 second, interval depends on multiplier\n"
1460 "Specify hello-interval for level-2 IIHs\n")
1462 struct isis_circuit *circuit;
1463 struct interface *ifp;
1464 long interval;
1465 char c;
1467 ifp = vty->index;
1468 circuit = ifp->info;
1469 if (circuit == NULL)
1471 return CMD_WARNING;
1473 assert (circuit);
1475 c = *argv[0];
1476 if (isdigit ((int) c))
1478 interval = atoi (argv[0]);
1480 else
1481 interval = HELLO_MINIMAL;
1483 circuit->hello_interval[1] = (u_int16_t) interval;
1485 return CMD_SUCCESS;
1488 DEFUN (no_isis_hello_interval_l2,
1489 no_isis_hello_interval_l2_cmd,
1490 "no isis hello-interval level-2",
1491 NO_STR
1492 "IS-IS commands\n"
1493 "Set Hello interval\n"
1494 "Specify hello-interval for level-2 IIHs\n")
1496 struct isis_circuit *circuit;
1497 struct interface *ifp;
1499 ifp = vty->index;
1500 circuit = ifp->info;
1501 if (circuit == NULL)
1503 return CMD_WARNING;
1505 assert (circuit);
1508 circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
1510 return CMD_SUCCESS;
1513 ALIAS (no_isis_hello_interval_l2,
1514 no_isis_hello_interval_l2_arg_cmd,
1515 "no isis hello-interval (<1-65535>|minimal) level-2",
1516 NO_STR
1517 "IS-IS commands\n"
1518 "Set Hello interval\n"
1519 "Hello interval value\n"
1520 "Holdtime 1 second, interval depends on multiplier\n"
1521 "Specify hello-interval for level-2 IIHs\n")
1523 DEFUN (isis_hello_multiplier,
1524 isis_hello_multiplier_cmd,
1525 "isis hello-multiplier <3-1000>",
1526 "IS-IS commands\n"
1527 "Set multiplier for Hello holding time\n"
1528 "Hello multiplier value\n")
1530 struct isis_circuit *circuit;
1531 struct interface *ifp;
1532 int mult;
1534 ifp = vty->index;
1535 circuit = ifp->info;
1536 if (circuit == NULL)
1538 return CMD_WARNING;
1540 assert (circuit);
1542 mult = atoi (argv[0]);
1544 circuit->hello_multiplier[0] = (u_int16_t) mult;
1545 circuit->hello_multiplier[1] = (u_int16_t) mult;
1547 return CMD_SUCCESS;
1550 DEFUN (no_isis_hello_multiplier,
1551 no_isis_hello_multiplier_cmd,
1552 "no isis hello-multiplier",
1553 NO_STR
1554 "IS-IS commands\n"
1555 "Set multiplier for Hello holding time\n")
1557 struct isis_circuit *circuit;
1558 struct interface *ifp;
1560 ifp = vty->index;
1561 circuit = ifp->info;
1562 if (circuit == NULL)
1564 return CMD_WARNING;
1566 assert (circuit);
1568 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1569 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1571 return CMD_SUCCESS;
1574 ALIAS (no_isis_hello_multiplier,
1575 no_isis_hello_multiplier_arg_cmd,
1576 "no isis hello-multiplier <3-1000>",
1577 NO_STR
1578 "IS-IS commands\n"
1579 "Set multiplier for Hello holding time\n"
1580 "Hello multiplier value\n")
1582 DEFUN (isis_hello_multiplier_l1,
1583 isis_hello_multiplier_l1_cmd,
1584 "isis hello-multiplier <3-1000> level-1",
1585 "IS-IS commands\n"
1586 "Set multiplier for Hello holding time\n"
1587 "Hello multiplier value\n"
1588 "Specify hello multiplier for level-1 IIHs\n")
1590 struct isis_circuit *circuit;
1591 struct interface *ifp;
1592 int mult;
1594 ifp = vty->index;
1595 circuit = ifp->info;
1596 if (circuit == NULL)
1598 return CMD_WARNING;
1600 assert (circuit);
1602 mult = atoi (argv[0]);
1604 circuit->hello_multiplier[0] = (u_int16_t) mult;
1606 return CMD_SUCCESS;
1609 DEFUN (no_isis_hello_multiplier_l1,
1610 no_isis_hello_multiplier_l1_cmd,
1611 "no isis hello-multiplier level-1",
1612 NO_STR
1613 "IS-IS commands\n"
1614 "Set multiplier for Hello holding time\n"
1615 "Specify hello multiplier for level-1 IIHs\n")
1617 struct isis_circuit *circuit;
1618 struct interface *ifp;
1620 ifp = vty->index;
1621 circuit = ifp->info;
1622 if (circuit == NULL)
1624 return CMD_WARNING;
1626 assert (circuit);
1628 circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
1630 return CMD_SUCCESS;
1633 ALIAS (no_isis_hello_multiplier_l1,
1634 no_isis_hello_multiplier_l1_arg_cmd,
1635 "no isis hello-multiplier <3-1000> level-1",
1636 NO_STR
1637 "IS-IS commands\n"
1638 "Set multiplier for Hello holding time\n"
1639 "Hello multiplier value\n"
1640 "Specify hello multiplier for level-1 IIHs\n")
1642 DEFUN (isis_hello_multiplier_l2,
1643 isis_hello_multiplier_l2_cmd,
1644 "isis hello-multiplier <3-1000> level-2",
1645 "IS-IS commands\n"
1646 "Set multiplier for Hello holding time\n"
1647 "Hello multiplier value\n"
1648 "Specify hello multiplier for level-2 IIHs\n")
1650 struct isis_circuit *circuit;
1651 struct interface *ifp;
1652 int mult;
1654 ifp = vty->index;
1655 circuit = ifp->info;
1656 if (circuit == NULL)
1658 return CMD_WARNING;
1660 assert (circuit);
1662 mult = atoi (argv[0]);
1664 circuit->hello_multiplier[1] = (u_int16_t) mult;
1666 return CMD_SUCCESS;
1669 DEFUN (no_isis_hello_multiplier_l2,
1670 no_isis_hello_multiplier_l2_cmd,
1671 "no isis hello-multiplier level-2",
1672 NO_STR
1673 "IS-IS commands\n"
1674 "Set multiplier for Hello holding time\n"
1675 "Specify hello multiplier for level-2 IIHs\n")
1677 struct isis_circuit *circuit;
1678 struct interface *ifp;
1680 ifp = vty->index;
1681 circuit = ifp->info;
1682 if (circuit == NULL)
1684 return CMD_WARNING;
1686 assert (circuit);
1688 circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
1690 return CMD_SUCCESS;
1693 ALIAS (no_isis_hello_multiplier_l2,
1694 no_isis_hello_multiplier_l2_arg_cmd,
1695 "no isis hello-multiplier <3-1000> level-2",
1696 NO_STR
1697 "IS-IS commands\n"
1698 "Set multiplier for Hello holding time\n"
1699 "Hello multiplier value\n"
1700 "Specify hello multiplier for level-2 IIHs\n")
1702 DEFUN (isis_hello,
1703 isis_hello_cmd,
1704 "isis hello padding",
1705 "IS-IS commands\n"
1706 "Add padding to IS-IS hello packets\n"
1707 "Pad hello packets\n"
1708 "<cr>\n")
1710 struct interface *ifp;
1711 struct isis_circuit *circuit;
1713 ifp = vty->index;
1714 circuit = ifp->info;
1715 if (circuit == NULL)
1717 return CMD_WARNING;
1719 assert (circuit);
1721 circuit->u.bc.pad_hellos = 1;
1723 return CMD_SUCCESS;
1726 DEFUN (no_isis_hello,
1727 no_isis_hello_cmd,
1728 "no isis hello padding",
1729 NO_STR
1730 "IS-IS commands\n"
1731 "Add padding to IS-IS hello packets\n"
1732 "Pad hello packets\n"
1733 "<cr>\n")
1735 struct isis_circuit *circuit;
1736 struct interface *ifp;
1738 ifp = vty->index;
1739 circuit = ifp->info;
1740 if (circuit == NULL)
1742 return CMD_WARNING;
1744 assert (circuit);
1746 circuit->u.bc.pad_hellos = 0;
1748 return CMD_SUCCESS;
1751 DEFUN (csnp_interval,
1752 csnp_interval_cmd,
1753 "isis csnp-interval <0-65535>",
1754 "IS-IS commands\n"
1755 "Set CSNP interval in seconds\n"
1756 "CSNP interval value\n")
1758 struct isis_circuit *circuit;
1759 struct interface *ifp;
1760 unsigned long interval;
1762 ifp = vty->index;
1763 circuit = ifp->info;
1764 if (circuit == NULL)
1766 return CMD_WARNING;
1768 assert (circuit);
1770 interval = atol (argv[0]);
1772 circuit->csnp_interval[0] = (u_int16_t) interval;
1773 circuit->csnp_interval[1] = (u_int16_t) interval;
1775 return CMD_SUCCESS;
1778 DEFUN (no_csnp_interval,
1779 no_csnp_interval_cmd,
1780 "no isis csnp-interval",
1781 NO_STR
1782 "IS-IS commands\n"
1783 "Set CSNP interval in seconds\n")
1785 struct isis_circuit *circuit;
1786 struct interface *ifp;
1788 ifp = vty->index;
1789 circuit = ifp->info;
1790 if (circuit == NULL)
1792 return CMD_WARNING;
1794 assert (circuit);
1796 circuit->csnp_interval[0] = CSNP_INTERVAL;
1797 circuit->csnp_interval[1] = CSNP_INTERVAL;
1799 return CMD_SUCCESS;
1802 ALIAS (no_csnp_interval,
1803 no_csnp_interval_arg_cmd,
1804 "no isis csnp-interval <0-65535>",
1805 NO_STR
1806 "IS-IS commands\n"
1807 "Set CSNP interval in seconds\n"
1808 "CSNP interval value\n")
1810 DEFUN (csnp_interval_l1,
1811 csnp_interval_l1_cmd,
1812 "isis csnp-interval <0-65535> level-1",
1813 "IS-IS commands\n"
1814 "Set CSNP interval in seconds\n"
1815 "CSNP interval value\n"
1816 "Specify interval for level-1 CSNPs\n")
1818 struct isis_circuit *circuit;
1819 struct interface *ifp;
1820 unsigned long interval;
1822 ifp = vty->index;
1823 circuit = ifp->info;
1824 if (circuit == NULL)
1826 return CMD_WARNING;
1828 assert (circuit);
1830 interval = atol (argv[0]);
1832 circuit->csnp_interval[0] = (u_int16_t) interval;
1834 return CMD_SUCCESS;
1837 DEFUN (no_csnp_interval_l1,
1838 no_csnp_interval_l1_cmd,
1839 "no isis csnp-interval level-1",
1840 NO_STR
1841 "IS-IS commands\n"
1842 "Set CSNP interval in seconds\n"
1843 "Specify interval for level-1 CSNPs\n")
1845 struct isis_circuit *circuit;
1846 struct interface *ifp;
1848 ifp = vty->index;
1849 circuit = ifp->info;
1850 if (circuit == NULL)
1852 return CMD_WARNING;
1854 assert (circuit);
1856 circuit->csnp_interval[0] = CSNP_INTERVAL;
1858 return CMD_SUCCESS;
1861 ALIAS (no_csnp_interval_l1,
1862 no_csnp_interval_l1_arg_cmd,
1863 "no isis csnp-interval <0-65535> level-1",
1864 NO_STR
1865 "IS-IS commands\n"
1866 "Set CSNP interval in seconds\n"
1867 "CSNP interval value\n"
1868 "Specify interval for level-1 CSNPs\n")
1870 DEFUN (csnp_interval_l2,
1871 csnp_interval_l2_cmd,
1872 "isis csnp-interval <0-65535> level-2",
1873 "IS-IS commands\n"
1874 "Set CSNP interval in seconds\n"
1875 "CSNP interval value\n"
1876 "Specify interval for level-2 CSNPs\n")
1878 struct isis_circuit *circuit;
1879 struct interface *ifp;
1880 unsigned long interval;
1882 ifp = vty->index;
1883 circuit = ifp->info;
1884 if (circuit == NULL)
1886 return CMD_WARNING;
1888 assert (circuit);
1890 interval = atol (argv[0]);
1892 circuit->csnp_interval[1] = (u_int16_t) interval;
1894 return CMD_SUCCESS;
1897 DEFUN (no_csnp_interval_l2,
1898 no_csnp_interval_l2_cmd,
1899 "no isis csnp-interval level-2",
1900 NO_STR
1901 "IS-IS commands\n"
1902 "Set CSNP interval in seconds\n"
1903 "Specify interval for level-2 CSNPs\n")
1905 struct isis_circuit *circuit;
1906 struct interface *ifp;
1908 ifp = vty->index;
1909 circuit = ifp->info;
1910 if (circuit == NULL)
1912 return CMD_WARNING;
1914 assert (circuit);
1916 circuit->csnp_interval[1] = CSNP_INTERVAL;
1918 return CMD_SUCCESS;
1921 ALIAS (no_csnp_interval_l2,
1922 no_csnp_interval_l2_arg_cmd,
1923 "no isis csnp-interval <0-65535> level-2",
1924 NO_STR
1925 "IS-IS commands\n"
1926 "Set CSNP interval in seconds\n"
1927 "CSNP interval value\n"
1928 "Specify interval for level-2 CSNPs\n")
1930 #ifdef HAVE_IPV6
1931 DEFUN (ipv6_router_isis,
1932 ipv6_router_isis_cmd,
1933 "ipv6 router isis WORD",
1934 "IPv6 interface subcommands\n"
1935 "IPv6 Router interface commands\n"
1936 "IS-IS Routing for IPv6\n"
1937 "Routing process tag\n")
1939 struct isis_circuit *c;
1940 struct interface *ifp;
1941 struct isis_area *area;
1943 ifp = (struct interface *) vty->index;
1944 assert (ifp);
1946 area = isis_area_lookup (argv[0]);
1948 /* Prevent more than one circuit per interface */
1949 if (area)
1950 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
1951 else
1952 c = NULL;
1954 if (c && (ifp->info != NULL))
1956 if (c->ipv6_router == 1)
1958 vty_out (vty, "ISIS circuit is already defined for IPv6%s",
1959 VTY_NEWLINE);
1960 return CMD_WARNING;
1964 /* this is here for ciscopability */
1965 if (!area)
1967 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1968 return CMD_WARNING;
1971 if (!c)
1973 c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
1974 c = isis_csm_state_change (ISIS_ENABLE, c, area);
1975 c->interface = ifp;
1976 ifp->info = c;
1979 if (!c)
1980 return CMD_WARNING;
1982 c->ipv6_router = 1;
1983 area->ipv6_circuits++;
1984 circuit_update_nlpids (c);
1986 vty->node = INTERFACE_NODE;
1988 return CMD_SUCCESS;
1991 DEFUN (no_ipv6_router_isis,
1992 no_ipv6_router_isis_cmd,
1993 "no ipv6 router isis WORD",
1994 NO_STR
1995 "IPv6 interface subcommands\n"
1996 "IPv6 Router interface commands\n"
1997 "IS-IS Routing for IPv6\n"
1998 "Routing process tag\n")
2000 struct isis_circuit *c;
2001 struct interface *ifp;
2002 struct isis_area *area;
2004 ifp = (struct interface *) vty->index;
2005 /* UGLY - will remove l8r
2006 if (circuit == NULL) {
2007 return CMD_WARNING;
2008 } */
2009 assert (ifp);
2011 area = isis_area_lookup (argv[0]);
2012 if (!area)
2014 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
2015 return CMD_WARNING;
2018 c = circuit_lookup_by_ifp (ifp, area->circuit_list);
2019 if (!c)
2020 return CMD_WARNING;
2022 c->ipv6_router = 0;
2023 area->ipv6_circuits--;
2024 if (c->ip_router == 0)
2025 isis_csm_state_change (ISIS_DISABLE, c, area);
2027 return CMD_SUCCESS;
2029 #endif /* HAVE_IPV6 */
2031 struct cmd_node interface_node = {
2032 INTERFACE_NODE,
2033 "%s(config-if)# ",
2038 isis_if_new_hook (struct interface *ifp)
2040 /* FIXME: Discuss if the circuit should be created here
2041 ifp->info = XMALLOC (MTYPE_ISIS_IF_INFO, sizeof (struct isis_if_info)); */
2042 ifp->info = NULL;
2043 return 0;
2047 isis_if_delete_hook (struct interface *ifp)
2049 /* FIXME: Discuss if the circuit should be created here
2050 XFREE (MTYPE_ISIS_IF_INFO, ifp->info);*/
2051 ifp->info = NULL;
2052 return 0;
2055 void
2056 isis_circuit_init ()
2058 /* Initialize Zebra interface data structure */
2059 if_init ();
2060 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2061 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2063 /* Install interface node */
2064 install_node (&interface_node, isis_interface_config_write);
2065 install_element (CONFIG_NODE, &interface_cmd);
2067 install_default (INTERFACE_NODE);
2068 install_element (INTERFACE_NODE, &interface_desc_cmd);
2069 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2071 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2072 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2074 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2075 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2077 install_element (INTERFACE_NODE, &isis_passwd_cmd);
2078 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2080 install_element (INTERFACE_NODE, &isis_priority_cmd);
2081 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2082 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2083 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2084 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2085 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2086 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2087 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2088 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2090 install_element (INTERFACE_NODE, &isis_metric_cmd);
2091 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2092 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
2094 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2095 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2096 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2097 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2098 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2099 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2100 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2101 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2102 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2104 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2105 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2106 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2107 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2108 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2109 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2110 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2111 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2112 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2114 install_element (INTERFACE_NODE, &isis_hello_cmd);
2115 install_element (INTERFACE_NODE, &no_isis_hello_cmd);
2116 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2117 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2118 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2119 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2120 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2121 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2122 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2123 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2124 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2126 #ifdef HAVE_IPV6
2127 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2128 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
2129 #endif