forked from Quagga/quagga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisis_circuit.c
2114 lines (1821 loc) · 49.7 KB
/
isis_circuit.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* IS-IS Rout(e)ing protocol - isis_circuit.h
*
* Copyright (C) 2001,2002 Sampo Saaristo
* Tampere University of Technology
* Institute of Communications Engineering
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public Licenseas published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <zebra.h>
#ifdef GNU_LINUX
#include <net/ethernet.h>
#else
#include <netinet/if_ether.h>
#endif
#include "log.h"
#include "memory.h"
#include "if.h"
#include "linklist.h"
#include "command.h"
#include "thread.h"
#include "hash.h"
#include "prefix.h"
#include "stream.h"
#include "isisd/dict.h"
#include "isisd/include-netbsd/iso.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_common.h"
#include "isisd/isis_circuit.h"
#include "isisd/isis_tlv.h"
#include "isisd/isis_lsp.h"
#include "isisd/isis_pdu.h"
#include "isisd/isis_network.h"
#include "isisd/isis_misc.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_adjacency.h"
#include "isisd/isis_dr.h"
#include "isisd/isis_flags.h"
#include "isisd/isisd.h"
#include "isisd/isis_csm.h"
#include "isisd/isis_events.h"
extern struct thread_master *master;
extern struct isis *isis;
struct isis_circuit *
isis_circuit_new ()
{
struct isis_circuit *circuit;
int i;
circuit = XCALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
if (circuit)
{
/* set default metrics for circuit */
for (i = 0; i < 2; i++)
{
circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS;
circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
circuit->te_metric[i] = DEFAULT_CIRCUIT_METRICS;
}
}
else
{
zlog_err ("Can't malloc isis circuit");
return NULL;
}
return circuit;
}
void
isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
{
int i;
circuit->area = area;
/*
* The level for the circuit is same as for the area, unless configured
* otherwise.
*/
circuit->circuit_is_type = area->is_type;
/*
* Default values
*/
for (i = 0; i < 2; i++)
{
circuit->hello_interval[i] = HELLO_INTERVAL;
circuit->hello_multiplier[i] = HELLO_MULTIPLIER;
circuit->csnp_interval[i] = CSNP_INTERVAL;
circuit->psnp_interval[i] = PSNP_INTERVAL;
circuit->u.bc.priority[i] = DEFAULT_PRIORITY;
}
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
circuit->u.bc.adjdb[0] = list_new ();
circuit->u.bc.adjdb[1] = list_new ();
circuit->u.bc.pad_hellos = 1;
}
circuit->lsp_interval = LSP_INTERVAL;
/*
* Add the circuit into area
*/
listnode_add (area->circuit_list, circuit);
circuit->idx = flags_get_index (&area->flags);
circuit->lsp_queue = list_new ();
return;
}
void
isis_circuit_deconfigure (struct isis_circuit *circuit,
struct isis_area *area)
{
/* Remove circuit from area */
listnode_delete (area->circuit_list, circuit);
/* Free the index of SRM and SSN flags */
flags_free_index (&area->flags, circuit->idx);
return;
}
struct isis_circuit *
circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
{
struct isis_circuit *circuit = NULL;
struct listnode *node;
if (!list)
return NULL;
for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
if (circuit->interface == ifp)
return circuit;
return NULL;
}
struct isis_circuit *
circuit_scan_by_ifp (struct interface *ifp)
{
struct isis_area *area;
struct listnode *node;
struct isis_circuit *circuit;
if (!isis->area_list)
return NULL;
for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
{
circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
if (circuit)
return circuit;
}
return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
}
void
isis_circuit_del (struct isis_circuit *circuit)
{
if (!circuit)
return;
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
/* destroy adjacency databases */
if (circuit->u.bc.adjdb[0])
list_delete (circuit->u.bc.adjdb[0]);
if (circuit->u.bc.adjdb[1])
list_delete (circuit->u.bc.adjdb[1]);
/* destroy neighbour lists */
if (circuit->u.bc.lan_neighs[0])
list_delete (circuit->u.bc.lan_neighs[0]);
if (circuit->u.bc.lan_neighs[1])
list_delete (circuit->u.bc.lan_neighs[1]);
/* destroy addresses */
}
if (circuit->ip_addrs)
list_delete (circuit->ip_addrs);
#ifdef HAVE_IPV6
if (circuit->ipv6_link)
list_delete (circuit->ipv6_link);
if (circuit->ipv6_non_link)
list_delete (circuit->ipv6_non_link);
#endif /* HAVE_IPV6 */
/* and lastly the circuit itself */
XFREE (MTYPE_ISIS_CIRCUIT, circuit);
return;
}
void
isis_circuit_add_addr (struct isis_circuit *circuit,
struct connected *connected)
{
struct prefix_ipv4 *ipv4;
u_char buf[BUFSIZ];
#ifdef HAVE_IPV6
struct prefix_ipv6 *ipv6;
#endif /* HAVE_IPV6 */
if (!circuit->ip_addrs)
circuit->ip_addrs = list_new ();
#ifdef HAVE_IPV6
if (!circuit->ipv6_link)
circuit->ipv6_link = list_new ();
if (!circuit->ipv6_non_link)
circuit->ipv6_non_link = list_new ();
#endif /* HAVE_IPV6 */
memset (&buf, 0, BUFSIZ);
if (connected->address->family == AF_INET)
{
ipv4 = prefix_ipv4_new ();
ipv4->prefixlen = connected->address->prefixlen;
ipv4->prefix = connected->address->u.prefix4;
listnode_add (circuit->ip_addrs, ipv4);
if (circuit->area)
lsp_regenerate_schedule (circuit->area);
#ifdef EXTREME_DEBUG
prefix2str (connected->address, buf, BUFSIZ);
zlog_debug ("Added IP address %s to circuit %d", buf,
circuit->circuit_id);
#endif /* EXTREME_DEBUG */
}
#ifdef HAVE_IPV6
if (connected->address->family == AF_INET6)
{
ipv6 = prefix_ipv6_new ();
ipv6->prefixlen = connected->address->prefixlen;
ipv6->prefix = connected->address->u.prefix6;
if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
listnode_add (circuit->ipv6_link, ipv6);
else
listnode_add (circuit->ipv6_non_link, ipv6);
if (circuit->area)
lsp_regenerate_schedule (circuit->area);
#ifdef EXTREME_DEBUG
prefix2str (connected->address, buf, BUFSIZ);
zlog_debug ("Added IPv6 address %s to circuit %d", buf,
circuit->circuit_id);
#endif /* EXTREME_DEBUG */
}
#endif /* HAVE_IPV6 */
return;
}
void
isis_circuit_del_addr (struct isis_circuit *circuit,
struct connected *connected)
{
struct prefix_ipv4 *ipv4, *ip = NULL;
struct listnode *node;
int found = 0;
u_char buf[BUFSIZ];
#ifdef HAVE_IPV6
struct prefix_ipv6 *ipv6, *ip6 = NULL;
#endif /* HAVE_IPV6 */
memset (&buf, 0, BUFSIZ);
if (connected->address->family == AF_INET)
{
ipv4 = prefix_ipv4_new ();
ipv4->prefixlen = connected->address->prefixlen;
ipv4->prefix = connected->address->u.prefix4;
for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
break;
if (ip)
{
listnode_delete (circuit->ip_addrs, ip);
if (circuit->area)
lsp_regenerate_schedule (circuit->area);
}
else
{
prefix2str (connected->address, (char *)buf, BUFSIZ);
zlog_warn("Nonexitant ip address %s removal attempt from circuit \
%d", buf, circuit->circuit_id);
}
}
#ifdef HAVE_IPV6
if (connected->address->family == AF_INET6)
{
ipv6 = prefix_ipv6_new ();
ipv6->prefixlen = connected->address->prefixlen;
ipv6->prefix = connected->address->u.prefix6;
if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
{
for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
{
if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
break;
}
if (ip6)
{
listnode_delete (circuit->ipv6_link, ip6);
found = 1;
}
}
else
{
for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
{
if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
break;
}
if (ip6)
{
listnode_delete (circuit->ipv6_non_link, ip6);
found = 1;
}
}
if (!found)
{
prefix2str (connected->address, (char *)buf, BUFSIZ);
zlog_warn("Nonexitant ip address %s removal attempt from \
circuit %d", buf, circuit->circuit_id);
}
else
if (circuit->area)
lsp_regenerate_schedule (circuit->area);
}
#endif /* HAVE_IPV6 */
return;
}
void
isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
{
struct listnode *node, *nnode;
struct connected *conn;
circuit->interface = ifp;
ifp->info = circuit;
circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
/* isis_circuit_update_addrs (circuit, ifp); */
if (if_is_broadcast (ifp))
{
circuit->circ_type = CIRCUIT_T_BROADCAST;
/*
* Get the Hardware Address
*/
#ifdef HAVE_SOCKADDR_DL
if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
zlog_warn ("unsupported link layer");
else
memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
ETH_ALEN);
#else
if (circuit->interface->hw_addr_len != ETH_ALEN)
{
zlog_warn ("unsupported link layer");
}
else
{
memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
}
#ifdef EXTREME_DEGUG
zlog_debug ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
circuit->interface->ifindex, ISO_MTU (circuit),
snpa_print (circuit->u.bc.snpa));
#endif /* EXTREME_DEBUG */
#endif /* HAVE_SOCKADDR_DL */
}
else if (if_is_pointopoint (ifp))
{
circuit->circ_type = CIRCUIT_T_P2P;
}
else
{
/* It's normal in case of loopback etc. */
if (isis->debugs & DEBUG_EVENTS)
zlog_debug ("isis_circuit_if_add: unsupported media");
}
for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
isis_circuit_add_addr (circuit, conn);
return;
}
void
isis_circuit_update_params (struct isis_circuit *circuit,
struct interface *ifp)
{
assert (circuit);
if (circuit->circuit_id != ifp->ifindex)
{
zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
ifp->ifindex);
circuit->circuit_id = ifp->ifindex % 255;
}
/* FIXME: Why is this needed? shouldn't we compare to the area's mtu */
/* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig)
The areas MTU is the minimum of mtu's of circuits in the area
now we can't catch the change
if (circuit->mtu != ifp->mtu) {
zlog_warn ("changing circuit mtu %d->%d", circuit->mtu,
ifp->mtu);
circuit->mtu = ifp->mtu;
}
*/
/*
* Get the Hardware Address
*/
#ifdef HAVE_SOCKADDR_DL
if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
zlog_warn ("unsupported link layer");
else
memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN);
#else
if (circuit->interface->hw_addr_len != ETH_ALEN)
{
zlog_warn ("unsupported link layer");
}
else
{
if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN))
{
zlog_warn ("changing circuit snpa %s->%s",
snpa_print (circuit->u.bc.snpa),
snpa_print (circuit->interface->hw_addr));
}
}
#endif
if (if_is_broadcast (ifp))
{
circuit->circ_type = CIRCUIT_T_BROADCAST;
}
else if (if_is_pointopoint (ifp))
{
circuit->circ_type = CIRCUIT_T_P2P;
}
else
{
zlog_warn ("isis_circuit_update_params: unsupported media");
}
return;
}
void
isis_circuit_if_del (struct isis_circuit *circuit)
{
circuit->interface->info = NULL;
circuit->interface = NULL;
return;
}
void
isis_circuit_up (struct isis_circuit *circuit)
{
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
if (circuit->area->min_bcast_mtu == 0 ||
ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
circuit->area->min_bcast_mtu = ISO_MTU (circuit);
/*
* ISO 10589 - 8.4.1 Enabling of broadcast circuits
*/
/* initilizing the hello sending threads
* for a broadcast IF
*/
/* 8.4.1 a) commence sending of IIH PDUs */
if (circuit->circuit_is_type & IS_LEVEL_1)
{
thread_add_event (master, send_lan_l1_hello, circuit, 0);
circuit->u.bc.lan_neighs[0] = list_new ();
}
if (circuit->circuit_is_type & IS_LEVEL_2)
{
thread_add_event (master, send_lan_l2_hello, circuit, 0);
circuit->u.bc.lan_neighs[1] = list_new ();
}
/* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
/* 8.4.1 c) FIXME: listen for ESH PDUs */
/* 8.4.1 d) */
/* dr election will commence in... */
if (circuit->circuit_is_type & IS_LEVEL_1)
THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
circuit, 2 * circuit->hello_interval[0]);
if (circuit->circuit_is_type & IS_LEVEL_2)
THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
circuit, 2 * circuit->hello_interval[1]);
}
else
{
/* initializing the hello send threads
* for a ptp IF
*/
thread_add_event (master, send_p2p_hello, circuit, 0);
}
/* initializing PSNP timers */
if (circuit->circuit_is_type & IS_LEVEL_1)
{
THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
}
if (circuit->circuit_is_type & IS_LEVEL_2)
{
THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
}
/* initialize the circuit streams */
if (circuit->rcv_stream == NULL)
circuit->rcv_stream = stream_new (ISO_MTU (circuit));
if (circuit->snd_stream == NULL)
circuit->snd_stream = stream_new (ISO_MTU (circuit));
/* unified init for circuits */
isis_sock_init (circuit);
#ifdef GNU_LINUX
THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
circuit->fd);
#else
THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
circuit->fd);
#endif
return;
}
void
isis_circuit_down (struct isis_circuit *circuit)
{
/* Cancel all active threads -- FIXME: wrong place */
/* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
THREAD_OFF (circuit->t_read);
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
{
THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
}
else if (circuit->circ_type == CIRCUIT_T_P2P)
{
THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
}
/* close the socket */
close (circuit->fd);
return;
}
void
circuit_update_nlpids (struct isis_circuit *circuit)
{
circuit->nlpids.count = 0;
if (circuit->ip_router)
{
circuit->nlpids.nlpids[0] = NLPID_IP;
circuit->nlpids.count++;
}
#ifdef HAVE_IPV6
if (circuit->ipv6_router)
{
circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
circuit->nlpids.count++;
}
#endif /* HAVE_IPV6 */
return;
}
int
isis_interface_config_write (struct vty *vty)
{
int write = 0;
struct listnode *node, *node2;
struct interface *ifp;
struct isis_area *area;
struct isis_circuit *c;
int i;
for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
/* IF name */
vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
write++;
/* IF desc */
if (ifp->desc)
{
vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
write++;
}
/* ISIS Circuit */
for (ALL_LIST_ELEMENTS_RO (isis->area_list, node2, area))
{
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
if (c)
{
if (c->ip_router)
{
vty_out (vty, " ip router isis %s%s", area->area_tag,
VTY_NEWLINE);
write++;
}
#ifdef HAVE_IPV6
if (c->ipv6_router)
{
vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
VTY_NEWLINE);
write++;
}
#endif /* HAVE_IPV6 */
/* ISIS - circuit type */
if (c->circuit_is_type == IS_LEVEL_1)
{
vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
write++;
}
else
{
if (c->circuit_is_type == IS_LEVEL_2)
{
vty_out (vty, " isis circuit-type level-2-only%s",
VTY_NEWLINE);
write++;
}
}
/* ISIS - CSNP interval - FIXME: compare to cisco */
if (c->csnp_interval[0] == c->csnp_interval[1])
{
if (c->csnp_interval[0] != CSNP_INTERVAL)
{
vty_out (vty, " isis csnp-interval %d%s",
c->csnp_interval[0], VTY_NEWLINE);
write++;
}
}
else
{
for (i = 0; i < 2; i++)
{
if (c->csnp_interval[1] != CSNP_INTERVAL)
{
vty_out (vty, " isis csnp-interval %d level-%d%s",
c->csnp_interval[1], i + 1, VTY_NEWLINE);
write++;
}
}
}
/* ISIS - Hello padding - Defaults to true so only display if false */
if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
{
vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
write++;
}
/* ISIS - Hello interval - FIXME: compare to cisco */
if (c->hello_interval[0] == c->hello_interval[1])
{
if (c->hello_interval[0] != HELLO_INTERVAL)
{
vty_out (vty, " isis hello-interval %d%s",
c->hello_interval[0], VTY_NEWLINE);
write++;
}
}
else
{
for (i = 0; i < 2; i++)
{
if (c->hello_interval[i] != HELLO_INTERVAL)
{
if (c->hello_interval[i] == HELLO_MINIMAL)
{
vty_out (vty,
" isis hello-interval minimal level-%d%s",
i + 1, VTY_NEWLINE);
}
else
{
vty_out (vty, " isis hello-interval %d level-%d%s",
c->hello_interval[i], i + 1, VTY_NEWLINE);
}
write++;
}
}
}
/* ISIS - Hello Multiplier */
if (c->hello_multiplier[0] == c->hello_multiplier[1])
{
if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
{
vty_out (vty, " isis hello-multiplier %d%s",
c->hello_multiplier[0], VTY_NEWLINE);
write++;
}
}
else
{
for (i = 0; i < 2; i++)
{
if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
{
vty_out (vty, " isis hello-multiplier %d level-%d%s",
c->hello_multiplier[i], i + 1, VTY_NEWLINE);
write++;
}
}
}
/* ISIS - Priority */
if (c->circ_type == CIRCUIT_T_BROADCAST)
{
if (c->u.bc.priority[0] == c->u.bc.priority[1])
{
if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
{
vty_out (vty, " isis priority %d%s",
c->u.bc.priority[0], VTY_NEWLINE);
write++;
}
}
else
{
for (i = 0; i < 2; i++)
{
if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
{
vty_out (vty, " isis priority %d level-%d%s",
c->u.bc.priority[i], i + 1, VTY_NEWLINE);
write++;
}
}
}
}
/* ISIS - Metric */
if (c->te_metric[0] == c->te_metric[1])
{
if (c->te_metric[0] != DEFAULT_CIRCUIT_METRICS)
{
vty_out (vty, " isis metric %d%s", c->te_metric[0],
VTY_NEWLINE);
write++;
}
}
else
{
for (i = 0; i < 2; i++)
{
if (c->te_metric[i] != DEFAULT_CIRCUIT_METRICS)
{
vty_out (vty, " isis metric %d level-%d%s",
c->te_metric[i], i + 1, VTY_NEWLINE);
write++;
}
}
}
}
}
vty_out (vty, "!%s", VTY_NEWLINE);
}
return write;
}
DEFUN (ip_router_isis,
ip_router_isis_cmd,
"ip router isis WORD",
"Interface Internet Protocol config commands\n"
"IP router interface commands\n"
"IS-IS Routing for IP\n"
"Routing process tag\n")
{
struct isis_circuit *c;
struct interface *ifp;
struct isis_area *area;
ifp = (struct interface *) vty->index;
assert (ifp);
area = isis_area_lookup (argv[0]);
/* Prevent more than one circuit per interface */
if (area)
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
else
c = NULL;
if (c && (ifp->info != NULL))
{
#ifdef HAVE_IPV6
if (c->ipv6_router == 0)
{
#endif /* HAVE_IPV6 */
/* FIXME: Find the way to warn only vty users. */
/* vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE); */
return CMD_WARNING;
#ifdef HAVE_IPV6
}
#endif /* HAVE_IPV6 */
}
/* this is here for ciscopability */
if (!area)
{
/* FIXME: Find the way to warn only vty users. */
/* vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE); */
return CMD_WARNING;
}
if (!c)
{
c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
c = isis_csm_state_change (ISIS_ENABLE, c, area);
c->interface = ifp; /* this is automatic */
ifp->info = c; /* hardly related to the FSM */
}
if (!c)
return CMD_WARNING;
c->ip_router = 1;
area->ip_circuits++;
circuit_update_nlpids (c);
vty->node = INTERFACE_NODE;
return CMD_SUCCESS;
}
DEFUN (no_ip_router_isis,
no_ip_router_isis_cmd,
"no ip router isis WORD",
NO_STR
"Interface Internet Protocol config commands\n"
"IP router interface commands\n"
"IS-IS Routing for IP\n"
"Routing process tag\n")
{
struct isis_circuit *circuit = NULL;
struct interface *ifp;
struct isis_area *area;
struct listnode *node;
ifp = (struct interface *) vty->index;
assert (ifp);
area = isis_area_lookup (argv[0]);
if (!area)
{
vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
return CMD_WARNING;
}
for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit))
if (circuit->interface == ifp)
break;
if (!circuit)
{
vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
return CMD_WARNING;
}
circuit->ip_router = 0;
area->ip_circuits--;
#ifdef HAVE_IPV6
if (circuit->ipv6_router == 0)
#endif
isis_csm_state_change (ISIS_DISABLE, circuit, area);
return CMD_SUCCESS;
}
DEFUN (isis_circuit_type,
isis_circuit_type_cmd,
"isis circuit-type (level-1|level-1-2|level-2-only)",
"IS-IS commands\n"
"Configure circuit type for interface\n"
"Level-1 only adjacencies are formed\n"
"Level-1-2 adjacencies are formed\n"
"Level-2 only adjacencies are formed\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int circuit_t;
int is_type;
ifp = vty->index;
circuit = ifp->info;
/* UGLY - will remove l8r */
if (circuit == NULL)
{
return CMD_WARNING;
}
/* XXX what to do when ip_router_isis is not executed */
if (circuit->area == NULL)
return CMD_WARNING;
assert (circuit);
circuit_t = string2circuit_t ((u_char *)argv[0]);
if (!circuit_t)
{
vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
return CMD_SUCCESS;
}
is_type = circuit->area->is_type;
if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
isis_event_circuit_type_change (circuit, circuit_t);
else
{
vty_out (vty, "invalid circuit level for area %s.%s",
circuit->area->area_tag, VTY_NEWLINE);
}
return CMD_SUCCESS;
}
DEFUN (no_isis_circuit_type,
no_isis_circuit_type_cmd,
"no isis circuit-type (level-1|level-1-2|level-2-only)",
NO_STR
"IS-IS commands\n"
"Configure circuit type for interface\n"
"Level-1 only adjacencies are formed\n"
"Level-1-2 adjacencies are formed\n"
"Level-2 only adjacencies are formed\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
ifp = vty->index;
circuit = ifp->info;
if (circuit == NULL)
{
return CMD_WARNING;
}
assert (circuit);
/*
* Set the circuits level to its default value which is that of the area
*/
isis_event_circuit_type_change (circuit, circuit->area->is_type);
return CMD_SUCCESS;
}
DEFUN (isis_passwd,
isis_passwd_cmd,
"isis password WORD",
"IS-IS commands\n"