forked from IxiaKeysight/FT2Classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FT2Classic.tcl
2640 lines (2358 loc) · 105 KB
/
FT2Classic.tcl
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
package provide Ixia 1.0
global env
source $env(IXIA_LIB)
source $env(ixTclNetwork)/pkgIndex.tcl
if {[info exists env(IxiaLibPath)]} {
set path $env(IxiaLibPath)
}
if {[info exist env(clear_stats)]} {
set apiData(clear_stats) $env(clear_stats)
}
namespace eval ixia {
set ::ixia::TclInterp [interp create classic]
interp eval $::ixia::TclInterp "package require Ixia"
package require IxTclNetwork
}
array set apiData {}
global env
global stream_name
set stream_name 1
if {[info exist env(ixnetwork_tcl_server)]} {
set apiData(tcl_server) $env(ixnetwork_tcl_server)
} else {
error "no tcl_server value given. please set it in env variable \"ixnetwork_tcl_server \""
}
proc debug_old {{s {}}} {
if ![info exists ::bp_skip] {
set ::bp_skip [list]
} elseif {[lsearch -exact $::bp_skip $s]>=0} return
if [catch {info level -1} who] {set who ::}
while 1 {
##puts -nonewline "$who/$s> "; flush stdout
#puts -nonewline "$s> "; flush stdout
gets stdin line
if {$line=="c"} {#puts "continuing.."; break}
if {$line=="i"} {set line "info locals"}
if {$line=="e"} {set line "exit 1"}
catch {uplevel 1 $line} res
#puts $res
}
}
proc expand_ipv6 {args} {
set ipAddress $args
if {[regexp -nocase {^([a-fA-F0-9]+)::([a-fA-F0-9]+)$} $ipAddress match m11 m12]} {
set ipAddress $m11:0:0:0:0:0:0:$m12
} elseif {[regexp -nocase {^([a-fA-F0-9]+):([a-fA-F0-9]+)::([a-fA-F0-9]+)$} $ipAddress match m1 m2 m3]} {
set ipAddress $m1:$m2:0:0:0:0:0:$m3
} elseif {[regexp -nocase {^([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+)::([a-fA-F0-9]+)$} $ipAddress match m1 m2 m3 m4]} {
set ipAddress $m1:$m2:$m3:0:0:0:0:$m4
} elseif {[regexp -nocase {^([a-fA-F0-9]+):([a-fA-F0-9]+)::([a-fA-F0-9]+):([a-fA-F0-9]+)$} $ipAddress match m1 m2 m3 m4]} {
set ipAddress $m1:$m2:0:0:0:0:$m3:$m4
} else {
set ipAddress $ipAddress
}
return $ipAddress
}
proc get_emulation_handle_ipv6 {ipAddress } {
#package require IxTclNetwork
set vports [interp eval $::ixia::TclInterp " ixNet getList [ixNet getRoot] vport "]
set handle_list ""
foreach vport_handle $vports {
set interfaces [interp eval $::ixia::TclInterp " ixNet getList $vport_handle interface"]
if {![string match $interfaces ""]} {
foreach intf $interfaces {
set val [catch {interp eval $::ixia::TclInterp " ixNet getA $intf/ipv6:1 -ip " } getIp]
if {[regexp -nocase {is null} $getIp match]} {
#puts "ip is null"
} else {
if {[string match $getIp [expand_ipv6 $ipAddress]]} {
#puts "appending handle $intf"
lappend handle_list $intf
}
}
}
}
set route_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/ospf router"]
if {![string match $route_handles ""]} {
foreach rthdl $route_handles {
set routeRanges_hdls [interp eval $::ixia::TclInterp " ixNet getL $rthdl routeRange"]
if {![string match $routeRanges_hdls ""]} {
foreach rtRangeHdl $routeRanges_hdls {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $rtRangeHdl -networkNumber"]
if {[string match $getIp [expand_ipv6 $ipAddress]]} {
lappend handle_list $rtRangeHdl
}
}
}
}
}
set route_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/isis router"]
if {![string match $route_handles ""]} {
foreach rthdl $route_handles {
set routeRanges_hdls [interp eval $::ixia::TclInterp " ixNet getL $rthdl routeRange"]
if {![string match $routeRanges_hdls ""]} {
foreach rtRangeHdl $routeRanges_hdls {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $rtRangeHdl -firstRoute"]
if {[string match $getIp [expand_ipv6 $ipAddress]]} {
lappend handle_list $rtRangeHdl
}
}
}
}
}
set route_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/bgp neighborRange"]
if {![string match $route_handles ""]} {
foreach rthdl $route_handles {
set routeRanges_hdls [interp eval $::ixia::TclInterp " ixNet getL $rthdl routeRange"]
if {![string match $routeRanges_hdls ""]} {
foreach rtRangeHdl $routeRanges_hdls {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $rtRangeHdl -networkAddress"]
if {[string match $getIp [expand_ipv6 $ipAddress]]} {
lappend handle_list $rtRangeHdl
}
}
}
}
}
}
return $handle_list
}
proc get_emulation_handle {ipAddress } {
#package require IxTclNetwork
set vports [interp eval $::ixia::TclInterp " ixNet getList [ixNet getRoot] vport "]
set handle_list ""
foreach vport_handle $vports {
set interfaces [interp eval $::ixia::TclInterp " ixNet getList $vport_handle interface"]
if {![string match $interfaces ""]} {
foreach intf $interfaces {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $intf/ipv4 -ip "]
if {[string match $getIp $ipAddress]} {
lappend handle_list $intf
}
}
}
set route_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/ospf router"]
if {![string match $route_handles ""]} {
foreach rthdl $route_handles {
set routeRanges_hdls [interp eval $::ixia::TclInterp " ixNet getL $rthdl routeRange"]
if {![string match $routeRanges_hdls ""]} {
foreach rtRangeHdl $routeRanges_hdls {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $rtRangeHdl -networkNumber"]
if {[string match $getIp $ipAddress]} {
lappend handle_list $rtRangeHdl
}
}
}
}
}
set route_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/isis router"]
if {![string match $route_handles ""]} {
foreach rthdl $route_handles {
set routeRanges_hdls [interp eval $::ixia::TclInterp " ixNet getL $rthdl routeRange"]
if {![string match $routeRanges_hdls ""]} {
foreach rtRangeHdl $routeRanges_hdls {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $rtRangeHdl -firstRoute"]
if {[string match $getIp $ipAddress]} {
#puts "getting handle"
lappend handle_list $rtRangeHdl
}
}
}
}
}
set route_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/bgp neighborRange"]
if {![string match $route_handles ""]} {
foreach rthdl $route_handles {
set routeRanges_hdls [interp eval $::ixia::TclInterp " ixNet getL $rthdl routeRange"]
if {![string match $routeRanges_hdls ""]} {
foreach rtRangeHdl $routeRanges_hdls {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $rtRangeHdl -networkAddress"]
if {[string match $getIp $ipAddress]} {
lappend handle_list $rtRangeHdl
}
}
}
}
}
set igmp_host_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/igmp host"]
if {![string match $igmp_host_handles ""]} {
foreach igmp_handle $igmp_host_handles {
set igmp_group_handles [interp eval $::ixia::TclInterp " ixNet getL $igmp_handle group"]
if {![string match $igmp_group_handles ""]} {
foreach igmp_group_handle $igmp_group_handles {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $igmp_group_handles -groupFrom"]
if {[string match $getIp $ipAddress]} {
lappend handle_list $igmp_group_handles
}
}
}
}
}
set igmp_querier_handles [interp eval $::ixia::TclInterp " ixNet getL $vport_handle/protocols/igmp querier"]
if {![string match $igmp_querier_handles ""]} {
foreach igmp_querier_handle $igmp_querier_handles {
set getIp [interp eval $::ixia::TclInterp " ixNet getA $igmp_querier_handle -querierAddress"]
if {[string match $getIp $ipAddress]} {
lappend handle_list $igmp_querier_handle
}
}
}
}
return $handle_list
}
proc mcastIPv6ToMac { mcastIP } {
set mcastMac 0000.0000.0000
set mcastIP [get_ipv6_full_add $mcastIP]
if { ![ regexp {([A-Z0-9]+):([A-Z0-9]+):([A-Z0-9]+):([A-Z0-9]+):([A-Z0-9]+):([A-Z0-9]+):([A-Z0-9]+):([A-Z0-9]+)} \
$mcastIP dump oct1 oct2 oct3 oct4 oct5 oct6 oct7 oct8] } {
puts "invalid ip format"
return $mcastMac
}
if { [expr 0x$oct1] < 65281 || [expr 0x$oct1] > 65535 } {
puts "invlaid mcast IPv6"
return $mcastMac
}
catch { unset mcastMac }
set oct7 [format "%04s" $oct7]
set oct8 [format "%04s" $oct8]
lappend mcastMac 3333 $oct7 $oct8
regsub -all { } $mcastMac {.} mcastMac
return $mcastMac
}
proc get_ipv6_full_add { add } {
set ipv6_split [split $add ":"]
set no_hex 1
foreach hex $ipv6_split {
if {$no_hex < 8 && $hex != ""} {
incr no_hex
append full_add "$hex:"
} elseif {$hex == ""} {
set empty_idx [lsearch $ipv6_split ""]
set length [llength $ipv6_split]
set rem_hex [expr [expr $length - $empty_idx] - 1]
for {set i $empty_idx} {$i < [expr 8-$rem_hex]} {incr i} {
incr no_hex
append full_add "0:"
}
if {$rem_hex == 1 && \
[lindex $ipv6_split [expr $length-1]] == ""} {
append full_add "0"
break
}
} else {
append full_add "$hex"
}
}
return $full_add
}
proc Parse_Dashed_Args {args} {
global apiData
set parse_args ""
regsub -all "^{|}$" $args "" args
set args [split $args " "]
for { set i 0 } { $i < [llength $args]} { incr i } {
set arg [lindex $args $i]
if {$arg != ""} {
set arg [string trim $arg]
switch -regexp -- $arg {
"-reset|-arp" {
if {[regexp -nocase "^-" [lindex $args [expr $i + 1]] match]} {
set $arg "1"
append parse_args " " "$arg 1"
} else {
append parse_args " " $arg
}
}
default {
append parse_args " " "$arg"
}
}
}
}
set parse_args [lsearch -all -inline -not -exact $parse_args {}]
set key ""
set val ""
foreach ele $parse_args {
if {[string equal $ele {}]} {
continue
}
if {[regexp -nocase "^-" $ele]} {
if {![string equal $key ""]} {
keylset apiData(parse_args) $key $val
set key ""
set val ""
}
}
if {[regexp -nocase "^-" $ele]} {
set key $ele
} else {
lappend val $ele
}
}
keylset apiData(parse_args) $key $val
return $parse_args
}
proc ::ixia::executeInChild {args} {
set api [lindex $args 0]
set args [lindex $args 1]
return [interp eval $::ixia::TclInterp "::ixia::$api $args"]
}
proc ::ixia::emulation_oam_config_msg {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
#Argument not supported in FT.This argument is Mandatory in Classic 'port_handle'
if {[lsearch $args "-port_handle"] == -1} {
error "Missing Mandatory Argument \"port_handle\""
}
set api "emulation_oam_config_msg $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::fc_client_global_config {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
set api "fc_client_global_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_rsvp_tunnel_config {args} {
set api "emulation_rsvp_tunnel_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_eigrp_config {args} {
set api "emulation_eigrp_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::uds_filter_pallette_config {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'port_handle'
if {[lsearch $args "-port_handle"] == -1} {
error "Missing Mandatory Argument \"port_handle\""
}
set api "uds_filter_pallette_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_stp_control {args} {
#Body { Arguments with no mandatory tag argument 'handle'}
#Body { Arguments with no mandatory tag argument 'mode'}
set api "emulation_stp_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_efm_config {args} {
set api "emulation_efm_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::interface_config {args} {
puts "inside wrapper ::ixia::interface_config"
global apiData
set args1 $args
Convert_List_To_Keyedlist $args1
#puts "inside wrapper ::ixia::interface_config"
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split3_width'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split3_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'integrity_signature'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pcs_marker_fields'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_byte_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split1_mask'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'signature_start_offset'}
#Argument not supported in FT.This argument is Mandatory in Classic 'port_handle'
if {[lsearch $args "-port_handle"] == -1} {
error "Missing Mandatory Argument \"port_handle\""
}
# #Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_stats'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split3_mask'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'rpr_hec_seed'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'signature_mask'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split2_width'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'tx_lanes'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_pattern_mask'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split3_offset_from'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'sequence_num_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'router_solicitation_retries'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'integrity_signature_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'signature_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pcs_period'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'signature'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_mask'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split2_offset_from'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pcs_sync_bits'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_pattern_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split1_offset_from'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'sequence_checking'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'bert_configuration'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split2_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pcs_period_type'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_packet_type'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_split2_mask'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_offset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pgid_128k_bin_enable'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pcs_repeat'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'bert_error_insertion'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'no_write'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'pcs_lane'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_pattern_match'}
if {[lsearch $args "-ipv4_prefix_length"] != -1} {
set ipv4_length [keylget apiData(expArgs) -ipv4_prefix_length]
set ipv4PrefixLength [ subnetmaskToCIDR $ipv4_length ]
keyldel apiData(expArgs) -ipv4_prefix_length
set args [Convert_Keyedlist_To_List $apiData(expArgs)]
lappend args -ipv4_prefix_length $ipv4PrefixLength
}
if {[lsearch $args "-signature"] != -1} {
keyldel apiData(expArgs) -signature
}
if {[lsearch $args "-signature_offset"] != -1} {
keyldel apiData(expArgs) -signature_offset
}
if {[lsearch $args "-pgid_mode"] != -1} {
set pgid_mode [keylget apiData(expArgs) -pgid_mode]
if {[string equal $pgid_mode "custom"]} {
keyldel apiData(expArgs) -pgid_mode
}
}
if {[lsearch $args "-pgid_offset"] != -1} {
set pgid_offset [keylget apiData(expArgs) -pgid_offset]
keyldel apiData(expArgs) -pgid_offset
}
set args [Convert_Keyedlist_To_List $apiData(expArgs)]
if {[lsearch $args "-gateway"] == -1} {
if {[lsearch $args "-intf_ip_addr"] != -1} {
set ipv4Address [keylget apiData(expArgs) -intf_ip_addr]
regexp -nocase {^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$} $ipv4Address match m1 m2 m3 m4
set m5 [expr $m4-1]
set gatewayIp $m1.$m2.$m3.$m5
lappend args -gateway $gatewayIp
}
}
if {[lsearch $args "-ipv6_gateway"] == -1} {
if {[lsearch $args "-ipv6_intf_addr"] != -1} {
set ipv6Address [keylget apiData(expArgs) -ipv6_intf_addr]
set ipv6 [expand_ipv6 $ipv6Address]
regexp -nocase {^([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+):([a-fA-F0-9]+)$} $ipv6 match m1 m2 m3 m4 m5 m6 m7 m8
if {$m8 == 1} {
set m9 [expr $m8+1]
set gatewayIp $m1:$m2:$m3:$m4:$m5:$m6:$m7:$m9
lappend args -ipv6_gateway $gatewayIp
} else {
set m9 [expr $m8-1]
set gatewayIp $m1:$m2:$m3:$m4:$m5:$m6:$m7:$m9
lappend args -ipv6_gateway $gatewayIp
}
}
}
if {[lsearch $args "-arp_send_req"] != -1} {
if {[lsearch $args "-arp"] == -1} {
lappend args -arp 1
}
if {[lsearch $args "-arp_on_linkup"] == -1} {
lappend args -arp_on_linkup 1
}
if {[lsearch $args "-arp_req_retries"] == -1} {
lappend args -arp_req_retries ""
}
if {[lsearch $args "-arp_refresh_interval"] == -1} {
lappend args -arp_refresh_interval 60
}
}
puts $args
set api "interface_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_cfm_links_config {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
set api "emulation_cfm_links_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_stp_bridge_config {args} {
#Body { Arguments with no mandatory tag argument 'auto_pick_bridge_mac'}
#Body { Arguments with no mandatory tag argument 'port_no_intf_step'}
#Body { Arguments with no mandatory tag argument 'cst_root_priority'}
#Body { Arguments with no mandatory tag argument 'jitter_percentage'}
#Body { Arguments with no mandatory tag argument 'cist_reg_root_mac'}
#Body { Arguments with no mandatory tag argument 'intf_ipv6_addr'}
#Body { Arguments with no mandatory tag argument 'cist_external_root_priority'}
#Body { Arguments with no mandatory tag argument 'intf_ip_addr_bridge_step'}
#Body { Arguments with no mandatory tag argument 'max_age'}
#Body { Arguments with no mandatory tag argument 'intf_count'}
#Body { Arguments with no mandatory tag argument 'auto_pick_port'}
#Body { Arguments with no mandatory tag argument 'override_tracking'}
#Body { Arguments with no mandatory tag argument 'root_priority'}
#Body { Arguments with no mandatory tag argument 'inter_bdpu_gap'}
#Body { Arguments with no mandatory tag argument 'vlan_user_priority'}
#Body { Arguments with no mandatory tag argument 'count'}
#Body { Arguments with no mandatory tag argument 'handle'}
#Body { Arguments with no mandatory tag argument 'bridge_mac_step'}
#Body { Arguments with no mandatory tag argument 'bridge_priority'}
#Body { Arguments with no mandatory tag argument 'cist_external_root_mac'}
#Body { Arguments with no mandatory tag argument 'port_priority'}
#Body { Arguments with no mandatory tag argument 'mstc_name'}
#Body { Arguments with no mandatory tag argument 'intf_ip_addr_step'}
#Body { Arguments with no mandatory tag argument 'bridge_msti_vlan'}
#Body { Arguments with no mandatory tag argument 'intf_ipv6_addr_bridge_step'}
#Body { Arguments with no mandatory tag argument 'mstc_revision'}
#Body { Arguments with no mandatory tag argument 'port_no'}
#Body { Arguments with no mandatory tag argument 'reset'}
#Body { Arguments with no mandatory tag argument 'mac_address_init'}
#Body { Arguments with no mandatory tag argument 'message_age'}
#Body { Arguments with no mandatory tag argument 'cist_remaining_hop'}
#Body { Arguments with no mandatory tag argument 'mtu'}
#Body { Arguments with no mandatory tag argument 'mode'}
#Body { Arguments with no mandatory tag argument 'cist_reg_root_cost'}
#Body { Arguments with no mandatory tag argument 'cist_external_root_cost'}
#Body { Arguments with no mandatory tag argument 'bridge_mac'}
#Body { Arguments with no mandatory tag argument 'intf_gw_ip_addr_step'}
#Body { Arguments with no mandatory tag argument 'override_existence_check'}
#Body { Arguments with no mandatory tag argument 'intf_ip_addr'}
#Body { Arguments with no mandatory tag argument 'port_no_bridge_step'}
#Body { Arguments with no mandatory tag argument 'hello_interval'}
#Body { Arguments with no mandatory tag argument 'cist_reg_root_priority'}
#Body { Arguments with no mandatory tag argument 'mac_address_bridge_step'}
#Body { Arguments with no mandatory tag argument 'intf_ipv6_addr_step'}
#Body { Arguments with no mandatory tag argument 'port_handle'}
#Body { Arguments with no mandatory tag argument 'bridge_system_id'}
#Body { Arguments with no mandatory tag argument 'root_cost'}
#Body { Arguments with no mandatory tag argument 'vlan_id'}
#Body { Arguments with no mandatory tag argument 'cst_root_path_cost'}
#Body { Arguments with no mandatory tag argument 'link_type'}
#Body { Arguments with no mandatory tag argument 'enable_jitter'}
#Body { Arguments with no mandatory tag argument 'root_mac'}
#Body { Arguments with no mandatory tag argument 'vlan_id_intf_step'}
#Body { Arguments with no mandatory tag argument 'cst_root_mac_address'}
#Body { Arguments with no mandatory tag argument 'root_system_id'}
#Body { Arguments with no mandatory tag argument 'vlan'}
#Body { Arguments with no mandatory tag argument 'intf_cost'}
#Body { Arguments with no mandatory tag argument 'cst_vlan_port_priority'}
#Body { Arguments with no mandatory tag argument 'intf_ip_prefix_length'}
#Body { Arguments with no mandatory tag argument 'vlan_id_bridge_step'}
#Body { Arguments with no mandatory tag argument 'intf_ipv6_prefix_length'}
#Body { Arguments with no mandatory tag argument 'intf_gw_ip_addr'}
#Body { Arguments with no mandatory tag argument 'interface_handle'}
#Body { Arguments with no mandatory tag argument 'pvid'}
#Body { Arguments with no mandatory tag argument 'mac_address_intf_step'}
#Body { Arguments with no mandatory tag argument 'intf_gw_ip_addr_bridge_step'}
#Body { Arguments with no mandatory tag argument 'vlan_user_priority_bridge_step'}
#Body { Arguments with no mandatory tag argument 'bridge_mode'}
#Body { Arguments with no mandatory tag argument 'forward_delay'}
set api "emulation_stp_bridge_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_cfm_custom_tlv_config {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
set api "emulation_cfm_custom_tlv_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_pbb_info {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
set api "emulation_pbb_info $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_igmp_info {args} {
set api "emulation_igmp_info $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::get_nodrop_rate {args} {
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'run_time_sec'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'stream_mode'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'min_percent'}
#Body { Need to fill equivalent logic in classic for FT Mandatory argument 'max_rate'}
#Body { Need to fill equivalent logic in classic for FT Mandatory argument 'rx_port_handle'}
#Body { Need to fill equivalent logic in classic for FT Mandatory argument 'stream_id'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'poll_timeout_sec'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'tolerance'}
#Body { Need to fill equivalent logic in classic for FT Mandatory argument 'tx_port_handle'}
set api "get_nodrop_rate $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_bgp_config {args} {
global apiData
set args1 $args
Convert_List_To_Keyedlist $args1
if {[lsearch $args "-mac_address_start"] != -1} {
puts "removing -mac_address_start"
keyldel apiData(expArgs) -mac_address_start
}
set args [Convert_Keyedlist_To_List $apiData(expArgs)]
# if {[lsearch $args "-port_handle"] != -1} {
# set portList [keylget apiData(expArgs) -port_handle]
# if {[llength $portList] > 1} {
# puts "remove port_handle"
# #set args [lreplace $args [lsearch $args $i] [lsearch $args $i]+1]
# #interpreter
# #set args [lreplace $args [lsearch $args "-port_handle"] [lsearch $args "-port_handle"]+1]
# set args [lreplace $args [lsearch $args "-port_handle"] [expr {[lsearch $args "-port_handle"] + 1}]]
# set port [lindex $portList 0]
# lappend args -port_handle $port
# set api "emulation_bgp_config $args"
# return [::ixia::executeInChild $api]
# } else {
#
# if {[lsearch $args "-mac_address_start"] != -1} {
# set srcmac [keylget apiData(expArgs) -mac_address_start]
# set api "interface_config -mode destroy -src_mac_addr $srcmac -port_handle $portList"
# puts "interface_config destroy is $api"
# set ret [::ixia::executeInChild $api]
# puts "return is $ret"
#
# }
set api "emulation_bgp_config $args"
return [::ixia::executeInChild $api]
# }
# }
}
proc ::ixia::emulation_igmp_config {args} {
# puts "inside wrapper ::ixia::emulation_config"
# global apiData
# set args1 $args
# Convert_List_To_Keyedlist $args
# if {[lsearch $args -ipv4_prefix_length ] != -1} {
# set args [lremove $args -ipv4_prefix_length]
# }
puts $args
global apiData
if {[lsearch $args "-intf_prefix_len"] != -1} {
Convert_List_To_Keyedlist $args
set intf_len [keylget apiData(expArgs) -intf_prefix_len]
set intfPrefixLen [ subnetmaskToCIDR $intf_len ]
keyldel apiData(expArgs) -intf_prefix_len
set args [Convert_Keyedlist_To_List $apiData(expArgs)]
lappend args -intf_prefix_len $intfPrefixLen
}
if {[lsearch $args "-ipv4_prefix_length"] != -1} {
Convert_List_To_Keyedlist $args
set ipv4_length [keylget apiData(expArgs) -ipv4_prefix_length]
set ipv4PrefixLength [ subnetmaskToCIDR $ipv4_length ]
keyldel apiData(expArgs) -ipv4_prefix_length
set args [Convert_Keyedlist_To_List $apiData(expArgs)]
lappend args -ipv4_prefix_length $ipv4PrefixLength
}
set args1 $args
Convert_List_To_Keyedlist $args1
if {[lsearch $args "-igmp_version"] !=-1} {
set igmp_version [keylget apiData(expArgs) -igmp_version]
if {[string match $igmp_version "v3"]} {
if {[lsearch $args "-filter_mode"] == -1} {
lappend args -filter_mode include
}
}
}
if {[lsearch $args "-unsolicited_report_interval"] == -1} {
lappend args -unsolicited_report_interval 120
}
if {[lsearch $args "-ip_router_alert"] == -1} {
lappend args -ip_router_alert 1
} else {
set ip_router_alert [keylget apiData(expArgs) -ip_router_alert]
if {[string match $ip_router_alert 0]} {
Convert_List_To_Keyedlist $args
keyldel apiData(expArgs) -ip_router_alert
set args [Convert_Keyedlist_To_List $apiData(expArgs)]
lappend args -ip_router_alert 1
}
}
set api "emulation_igmp_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_dhcp_control {args} {
set api "emulation_dhcp_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_isis_control {args} {
set api "emulation_isis_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::interface_stats {args} {
#Body { Arguments with no mandatory tag argument 'port_handle'}
set api "interface_stats $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_multicast_source_config {args} {
set api "emulation_multicast_source_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_multicast_group_config {args} {
set api "emulation_multicast_group_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::cleanup_session {args} {
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'reset'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'port_handle'}
set api "cleanup_session $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_ospf_lsa_config {args} {
set api "emulation_ospf_lsa_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_eigrp_control {args} {
set api "emulation_eigrp_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::vport_info {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
set api "vport_info $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_bgp_control {args} {
set api "emulation_bgp_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_rsvp_control {args} {
set api "emulation_rsvp_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_ospf_topology_route_config {args} {
global apiData
set args_list [Parse_Dashed_Args $args]
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
} else {
set mod [keylget apiData(parse_args) -mode]
if {[string equal "create" $mod]} {
if {[lsearch $args "-type"] == -1} {
error "Missing Mandatory Argument \"-type\""
}
if {[lsearch $args "-handle"] == -1} {
error "Missing Mandatory Argument \"handle\""
}
} elseif {[string equal "modify" $mod] || [string equal "enable" $mod] || [string equal "disable" $mod]} {
if {[lsearch $args "-type"] == -1} {
error "Missing Mandatory Argument \"-type\""
}
if {[lsearch $args "-handle"] == -1} {
error "Missing Mandatory Argument \"handle\""
}
if {[lsearch $args "-elem_handle"] == -1} {
error "Missing Mandatory Argument \"elem_handle\""
}
} elseif {[string equal "delete" $mod]} {
if {[lsearch $args "-handle"] == -1} {
error "Missing Mandatory Argument \"handle\""
}
if {[lsearch $args "-elem_handle"] == -1} {
error "Missing Mandatory Argument \"elem_handle\""
}
}
}
set api "emulation_ospf_topology_route_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::packet_control {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'packet_type'
if {[lsearch $args "-packet_type"] == -1} {
#error "Missing Mandatory Argument \"packet_type\""
lappend args -packet_type both
}
set api "packet_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::traffic_stats {args} {
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'vci_step'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_counter_vci_data_item_list'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_counter_vpi_type'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_counter_vpi_mode'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_reassembly_enable_iptcpudp_checksum'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_reassembly_encapsulation'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'vpi'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_counter_vci_mode'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_counter_vpi_data_item_list'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_reassembly_enable_ip_qos'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'ignore_rate'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'qos_stats'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'vci_count'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'vpi_step'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'packet_group_id'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'atm_counter_vci_type'}
#Body { Need to fill equivalent logic in classic for FT Non-mandatory argument 'vci'}
sleep 30
global env
if {[info exists env(findNdr)]} {
set findndr $env(findNdr)
} else {
set findndr ""
}
global apiData
set args2 $args
Convert_List_To_Keyedlist $args2
set pgidStr "pgid"
if {[lsearch $args "-packet_group_id"] != -1} {
set pgid [expr [keylget apiData(expArgs) -packet_group_id]-1]
puts "pgid: $pgid"
puts "Removing -packet_group_id "
keyldel apiData(expArgs) -packet_group_id
set pgidStr "pgid"
}
set api "traffic_stats $args"
set stats [::ixia::executeInChild $api]
set ports [list [keylget apiData(expArgs) -port_handle]]
regsub -all "{" $ports {} ports
regsub -all "}" $ports {} ports
set portLength [llength $ports]
set i 1
foreach port $ports {
if {[catch {keylget stats $port.aggregate.rx.pkt_count} errmsg]} {
puts "This port dont have pkt_count: $port"
#keylset stats $port.aggregate.rx.uds1_count "NA"
} else {
set pkts [keylget stats $port.aggregate.rx.pkt_count]
keylset stats $port.aggregate.rx.uds1_count $pkts
sleep 5
}
if {[catch {keylget apiData(expArgs) -mode} errmsg]} {
puts "Traffic stats doesn't have mode param"
} else {
set mod [keylget apiData(expArgs) -mode]
if {[string equal $mod "stream"]} {
if {[string match $findndr "ndr"]} {
set streamValues [keylget stats $port.stream]
foreach streamValue $streamValues {
set value [lindex $streamValue 0]
break
}
if {$i<=$portLength} {
set newValue [string trim $value]
regsub -all "$newValue" $stats $i stats
set i [expr {$i + 1}]
}
}
if {[string equal "pgid" $pgidStr]} {
set streamValues [keylget stats $port.stream]
foreach streamValue $streamValues {
set value [lindex $streamValue 0]
break
}
set newValue [string trim $value]
if {[catch {keylget stats $port.stream.$newValue.rx.total_pkts} errmsg]} {
puts "This port $port not have rx details"
} else {
set pktCount [keylget stats $port.stream.$newValue.rx.total_pkts]
keylset stats $port.$pgidStr.rx.pkt_count.$pgid $pktCount
}
}
}
}
}
if {[catch {keylget stats aggregate.rx.uds1_frame_count.max} errmsg]} {
puts "Traffic stats doesn't have User Defined stats"
} else {
set udsmin [keylget stats aggregate.rx.data_int_frames_count.min]
set udsmax [keylget stats aggregate.rx.data_int_frames_count.max]
set udsavg [keylget stats aggregate.rx.data_int_frames_count.avg]
set uds1max [keylget stats aggregate.rx.uds1_frame_count.max]
if {[string equal $uds1max "0"]} {
keylset stats aggregate.rx.uds1_frame_count.min $udsmin
keylset stats aggregate.rx.uds1_frame_count.max $udsmax
keylset stats aggregate.rx.uds1_frame_count.avg $udsavg
}
}
if {0} {
if {[catch {keylget stats $port.aggregate.rx.uds2_frame_count} errmsg]} {
puts "This port dont have uds2_frame_count: $port"
#set udsCount [keylget stats $port.aggregate.rx.uds2_frame_count]
keylset stats $port.aggregate.rx.uds_count2 "NA"
} else {
set udsCount [keylget stats $port.aggregate.rx.uds2_frame_count]
keylset stats $port.aggregate.rx.uds_count2 $udsCount
}
}
return $stats
}
proc ::ixia::emulation_twamp_test_range_config {args} {
set api "emulation_twamp_test_range_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::pppox_control {args} {
set api "pppox_control $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::emulation_stp_msti_config {args} {
#Body { Arguments with no mandatory tag argument 'msti_mac_step'}
#Body { Arguments with no mandatory tag argument 'handle'}
#Body { Arguments with no mandatory tag argument 'msti_vlan_stop_step'}
#Body { Arguments with no mandatory tag argument 'msti_vlan_start_step'}
#Body { Arguments with no mandatory tag argument 'msti_vlan_start'}
#Body { Arguments with no mandatory tag argument 'msti_wildcard_percent_start'}
#Body { Arguments with no mandatory tag argument 'msti_internal_root_path_cost'}
#Body { Arguments with no mandatory tag argument 'msti_wildcard_percent_enable'}
#Body { Arguments with no mandatory tag argument 'count'}
#Body { Arguments with no mandatory tag argument 'msti_id'}
#Body { Arguments with no mandatory tag argument 'msti_mac'}
#Body { Arguments with no mandatory tag argument 'msti_hops'}
#Body { Arguments with no mandatory tag argument 'msti_port_priority'}
#Body { Arguments with no mandatory tag argument 'msti_id_step'}
#Body { Arguments with no mandatory tag argument 'msti_vlan_stop'}
#Body { Arguments with no mandatory tag argument 'bridge_handle'}
#Body { Arguments with no mandatory tag argument 'msti_priority'}
#Body { Arguments with no mandatory tag argument 'msti_name'}
#Body { Arguments with no mandatory tag argument 'mode'}
set api "emulation_stp_msti_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::fc_fport_options_config {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'mode'
if {[lsearch $args "-mode"] == -1} {
error "Missing Mandatory Argument \"mode\""
}
#Argument not supported in FT.This argument is Mandatory in Classic 'port_handle'
if {[lsearch $args "-port_handle"] == -1} {
error "Missing Mandatory Argument \"port_handle\""
}
set api "fc_fport_options_config $args"
return [::ixia::executeInChild $api]
}
proc ::ixia::pppox_config {args} {
#Argument not supported in FT.This argument is Mandatory in Classic 'protocol'
if {[lsearch $args "-protocol"] == -1} {
error "Missing Mandatory Argument \"protocol\""
}