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