-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIxia_NetNgpfLdp.tcl
More file actions
1342 lines (1185 loc) · 40.5 KB
/
Ixia_NetNgpfLdp.tcl
File metadata and controls
1342 lines (1185 loc) · 40.5 KB
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
# Copyright (c) Ixia technologies 2010-2011, Inc.
# Release Version 1.3
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# Version 1.1.2.3
# 2. Add LSP class
# Version 1.2.4.34
# 3. Add reborn in Ldp.config
# Version 1.3.4.42
# 4. change inherit structure from emulation
class LdpSession {
inherit RouterNgpfEmulationObject
public variable handle
public variable version
public variable ldpInterface
constructor { port } {
global errNumber
set tag "body LdpSession::ctor [info script]"
Deputs "----- TAG: $tag -----"
set portObj [ GetObject $port ]
set handle ""
reborn
}
method reborn {} {
global errNumber
global rb_interface
set tag "body LdpSession::reborn [info script]"
set version "ipv4"
set ip_version $version
if { [ catch {
set hPort [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in LdpSession ctor"
}
#-- add interface and ldp protocol
set topoObjList [ixNet getL [ixNet getRoot] topology]
set vportList [ixNet getL [ixNet getRoot] vport]
if {[llength $topoObjList] != [llength $vportList]} {
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
foreach vport $vportList {
if {$vportObj != $vport && $vport == $hPort} {
set vportTopoList ""
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
lappend vportTopoList $vportObj
}
if {[string first $hPort $vportTopoList] == -1} {
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
ixNet commit
set deviceGroupObj [ixNet add $topoObj deviceGroup]
ixNet commit
ixNet setA $deviceGroupObj -multiplier 1
ixNet commit
set ethernetObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
set ipv4Obj [ixNet add $ethernetObj ipv4]
ixNet commit
set handle [ixNet add $ipv4Obj ldpBasicRouter]
ixNet commit
set handle [ ixNet remapIds $handle ]
}
}
}
break
}
}
if { [ llength $topoObjList ] == 0 } {
set topoObjList [ixNet getL [ixNet getRoot] topology]
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
ixNet commit
set deviceGroupObj [ixNet add $topoObj deviceGroup]
ixNet commit
ixNet setA $deviceGroupObj -multiplier 1
ixNet commit
set ethernetObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
set ipv4Obj [ixNet add $ethernetObj ipv4]
ixNet commit
set handle [ixNet add $ipv4Obj ldpBasicRouter]
ixNet commit
set handle [ ixNet remapIds $handle ]
} else {
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupList [ixNet getL $topoObj deviceGroup]
foreach deviceGroupObj $deviceGroupList {
set ethernetList [ixNet getL $deviceGroupObj ethernet]
foreach ethernetObj $ethernetList {
set ipv4Obj [ixNet getL $ethernetObj ipv4]
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if { [info exists ipv4Obj] && $ipv4Obj != "" && $ip_version == "ipv4" } {
set handle [ixNet getL $ipv4Obj ldpBasicRouter]
if {[llength $handle] != 0} {
set handle [ ixNet remapIds $handle ]
} else {
set handle [ixNet add $ipv4Obj ldpBasicRouter]
ixNet commit
set handle [ ixNet remapIds $handle ]
}
} else {
if { [info exists ipv6Obj] && $ipv6Obj != "" } {
set handle [ixNet getL $ipv6Obj ldpBasicRouterV6]
if {[llength $handle] != 0} {
set handle [ ixNet remapIds $handle ]
} else {
set handle [ixNet add $ipv6Obj ldpBasicRouterV6]
ixNet commit
set handle [ ixNet remapIds $handle ]
}
}
}
}
}
}
}
}
#Enable protocol
set ipPattern [ixNet getA [ixNet getA $handle -active] -pattern]
SetMultiValues $handle "-active" $ipPattern True
ixNet commit
#Retrive the interface
set rb_interface [GetDependentNgpfProtocolHandle $handle "ethernet"]
Deputs "rb_interface is: $rb_interface"
ixNet setA $handle -name $this
$this configure -handle $handle
$this configure -version $ip_version
set protocol ldp
ixNet commit
array set interface [ list ]
generate_interface
}
method establish_lsp { args } {}
method teardown_lsp { args } {}
method flapping_lsp { args } {}
method config { args } {}
method get_status {} {}
method get_stats {} {}
method generate_interface { args } {
set tag "body LdpSession::generate_interface [info script]"
Deputs "----- TAG: $tag -----"
global rb_interface
global hInt
foreach int $rb_interface {
if { [ ixNet getA $int -type ] == "routed" } {
continue
}
set ipObj [GetDependentNgpfProtocolHandle $handle ip]
if {[string first "ipv4" $ipObj] != -1} {
set ip_version "ipv4"
set hInt [ixNet getL $ipObj "ldpConnectedInterface"]
}
if {[string first "ipv6" $ipObj] != -1} {
set ip_version "ipv6"
set hInt [ixNet getL $ipObj "ldpv6ConnectedInterface"]
}
if { [llength $ipObj] != 0 } {
set ipPattern [ixNet getA [ixNet getA $hInt -active] -pattern]
SetMultiValues $hInt "-active" $ipPattern True
ixNet commit
set hInt [ ixNet remapIds $hInt ]
set interface($int) $hInt
}
}
$this configure -ldpInterface $hInt
Deputs "interface: [array get interface]"
}
}
body LdpSession::get_status {} {
set tag "body LdpSession::get_status [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "root $root"
set viewList [ixNet getL ::ixNet::OBJ-/statistics view]
if {[string first "LDP Per Port" $viewList] != -1 } {
set view {::ixNet::OBJ-/statistics/view:"LDP Per Port"}
getStatusView $view $hPort
}
if {[string first "LDPv6 Per Port" $viewList] != -1 } {
set view {::ixNet::OBJ-/statistics/view:"LDPv6 Per Port"}
getStatusView $view $hPort
}
}
proc getStatusView {view {hPort}} {
after 5000
set captionList [ ixNet getA $view/page -columnCaptions ]
Deputs "captionList $captionList"
set name_index [ lsearch -exact $captionList {Port} ]
set sessionUp_index [ lsearch -exact $captionList {Sessions Up} ]
set sessionFlap_index [ lsearch -exact $captionList {Session Flap} ]
set lspEg_index [ lsearch -exact $captionList {Established LSP Egress} ]
set lspIn_index [ lsearch -exact $captionList {Established LSP Ingress} ]
set mappingTx_index [ lsearch -exact $captionList {Label Mapping Tx} ]
set releaseTx_index [ lsearch -exact $captionList {Label Release Tx} ]
set releaseRx_index [ lsearch -exact $captionList {Label Release Rx} ]
set withdrawTx_index [ lsearch -exact $captionList {Label Withdraw Tx} ]
set withdrawRx_index [ lsearch -exact $captionList {Label Withdraw Rx} ]
set adjV4Count_index [ lsearch -exact $captionList {Established IPv4 Adjacency Count} ]
set adjV6Count_index [ lsearch -exact $captionList {Established IPv6 Adjacency Count} ]
set sessionUpV4_index [ lsearch -exact $captionList {IPv4 Sessions Up} ]
set sessionUpV6_index [ lsearch -exact $captionList {IPv6 Sessions Up} ]
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set portFound 0
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "port index:$name_index"
set rowPortName [ lindex $row $name_index ]
Deputs "row port name:$name_index"
set connectionInfo [ ixNet getA $hPort -connectionInfo ]
Deputs "connectionInfo :$connectionInfo"
set connectionStatus [ixNet getA $hPort -connectionStatus]
regexp -nocase {chassis=\"([0-9\.]+)\" card=\"([0-9\.]+)\" port=\"([0-9\.]+)\"} $connectionInfo match chassis card port
Deputs "chas:$chassis card:$card port:$port"
set portName ${chassis}/Card${card}/Port${port}
Deputs "filter name: $portName"
# 192.168.0.110/Card1/Port7
# 192.168.0.110/Card01/Port07
#regexp -nocase {([0-9\.]+)/Card([0-9\.]+)/Port([0-9\.]+)} $rowPortName match rchassis rcard rport
regexp -nocase {([0-9\.]+);([0-9\.]+);([0-9\.]+)} $connectionStatus match rchassis rcard rport
Deputs "rchass:$rchassis rcard:$rcard rport:$rport"
if { $card < 10 } {
set card 0$card
}
if { $port < 10 } {
set port 0$port
}
if {$chassis == $rchassis && $card == $rcard && $port == $rport} {
set portFound 1
break
}
}
set status "down"
if { $portFound } {
set sessionUp [ lindex $row $sessionUp_index ]
set sessionFlap [ lindex $row $sessionFlap_index ]
set lspEg [ lindex $row $lspEg_index ]
set lspIn [ lindex $row $lspIn_index ]
set mappingTx [ lindex $row $mappingTx_index ]
set releaseTx [ lindex $row $releaseTx_index ]
set releaseRx [ lindex $row $releaseRx_index ]
set withdrawTx [ lindex $row $withdrawTx_index ]
set withdrawRx [ lindex $row $withdrawRx_index ]
set adjV4Count [ lindex $row $adjV4Count_index ]
set adjV6Count [ lindex $row $adjV6Count_index ]
set sessionUpV4 [ lindex $row $sessionUpV4_index ]
set sessionUpV6 [ lindex $row $sessionUpV6_index ]
if { $sessionUp } {
set status "sessionUp"
}
if { $sessionFlap } {
set status "sessionFlap"
}
if { $lspEg } {
set status "lspEg"
}
if { $mappingTx } {
set status "mappingTx"
}
if { $releaseTx } {
set status "releaseTx"
}
if { $releaseRx } {
set status "releaseRx"
}
if { $withdrawTx } {
set status "withdrawTx"
}
if { $withdrawRx } {
set status "withdrawRx"
}
if { $adjV4Count } {
set status "adjV4Count"
}
if { $adjV6Count } {
set status "adjV6Count"
}
if { $sessionUpV4 } {
set status "sessionUpV4"
}
if { $sessionUpV6 } {
set status "sessionUpV6"
}
}
set ret [ GetStandardReturnHeader ]
set ret $ret[ GetStandardReturnBody "status" $status ]
return $ret
}
body LdpSession::get_stats {} {
set tag "body LdpSession::get_stats [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set viewList [ixNet getL ::ixNet::OBJ-/statistics view]
if {[string first "LDP Drill Down" $viewList] != -1 } {
set protocol "LDP"
set view [CreateNgpfProtocolView $protocol]
getStatsView $view $hPort
}
if {[string first "LDPv6 Drill Down" $viewList] != -1 } {
set protocol "LDPv6"
set view [CreateNgpfProtocolView $protocol]
getStatsView $view $hPort
}
}
proc getStatsView {view {hPort}} {
after 5000
set captionList [ ixNet getA $view/page -columnCaptions ]
Deputs "captionList $captionList"
set port_name [ lsearch -exact $captionList {Port} ]
set session_succ [ lsearch -exact $captionList {Sessions Up} ]
set flap [ lsearch -exact $captionList {Session Flap} ]
set ret [ GetStandardReturnHeader ]
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set portFound 0
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "port index:$port_name"
set rowPortName [ lindex $row $port_name ]
Deputs "row port name:$port_name"
set connectionInfo [ ixNet getA $hPort -connectionInfo ]
Deputs "connectionInfo :$connectionInfo"
set connectionStatus [ixNet getA $hPort -connectionStatus]
regexp -nocase {chassis=\"([0-9\.]+)\" card=\"([0-9\.]+)\" port=\"([0-9\.]+)\"} $connectionInfo match chassis card port
Deputs "chas:$chassis card:$card port:$port"
set portName ${chassis}/Card${card}/Port${port}
Deputs "filter name: $portName"
# 192.168.0.110/Card1/Port7
# 192.168.0.110/Card01/Port07
#regexp -nocase {([0-9\.]+)/Card([0-9\.]+)/Port([0-9\.]+)} $rowPortName match rchassis rcard rport
regexp -nocase {([0-9\.]+);([0-9\.]+);([0-9\.]+)} $connectionStatus match rchassis rcard rport
Deputs "rchass:$rchassis rcard:$rcard rport:$rport"
if { $card < 10 } {
set card 0$card
}
if { $port < 10 } {
set port 0$port
}
if {$chassis == $rchassis && $card == $rcard && $port == $rport} {
set portFound 1
break
}
}
set statsItem "session_succ"
set statsVal [ lindex $row $session_succ ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "flap"
set statsVal [ lindex $row $flap ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
Deputs "ret:$ret"
return $ret
}
body LdpSession::config { args } {
global errorInfo
global errNumber
global rb_interface
if { [ catch {
set hport [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in LdpSession ctor"
}
set tag "body LdpSession::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
set version "ipv4"
set ip_version $version
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-router_id {
set router_id $value
}
-egress_label {
set egress_label $value
}
-hello_interval {
set hello_interval $value
}
-bfd {
set bfd $value
}
-enable_graceful_restart {
set enable_graceful_restart $value
}
-hello_type {
set hello_type $value
}
-label_min {
set label_min $value
}
-keep_alive_interval {
set keep_alive_interval $value
}
-reconnect_time {
set reconnect_time $value
}
-recovery_time {
set recovery_time $value
}
-transport_tlv_mode {
set transport_tlv_mode $value
}
-lsp_type {
set lsp_type $value
}
-label_advertise_mode {
set label_advertise_mode $value
}
-ipv4_addr {
set ipv4_addr $value
}
-ipv4_prefix_len {
set ipv4_prefix_len $value
}
-ipv4_gw -
-dut_ip {
set ipv4_gw $value
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
if { $handle == "" } {
reborn
}
set topoObjList [ixNet getL [ixNet getRoot] topology]
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupObjList [ixNet getL $topoObj deviceGroup]
foreach deviceGroupObj $deviceGroupObjList {
set ethernetObj [ixNet getL $deviceGroupObj ethernet]
set ipv4Obj [ixNet getL $ethernetObj ipv4]
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if {[ llength $ipv4Obj ] != 0} {
if { [ info exists ipv4_addr ] } {
foreach int $rb_interface {
set ipv4_hdl [ixNet getL $int ipv4]
set ipPattern [ixNet getA [ixNet getA $ipv4_hdl -address] -pattern]
set ip_addr [GetMultiValues $ipv4_hdl "-address" $ipPattern]
if {[info exists ipv4_gw]} {
set ipPattern [ixNet getA [ixNet getA $ipv4_hdl -gatewayIp] -pattern]
set ip_gw [GetMultiValues $ipv4_hdl "-gatewayIp" $ipPattern]
if {$ip_addr == $ipv4_addr && $ipv4_gw == $ip_gw} {
set matched_int $int
break
}
} elseif {$ip_addr == $ipv4_addr} {
set matched_int $int
break
}
}
if {[info exists matched_int]} {
foreach int $rb_interface {
if {$matched_int == $int} {
continue
}
if { [info exists interface($int)] } {
set ipPattern [ixNet getA [ixNet getA $interface($int) -active] -pattern]
SetMultiValues $interface($int) "-active" $ipPattern False
}
}
set rb_interface $matched_int
ixNet commit
}
foreach int $rb_interface {
catch {
if { [info exists interface($int)] } {
set ipPattern [ixNet getA [ixNet getA $interface($int) -address] -pattern]
SetMultiValues $interface($int) "-address" $ipPattern $ipv4_addr
ixNet commit
}
}
}
}
if { [ info exists ipv4_prefix_len ] } {
foreach int $rb_interface {
catch {
if { [info exists interface($int)] } {
set pLen 24
if {$ipv4_prefix_len == "255.0.0.0"} {
set pLen 8
} elseif {$ipv4_prefix_len == "255.255.0.0"} {
set pLen 16
} elseif {$ipv4_prefix_len == "255.255.255.0"} {
set pLen 24
} else {
set pLen 32
}
set ipPattern [ixNet getA [ixNet getA $interface($int) -prefix] -pattern]
SetMultiValues $interface($int) "-prefix" $ipPattern $pLen
ixNet commit
}
}
}
}
if { [ info exists ipv4_gw ] } {
foreach int $rb_interface {
catch {
if { [info exists interface($int)] } {
set ipPattern [ixNet getA [ixNet getA $interface($int) -gateway] -pattern]
SetMultiValues $interface($int) "-gateway" $ipPattern $ipv4_gw
ixNet commit
}
}
}
}
}
if { [ info exists egress_label ] } {
puts "Not implemented"
}
if { [ info exists bfd ] } {
puts "Not implemented"
}
if { [ info exists hello_type ] } {
puts "Not implemented"
}
if { [ info exists label_min ] } {
puts "Not implemented"
}
if { [ info exists keep_alive_interval ] } {
set ipPattern [ixNet getA [ixNet getA $handle -keepAliveInterval] -pattern]
SetMultiValues $handle "-keepAliveInterval" $ipPattern $keep_alive_interval
}
if { [ info exists lsp_type ] } {
puts "Not implemented"
}
if { [ info exists router_id ] } {
set routeDataObj [ixNet getL $deviceGroupObj routerData]
set ipPattern [ixNet getA [ixNet getA $routeDataObj -routerId] -pattern]
SetMultiValues $routeDataObj "-routerId" $ipPattern $router_id
}
if { [ info exists enable_graceful_restart ] } {
set ipPattern [ixNet getA [ixNet getA $handle -enableGracefulRestart] -pattern]
SetMultiValues $handle "-enableGracefulRestart" $ipPattern $enable_graceful_restart
}
if { [ info exists reconnect_time ] } {
set ipPattern [ixNet getA [ixNet getA $handle -reconnectTime] -pattern]
SetMultiValues $handle "-reconnectTime" $ipPattern $reconnect_time
}
if { [ info exists recovery_time ] } {
set ipPattern [ixNet getA [ixNet getA $handle -recoveryTime] -pattern]
SetMultiValues $handle "-recoveryTime" $ipPattern $recovery_time
}
if { [ info exists label_advertise_mode ] } {
set label_advertise_mode [ string tolower $label_advertise_mode ]
switch $label_advertise_mode {
du {
set label_advertise_mode unsolicited
}
dod {
set label_advertise_mode ondemand
}
}
set ipPattern [ixNet getA [ixNet getA $ldpInterface -operationMode] -pattern]
SetMultiValues $ldpInterface "-operationMode" $ipPattern $label_advertise_mode
}
if { [ info exists hello_interval ] } {
set ipPattern [ixNet getA [ixNet getA $ldpInterface -basicHelloInterval] -pattern]
SetMultiValues $ldpInterface "-basicHelloInterval" $ipPattern $hello_interval
}
if { [ info exists transport_tlv_mode ] } {
set transport_tlv_mode [ string toupper $transport_tlv_mode ]
switch $transport_tlv_mode {
TRANSPORT_TLV_MODE_NONE {
set ipPattern [ixNet getA [ixNet getA $handle -sessionPreference] -pattern]
SetMultiValues $handle "-sessionPreference" $ipPattern any
}
TRANSPORT_TLV_MODE_TESTER_IP {
set ipPattern [ixNet getA [ixNet getA $handle -sessionPreference] -pattern]
SetMultiValues $handle "-sessionPreference" $ipPattern ipv4
set ipPattern [ixNet getA [ixNet getA $routeDataObj -routerId] -pattern]
set routerId [GetMultiValues $routeDataObj "-routerId" $ipPattern]
if {[ llength $ipv4Obj ] != 0} {
set ipPattern [ixNet getA [ixNet getA $ipv4_hdl -address] -pattern]
SetMultiValues $ipv4_hdl "-address" $ipPattern $routerId
}
}
TRANSPORT_TLV_MODE_ROUTER_ID {
set ipPattern [ixNet getA [ixNet getA $handle -sessionPreference] -pattern]
SetMultiValues $handle "-sessionPreference" $ipPattern ipv6
}
}
}
ixNet commit
}
}
}
ixNet exec applyOnTheFly ::ixNet::OBJ-/globals/topology
return [GetStandardReturnHeader]
}
body LdpSession::establish_lsp { args } {
global errorInfo
global errNumber
set tag "body LdpSession::establish_lsp [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-lsp {
set lsp $value
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
if { [ $lsp isa LdpLsp ] } {
eval $lsp establish_lsp
} else {
return [ GetErrorReturnHeader "Bad LSP object... $lsp" ]
}
return [GetStandardReturnHeader]
}
body LdpSession::teardown_lsp { args } {
global errorInfo
global errNumber
set tag "body LdpSession::teardown_lsp [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-lsp {
set lsp $value
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
if { [ $lsp isa LdpLsp ] } {
$lsp teardown_lsp
} else {
return [ GetErrorReturnHeader "Bad LSP object... $lsp" ]
}
return [GetStandardReturnHeader]
}
body LdpSession::flapping_lsp { args } {
global errorInfo
global errNumber
set tag "body LdpSession::flapping_lsp [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-lsp {
set lsp $value
}
-flap_times -
-flap_interval {
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
if { [ $lsp isa LdpLsp ] } {
eval $lsp flapping_lsp $args
} else {
return [ GetErrorReturnHeader "Bad LSP object... $lsp" ]
}
ixNet exec applyOnTheFly ::ixNet::OBJ-/globals/topology
return [GetStandardReturnHeader]
}
class LdpLsp {
inherit RouterNgpfEmulationObject
public variable hInt
method config { args } {}
method establish_lsp {} {}
method teardown_lsp {} {}
method flapping_lsp { args } {}
}
body LdpLsp::establish_lsp {} {
global hInt
set tag "body LdpLsp::establish_lsp [info script]"
Deputs "----- TAG: $tag -----"
foreach eachInterface $hInt {
ixNet setA [ixNet getA $eachInterface -active]/singleValue -value True
}
ixNet commit
}
body LdpLsp::teardown_lsp {} {
set tag "body LdpLsp::teardown_lsp [info script]"
global hInt
Deputs "----- TAG: $tag -----"
foreach eachInterface $hInt {
ixNet setA [ixNet getA $eachInterface -active]/singleValue -value False
}
ixNet commit
}
body LdpLsp::flapping_lsp { args } {
global errorInfo
global errNumber
set tag "body LdpLsp::flapping_lsp [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-flap_times {
set flap_times $value
}
-flap_interval {
set flap_interval $value
}
-lsp {
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
for { set index 0 } { $index < $flap_times } { incr index } {
teardown_lsp
after [ expr $flap_interval * 1000 ]
establish_lsp
after [ expr $flap_interval * 1000 ]
}
return [GetStandardReturnHeader]
}
class Ipv4PrefixLsp {
inherit LdpLsp
public variable ldpObj
#public variable version
public variable ipPoolObj
constructor { ldp } {
global errNumber
set tag "body Ipv4PrefixLsp::ctor [info script]"
Deputs "----- TAG: $tag -----"
set ldpObj $ldp
Deputs "value received at constructor is $ldp"
reborn
}
method reborn {} {
global errNumber
set tag "body Ipv4PrefixLsp::reborn [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
set hLdp [ $ldpObj cget -handle ]
set deviceGroupObj [GetDependentNgpfProtocolHandle $hLdp "deviceGroup"]
set ethernetObj [GetDependentNgpfProtocolHandle $hLdp "ethernet"]
set ipObj [GetDependentNgpfProtocolHandle $hLdp "ip"]
puts "******************************** deviceGroup obj is :: $deviceGroupObj"
set networkGroupObj [ixNet add $deviceGroupObj "networkGroup"]
ixNet commit
set networkGroupObj [ ixNet remapIds $networkGroupObj ]
if {[string first "ipv4" $ipObj] != -1} {
set ip_version "ipv4"
} else {
set ip_version "ipv6"
}
if { $ip_version == "ipv4" } {
set ipPoolObj [ixNet add $networkGroupObj "ipv4PrefixPools"]
ixNet commit
ixNet setM $ipPoolObj -addrStepSupported true -name "Basic\ IPv4\ Addresses\ 1"
ixNet setA $ipPoolObj/connector -connectedTo $hLdp
set connector [ixNet add $ipPoolObj connector]
ixNet setA $connector -connectedTo $hLdp
ixNet commit
set range [ixNet getL $ipPoolObj ldpFECProperty]
set ipPattern [ixNet getA [ixNet getA $range -active] -pattern]
SetMultiValues $range "-active" $ipPattern true
#ixNet setA [ixNet getA $range -active]/singleValue -value true
ixNet commit
set handle [ ixNet remapIds $range ]
} else {
set ipPoolObj [ixNet add $networkGroupObj "ipv6PrefixPools"]
ixNet commit
ixNet setM $ipPoolObj -addrStepSupported true -name "Basic\ IPv6\ Addresses\ 1"
#ixNet setA $ipPoolObj/connector -connectedTo $hLdp
ixNet commit
set connector [ixNet add $ipPoolObj connector]
ixNet setA $connector -connectedTo $hLdp
ixNet commit
set range [ixNet getL $ipPoolObj ldpIpv6FECProperty]
ixNet setA [ixNet getA $range -active]/singleValue -value true
ixNet commit
set handle [ ixNet remapIds $range ]
}
} ] } {
error "$errNumber(1) LDP Object in Ipv4PrefixLsp ctorn"
}
}
method config { args } {}
}
body Ipv4PrefixLsp::config { args } {
global errorInfo
global errNumber
#set pLen 24
set assinged_label 3
set fec_type LDP_FEC_TYPE_PREFIX
set tag "body Ipv4PrefixLsp::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
if { $handle == "" } {
reborn
}
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-route_block {
set route_block $value
}
-fec_type {
set fec_type $value
}
-assinged_label {
set assinged_label $value
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
if { [ info exists route_block ] } {
if { [ $route_block isa RouteBlock ] } {
set num [ $route_block cget -num ]
set start [ $route_block cget -start ]
set step [ $route_block cget -step ]
set prefix_len [ $route_block cget -prefix_len ]
set type [ $route_block cget -type ]
} else {
return [ GetErrorReturnHeader "Bad RouteBlock obj... $route_block" ]
}
} else {
return [ GetErrorReturnHeader "Missing madatory parameter... -route_block" ]
}
if { [ info exists num ] } {
set ipPattern [ixNet getA [ixNet getA $ipPoolObj -numberOfAddressesAsy] -pattern]
SetMultiValues $ipPoolObj "-numberOfAddressesAsy" $ipPattern $num
}
if { [ info exists start ] } {
set ipPattern [ixNet getA [ixNet getA $ipPoolObj -networkAddress] -pattern]
SetMultiValues $ipPoolObj "-networkAddress" $ipPattern $start
}
if { [ info exists step ] } {
puts "not implemented "
}
if { $prefix_len != "" } {
if {$type == "ipv4"} {
if {[string first "." $prefix_len] != -1} {
set pLen [SubnetToPrefixlenV4 $prefix_len]
} else {
set pLen $prefix_len
}
} else {
set pLen $prefix_len
}
set ipPattern [ixNet getA [ixNet getA $ipPoolObj -prefixLength] -pattern]
SetMultiValues $ipPoolObj "-prefixLength" $ipPattern $pLen
}
if { [ info exists assinged_label ] } {
set ipPattern [ixNet getA [ixNet getA $handle -labelValue] -pattern]
SetMultiValues $handle "-labelValue" $ipPattern $assinged_label
}
if { [ info exists fec_type ] } {
set fec_type [ string toupper $fec_type ]
switch $fec_type {
LDP_FEC_TYPE_PREFIX {
set pLen $prefix_len
}
LDP_FEC_TYPE_HOST_ADDR {
set pLen 32
}
}
set ipPattern [ixNet getA [ixNet getA $ipPoolObj -prefixLength] -pattern]
SetMultiValues $ipPoolObj "-prefixLength" $ipPattern $pLen
}
ixNet commit
ixNet exec applyOnTheFly ::ixNet::OBJ-/globals/topology
return [GetStandardReturnHeader]
}