]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_circuit.c
Merge remote-tracking branch 'origin/cmaster' into cmaster-next
[mirror_frr.git] / isisd / isis_circuit.c
1 /*
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 <zebra.h>
23 #ifdef GNU_LINUX
24 #include <net/ethernet.h>
25 #else
26 #include <netinet/if_ether.h>
27 #endif
28
29 #ifndef ETHER_ADDR_LEN
30 #define ETHER_ADDR_LEN ETHERADDRL
31 #endif
32
33 #include "log.h"
34 #include "memory.h"
35 #include "vrf.h"
36 #include "if.h"
37 #include "linklist.h"
38 #include "command.h"
39 #include "thread.h"
40 #include "hash.h"
41 #include "prefix.h"
42 #include "stream.h"
43
44 #include "isisd/dict.h"
45 #include "isisd/include-netbsd/iso.h"
46 #include "isisd/isis_constants.h"
47 #include "isisd/isis_common.h"
48 #include "isisd/isis_flags.h"
49 #include "isisd/isis_circuit.h"
50 #include "isisd/isis_tlv.h"
51 #include "isisd/isis_lsp.h"
52 #include "isisd/isis_pdu.h"
53 #include "isisd/isis_network.h"
54 #include "isisd/isis_misc.h"
55 #include "isisd/isis_constants.h"
56 #include "isisd/isis_adjacency.h"
57 #include "isisd/isis_dr.h"
58 #include "isisd/isisd.h"
59 #include "isisd/isis_csm.h"
60 #include "isisd/isis_events.h"
61
62 /*
63 * Prototypes.
64 */
65 int isis_interface_config_write(struct vty *);
66 int isis_if_new_hook(struct interface *);
67 int isis_if_delete_hook(struct interface *);
68
69 struct isis_circuit *
70 isis_circuit_new ()
71 {
72 struct isis_circuit *circuit;
73 int i;
74
75 circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
76 if (circuit == NULL)
77 {
78 zlog_err ("Can't malloc isis circuit");
79 return NULL;
80 }
81
82 /*
83 * Default values
84 */
85 circuit->is_type = IS_LEVEL_1_AND_2;
86 circuit->flags = 0;
87 circuit->pad_hellos = 1;
88 for (i = 0; i < 2; i++)
89 {
90 circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL;
91 circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER;
92 circuit->csnp_interval[i] = DEFAULT_CSNP_INTERVAL;
93 circuit->psnp_interval[i] = DEFAULT_PSNP_INTERVAL;
94 circuit->priority[i] = DEFAULT_PRIORITY;
95 circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRIC;
96 circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
97 circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
98 circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
99 circuit->te_metric[i] = DEFAULT_CIRCUIT_METRIC;
100 }
101
102 return circuit;
103 }
104
105 void
106 isis_circuit_del (struct isis_circuit *circuit)
107 {
108 if (!circuit)
109 return;
110
111 isis_circuit_if_unbind (circuit, circuit->interface);
112
113 /* and lastly the circuit itself */
114 XFREE (MTYPE_ISIS_CIRCUIT, circuit);
115
116 return;
117 }
118
119 void
120 isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
121 {
122 assert (area);
123 circuit->area = area;
124
125 /*
126 * Whenever the is-type of an area is changed, the is-type of each circuit
127 * in that area is updated to a non-empty subset of the area is-type.
128 * Inversely, when configuring a new circuit, this property should be
129 * ensured as well.
130 */
131 if (area->is_type != IS_LEVEL_1_AND_2)
132 circuit->is_type = area->is_type;
133
134 /*
135 * Add the circuit into area
136 */
137 listnode_add (area->circuit_list, circuit);
138
139 circuit->idx = flags_get_index (&area->flags);
140
141 return;
142 }
143
144 void
145 isis_circuit_deconfigure (struct isis_circuit *circuit, struct isis_area *area)
146 {
147 /* Free the index of SRM and SSN flags */
148 flags_free_index (&area->flags, circuit->idx);
149 circuit->idx = 0;
150 /* Remove circuit from area */
151 assert (circuit->area == area);
152 listnode_delete (area->circuit_list, circuit);
153 circuit->area = NULL;
154
155 return;
156 }
157
158 struct isis_circuit *
159 circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
160 {
161 struct isis_circuit *circuit = NULL;
162 struct listnode *node;
163
164 if (!list)
165 return NULL;
166
167 for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
168 if (circuit->interface == ifp)
169 {
170 assert (ifp->info == circuit);
171 return circuit;
172 }
173
174 return NULL;
175 }
176
177 struct isis_circuit *
178 circuit_scan_by_ifp (struct interface *ifp)
179 {
180 struct isis_area *area;
181 struct listnode *node;
182 struct isis_circuit *circuit;
183
184 if (ifp->info)
185 return (struct isis_circuit *)ifp->info;
186
187 if (isis->area_list)
188 {
189 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
190 {
191 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
192 if (circuit)
193 return circuit;
194 }
195 }
196 return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
197 }
198
199 static struct isis_circuit *
200 isis_circuit_lookup (struct vty *vty)
201 {
202 struct interface *ifp;
203 struct isis_circuit *circuit;
204
205 ifp = (struct interface *) vty->index;
206 if (!ifp)
207 {
208 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
209 return NULL;
210 }
211
212 circuit = circuit_scan_by_ifp (ifp);
213 if (!circuit)
214 {
215 vty_out (vty, "ISIS is not enabled on circuit %s%s",
216 ifp->name, VTY_NEWLINE);
217 return NULL;
218 }
219
220 return circuit;
221 }
222
223 void
224 isis_circuit_add_addr (struct isis_circuit *circuit,
225 struct connected *connected)
226 {
227 struct listnode *node;
228 struct prefix_ipv4 *ipv4;
229 #if defined(EXTREME_DEBUG)
230 char buf[PREFIX2STR_BUFFER];
231 #endif
232 struct prefix_ipv6 *ipv6;
233
234 if (connected->address->family == AF_INET)
235 {
236 u_int32_t addr = connected->address->u.prefix4.s_addr;
237 addr = ntohl (addr);
238 if (IPV4_NET0(addr) ||
239 IPV4_NET127(addr) ||
240 IN_CLASSD(addr) ||
241 IPV4_LINKLOCAL(addr))
242 return;
243
244 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ipv4))
245 if (prefix_same ((struct prefix *) ipv4, connected->address))
246 return;
247
248 ipv4 = prefix_ipv4_new ();
249 ipv4->prefixlen = connected->address->prefixlen;
250 ipv4->prefix = connected->address->u.prefix4;
251 listnode_add (circuit->ip_addrs, ipv4);
252 if (circuit->area)
253 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
254
255 #ifdef EXTREME_DEBUG
256 prefix2str (connected->address, buf, sizeof (buf));
257 zlog_debug ("Added IP address %s to circuit %d", buf,
258 circuit->circuit_id);
259 #endif /* EXTREME_DEBUG */
260 }
261 if (connected->address->family == AF_INET6)
262 {
263 if (IN6_IS_ADDR_LOOPBACK(&connected->address->u.prefix6))
264 return;
265
266 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ipv6))
267 if (prefix_same ((struct prefix *) ipv6, connected->address))
268 return;
269 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ipv6))
270 if (prefix_same ((struct prefix *) ipv6, connected->address))
271 return;
272
273 ipv6 = prefix_ipv6_new ();
274 ipv6->prefixlen = connected->address->prefixlen;
275 ipv6->prefix = connected->address->u.prefix6;
276
277 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
278 listnode_add (circuit->ipv6_link, ipv6);
279 else
280 listnode_add (circuit->ipv6_non_link, ipv6);
281 if (circuit->area)
282 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
283
284 #ifdef EXTREME_DEBUG
285 prefix2str (connected->address, buf, sizeof (buf));
286 zlog_debug ("Added IPv6 address %s to circuit %d", buf,
287 circuit->circuit_id);
288 #endif /* EXTREME_DEBUG */
289 }
290 return;
291 }
292
293 void
294 isis_circuit_del_addr (struct isis_circuit *circuit,
295 struct connected *connected)
296 {
297 struct prefix_ipv4 *ipv4, *ip = NULL;
298 struct listnode *node;
299 char buf[PREFIX2STR_BUFFER];
300 #ifdef HAVE_IPV6
301 struct prefix_ipv6 *ipv6, *ip6 = NULL;
302 int found = 0;
303 #endif /* HAVE_IPV6 */
304
305 if (connected->address->family == AF_INET)
306 {
307 ipv4 = prefix_ipv4_new ();
308 ipv4->prefixlen = connected->address->prefixlen;
309 ipv4->prefix = connected->address->u.prefix4;
310
311 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
312 if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
313 break;
314
315 if (ip)
316 {
317 listnode_delete (circuit->ip_addrs, ip);
318 if (circuit->area)
319 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
320 }
321 else
322 {
323 prefix2str (connected->address, buf, sizeof (buf));
324 zlog_warn ("Nonexitant ip address %s removal attempt from \
325 circuit %d", buf, circuit->circuit_id);
326 zlog_warn ("Current ip addresses on %s:", circuit->interface->name);
327 for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, ip))
328 {
329 prefix2str((struct prefix*)ip, (char *)buf, BUFSIZ);
330 zlog_warn(" %s", buf);
331 }
332 zlog_warn("End of addresses");
333 }
334
335 prefix_ipv4_free (ipv4);
336 }
337 #ifdef HAVE_IPV6
338 if (connected->address->family == AF_INET6)
339 {
340 ipv6 = prefix_ipv6_new ();
341 ipv6->prefixlen = connected->address->prefixlen;
342 ipv6->prefix = connected->address->u.prefix6;
343
344 if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
345 {
346 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
347 {
348 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
349 break;
350 }
351 if (ip6)
352 {
353 listnode_delete (circuit->ipv6_link, ip6);
354 found = 1;
355 }
356 }
357 else
358 {
359 for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
360 {
361 if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
362 break;
363 }
364 if (ip6)
365 {
366 listnode_delete (circuit->ipv6_non_link, ip6);
367 found = 1;
368 }
369 }
370
371 if (!found)
372 {
373 prefix2str (connected->address, buf, sizeof (buf));
374 zlog_warn ("Nonexitant ip address %s removal attempt from \
375 circuit %d", buf, circuit->circuit_id);
376 zlog_warn ("Current ip addresses on %s:", circuit->interface->name);
377 for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip6))
378 {
379 prefix2str((struct prefix*)ip6, (char *)buf, BUFSIZ);
380 zlog_warn(" %s", buf);
381 }
382 zlog_warn(" -----");
383 for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip6))
384 {
385 prefix2str((struct prefix*)ip6, (char *)buf, BUFSIZ);
386 zlog_warn(" %s", buf);
387 }
388 zlog_warn("End of addresses");
389 }
390 else if (circuit->area)
391 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
392
393 prefix_ipv6_free (ipv6);
394 }
395 #endif /* HAVE_IPV6 */
396 return;
397 }
398
399 static u_char
400 isis_circuit_id_gen (struct interface *ifp)
401 {
402 u_char id = 0;
403 char ifname[16];
404 unsigned int i;
405 int start = -1, end = -1;
406
407 /*
408 * Get a stable circuit id from ifname. This makes
409 * the ifindex from flapping when netdevs are created
410 * and deleted on the fly. Note that this circuit id
411 * is used in pseudo lsps so it is better to be stable.
412 * The following code works on any reasonanle ifname
413 * like: eth1 or trk-1.1 etc.
414 */
415 for (i = 0; i < strlen (ifp->name); i++)
416 {
417 if (isdigit((unsigned char)ifp->name[i]))
418 {
419 if (start < 0)
420 {
421 start = i;
422 end = i + 1;
423 }
424 else
425 {
426 end = i + 1;
427 }
428 }
429 else if (start >= 0)
430 break;
431 }
432
433 if ((start >= 0) && (end >= start) && (end - start) < 16)
434 {
435 memset (ifname, 0, 16);
436 strncpy (ifname, &ifp->name[start], end - start);
437 id = (u_char)atoi(ifname);
438 }
439
440 /* Try to be unique. */
441 if (!id)
442 id = (u_char)((ifp->ifindex & 0xff) | 0x80);
443
444 return id;
445 }
446
447 void
448 isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
449 {
450 struct listnode *node, *nnode;
451 struct connected *conn;
452
453 circuit->circuit_id = isis_circuit_id_gen (ifp);
454
455 isis_circuit_if_bind (circuit, ifp);
456 /* isis_circuit_update_addrs (circuit, ifp); */
457
458 if (if_is_broadcast (ifp))
459 {
460 if (circuit->circ_type_config == CIRCUIT_T_P2P)
461 circuit->circ_type = CIRCUIT_T_P2P;
462 else
463 circuit->circ_type = CIRCUIT_T_BROADCAST;
464 }
465 else if (if_is_pointopoint (ifp))
466 {
467 circuit->circ_type = CIRCUIT_T_P2P;
468 }
469 else if (if_is_loopback (ifp))
470 {
471 circuit->circ_type = CIRCUIT_T_LOOPBACK;
472 circuit->is_passive = 1;
473 }
474 else
475 {
476 /* It's normal in case of loopback etc. */
477 if (isis->debugs & DEBUG_EVENTS)
478 zlog_debug ("isis_circuit_if_add: unsupported media");
479 circuit->circ_type = CIRCUIT_T_UNKNOWN;
480 }
481
482 circuit->ip_addrs = list_new ();
483 #ifdef HAVE_IPV6
484 circuit->ipv6_link = list_new ();
485 circuit->ipv6_non_link = list_new ();
486 #endif /* HAVE_IPV6 */
487
488 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
489 isis_circuit_add_addr (circuit, conn);
490
491 return;
492 }
493
494 void
495 isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp)
496 {
497 struct listnode *node, *nnode;
498 struct connected *conn;
499
500 assert (circuit->interface == ifp);
501
502 /* destroy addresses */
503 for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
504 isis_circuit_del_addr (circuit, conn);
505
506 if (circuit->ip_addrs)
507 {
508 assert (listcount(circuit->ip_addrs) == 0);
509 list_delete (circuit->ip_addrs);
510 circuit->ip_addrs = NULL;
511 }
512
513 #ifdef HAVE_IPV6
514 if (circuit->ipv6_link)
515 {
516 assert (listcount(circuit->ipv6_link) == 0);
517 list_delete (circuit->ipv6_link);
518 circuit->ipv6_link = NULL;
519 }
520
521 if (circuit->ipv6_non_link)
522 {
523 assert (listcount(circuit->ipv6_non_link) == 0);
524 list_delete (circuit->ipv6_non_link);
525 circuit->ipv6_non_link = NULL;
526 }
527 #endif /* HAVE_IPV6 */
528
529 circuit->circ_type = CIRCUIT_T_UNKNOWN;
530 circuit->circuit_id = 0;
531
532 return;
533 }
534
535 void
536 isis_circuit_if_bind (struct isis_circuit *circuit, struct interface *ifp)
537 {
538 assert (circuit != NULL);
539 assert (ifp != NULL);
540 if (circuit->interface)
541 assert (circuit->interface == ifp);
542 else
543 circuit->interface = ifp;
544 if (ifp->info)
545 assert (ifp->info == circuit);
546 else
547 ifp->info = circuit;
548 }
549
550 void
551 isis_circuit_if_unbind (struct isis_circuit *circuit, struct interface *ifp)
552 {
553 assert (circuit != NULL);
554 assert (ifp != NULL);
555 assert (circuit->interface == ifp);
556 assert (ifp->info == circuit);
557 circuit->interface = NULL;
558 ifp->info = NULL;
559 }
560
561 static void
562 isis_circuit_update_all_srmflags (struct isis_circuit *circuit, int is_set)
563 {
564 struct isis_area *area;
565 struct isis_lsp *lsp;
566 dnode_t *dnode, *dnode_next;
567 int level;
568
569 assert (circuit);
570 area = circuit->area;
571 assert (area);
572 for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++)
573 {
574 if (level & circuit->is_type)
575 {
576 if (area->lspdb[level - 1] &&
577 dict_count (area->lspdb[level - 1]) > 0)
578 {
579 for (dnode = dict_first (area->lspdb[level - 1]);
580 dnode != NULL; dnode = dnode_next)
581 {
582 dnode_next = dict_next (area->lspdb[level - 1], dnode);
583 lsp = dnode_get (dnode);
584 if (is_set)
585 {
586 ISIS_SET_FLAG (lsp->SRMflags, circuit);
587 }
588 else
589 {
590 ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
591 }
592 }
593 }
594 }
595 }
596 }
597
598 size_t
599 isis_circuit_pdu_size(struct isis_circuit *circuit)
600 {
601 return ISO_MTU(circuit);
602 }
603
604 void
605 isis_circuit_stream(struct isis_circuit *circuit, struct stream **stream)
606 {
607 size_t stream_size = isis_circuit_pdu_size(circuit);
608
609 if (!*stream)
610 {
611 *stream = stream_new(stream_size);
612 }
613 else
614 {
615 if (STREAM_SIZE(*stream) != stream_size)
616 stream_resize(*stream, stream_size);
617 stream_reset(*stream);
618 }
619 }
620
621 int
622 isis_circuit_up (struct isis_circuit *circuit)
623 {
624 int retv;
625
626 /* Set the flags for all the lsps of the circuit. */
627 isis_circuit_update_all_srmflags (circuit, 1);
628
629 if (circuit->state == C_STATE_UP)
630 return ISIS_OK;
631
632 if (circuit->is_passive)
633 return ISIS_OK;
634
635 if (circuit->area->lsp_mtu > isis_circuit_pdu_size(circuit))
636 {
637 zlog_err("Interface MTU %zu on %s is too low to support area lsp mtu %u!",
638 isis_circuit_pdu_size(circuit), circuit->interface->name,
639 circuit->area->lsp_mtu);
640 isis_circuit_update_all_srmflags(circuit, 0);
641 return ISIS_ERROR;
642 }
643
644 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
645 {
646 /*
647 * Get the Hardware Address
648 */
649 #ifdef HAVE_STRUCT_SOCKADDR_DL
650 #ifndef SUNOS_5
651 if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
652 zlog_warn ("unsupported link layer");
653 else
654 memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
655 ETH_ALEN);
656 #endif
657 #else
658 if (circuit->interface->hw_addr_len != ETH_ALEN)
659 {
660 zlog_warn ("unsupported link layer");
661 }
662 else
663 {
664 memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
665 }
666 #ifdef EXTREME_DEGUG
667 zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
668 circuit->interface->ifindex, ISO_MTU (circuit),
669 snpa_print (circuit->u.bc.snpa));
670 #endif /* EXTREME_DEBUG */
671 #endif /* HAVE_STRUCT_SOCKADDR_DL */
672
673 circuit->u.bc.adjdb[0] = list_new ();
674 circuit->u.bc.adjdb[1] = list_new ();
675
676 /*
677 * ISO 10589 - 8.4.1 Enabling of broadcast circuits
678 */
679
680 /* initilizing the hello sending threads
681 * for a broadcast IF
682 */
683
684 /* 8.4.1 a) commence sending of IIH PDUs */
685
686 if (circuit->is_type & IS_LEVEL_1)
687 {
688 thread_add_event (master, send_lan_l1_hello, circuit, 0);
689 circuit->u.bc.lan_neighs[0] = list_new ();
690 }
691
692 if (circuit->is_type & IS_LEVEL_2)
693 {
694 thread_add_event (master, send_lan_l2_hello, circuit, 0);
695 circuit->u.bc.lan_neighs[1] = list_new ();
696 }
697
698 /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
699 /* 8.4.1 c) FIXME: listen for ESH PDUs */
700
701 /* 8.4.1 d) */
702 /* dr election will commence in... */
703 if (circuit->is_type & IS_LEVEL_1)
704 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
705 circuit, 2 * circuit->hello_interval[0]);
706 if (circuit->is_type & IS_LEVEL_2)
707 THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
708 circuit, 2 * circuit->hello_interval[1]);
709 }
710 else
711 {
712 /* initializing the hello send threads
713 * for a ptp IF
714 */
715 circuit->u.p2p.neighbor = NULL;
716 thread_add_event (master, send_p2p_hello, circuit, 0);
717 }
718
719 /* initializing PSNP timers */
720 if (circuit->is_type & IS_LEVEL_1)
721 THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
722 isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
723
724 if (circuit->is_type & IS_LEVEL_2)
725 THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
726 isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
727
728 /* unified init for circuits; ignore warnings below this level */
729 retv = isis_sock_init (circuit);
730 if (retv != ISIS_OK)
731 {
732 isis_circuit_down (circuit);
733 return retv;
734 }
735
736 /* initialize the circuit streams after opening connection */
737 isis_circuit_stream(circuit, &circuit->rcv_stream);
738 isis_circuit_stream(circuit, &circuit->snd_stream);
739
740 #ifdef GNU_LINUX
741 THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
742 circuit->fd);
743 #else
744 THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
745 circuit->fd);
746 #endif
747
748 circuit->lsp_queue = list_new ();
749 circuit->lsp_queue_last_cleared = time (NULL);
750
751 return ISIS_OK;
752 }
753
754 void
755 isis_circuit_down (struct isis_circuit *circuit)
756 {
757 if (circuit->state != C_STATE_UP)
758 return;
759
760 /* Clear the flags for all the lsps of the circuit. */
761 isis_circuit_update_all_srmflags (circuit, 0);
762
763 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
764 {
765 /* destroy neighbour lists */
766 if (circuit->u.bc.lan_neighs[0])
767 {
768 list_delete (circuit->u.bc.lan_neighs[0]);
769 circuit->u.bc.lan_neighs[0] = NULL;
770 }
771 if (circuit->u.bc.lan_neighs[1])
772 {
773 list_delete (circuit->u.bc.lan_neighs[1]);
774 circuit->u.bc.lan_neighs[1] = NULL;
775 }
776 /* destroy adjacency databases */
777 if (circuit->u.bc.adjdb[0])
778 {
779 circuit->u.bc.adjdb[0]->del = isis_delete_adj;
780 list_delete (circuit->u.bc.adjdb[0]);
781 circuit->u.bc.adjdb[0] = NULL;
782 }
783 if (circuit->u.bc.adjdb[1])
784 {
785 circuit->u.bc.adjdb[1]->del = isis_delete_adj;
786 list_delete (circuit->u.bc.adjdb[1]);
787 circuit->u.bc.adjdb[1] = NULL;
788 }
789 if (circuit->u.bc.is_dr[0])
790 {
791 isis_dr_resign (circuit, 1);
792 circuit->u.bc.is_dr[0] = 0;
793 }
794 memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1);
795 if (circuit->u.bc.is_dr[1])
796 {
797 isis_dr_resign (circuit, 2);
798 circuit->u.bc.is_dr[1] = 0;
799 }
800 memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1);
801 memset (circuit->u.bc.snpa, 0, ETH_ALEN);
802
803 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
804 THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
805 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
806 THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
807 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[0]);
808 THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[1]);
809 circuit->lsp_regenerate_pending[0] = 0;
810 circuit->lsp_regenerate_pending[1] = 0;
811 }
812 else if (circuit->circ_type == CIRCUIT_T_P2P)
813 {
814 isis_delete_adj (circuit->u.p2p.neighbor);
815 circuit->u.p2p.neighbor = NULL;
816 THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
817 }
818
819 /* Cancel all active threads */
820 THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
821 THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
822 THREAD_TIMER_OFF (circuit->t_send_psnp[0]);
823 THREAD_TIMER_OFF (circuit->t_send_psnp[1]);
824 THREAD_OFF (circuit->t_read);
825
826 if (circuit->lsp_queue)
827 {
828 circuit->lsp_queue->del = NULL;
829 list_delete (circuit->lsp_queue);
830 circuit->lsp_queue = NULL;
831 }
832
833 /* send one gratuitous hello to spead up convergence */
834 if (circuit->is_type & IS_LEVEL_1)
835 send_hello (circuit, IS_LEVEL_1);
836 if (circuit->is_type & IS_LEVEL_2)
837 send_hello (circuit, IS_LEVEL_2);
838
839 circuit->upadjcount[0] = 0;
840 circuit->upadjcount[1] = 0;
841
842 /* close the socket */
843 if (circuit->fd)
844 {
845 close (circuit->fd);
846 circuit->fd = 0;
847 }
848
849 if (circuit->rcv_stream != NULL)
850 {
851 stream_free (circuit->rcv_stream);
852 circuit->rcv_stream = NULL;
853 }
854
855 if (circuit->snd_stream != NULL)
856 {
857 stream_free (circuit->snd_stream);
858 circuit->snd_stream = NULL;
859 }
860
861 thread_cancel_event (master, circuit);
862
863 return;
864 }
865
866 void
867 circuit_update_nlpids (struct isis_circuit *circuit)
868 {
869 circuit->nlpids.count = 0;
870
871 if (circuit->ip_router)
872 {
873 circuit->nlpids.nlpids[0] = NLPID_IP;
874 circuit->nlpids.count++;
875 }
876 #ifdef HAVE_IPV6
877 if (circuit->ipv6_router)
878 {
879 circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
880 circuit->nlpids.count++;
881 }
882 #endif /* HAVE_IPV6 */
883 return;
884 }
885
886 void
887 isis_circuit_print_vty (struct isis_circuit *circuit, struct vty *vty,
888 char detail)
889 {
890 if (detail == ISIS_UI_LEVEL_BRIEF)
891 {
892 vty_out (vty, " %-12s", circuit->interface->name);
893 vty_out (vty, "0x%-7x", circuit->circuit_id);
894 vty_out (vty, "%-9s", circuit_state2string (circuit->state));
895 vty_out (vty, "%-9s", circuit_type2string (circuit->circ_type));
896 vty_out (vty, "%-9s", circuit_t2string (circuit->is_type));
897 vty_out (vty, "%s", VTY_NEWLINE);
898 }
899
900 if (detail == ISIS_UI_LEVEL_DETAIL)
901 {
902 struct listnode *node;
903 struct prefix *ip_addr;
904 char buf[BUFSIZ];
905
906 vty_out (vty, " Interface: %s", circuit->interface->name);
907 vty_out (vty, ", State: %s", circuit_state2string (circuit->state));
908 if (circuit->is_passive)
909 vty_out (vty, ", Passive");
910 else
911 vty_out (vty, ", Active");
912 vty_out (vty, ", Circuit Id: 0x%x", circuit->circuit_id);
913 vty_out (vty, "%s", VTY_NEWLINE);
914 vty_out (vty, " Type: %s", circuit_type2string (circuit->circ_type));
915 vty_out (vty, ", Level: %s", circuit_t2string (circuit->is_type));
916 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
917 vty_out (vty, ", SNPA: %-10s", snpa_print (circuit->u.bc.snpa));
918 vty_out (vty, "%s", VTY_NEWLINE);
919 if (circuit->is_type & IS_LEVEL_1)
920 {
921 vty_out (vty, " Level-1 Information:%s", VTY_NEWLINE);
922 if (circuit->area->newmetric)
923 vty_out (vty, " Metric: %d", circuit->te_metric[0]);
924 else
925 vty_out (vty, " Metric: %d",
926 circuit->metrics[0].metric_default);
927 if (!circuit->is_passive)
928 {
929 vty_out (vty, ", Active neighbors: %u%s",
930 circuit->upadjcount[0], VTY_NEWLINE);
931 vty_out (vty, " Hello interval: %u, "
932 "Holddown count: %u %s%s",
933 circuit->hello_interval[0],
934 circuit->hello_multiplier[0],
935 (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
936 VTY_NEWLINE);
937 vty_out (vty, " CNSP interval: %u, "
938 "PSNP interval: %u%s",
939 circuit->csnp_interval[0],
940 circuit->psnp_interval[0], VTY_NEWLINE);
941 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
942 vty_out (vty, " LAN Priority: %u, %s%s",
943 circuit->priority[0],
944 (circuit->u.bc.is_dr[0] ? \
945 "is DIS" : "is not DIS"), VTY_NEWLINE);
946 }
947 else
948 {
949 vty_out (vty, "%s", VTY_NEWLINE);
950 }
951 }
952 if (circuit->is_type & IS_LEVEL_2)
953 {
954 vty_out (vty, " Level-2 Information:%s", VTY_NEWLINE);
955 if (circuit->area->newmetric)
956 vty_out (vty, " Metric: %d", circuit->te_metric[1]);
957 else
958 vty_out (vty, " Metric: %d",
959 circuit->metrics[1].metric_default);
960 if (!circuit->is_passive)
961 {
962 vty_out (vty, ", Active neighbors: %u%s",
963 circuit->upadjcount[1], VTY_NEWLINE);
964 vty_out (vty, " Hello interval: %u, "
965 "Holddown count: %u %s%s",
966 circuit->hello_interval[1],
967 circuit->hello_multiplier[1],
968 (circuit->pad_hellos ? "(pad)" : "(no-pad)"),
969 VTY_NEWLINE);
970 vty_out (vty, " CNSP interval: %u, "
971 "PSNP interval: %u%s",
972 circuit->csnp_interval[1],
973 circuit->psnp_interval[1], VTY_NEWLINE);
974 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
975 vty_out (vty, " LAN Priority: %u, %s%s",
976 circuit->priority[1],
977 (circuit->u.bc.is_dr[1] ? \
978 "is DIS" : "is not DIS"), VTY_NEWLINE);
979 }
980 else
981 {
982 vty_out (vty, "%s", VTY_NEWLINE);
983 }
984 }
985 if (circuit->ip_addrs && listcount (circuit->ip_addrs) > 0)
986 {
987 vty_out (vty, " IP Prefix(es):%s", VTY_NEWLINE);
988 for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip_addr))
989 {
990 prefix2str (ip_addr, buf, sizeof (buf)),
991 vty_out (vty, " %s%s", buf, VTY_NEWLINE);
992 }
993 }
994 if (circuit->ipv6_link && listcount(circuit->ipv6_link) > 0)
995 {
996 vty_out(vty, " IPv6 Link-Locals:%s", VTY_NEWLINE);
997 for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ip_addr))
998 {
999 prefix2str(ip_addr, (char*)buf, BUFSIZ),
1000 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
1001 }
1002 }
1003 if (circuit->ipv6_link && listcount(circuit->ipv6_non_link) > 0)
1004 {
1005 vty_out(vty, " IPv6 Prefixes:%s", VTY_NEWLINE);
1006 for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ip_addr))
1007 {
1008 prefix2str(ip_addr, (char*)buf, BUFSIZ),
1009 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
1010 }
1011 }
1012
1013 vty_out (vty, "%s", VTY_NEWLINE);
1014 }
1015 return;
1016 }
1017
1018 int
1019 isis_interface_config_write (struct vty *vty)
1020 {
1021 int write = 0;
1022 struct listnode *node, *node2;
1023 struct interface *ifp;
1024 struct isis_area *area;
1025 struct isis_circuit *circuit;
1026 int i;
1027
1028 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
1029 {
1030 if (ifp->ifindex == IFINDEX_DELETED)
1031 continue;
1032
1033 /* IF name */
1034 vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
1035 write++;
1036 /* IF desc */
1037 if (ifp->desc)
1038 {
1039 vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
1040 write++;
1041 }
1042 /* ISIS Circuit */
1043 for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
1044 {
1045 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
1046 if (circuit == NULL)
1047 continue;
1048 if (circuit->ip_router)
1049 {
1050 vty_out (vty, " ip router isis %s%s", area->area_tag,
1051 VTY_NEWLINE);
1052 write++;
1053 }
1054 if (circuit->is_passive)
1055 {
1056 vty_out (vty, " isis passive%s", VTY_NEWLINE);
1057 write++;
1058 }
1059 if (circuit->circ_type_config == CIRCUIT_T_P2P)
1060 {
1061 vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE);
1062 write++;
1063 }
1064 #ifdef HAVE_IPV6
1065 if (circuit->ipv6_router)
1066 {
1067 vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
1068 VTY_NEWLINE);
1069 write++;
1070 }
1071 #endif /* HAVE_IPV6 */
1072
1073 /* ISIS - circuit type */
1074 if (circuit->is_type == IS_LEVEL_1)
1075 {
1076 vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
1077 write++;
1078 }
1079 else
1080 {
1081 if (circuit->is_type == IS_LEVEL_2)
1082 {
1083 vty_out (vty, " isis circuit-type level-2-only%s",
1084 VTY_NEWLINE);
1085 write++;
1086 }
1087 }
1088
1089 /* ISIS - CSNP interval */
1090 if (circuit->csnp_interval[0] == circuit->csnp_interval[1])
1091 {
1092 if (circuit->csnp_interval[0] != DEFAULT_CSNP_INTERVAL)
1093 {
1094 vty_out (vty, " isis csnp-interval %d%s",
1095 circuit->csnp_interval[0], VTY_NEWLINE);
1096 write++;
1097 }
1098 }
1099 else
1100 {
1101 for (i = 0; i < 2; i++)
1102 {
1103 if (circuit->csnp_interval[i] != DEFAULT_CSNP_INTERVAL)
1104 {
1105 vty_out (vty, " isis csnp-interval %d level-%d%s",
1106 circuit->csnp_interval[i], i + 1, VTY_NEWLINE);
1107 write++;
1108 }
1109 }
1110 }
1111
1112 /* ISIS - PSNP interval */
1113 if (circuit->psnp_interval[0] == circuit->psnp_interval[1])
1114 {
1115 if (circuit->psnp_interval[0] != DEFAULT_PSNP_INTERVAL)
1116 {
1117 vty_out (vty, " isis psnp-interval %d%s",
1118 circuit->psnp_interval[0], VTY_NEWLINE);
1119 write++;
1120 }
1121 }
1122 else
1123 {
1124 for (i = 0; i < 2; i++)
1125 {
1126 if (circuit->psnp_interval[i] != DEFAULT_PSNP_INTERVAL)
1127 {
1128 vty_out (vty, " isis psnp-interval %d level-%d%s",
1129 circuit->psnp_interval[i], i + 1, VTY_NEWLINE);
1130 write++;
1131 }
1132 }
1133 }
1134
1135 /* ISIS - Hello padding - Defaults to true so only display if false */
1136 if (circuit->pad_hellos == 0)
1137 {
1138 vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
1139 write++;
1140 }
1141
1142 /* ISIS - Hello interval */
1143 if (circuit->hello_interval[0] == circuit->hello_interval[1])
1144 {
1145 if (circuit->hello_interval[0] != DEFAULT_HELLO_INTERVAL)
1146 {
1147 vty_out (vty, " isis hello-interval %d%s",
1148 circuit->hello_interval[0], VTY_NEWLINE);
1149 write++;
1150 }
1151 }
1152 else
1153 {
1154 for (i = 0; i < 2; i++)
1155 {
1156 if (circuit->hello_interval[i] != DEFAULT_HELLO_INTERVAL)
1157 {
1158 vty_out (vty, " isis hello-interval %d level-%d%s",
1159 circuit->hello_interval[i], i + 1, VTY_NEWLINE);
1160 write++;
1161 }
1162 }
1163 }
1164
1165 /* ISIS - Hello Multiplier */
1166 if (circuit->hello_multiplier[0] == circuit->hello_multiplier[1])
1167 {
1168 if (circuit->hello_multiplier[0] != DEFAULT_HELLO_MULTIPLIER)
1169 {
1170 vty_out (vty, " isis hello-multiplier %d%s",
1171 circuit->hello_multiplier[0], VTY_NEWLINE);
1172 write++;
1173 }
1174 }
1175 else
1176 {
1177 for (i = 0; i < 2; i++)
1178 {
1179 if (circuit->hello_multiplier[i] != DEFAULT_HELLO_MULTIPLIER)
1180 {
1181 vty_out (vty, " isis hello-multiplier %d level-%d%s",
1182 circuit->hello_multiplier[i], i + 1,
1183 VTY_NEWLINE);
1184 write++;
1185 }
1186 }
1187 }
1188
1189 /* ISIS - Priority */
1190 if (circuit->priority[0] == circuit->priority[1])
1191 {
1192 if (circuit->priority[0] != DEFAULT_PRIORITY)
1193 {
1194 vty_out (vty, " isis priority %d%s",
1195 circuit->priority[0], VTY_NEWLINE);
1196 write++;
1197 }
1198 }
1199 else
1200 {
1201 for (i = 0; i < 2; i++)
1202 {
1203 if (circuit->priority[i] != DEFAULT_PRIORITY)
1204 {
1205 vty_out (vty, " isis priority %d level-%d%s",
1206 circuit->priority[i], i + 1, VTY_NEWLINE);
1207 write++;
1208 }
1209 }
1210 }
1211
1212 /* ISIS - Metric */
1213 if (circuit->te_metric[0] == circuit->te_metric[1])
1214 {
1215 if (circuit->te_metric[0] != DEFAULT_CIRCUIT_METRIC)
1216 {
1217 vty_out (vty, " isis metric %d%s", circuit->te_metric[0],
1218 VTY_NEWLINE);
1219 write++;
1220 }
1221 }
1222 else
1223 {
1224 for (i = 0; i < 2; i++)
1225 {
1226 if (circuit->te_metric[i] != DEFAULT_CIRCUIT_METRIC)
1227 {
1228 vty_out (vty, " isis metric %d level-%d%s",
1229 circuit->te_metric[i], i + 1, VTY_NEWLINE);
1230 write++;
1231 }
1232 }
1233 }
1234 if (circuit->passwd.type == ISIS_PASSWD_TYPE_HMAC_MD5)
1235 {
1236 vty_out (vty, " isis password md5 %s%s", circuit->passwd.passwd,
1237 VTY_NEWLINE);
1238 write++;
1239 }
1240 else if (circuit->passwd.type == ISIS_PASSWD_TYPE_CLEARTXT)
1241 {
1242 vty_out (vty, " isis password clear %s%s", circuit->passwd.passwd,
1243 VTY_NEWLINE);
1244 write++;
1245 }
1246 }
1247 vty_out (vty, "!%s", VTY_NEWLINE);
1248 }
1249
1250 return write;
1251 }
1252
1253 DEFUN (ip_router_isis,
1254 ip_router_isis_cmd,
1255 "ip router isis WORD",
1256 "Interface Internet Protocol config commands\n"
1257 "IP router interface commands\n"
1258 "IS-IS Routing for IP\n"
1259 "Routing process tag\n")
1260 {
1261 struct isis_circuit *circuit;
1262 struct interface *ifp;
1263 struct isis_area *area;
1264 int rv;
1265
1266 ifp = (struct interface *) vty->index;
1267 assert (ifp);
1268
1269 /* Prevent more than one area per circuit */
1270 circuit = circuit_scan_by_ifp (ifp);
1271 if (circuit)
1272 {
1273 if (circuit->ip_router == 1)
1274 {
1275 if (strcmp (circuit->area->area_tag, argv[0]))
1276 {
1277 vty_out (vty, "ISIS circuit is already defined on %s%s",
1278 circuit->area->area_tag, VTY_NEWLINE);
1279 return CMD_ERR_NOTHING_TODO;
1280 }
1281 return CMD_SUCCESS;
1282 }
1283 }
1284
1285 if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
1286 {
1287 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1288 return CMD_ERR_NO_MATCH;
1289 }
1290 area = vty->index;
1291
1292 circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
1293 if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP)
1294 {
1295 vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE);
1296 rv = CMD_WARNING;
1297 }
1298 else
1299 {
1300 isis_circuit_if_bind (circuit, ifp);
1301
1302 circuit->ip_router = 1;
1303 area->ip_circuits++;
1304 circuit_update_nlpids (circuit);
1305 rv = CMD_SUCCESS;
1306 }
1307
1308 vty->node = INTERFACE_NODE;
1309 vty->index = ifp;
1310
1311 if (circuit->ipv6_router)
1312 lsp_regenerate_schedule(circuit->area, circuit->is_type, 0);
1313 return rv;
1314 }
1315
1316 DEFUN (no_ip_router_isis,
1317 no_ip_router_isis_cmd,
1318 "no ip router isis WORD",
1319 NO_STR
1320 "Interface Internet Protocol config commands\n"
1321 "IP router interface commands\n"
1322 "IS-IS Routing for IP\n"
1323 "Routing process tag\n")
1324 {
1325 struct interface *ifp;
1326 struct isis_area *area;
1327 struct isis_circuit *circuit;
1328
1329 ifp = (struct interface *) vty->index;
1330 if (!ifp)
1331 {
1332 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1333 return CMD_ERR_NO_MATCH;
1334 }
1335
1336 area = isis_area_lookup (argv[0]);
1337 if (!area)
1338 {
1339 vty_out (vty, "Can't find ISIS instance %s%s",
1340 argv[0], VTY_NEWLINE);
1341 return CMD_ERR_NO_MATCH;
1342 }
1343
1344 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
1345 if (!circuit)
1346 {
1347 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1348 ifp->name, VTY_NEWLINE);
1349 return CMD_ERR_NO_MATCH;
1350 }
1351
1352 circuit->ip_router = 0;
1353 area->ip_circuits--;
1354 if (circuit->ipv6_router == 0)
1355 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1356 else
1357 lsp_regenerate_schedule(area, circuit->is_type, 0);
1358
1359 return CMD_SUCCESS;
1360 }
1361
1362 #ifdef HAVE_IPV6
1363 DEFUN (ipv6_router_isis,
1364 ipv6_router_isis_cmd,
1365 "ipv6 router isis WORD",
1366 "IPv6 interface subcommands\n"
1367 "IPv6 Router interface commands\n"
1368 "IS-IS Routing for IPv6\n"
1369 "Routing process tag\n")
1370 {
1371 struct isis_circuit *circuit;
1372 struct interface *ifp;
1373 struct isis_area *area;
1374 int rv;
1375
1376 ifp = (struct interface *) vty->index;
1377 assert (ifp);
1378
1379 /* Prevent more than one area per circuit */
1380 circuit = circuit_scan_by_ifp (ifp);
1381 if (circuit)
1382 {
1383 if (circuit->ipv6_router == 1)
1384 {
1385 if (strcmp (circuit->area->area_tag, argv[0]))
1386 {
1387 vty_out (vty, "ISIS circuit is already defined for IPv6 on %s%s",
1388 circuit->area->area_tag, VTY_NEWLINE);
1389 return CMD_ERR_NOTHING_TODO;
1390 }
1391 return CMD_SUCCESS;
1392 }
1393 }
1394
1395 if (isis_area_get (vty, argv[0]) != CMD_SUCCESS)
1396 {
1397 vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
1398 return CMD_ERR_NO_MATCH;
1399 }
1400 area = vty->index;
1401
1402 circuit = isis_csm_state_change (ISIS_ENABLE, circuit, area);
1403 if (circuit->state != C_STATE_CONF && circuit->state != C_STATE_UP)
1404 {
1405 vty_out(vty, "Couldn't bring up interface, please check log.%s", VTY_NEWLINE);
1406 rv = CMD_WARNING;
1407 }
1408 else
1409 {
1410 isis_circuit_if_bind (circuit, ifp);
1411
1412 circuit->ipv6_router = 1;
1413 area->ipv6_circuits++;
1414 circuit_update_nlpids (circuit);
1415 rv = CMD_SUCCESS;
1416 }
1417
1418 vty->node = INTERFACE_NODE;
1419 vty->index = ifp;
1420
1421 if (circuit->ip_router)
1422 lsp_regenerate_schedule(circuit->area, circuit->is_type, 0);
1423 return rv;
1424 }
1425
1426 DEFUN (no_ipv6_router_isis,
1427 no_ipv6_router_isis_cmd,
1428 "no ipv6 router isis WORD",
1429 NO_STR
1430 "IPv6 interface subcommands\n"
1431 "IPv6 Router interface commands\n"
1432 "IS-IS Routing for IPv6\n"
1433 "Routing process tag\n")
1434 {
1435 struct interface *ifp;
1436 struct isis_area *area;
1437 struct isis_circuit *circuit;
1438
1439 ifp = (struct interface *) vty->index;
1440 if (!ifp)
1441 {
1442 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1443 return CMD_ERR_NO_MATCH;
1444 }
1445
1446 area = isis_area_lookup (argv[0]);
1447 if (!area)
1448 {
1449 vty_out (vty, "Can't find ISIS instance %s%s",
1450 argv[0], VTY_NEWLINE);
1451 return CMD_ERR_NO_MATCH;
1452 }
1453
1454 circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
1455 if (!circuit)
1456 {
1457 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1458 ifp->name, VTY_NEWLINE);
1459 return CMD_ERR_NO_MATCH;
1460 }
1461
1462 circuit->ipv6_router = 0;
1463 area->ipv6_circuits--;
1464 if (circuit->ip_router == 0)
1465 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1466 else
1467 lsp_regenerate_schedule(area, circuit->is_type, 0);
1468
1469 return CMD_SUCCESS;
1470 }
1471 #endif /* HAVE_IPV6 */
1472
1473 DEFUN (isis_passive,
1474 isis_passive_cmd,
1475 "isis passive",
1476 "IS-IS commands\n"
1477 "Configure the passive mode for interface\n")
1478 {
1479 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1480 if (!circuit)
1481 return CMD_ERR_NO_MATCH;
1482
1483 if (circuit->is_passive == 1)
1484 return CMD_SUCCESS;
1485
1486 if (circuit->state != C_STATE_UP)
1487 {
1488 circuit->is_passive = 1;
1489 }
1490 else
1491 {
1492 struct isis_area *area = circuit->area;
1493 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1494 circuit->is_passive = 1;
1495 isis_csm_state_change (ISIS_ENABLE, circuit, area);
1496 }
1497
1498 return CMD_SUCCESS;
1499 }
1500
1501 DEFUN (no_isis_passive,
1502 no_isis_passive_cmd,
1503 "no isis passive",
1504 NO_STR
1505 "IS-IS commands\n"
1506 "Configure the passive mode for interface\n")
1507 {
1508 struct interface *ifp;
1509 struct isis_circuit *circuit;
1510
1511 ifp = (struct interface *) vty->index;
1512 if (!ifp)
1513 {
1514 vty_out (vty, "Invalid interface %s", VTY_NEWLINE);
1515 return CMD_ERR_NO_MATCH;
1516 }
1517
1518 /* FIXME: what is wrong with circuit = ifp->info ? */
1519 circuit = circuit_scan_by_ifp (ifp);
1520 if (!circuit)
1521 {
1522 vty_out (vty, "ISIS is not enabled on circuit %s%s",
1523 ifp->name, VTY_NEWLINE);
1524 return CMD_ERR_NO_MATCH;
1525 }
1526
1527 if (if_is_loopback(ifp))
1528 {
1529 vty_out (vty, "Can't set no passive for loopback interface%s",
1530 VTY_NEWLINE);
1531 return CMD_ERR_AMBIGUOUS;
1532 }
1533
1534 if (circuit->is_passive == 0)
1535 return CMD_SUCCESS;
1536
1537 if (circuit->state != C_STATE_UP)
1538 {
1539 circuit->is_passive = 0;
1540 }
1541 else
1542 {
1543 struct isis_area *area = circuit->area;
1544 isis_csm_state_change (ISIS_DISABLE, circuit, area);
1545 circuit->is_passive = 0;
1546 isis_csm_state_change (ISIS_ENABLE, circuit, area);
1547 }
1548
1549 return CMD_SUCCESS;
1550 }
1551
1552 DEFUN (isis_circuit_type,
1553 isis_circuit_type_cmd,
1554 "isis circuit-type (level-1|level-1-2|level-2-only)",
1555 "IS-IS commands\n"
1556 "Configure circuit type for interface\n"
1557 "Level-1 only adjacencies are formed\n"
1558 "Level-1-2 adjacencies are formed\n"
1559 "Level-2 only adjacencies are formed\n")
1560 {
1561 int circuit_type;
1562 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1563 if (!circuit)
1564 return CMD_ERR_NO_MATCH;
1565
1566 circuit_type = string2circuit_t (argv[0]);
1567 if (!circuit_type)
1568 {
1569 vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
1570 return CMD_ERR_AMBIGUOUS;
1571 }
1572
1573 if (circuit->state == C_STATE_UP &&
1574 circuit->area->is_type != IS_LEVEL_1_AND_2 &&
1575 circuit->area->is_type != circuit_type)
1576 {
1577 vty_out (vty, "Invalid circuit level for area %s.%s",
1578 circuit->area->area_tag, VTY_NEWLINE);
1579 return CMD_ERR_AMBIGUOUS;
1580 }
1581 isis_event_circuit_type_change (circuit, circuit_type);
1582
1583 return CMD_SUCCESS;
1584 }
1585
1586 DEFUN (no_isis_circuit_type,
1587 no_isis_circuit_type_cmd,
1588 "no isis circuit-type (level-1|level-1-2|level-2-only)",
1589 NO_STR
1590 "IS-IS commands\n"
1591 "Configure circuit type for interface\n"
1592 "Level-1 only adjacencies are formed\n"
1593 "Level-1-2 adjacencies are formed\n"
1594 "Level-2 only adjacencies are formed\n")
1595 {
1596 int circuit_type;
1597 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1598 if (!circuit)
1599 return CMD_ERR_NO_MATCH;
1600
1601 /*
1602 * Set the circuits level to its default value
1603 */
1604 if (circuit->state == C_STATE_UP)
1605 circuit_type = circuit->area->is_type;
1606 else
1607 circuit_type = IS_LEVEL_1_AND_2;
1608 isis_event_circuit_type_change (circuit, circuit_type);
1609
1610 return CMD_SUCCESS;
1611 }
1612
1613 DEFUN (isis_passwd_md5,
1614 isis_passwd_md5_cmd,
1615 "isis password md5 WORD",
1616 "IS-IS commands\n"
1617 "Configure the authentication password for a circuit\n"
1618 "Authentication type\n"
1619 "Circuit password\n")
1620 {
1621 int len;
1622 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1623 if (!circuit)
1624 return CMD_ERR_NO_MATCH;
1625
1626 len = strlen (argv[0]);
1627 if (len > 254)
1628 {
1629 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1630 return CMD_ERR_AMBIGUOUS;
1631 }
1632 circuit->passwd.len = len;
1633 circuit->passwd.type = ISIS_PASSWD_TYPE_HMAC_MD5;
1634 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
1635
1636 return CMD_SUCCESS;
1637 }
1638
1639 DEFUN (isis_passwd_clear,
1640 isis_passwd_clear_cmd,
1641 "isis password clear WORD",
1642 "IS-IS commands\n"
1643 "Configure the authentication password for a circuit\n"
1644 "Authentication type\n"
1645 "Circuit password\n")
1646 {
1647 int len;
1648 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1649 if (!circuit)
1650 return CMD_ERR_NO_MATCH;
1651
1652 len = strlen (argv[0]);
1653 if (len > 254)
1654 {
1655 vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
1656 return CMD_ERR_AMBIGUOUS;
1657 }
1658 circuit->passwd.len = len;
1659 circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
1660 strncpy ((char *)circuit->passwd.passwd, argv[0], 255);
1661
1662 return CMD_SUCCESS;
1663 }
1664
1665 DEFUN (no_isis_passwd,
1666 no_isis_passwd_cmd,
1667 "no isis password",
1668 NO_STR
1669 "IS-IS commands\n"
1670 "Configure the authentication password for a circuit\n")
1671 {
1672 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1673 if (!circuit)
1674 return CMD_ERR_NO_MATCH;
1675
1676 memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
1677
1678 return CMD_SUCCESS;
1679 }
1680
1681 DEFUN (isis_priority,
1682 isis_priority_cmd,
1683 "isis priority <0-127>",
1684 "IS-IS commands\n"
1685 "Set priority for Designated Router election\n"
1686 "Priority value\n")
1687 {
1688 int prio;
1689 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1690 if (!circuit)
1691 return CMD_ERR_NO_MATCH;
1692
1693 prio = atoi (argv[0]);
1694 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1695 {
1696 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1697 prio, VTY_NEWLINE);
1698 return CMD_ERR_AMBIGUOUS;
1699 }
1700
1701 circuit->priority[0] = prio;
1702 circuit->priority[1] = prio;
1703
1704 return CMD_SUCCESS;
1705 }
1706
1707 DEFUN (no_isis_priority,
1708 no_isis_priority_cmd,
1709 "no isis priority",
1710 NO_STR
1711 "IS-IS commands\n"
1712 "Set priority for Designated Router election\n")
1713 {
1714 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1715 if (!circuit)
1716 return CMD_ERR_NO_MATCH;
1717
1718 circuit->priority[0] = DEFAULT_PRIORITY;
1719 circuit->priority[1] = DEFAULT_PRIORITY;
1720
1721 return CMD_SUCCESS;
1722 }
1723
1724 ALIAS (no_isis_priority,
1725 no_isis_priority_arg_cmd,
1726 "no isis priority <0-127>",
1727 NO_STR
1728 "IS-IS commands\n"
1729 "Set priority for Designated Router election\n"
1730 "Priority value\n")
1731
1732 DEFUN (isis_priority_l1,
1733 isis_priority_l1_cmd,
1734 "isis priority <0-127> level-1",
1735 "IS-IS commands\n"
1736 "Set priority for Designated Router election\n"
1737 "Priority value\n"
1738 "Specify priority for level-1 routing\n")
1739 {
1740 int prio;
1741 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1742 if (!circuit)
1743 return CMD_ERR_NO_MATCH;
1744
1745 prio = atoi (argv[0]);
1746 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1747 {
1748 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1749 prio, VTY_NEWLINE);
1750 return CMD_ERR_AMBIGUOUS;
1751 }
1752
1753 circuit->priority[0] = prio;
1754
1755 return CMD_SUCCESS;
1756 }
1757
1758 DEFUN (no_isis_priority_l1,
1759 no_isis_priority_l1_cmd,
1760 "no isis priority level-1",
1761 NO_STR
1762 "IS-IS commands\n"
1763 "Set priority for Designated Router election\n"
1764 "Specify priority for level-1 routing\n")
1765 {
1766 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1767 if (!circuit)
1768 return CMD_ERR_NO_MATCH;
1769
1770 circuit->priority[0] = DEFAULT_PRIORITY;
1771
1772 return CMD_SUCCESS;
1773 }
1774
1775 ALIAS (no_isis_priority_l1,
1776 no_isis_priority_l1_arg_cmd,
1777 "no isis priority <0-127> level-1",
1778 NO_STR
1779 "IS-IS commands\n"
1780 "Set priority for Designated Router election\n"
1781 "Priority value\n"
1782 "Specify priority for level-1 routing\n")
1783
1784 DEFUN (isis_priority_l2,
1785 isis_priority_l2_cmd,
1786 "isis priority <0-127> level-2",
1787 "IS-IS commands\n"
1788 "Set priority for Designated Router election\n"
1789 "Priority value\n"
1790 "Specify priority for level-2 routing\n")
1791 {
1792 int prio;
1793 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1794 if (!circuit)
1795 return CMD_ERR_NO_MATCH;
1796
1797 prio = atoi (argv[0]);
1798 if (prio < MIN_PRIORITY || prio > MAX_PRIORITY)
1799 {
1800 vty_out (vty, "Invalid priority %d - should be <0-127>%s",
1801 prio, VTY_NEWLINE);
1802 return CMD_ERR_AMBIGUOUS;
1803 }
1804
1805 circuit->priority[1] = prio;
1806
1807 return CMD_SUCCESS;
1808 }
1809
1810 DEFUN (no_isis_priority_l2,
1811 no_isis_priority_l2_cmd,
1812 "no isis priority level-2",
1813 NO_STR
1814 "IS-IS commands\n"
1815 "Set priority for Designated Router election\n"
1816 "Specify priority for level-2 routing\n")
1817 {
1818 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1819 if (!circuit)
1820 return CMD_ERR_NO_MATCH;
1821
1822 circuit->priority[1] = DEFAULT_PRIORITY;
1823
1824 return CMD_SUCCESS;
1825 }
1826
1827 ALIAS (no_isis_priority_l2,
1828 no_isis_priority_l2_arg_cmd,
1829 "no isis priority <0-127> level-2",
1830 NO_STR
1831 "IS-IS commands\n"
1832 "Set priority for Designated Router election\n"
1833 "Priority value\n"
1834 "Specify priority for level-2 routing\n")
1835
1836 /* Metric command */
1837 DEFUN (isis_metric,
1838 isis_metric_cmd,
1839 "isis metric <0-16777215>",
1840 "IS-IS commands\n"
1841 "Set default metric for circuit\n"
1842 "Default metric value\n")
1843 {
1844 int met;
1845 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1846 if (!circuit)
1847 return CMD_ERR_NO_MATCH;
1848
1849 met = atoi (argv[0]);
1850
1851 /* RFC3787 section 5.1 */
1852 if (circuit->area && circuit->area->oldmetric == 1 &&
1853 met > MAX_NARROW_LINK_METRIC)
1854 {
1855 vty_out (vty, "Invalid metric %d - should be <0-63> "
1856 "when narrow metric type enabled%s",
1857 met, VTY_NEWLINE);
1858 return CMD_ERR_AMBIGUOUS;
1859 }
1860
1861 /* RFC4444 */
1862 if (circuit->area && circuit->area->newmetric == 1 &&
1863 met > MAX_WIDE_LINK_METRIC)
1864 {
1865 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1866 "when wide metric type enabled%s",
1867 met, VTY_NEWLINE);
1868 return CMD_ERR_AMBIGUOUS;
1869 }
1870
1871 circuit->te_metric[0] = met;
1872 circuit->te_metric[1] = met;
1873
1874 circuit->metrics[0].metric_default = met;
1875 circuit->metrics[1].metric_default = met;
1876
1877 if (circuit->area)
1878 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
1879
1880 return CMD_SUCCESS;
1881 }
1882
1883 DEFUN (no_isis_metric,
1884 no_isis_metric_cmd,
1885 "no isis metric",
1886 NO_STR
1887 "IS-IS commands\n"
1888 "Set default metric for circuit\n")
1889 {
1890 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1891 if (!circuit)
1892 return CMD_ERR_NO_MATCH;
1893
1894 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
1895 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
1896 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
1897 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
1898
1899 if (circuit->area)
1900 lsp_regenerate_schedule (circuit->area, circuit->is_type, 0);
1901
1902 return CMD_SUCCESS;
1903 }
1904
1905 ALIAS (no_isis_metric,
1906 no_isis_metric_arg_cmd,
1907 "no isis metric <0-16777215>",
1908 NO_STR
1909 "IS-IS commands\n"
1910 "Set default metric for circuit\n"
1911 "Default metric value\n")
1912
1913 DEFUN (isis_metric_l1,
1914 isis_metric_l1_cmd,
1915 "isis metric <0-16777215> level-1",
1916 "IS-IS commands\n"
1917 "Set default metric for circuit\n"
1918 "Default metric value\n"
1919 "Specify metric for level-1 routing\n")
1920 {
1921 int met;
1922 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1923 if (!circuit)
1924 return CMD_ERR_NO_MATCH;
1925
1926 met = atoi (argv[0]);
1927
1928 /* RFC3787 section 5.1 */
1929 if (circuit->area && circuit->area->oldmetric == 1 &&
1930 met > MAX_NARROW_LINK_METRIC)
1931 {
1932 vty_out (vty, "Invalid metric %d - should be <0-63> "
1933 "when narrow metric type enabled%s",
1934 met, VTY_NEWLINE);
1935 return CMD_ERR_AMBIGUOUS;
1936 }
1937
1938 /* RFC4444 */
1939 if (circuit->area && circuit->area->newmetric == 1 &&
1940 met > MAX_WIDE_LINK_METRIC)
1941 {
1942 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
1943 "when wide metric type enabled%s",
1944 met, VTY_NEWLINE);
1945 return CMD_ERR_AMBIGUOUS;
1946 }
1947
1948 circuit->te_metric[0] = met;
1949 circuit->metrics[0].metric_default = met;
1950
1951 if (circuit->area)
1952 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
1953
1954 return CMD_SUCCESS;
1955 }
1956
1957 DEFUN (no_isis_metric_l1,
1958 no_isis_metric_l1_cmd,
1959 "no isis metric level-1",
1960 NO_STR
1961 "IS-IS commands\n"
1962 "Set default metric for circuit\n"
1963 "Specify metric for level-1 routing\n")
1964 {
1965 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1966 if (!circuit)
1967 return CMD_ERR_NO_MATCH;
1968
1969 circuit->te_metric[0] = DEFAULT_CIRCUIT_METRIC;
1970 circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRIC;
1971
1972 if (circuit->area)
1973 lsp_regenerate_schedule (circuit->area, IS_LEVEL_1, 0);
1974
1975 return CMD_SUCCESS;
1976 }
1977
1978 ALIAS (no_isis_metric_l1,
1979 no_isis_metric_l1_arg_cmd,
1980 "no isis metric <0-16777215> level-1",
1981 NO_STR
1982 "IS-IS commands\n"
1983 "Set default metric for circuit\n"
1984 "Default metric value\n"
1985 "Specify metric for level-1 routing\n")
1986
1987 DEFUN (isis_metric_l2,
1988 isis_metric_l2_cmd,
1989 "isis metric <0-16777215> level-2",
1990 "IS-IS commands\n"
1991 "Set default metric for circuit\n"
1992 "Default metric value\n"
1993 "Specify metric for level-2 routing\n")
1994 {
1995 int met;
1996 struct isis_circuit *circuit = isis_circuit_lookup (vty);
1997 if (!circuit)
1998 return CMD_ERR_NO_MATCH;
1999
2000 met = atoi (argv[0]);
2001
2002 /* RFC3787 section 5.1 */
2003 if (circuit->area && circuit->area->oldmetric == 1 &&
2004 met > MAX_NARROW_LINK_METRIC)
2005 {
2006 vty_out (vty, "Invalid metric %d - should be <0-63> "
2007 "when narrow metric type enabled%s",
2008 met, VTY_NEWLINE);
2009 return CMD_ERR_AMBIGUOUS;
2010 }
2011
2012 /* RFC4444 */
2013 if (circuit->area && circuit->area->newmetric == 1 &&
2014 met > MAX_WIDE_LINK_METRIC)
2015 {
2016 vty_out (vty, "Invalid metric %d - should be <0-16777215> "
2017 "when wide metric type enabled%s",
2018 met, VTY_NEWLINE);
2019 return CMD_ERR_AMBIGUOUS;
2020 }
2021
2022 circuit->te_metric[1] = met;
2023 circuit->metrics[1].metric_default = met;
2024
2025 if (circuit->area)
2026 lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
2027
2028 return CMD_SUCCESS;
2029 }
2030
2031 DEFUN (no_isis_metric_l2,
2032 no_isis_metric_l2_cmd,
2033 "no isis metric level-2",
2034 NO_STR
2035 "IS-IS commands\n"
2036 "Set default metric for circuit\n"
2037 "Specify metric for level-2 routing\n")
2038 {
2039 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2040 if (!circuit)
2041 return CMD_ERR_NO_MATCH;
2042
2043 circuit->te_metric[1] = DEFAULT_CIRCUIT_METRIC;
2044 circuit->metrics[1].metric_default = DEFAULT_CIRCUIT_METRIC;
2045
2046 if (circuit->area)
2047 lsp_regenerate_schedule (circuit->area, IS_LEVEL_2, 0);
2048
2049 return CMD_SUCCESS;
2050 }
2051
2052 ALIAS (no_isis_metric_l2,
2053 no_isis_metric_l2_arg_cmd,
2054 "no isis metric <0-16777215> level-2",
2055 NO_STR
2056 "IS-IS commands\n"
2057 "Set default metric for circuit\n"
2058 "Default metric value\n"
2059 "Specify metric for level-2 routing\n")
2060 /* end of metrics */
2061
2062 DEFUN (isis_hello_interval,
2063 isis_hello_interval_cmd,
2064 "isis hello-interval <1-600>",
2065 "IS-IS commands\n"
2066 "Set Hello interval\n"
2067 "Hello interval value\n"
2068 "Holdtime 1 seconds, interval depends on multiplier\n")
2069 {
2070 int interval;
2071 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2072 if (!circuit)
2073 return CMD_ERR_NO_MATCH;
2074
2075 interval = atoi (argv[0]);
2076 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
2077 {
2078 vty_out (vty, "Invalid hello-interval %d - should be <1-600>%s",
2079 interval, VTY_NEWLINE);
2080 return CMD_ERR_AMBIGUOUS;
2081 }
2082
2083 circuit->hello_interval[0] = (u_int16_t) interval;
2084 circuit->hello_interval[1] = (u_int16_t) interval;
2085
2086 return CMD_SUCCESS;
2087 }
2088
2089 DEFUN (no_isis_hello_interval,
2090 no_isis_hello_interval_cmd,
2091 "no isis hello-interval",
2092 NO_STR
2093 "IS-IS commands\n"
2094 "Set Hello interval\n")
2095 {
2096 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2097 if (!circuit)
2098 return CMD_ERR_NO_MATCH;
2099
2100 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
2101 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
2102
2103 return CMD_SUCCESS;
2104 }
2105
2106 ALIAS (no_isis_hello_interval,
2107 no_isis_hello_interval_arg_cmd,
2108 "no isis hello-interval <1-600>",
2109 NO_STR
2110 "IS-IS commands\n"
2111 "Set Hello interval\n"
2112 "Hello interval value\n"
2113 "Holdtime 1 second, interval depends on multiplier\n")
2114
2115 DEFUN (isis_hello_interval_l1,
2116 isis_hello_interval_l1_cmd,
2117 "isis hello-interval <1-600> level-1",
2118 "IS-IS commands\n"
2119 "Set Hello interval\n"
2120 "Hello interval value\n"
2121 "Holdtime 1 second, interval depends on multiplier\n"
2122 "Specify hello-interval for level-1 IIHs\n")
2123 {
2124 long interval;
2125 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2126 if (!circuit)
2127 return CMD_ERR_NO_MATCH;
2128
2129 interval = atoi (argv[0]);
2130 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
2131 {
2132 vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
2133 interval, VTY_NEWLINE);
2134 return CMD_ERR_AMBIGUOUS;
2135 }
2136
2137 circuit->hello_interval[0] = (u_int16_t) interval;
2138
2139 return CMD_SUCCESS;
2140 }
2141
2142 DEFUN (no_isis_hello_interval_l1,
2143 no_isis_hello_interval_l1_cmd,
2144 "no isis hello-interval level-1",
2145 NO_STR
2146 "IS-IS commands\n"
2147 "Set Hello interval\n"
2148 "Specify hello-interval for level-1 IIHs\n")
2149 {
2150 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2151 if (!circuit)
2152 return CMD_ERR_NO_MATCH;
2153
2154 circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL;
2155
2156 return CMD_SUCCESS;
2157 }
2158
2159 ALIAS (no_isis_hello_interval_l1,
2160 no_isis_hello_interval_l1_arg_cmd,
2161 "no isis hello-interval <1-600> level-1",
2162 NO_STR
2163 "IS-IS commands\n"
2164 "Set Hello interval\n"
2165 "Hello interval value\n"
2166 "Holdtime 1 second, interval depends on multiplier\n"
2167 "Specify hello-interval for level-1 IIHs\n")
2168
2169 DEFUN (isis_hello_interval_l2,
2170 isis_hello_interval_l2_cmd,
2171 "isis hello-interval <1-600> level-2",
2172 "IS-IS commands\n"
2173 "Set Hello interval\n"
2174 "Hello interval value\n"
2175 "Holdtime 1 second, interval depends on multiplier\n"
2176 "Specify hello-interval for level-2 IIHs\n")
2177 {
2178 long interval;
2179 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2180 if (!circuit)
2181 return CMD_ERR_NO_MATCH;
2182
2183 interval = atoi (argv[0]);
2184 if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL)
2185 {
2186 vty_out (vty, "Invalid hello-interval %ld - should be <1-600>%s",
2187 interval, VTY_NEWLINE);
2188 return CMD_ERR_AMBIGUOUS;
2189 }
2190
2191 circuit->hello_interval[1] = (u_int16_t) interval;
2192
2193 return CMD_SUCCESS;
2194 }
2195
2196 DEFUN (no_isis_hello_interval_l2,
2197 no_isis_hello_interval_l2_cmd,
2198 "no isis hello-interval level-2",
2199 NO_STR
2200 "IS-IS commands\n"
2201 "Set Hello interval\n"
2202 "Specify hello-interval for level-2 IIHs\n")
2203 {
2204 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2205 if (!circuit)
2206 return CMD_ERR_NO_MATCH;
2207
2208 circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL;
2209
2210 return CMD_SUCCESS;
2211 }
2212
2213 ALIAS (no_isis_hello_interval_l2,
2214 no_isis_hello_interval_l2_arg_cmd,
2215 "no isis hello-interval <1-600> level-2",
2216 NO_STR
2217 "IS-IS commands\n"
2218 "Set Hello interval\n"
2219 "Hello interval value\n"
2220 "Holdtime 1 second, interval depends on multiplier\n"
2221 "Specify hello-interval for level-2 IIHs\n")
2222
2223 DEFUN (isis_hello_multiplier,
2224 isis_hello_multiplier_cmd,
2225 "isis hello-multiplier <2-100>",
2226 "IS-IS commands\n"
2227 "Set multiplier for Hello holding time\n"
2228 "Hello multiplier value\n")
2229 {
2230 int mult;
2231 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2232 if (!circuit)
2233 return CMD_ERR_NO_MATCH;
2234
2235 mult = atoi (argv[0]);
2236 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2237 {
2238 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2239 mult, VTY_NEWLINE);
2240 return CMD_ERR_AMBIGUOUS;
2241 }
2242
2243 circuit->hello_multiplier[0] = (u_int16_t) mult;
2244 circuit->hello_multiplier[1] = (u_int16_t) mult;
2245
2246 return CMD_SUCCESS;
2247 }
2248
2249 DEFUN (no_isis_hello_multiplier,
2250 no_isis_hello_multiplier_cmd,
2251 "no isis hello-multiplier",
2252 NO_STR
2253 "IS-IS commands\n"
2254 "Set multiplier for Hello holding time\n")
2255 {
2256 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2257 if (!circuit)
2258 return CMD_ERR_NO_MATCH;
2259
2260 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
2261 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
2262
2263 return CMD_SUCCESS;
2264 }
2265
2266 ALIAS (no_isis_hello_multiplier,
2267 no_isis_hello_multiplier_arg_cmd,
2268 "no isis hello-multiplier <2-100>",
2269 NO_STR
2270 "IS-IS commands\n"
2271 "Set multiplier for Hello holding time\n"
2272 "Hello multiplier value\n")
2273
2274 DEFUN (isis_hello_multiplier_l1,
2275 isis_hello_multiplier_l1_cmd,
2276 "isis hello-multiplier <2-100> level-1",
2277 "IS-IS commands\n"
2278 "Set multiplier for Hello holding time\n"
2279 "Hello multiplier value\n"
2280 "Specify hello multiplier for level-1 IIHs\n")
2281 {
2282 int mult;
2283 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2284 if (!circuit)
2285 return CMD_ERR_NO_MATCH;
2286
2287 mult = atoi (argv[0]);
2288 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2289 {
2290 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2291 mult, VTY_NEWLINE);
2292 return CMD_ERR_AMBIGUOUS;
2293 }
2294
2295 circuit->hello_multiplier[0] = (u_int16_t) mult;
2296
2297 return CMD_SUCCESS;
2298 }
2299
2300 DEFUN (no_isis_hello_multiplier_l1,
2301 no_isis_hello_multiplier_l1_cmd,
2302 "no isis hello-multiplier level-1",
2303 NO_STR
2304 "IS-IS commands\n"
2305 "Set multiplier for Hello holding time\n"
2306 "Specify hello multiplier for level-1 IIHs\n")
2307 {
2308 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2309 if (!circuit)
2310 return CMD_ERR_NO_MATCH;
2311
2312 circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER;
2313
2314 return CMD_SUCCESS;
2315 }
2316
2317 ALIAS (no_isis_hello_multiplier_l1,
2318 no_isis_hello_multiplier_l1_arg_cmd,
2319 "no isis hello-multiplier <2-100> level-1",
2320 NO_STR
2321 "IS-IS commands\n"
2322 "Set multiplier for Hello holding time\n"
2323 "Hello multiplier value\n"
2324 "Specify hello multiplier for level-1 IIHs\n")
2325
2326 DEFUN (isis_hello_multiplier_l2,
2327 isis_hello_multiplier_l2_cmd,
2328 "isis hello-multiplier <2-100> level-2",
2329 "IS-IS commands\n"
2330 "Set multiplier for Hello holding time\n"
2331 "Hello multiplier value\n"
2332 "Specify hello multiplier for level-2 IIHs\n")
2333 {
2334 int mult;
2335 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2336 if (!circuit)
2337 return CMD_ERR_NO_MATCH;
2338
2339 mult = atoi (argv[0]);
2340 if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER)
2341 {
2342 vty_out (vty, "Invalid hello-multiplier %d - should be <2-100>%s",
2343 mult, VTY_NEWLINE);
2344 return CMD_ERR_AMBIGUOUS;
2345 }
2346
2347 circuit->hello_multiplier[1] = (u_int16_t) mult;
2348
2349 return CMD_SUCCESS;
2350 }
2351
2352 DEFUN (no_isis_hello_multiplier_l2,
2353 no_isis_hello_multiplier_l2_cmd,
2354 "no isis hello-multiplier level-2",
2355 NO_STR
2356 "IS-IS commands\n"
2357 "Set multiplier for Hello holding time\n"
2358 "Specify hello multiplier for level-2 IIHs\n")
2359 {
2360 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2361 if (!circuit)
2362 return CMD_ERR_NO_MATCH;
2363
2364 circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER;
2365
2366 return CMD_SUCCESS;
2367 }
2368
2369 ALIAS (no_isis_hello_multiplier_l2,
2370 no_isis_hello_multiplier_l2_arg_cmd,
2371 "no isis hello-multiplier <2-100> level-2",
2372 NO_STR
2373 "IS-IS commands\n"
2374 "Set multiplier for Hello holding time\n"
2375 "Hello multiplier value\n"
2376 "Specify hello multiplier for level-2 IIHs\n")
2377
2378 DEFUN (isis_hello_padding,
2379 isis_hello_padding_cmd,
2380 "isis hello padding",
2381 "IS-IS commands\n"
2382 "Add padding to IS-IS hello packets\n"
2383 "Pad hello packets\n"
2384 "<cr>\n")
2385 {
2386 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2387 if (!circuit)
2388 return CMD_ERR_NO_MATCH;
2389
2390 circuit->pad_hellos = 1;
2391
2392 return CMD_SUCCESS;
2393 }
2394
2395 DEFUN (no_isis_hello_padding,
2396 no_isis_hello_padding_cmd,
2397 "no isis hello padding",
2398 NO_STR
2399 "IS-IS commands\n"
2400 "Add padding to IS-IS hello packets\n"
2401 "Pad hello packets\n"
2402 "<cr>\n")
2403 {
2404 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2405 if (!circuit)
2406 return CMD_ERR_NO_MATCH;
2407
2408 circuit->pad_hellos = 0;
2409
2410 return CMD_SUCCESS;
2411 }
2412
2413 DEFUN (csnp_interval,
2414 csnp_interval_cmd,
2415 "isis csnp-interval <1-600>",
2416 "IS-IS commands\n"
2417 "Set CSNP interval in seconds\n"
2418 "CSNP interval value\n")
2419 {
2420 unsigned long interval;
2421 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2422 if (!circuit)
2423 return CMD_ERR_NO_MATCH;
2424
2425 interval = atol (argv[0]);
2426 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2427 {
2428 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2429 interval, VTY_NEWLINE);
2430 return CMD_ERR_AMBIGUOUS;
2431 }
2432
2433 circuit->csnp_interval[0] = (u_int16_t) interval;
2434 circuit->csnp_interval[1] = (u_int16_t) interval;
2435
2436 return CMD_SUCCESS;
2437 }
2438
2439 DEFUN (no_csnp_interval,
2440 no_csnp_interval_cmd,
2441 "no isis csnp-interval",
2442 NO_STR
2443 "IS-IS commands\n"
2444 "Set CSNP interval in seconds\n")
2445 {
2446 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2447 if (!circuit)
2448 return CMD_ERR_NO_MATCH;
2449
2450 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
2451 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
2452
2453 return CMD_SUCCESS;
2454 }
2455
2456 ALIAS (no_csnp_interval,
2457 no_csnp_interval_arg_cmd,
2458 "no isis csnp-interval <1-600>",
2459 NO_STR
2460 "IS-IS commands\n"
2461 "Set CSNP interval in seconds\n"
2462 "CSNP interval value\n")
2463
2464 DEFUN (csnp_interval_l1,
2465 csnp_interval_l1_cmd,
2466 "isis csnp-interval <1-600> level-1",
2467 "IS-IS commands\n"
2468 "Set CSNP interval in seconds\n"
2469 "CSNP interval value\n"
2470 "Specify interval for level-1 CSNPs\n")
2471 {
2472 unsigned long interval;
2473 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2474 if (!circuit)
2475 return CMD_ERR_NO_MATCH;
2476
2477 interval = atol (argv[0]);
2478 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2479 {
2480 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2481 interval, VTY_NEWLINE);
2482 return CMD_ERR_AMBIGUOUS;
2483 }
2484
2485 circuit->csnp_interval[0] = (u_int16_t) interval;
2486
2487 return CMD_SUCCESS;
2488 }
2489
2490 DEFUN (no_csnp_interval_l1,
2491 no_csnp_interval_l1_cmd,
2492 "no isis csnp-interval level-1",
2493 NO_STR
2494 "IS-IS commands\n"
2495 "Set CSNP interval in seconds\n"
2496 "Specify interval for level-1 CSNPs\n")
2497 {
2498 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2499 if (!circuit)
2500 return CMD_ERR_NO_MATCH;
2501
2502 circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL;
2503
2504 return CMD_SUCCESS;
2505 }
2506
2507 ALIAS (no_csnp_interval_l1,
2508 no_csnp_interval_l1_arg_cmd,
2509 "no isis csnp-interval <1-600> level-1",
2510 NO_STR
2511 "IS-IS commands\n"
2512 "Set CSNP interval in seconds\n"
2513 "CSNP interval value\n"
2514 "Specify interval for level-1 CSNPs\n")
2515
2516 DEFUN (csnp_interval_l2,
2517 csnp_interval_l2_cmd,
2518 "isis csnp-interval <1-600> level-2",
2519 "IS-IS commands\n"
2520 "Set CSNP interval in seconds\n"
2521 "CSNP interval value\n"
2522 "Specify interval for level-2 CSNPs\n")
2523 {
2524 unsigned long interval;
2525 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2526 if (!circuit)
2527 return CMD_ERR_NO_MATCH;
2528
2529 interval = atol (argv[0]);
2530 if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL)
2531 {
2532 vty_out (vty, "Invalid csnp-interval %lu - should be <1-600>%s",
2533 interval, VTY_NEWLINE);
2534 return CMD_ERR_AMBIGUOUS;
2535 }
2536
2537 circuit->csnp_interval[1] = (u_int16_t) interval;
2538
2539 return CMD_SUCCESS;
2540 }
2541
2542 DEFUN (no_csnp_interval_l2,
2543 no_csnp_interval_l2_cmd,
2544 "no isis csnp-interval level-2",
2545 NO_STR
2546 "IS-IS commands\n"
2547 "Set CSNP interval in seconds\n"
2548 "Specify interval for level-2 CSNPs\n")
2549 {
2550 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2551 if (!circuit)
2552 return CMD_ERR_NO_MATCH;
2553
2554 circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL;
2555
2556 return CMD_SUCCESS;
2557 }
2558
2559 ALIAS (no_csnp_interval_l2,
2560 no_csnp_interval_l2_arg_cmd,
2561 "no isis csnp-interval <1-600> level-2",
2562 NO_STR
2563 "IS-IS commands\n"
2564 "Set CSNP interval in seconds\n"
2565 "CSNP interval value\n"
2566 "Specify interval for level-2 CSNPs\n")
2567
2568 DEFUN (psnp_interval,
2569 psnp_interval_cmd,
2570 "isis psnp-interval <1-120>",
2571 "IS-IS commands\n"
2572 "Set PSNP interval in seconds\n"
2573 "PSNP interval value\n")
2574 {
2575 unsigned long interval;
2576 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2577 if (!circuit)
2578 return CMD_ERR_NO_MATCH;
2579
2580 interval = atol (argv[0]);
2581 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2582 {
2583 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2584 interval, VTY_NEWLINE);
2585 return CMD_ERR_AMBIGUOUS;
2586 }
2587
2588 circuit->psnp_interval[0] = (u_int16_t) interval;
2589 circuit->psnp_interval[1] = (u_int16_t) interval;
2590
2591 return CMD_SUCCESS;
2592 }
2593
2594 DEFUN (no_psnp_interval,
2595 no_psnp_interval_cmd,
2596 "no isis psnp-interval",
2597 NO_STR
2598 "IS-IS commands\n"
2599 "Set PSNP interval in seconds\n")
2600 {
2601 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2602 if (!circuit)
2603 return CMD_ERR_NO_MATCH;
2604
2605 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
2606 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
2607
2608 return CMD_SUCCESS;
2609 }
2610
2611 ALIAS (no_psnp_interval,
2612 no_psnp_interval_arg_cmd,
2613 "no isis psnp-interval <1-120>",
2614 NO_STR
2615 "IS-IS commands\n"
2616 "Set PSNP interval in seconds\n"
2617 "PSNP interval value\n")
2618
2619 DEFUN (psnp_interval_l1,
2620 psnp_interval_l1_cmd,
2621 "isis psnp-interval <1-120> level-1",
2622 "IS-IS commands\n"
2623 "Set PSNP interval in seconds\n"
2624 "PSNP interval value\n"
2625 "Specify interval for level-1 PSNPs\n")
2626 {
2627 unsigned long interval;
2628 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2629 if (!circuit)
2630 return CMD_ERR_NO_MATCH;
2631
2632 interval = atol (argv[0]);
2633 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2634 {
2635 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2636 interval, VTY_NEWLINE);
2637 return CMD_ERR_AMBIGUOUS;
2638 }
2639
2640 circuit->psnp_interval[0] = (u_int16_t) interval;
2641
2642 return CMD_SUCCESS;
2643 }
2644
2645 DEFUN (no_psnp_interval_l1,
2646 no_psnp_interval_l1_cmd,
2647 "no isis psnp-interval level-1",
2648 NO_STR
2649 "IS-IS commands\n"
2650 "Set PSNP interval in seconds\n"
2651 "Specify interval for level-1 PSNPs\n")
2652 {
2653 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2654 if (!circuit)
2655 return CMD_ERR_NO_MATCH;
2656
2657 circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL;
2658
2659 return CMD_SUCCESS;
2660 }
2661
2662 ALIAS (no_psnp_interval_l1,
2663 no_psnp_interval_l1_arg_cmd,
2664 "no isis psnp-interval <1-120> level-1",
2665 NO_STR
2666 "IS-IS commands\n"
2667 "Set PSNP interval in seconds\n"
2668 "PSNP interval value\n"
2669 "Specify interval for level-1 PSNPs\n")
2670
2671 DEFUN (psnp_interval_l2,
2672 psnp_interval_l2_cmd,
2673 "isis psnp-interval <1-120> level-2",
2674 "IS-IS commands\n"
2675 "Set PSNP interval in seconds\n"
2676 "PSNP interval value\n"
2677 "Specify interval for level-2 PSNPs\n")
2678 {
2679 unsigned long interval;
2680 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2681 if (!circuit)
2682 return CMD_ERR_NO_MATCH;
2683
2684 interval = atol (argv[0]);
2685 if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL)
2686 {
2687 vty_out (vty, "Invalid psnp-interval %lu - should be <1-120>%s",
2688 interval, VTY_NEWLINE);
2689 return CMD_ERR_AMBIGUOUS;
2690 }
2691
2692 circuit->psnp_interval[1] = (u_int16_t) interval;
2693
2694 return CMD_SUCCESS;
2695 }
2696
2697 DEFUN (no_psnp_interval_l2,
2698 no_psnp_interval_l2_cmd,
2699 "no isis psnp-interval level-2",
2700 NO_STR
2701 "IS-IS commands\n"
2702 "Set PSNP interval in seconds\n"
2703 "Specify interval for level-2 PSNPs\n")
2704 {
2705 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2706 if (!circuit)
2707 return CMD_ERR_NO_MATCH;
2708
2709 circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL;
2710
2711 return CMD_SUCCESS;
2712 }
2713
2714 ALIAS (no_psnp_interval_l2,
2715 no_psnp_interval_l2_arg_cmd,
2716 "no isis psnp-interval <1-120> level-2",
2717 NO_STR
2718 "IS-IS commands\n"
2719 "Set PSNP interval in seconds\n"
2720 "PSNP interval value\n"
2721 "Specify interval for level-2 PSNPs\n")
2722
2723 struct cmd_node interface_node = {
2724 INTERFACE_NODE,
2725 "%s(config-if)# ",
2726 1,
2727 };
2728
2729 DEFUN (isis_network,
2730 isis_network_cmd,
2731 "isis network point-to-point",
2732 "IS-IS commands\n"
2733 "Set network type\n"
2734 "point-to-point network type\n")
2735 {
2736 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2737 if (!circuit)
2738 return CMD_ERR_NO_MATCH;
2739
2740 /* RFC5309 section 4 */
2741 if (circuit->circ_type == CIRCUIT_T_P2P)
2742 return CMD_SUCCESS;
2743
2744 if (circuit->state != C_STATE_UP)
2745 {
2746 circuit->circ_type = CIRCUIT_T_P2P;
2747 circuit->circ_type_config = CIRCUIT_T_P2P;
2748 }
2749 else
2750 {
2751 struct isis_area *area = circuit->area;
2752 if (!if_is_broadcast (circuit->interface))
2753 {
2754 vty_out (vty, "isis network point-to-point "
2755 "is valid only on broadcast interfaces%s",
2756 VTY_NEWLINE);
2757 return CMD_ERR_AMBIGUOUS;
2758 }
2759
2760 isis_csm_state_change (ISIS_DISABLE, circuit, area);
2761 circuit->circ_type = CIRCUIT_T_P2P;
2762 circuit->circ_type_config = CIRCUIT_T_P2P;
2763 isis_csm_state_change (ISIS_ENABLE, circuit, area);
2764 }
2765
2766 return CMD_SUCCESS;
2767 }
2768
2769 DEFUN (no_isis_network,
2770 no_isis_network_cmd,
2771 "no isis network point-to-point",
2772 NO_STR
2773 "IS-IS commands\n"
2774 "Set network type for circuit\n"
2775 "point-to-point network type\n")
2776 {
2777 struct isis_circuit *circuit = isis_circuit_lookup (vty);
2778 if (!circuit)
2779 return CMD_ERR_NO_MATCH;
2780
2781 /* RFC5309 section 4 */
2782 if (circuit->circ_type == CIRCUIT_T_BROADCAST)
2783 return CMD_SUCCESS;
2784
2785 if (circuit->state != C_STATE_UP)
2786 {
2787 circuit->circ_type = CIRCUIT_T_BROADCAST;
2788 circuit->circ_type_config = CIRCUIT_T_BROADCAST;
2789 }
2790 else
2791 {
2792 struct isis_area *area = circuit->area;
2793 if (circuit->interface &&
2794 !if_is_broadcast (circuit->interface))
2795 {
2796 vty_out (vty, "no isis network point-to-point "
2797 "is valid only on broadcast interfaces%s",
2798 VTY_NEWLINE);
2799 return CMD_ERR_AMBIGUOUS;
2800 }
2801
2802 isis_csm_state_change (ISIS_DISABLE, circuit, area);
2803 circuit->circ_type = CIRCUIT_T_BROADCAST;
2804 circuit->circ_type_config = CIRCUIT_T_BROADCAST;
2805 isis_csm_state_change (ISIS_ENABLE, circuit, area);
2806 }
2807
2808 return CMD_SUCCESS;
2809 }
2810
2811 int
2812 isis_if_new_hook (struct interface *ifp)
2813 {
2814 return 0;
2815 }
2816
2817 int
2818 isis_if_delete_hook (struct interface *ifp)
2819 {
2820 struct isis_circuit *circuit;
2821 /* Clean up the circuit data */
2822 if (ifp && ifp->info)
2823 {
2824 circuit = ifp->info;
2825 isis_csm_state_change (IF_DOWN_FROM_Z, circuit, circuit->area);
2826 isis_csm_state_change (ISIS_DISABLE, circuit, circuit->area);
2827 }
2828
2829 return 0;
2830 }
2831
2832 void
2833 isis_circuit_init ()
2834 {
2835 /* Initialize Zebra interface data structure */
2836 if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
2837 if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
2838
2839 /* Install interface node */
2840 install_node (&interface_node, isis_interface_config_write);
2841 install_element (CONFIG_NODE, &interface_cmd);
2842 install_element (CONFIG_NODE, &no_interface_cmd);
2843
2844 install_default (INTERFACE_NODE);
2845 install_element (INTERFACE_NODE, &interface_desc_cmd);
2846 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
2847
2848 install_element (INTERFACE_NODE, &ip_router_isis_cmd);
2849 install_element (INTERFACE_NODE, &no_ip_router_isis_cmd);
2850
2851 install_element (INTERFACE_NODE, &isis_passive_cmd);
2852 install_element (INTERFACE_NODE, &no_isis_passive_cmd);
2853
2854 install_element (INTERFACE_NODE, &isis_circuit_type_cmd);
2855 install_element (INTERFACE_NODE, &no_isis_circuit_type_cmd);
2856
2857 install_element (INTERFACE_NODE, &isis_passwd_clear_cmd);
2858 install_element (INTERFACE_NODE, &isis_passwd_md5_cmd);
2859 install_element (INTERFACE_NODE, &no_isis_passwd_cmd);
2860
2861 install_element (INTERFACE_NODE, &isis_priority_cmd);
2862 install_element (INTERFACE_NODE, &no_isis_priority_cmd);
2863 install_element (INTERFACE_NODE, &no_isis_priority_arg_cmd);
2864 install_element (INTERFACE_NODE, &isis_priority_l1_cmd);
2865 install_element (INTERFACE_NODE, &no_isis_priority_l1_cmd);
2866 install_element (INTERFACE_NODE, &no_isis_priority_l1_arg_cmd);
2867 install_element (INTERFACE_NODE, &isis_priority_l2_cmd);
2868 install_element (INTERFACE_NODE, &no_isis_priority_l2_cmd);
2869 install_element (INTERFACE_NODE, &no_isis_priority_l2_arg_cmd);
2870
2871 install_element (INTERFACE_NODE, &isis_metric_cmd);
2872 install_element (INTERFACE_NODE, &no_isis_metric_cmd);
2873 install_element (INTERFACE_NODE, &no_isis_metric_arg_cmd);
2874 install_element (INTERFACE_NODE, &isis_metric_l1_cmd);
2875 install_element (INTERFACE_NODE, &no_isis_metric_l1_cmd);
2876 install_element (INTERFACE_NODE, &no_isis_metric_l1_arg_cmd);
2877 install_element (INTERFACE_NODE, &isis_metric_l2_cmd);
2878 install_element (INTERFACE_NODE, &no_isis_metric_l2_cmd);
2879 install_element (INTERFACE_NODE, &no_isis_metric_l2_arg_cmd);
2880
2881 install_element (INTERFACE_NODE, &isis_hello_interval_cmd);
2882 install_element (INTERFACE_NODE, &no_isis_hello_interval_cmd);
2883 install_element (INTERFACE_NODE, &no_isis_hello_interval_arg_cmd);
2884 install_element (INTERFACE_NODE, &isis_hello_interval_l1_cmd);
2885 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_cmd);
2886 install_element (INTERFACE_NODE, &no_isis_hello_interval_l1_arg_cmd);
2887 install_element (INTERFACE_NODE, &isis_hello_interval_l2_cmd);
2888 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_cmd);
2889 install_element (INTERFACE_NODE, &no_isis_hello_interval_l2_arg_cmd);
2890
2891 install_element (INTERFACE_NODE, &isis_hello_multiplier_cmd);
2892 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2893 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_arg_cmd);
2894 install_element (INTERFACE_NODE, &isis_hello_multiplier_l1_cmd);
2895 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd);
2896 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l1_arg_cmd);
2897 install_element (INTERFACE_NODE, &isis_hello_multiplier_l2_cmd);
2898 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd);
2899 install_element (INTERFACE_NODE, &no_isis_hello_multiplier_l2_arg_cmd);
2900
2901 install_element (INTERFACE_NODE, &isis_hello_padding_cmd);
2902 install_element (INTERFACE_NODE, &no_isis_hello_padding_cmd);
2903
2904 install_element (INTERFACE_NODE, &csnp_interval_cmd);
2905 install_element (INTERFACE_NODE, &no_csnp_interval_cmd);
2906 install_element (INTERFACE_NODE, &no_csnp_interval_arg_cmd);
2907 install_element (INTERFACE_NODE, &csnp_interval_l1_cmd);
2908 install_element (INTERFACE_NODE, &no_csnp_interval_l1_cmd);
2909 install_element (INTERFACE_NODE, &no_csnp_interval_l1_arg_cmd);
2910 install_element (INTERFACE_NODE, &csnp_interval_l2_cmd);
2911 install_element (INTERFACE_NODE, &no_csnp_interval_l2_cmd);
2912 install_element (INTERFACE_NODE, &no_csnp_interval_l2_arg_cmd);
2913
2914 install_element (INTERFACE_NODE, &psnp_interval_cmd);
2915 install_element (INTERFACE_NODE, &no_psnp_interval_cmd);
2916 install_element (INTERFACE_NODE, &no_psnp_interval_arg_cmd);
2917 install_element (INTERFACE_NODE, &psnp_interval_l1_cmd);
2918 install_element (INTERFACE_NODE, &no_psnp_interval_l1_cmd);
2919 install_element (INTERFACE_NODE, &no_psnp_interval_l1_arg_cmd);
2920 install_element (INTERFACE_NODE, &psnp_interval_l2_cmd);
2921 install_element (INTERFACE_NODE, &no_psnp_interval_l2_cmd);
2922 install_element (INTERFACE_NODE, &no_psnp_interval_l2_arg_cmd);
2923
2924 install_element (INTERFACE_NODE, &isis_network_cmd);
2925 install_element (INTERFACE_NODE, &no_isis_network_cmd);
2926
2927 #ifdef HAVE_IPV6
2928 install_element (INTERFACE_NODE, &ipv6_router_isis_cmd);
2929 install_element (INTERFACE_NODE, &no_ipv6_router_isis_cmd);
2930 #endif
2931 }