forked from keysightgems/Huawei_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIxia_NetNgpfDhcpPD.tcl
More file actions
1465 lines (1278 loc) · 45.6 KB
/
Ixia_NetNgpfDhcpPD.tcl
File metadata and controls
1465 lines (1278 loc) · 45.6 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 201-2011, Inc.
# Release Version 1.0
#===============================================================================
# Change made
# Version 1.0
# 1. Create
class DhcpPDHost {
inherit ProtocolStackObject
#public variable type
#public variable stack
public variable optionSet
public variable rangeStats
public variable hostCnt
public variable hPppox
public variable hDhcp
public variable hDhcpv6PdClient
public variable requestDuration
public variable statsView
constructor { port { onStack null } } { chain $port $onStack } {}
method reborn { { onStack null } } {
set tag "body DhcpPDHost::reborn [info script]"
Deputs "----- TAG: $tag -----"
array set rangeStats [list]
if { $onStack == "null" } {
chain
} else {
Deputs "based on existing stack:$onStack"
set hDhcp $onStack
}
}
method config { args } {}
method request {} {}
method release {} {}
method renew {} {}
method resume {} {}
method pause {} {}
method rebind {} {}
method set_dhcp_msg_option { args } {}
method get_summary_stats {} {}
method get_detailed_stats {} {}
method set_igmp_over_dhcp { args } {}
method unset_igmp_over_dhcp {} {}
method wait_request_complete { args } {}
method wait_release_complete { args } {}
method get_port_summary_stats { view } {}
method CreateDhcpPerSessionView {} {
set tag "body DhcpPDHost::CreateDhcpPerSessionView [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set customView [ ixNet add $root/statistics view ]
ixNet setM $customView -caption "dhcpPerSessionView" -type layer23ProtocolStack -visible true
ixNet commit
set customView [ ixNet remapIds $customView ]
Deputs "view:$customView"
set availableFilter [ ixNet getList $customView availableProtocolStackFilter ]
Deputs "available filter:$availableFilter"
set filter [ ixNet getList $customView layer23ProtocolStackFilter ]
Deputs "filter:$filter"
Deputs "handle:$handle"
set dhcpRange [ixNet getList $handle dhcpRange]
Deputs "dhcpRange:$dhcpRange"
set rangeName [ ixNet getA $dhcpRange -name ]
Deputs "range name:$rangeName"
foreach afil $availableFilter {
Deputs "$afil"
if { [ regexp $rangeName $afil ] } {
set stackFilter $afil
}
}
Deputs "stack filter:$stackFilter"
ixNet setM $filter -drilldownType perSession -protocolStackFilterId $stackFilter
ixNet commit
set srtStat [lindex [ixNet getF $customView statistic -caption {Session Name}] 0]
ixNet setA $filter -sortAscending true -sortingStatistic $srtStat
ixNet commit
foreach s [ixNet getL $customView statistic] {
ixNet setA $s -enabled true
}
ixNet setA $customView -enabled true
ixNet commit
return $customView
}
method CreateDhcpPerRangeView {} {
set tag "body DhcpPDHost::CreateDhcpPerRangeView [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set customView [ ixNet add $root/statistics view ]
ixNet setM $customView -caption "dhcpPerRangeView" -type layer23ProtocolStack -visible true
ixNet commit
set customView [ ixNet remapIds $customView ]
Deputs "view:customView"
set availableFilter [ ixNet getList $customView availableProtocolStackFilter ]
Deputs "available filter:$availableFilter"
set filter [ ixNet getList $customView layer23ProtocolStackFilter ]
Deputs "filter:$filter"
Deputs "handle:$handle"
set dhcpRange [ixNet getList $handle dhcpHostsRange]
Deputs "dhcpRange:$dhcpRange"
set rangeName [ ixNet getA $dhcpRange -name ]
Deputs "range name:$rangeName"
foreach afil $availableFilter {
Deputs "$afil"
if { [ regexp $rangeName $afil ] } {
set stackFilter $afil
}
}
Deputs "stack filter:$stackFilter"
ixNet setM $filter -drilldownType perRange -protocolStackFilterId $stackFilter
ixNet commit
set srtStat [lindex [ixNet getF $customView statistic -caption {Range Name}] 0]
Deputs "sorting stats:$srtStat"
ixNet setA $filter -sortAscending true -sortingStatistic $srtStat
ixNet commit
Deputs "enable view..."
foreach s [ixNet getL $customView statistic] {
ixNet setA $s -enabled true
}
ixNet setA $customView -enabled true
ixNet commit
return $customView
}
}
body DhcpPDHost::config { args } {
global errorInfo
global errNumber
set tag "body DhcpPDHost::config [info script]"
Deputs "----- TAG: $tag -----"
#disable the interface
eval { chain } $args
#param collection
Deputs "Args:$args "
set hOuterVlan [lindex [ixNet getL $handle/vlanRange vlanIdInfo] 0]
set hInnerVlan [lindex [ixNet getL $handle/vlanRange vlanIdInfo] 1]
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-count {
if { [ string is integer $value ] && ( $value <= 65535 ) } {
set count $value
set hostCnt $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_enable {
set outer_vlan_enable $value
ixNet setA $hOuterVlan -enabled $value
}
-outer_vlan_id {
set outer_vlan_enable $value
ixNet setA $hOuterVlan -firstId $value
}
-oute_vlan_step {
set outer_vlan_enable $value
ixNet setA $hOuterVlan -incrementStep $value
}
-outer_vlan_num {
set outer_vlan_enable $value
ixNet setA $hOuterVlan -uniqueCount $value
}
-outer_vlan_priority {
set outer_vlan_enable $value
ixNet setA $hOuterVlan -priority $value
}
-outer_vlan_cfi {
set outer_vlan_enable $value
}
-inner_vlan_enable {
set inner_vlan_enable $value
ixNet setA $hInnerVlan -enabled $value
}
-inner_vlan_id {
set inner_vlan_enable $value
ixNet setA $hInnerVlan -firstId $value
}
-inner_vlan_step {
set inner_vlan_enable $value
ixNet setA $hInnerVlan -incrementStep $value
}
-inner_vlan_num {
set inner_vlan_enable $value
ixNet setA $hInnerVlan -uniqueCount $value
}
-inner_vlan_priority {
set inner_vlan_enable $value
ixNet setA $hInnerVlan -priority $value
}
-inner_vlan_cfi {
set inner_vlan_enable $value
}
}
}
set range $handle
if { [ info exists count ] } {
ixNet setA $range/dhcpHostsRange -count $count
}
ixNet commit
return [GetStandardReturnHeader]
}
body DhcpPDHost::request {} {
set tag "body DhcpPDHost::request [info script]"
Deputs "----- TAG: $tag -----"
Deputs "handle :$handle"
# after 3000
set requestTimestamp [ clock seconds ]
if { [ catch {
ixNet exec start $handle
} err ] } {
Deputs "err:$err"
after 3000
set requestTimestamp [ clock seconds ]
ixNet exec start $handle
}
set completeTimestamp [ clock seconds ]
set requestDuration [ expr $completeTimestamp - $requestTimestamp ]
#-- make sure the stats will be updated
return [GetStandardReturnHeader]
}
body DhcpPDHost::release {} {
set tag "body DhcpPDHost::release [info script]"
Deputs "----- TAG: $tag -----"
ixNet exec stop $handle
#ixNet exec dhcpClientClearStats $hDhcp
ixNet commit
return [GetStandardReturnHeader]
}
body DhcpPDHost::renew {} {
set tag "body DhcpPDHost::renew [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
ixNet exec dhcpv6PdClientRenew $hDhcpv6PdClient
} ] } {
return [GetErrorReturnHeader "Unsupported functionality."]
}
return [GetStandardReturnHeader]
}
body DhcpPDHost::resume {} {
set tag "body DhcpPDHost::resume [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
ixNet exec dhcpHostsResume $handle
} ] } {
return [GetErrorReturnHeader "Unsupported functionality."]
}
return [GetStandardReturnHeader]
}
body DhcpPDHost::pause {} {
set tag "body DhcpPDHost::pause [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
ixNet exec dhcpHostsPause $handle
} ] } {
return [GetErrorReturnHeader "Unsupported functionality."]
}
return [GetStandardReturnHeader]
}
body DhcpPDHost::rebind {} {
set tag "body DhcpPDHost::rebind [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
ixNet exec dhcpv6PdClientRebind $hDhcpv6PdClient
} ] } {
return [GetErrorReturnHeader "Unsupported functionality."]
}
return [GetStandardReturnHeader]
}
body DhcpPDHost::wait_request_complete { args } {
set tag "body DhcpPDHost::wait_request_complete [info script]"
Deputs "----- TAG: $tag -----"
set timeout 300
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-timeout {
set trans [ TimeTrans $value ]
if { [ string is integer $trans ] } {
set timeout $trans
} else {
error "$errNumber(1) key:$key value:$value"
}
}
}
}
set startClick [ clock seconds ]
while { 1 } {
set click [ clock seconds ]
if { [ expr $click - $startClick ] >= $timeout } {
return [ GetErrorReturnHeader "timeout" ]
}
set root [ixNet getRoot]
set view $statsView
# set view [ ixNet getF $root/statistics view -caption "Port Statistics" ]
Deputs "view:$view"
set captionList [ ixNet getA $view/page -columnCaptions ]
Deputs "caption list:$captionList"
set port_name [ lsearch -exact $captionList {Stat Name} ]
set initStatsIndex [ lsearch -exact $captionList {Sessions Initiated} ]
set succStatsIndex [ lsearch -exact $captionList {Sessions Succeeded} ]
set ackRcvIndex [ lsearch -exact $captionList {ACKs Received} ]
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set connectionInfo [ ixNet getA $hPort -connectionInfo ]
Deputs "connectionInfo :$connectionInfo"
regexp -nocase {chassis=\"([0-9\.]+)\" card=\"([0-9\.]+)\" port=\"([0-9\.]+)\"} $connectionInfo match chassis card port
Deputs "chas:$chassis card:$card port$port"
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "portname:[ lindex $row $port_name ]"
if { [ string length $card ] == 1 } {
set card "0$card"
}
if { [ string length $port ] == 1 } {
set port "0$port"
}
if { "${chassis}/Card${card}/Port${port}" != [ lindex $row $port_name ] } {
continue
}
set initStats [ lindex $row $initStatsIndex ]
set succStats [ lindex $row $succStatsIndex ]
set ackRcvStats [ lindex $row $ackRcvIndex ]
break
}
Deputs "initStats:$initStats == succStats:$succStats == ackRcvStats:$ackRcvStats ?"
if { $succStats != "" && $succStats >= $initStats && $initStats > 0 && $ackRcvStats >= $succStats } {
break
}
after 1000
}
return [GetStandardReturnHeader]
}
body DhcpPDHost::wait_release_complete { args } {
set tag "body DhcpPDHost::wait_release_complete [info script]"
Deputs "----- TAG: $tag -----"
set timeout 10
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-timeout {
set timeout $value
}
}
}
set timerStart [ clock second ]
set root [ixNet getRoot]
set view [ lindex [ ixNet getF $root/statistics view -caption "dhcpPerSessionView" ] 0 ]
if { $view == "" } {
if { [ catch {
set view [ CreateDhcpPerSessionView ]
} ] } {
return [ GetErrorReturnHeader "Can't fetch stats view, please make sure the session starting correctly." ]
}
}
set captionList [ ixNet getA $view/page -columnCaptions ]
set ipIndex [ lsearch -exact $captionList {IP Address} ]
set pageCount [ ixNet getA $view/page -totalPages ]
while { [ expr [ clock second ] - $timeStart ] > $timeout } {
for { set index 1 } { $index <= $pageCount } { incr index } {
ixNet setA $view/page -currentPage $index
ixNet commit
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
foreach row $stats {
eval {set row} $row
set statsItem "ipv4_addr"
set statsVal [ lindex $row $ipIndex ]
Deputs "stats val:$statsVal"
if { $statsVal != "0.0.0.0" } {
ixNet remove $view
ixNet commit
return [ GetErrorReturnHeader "" ]
}
}
Deputs "ret:$ret"
}
after 1000
ixNet exec refresh $view
}
ixNet remove $view
ixNet commit
return [ GetStandardReturnHeader ]
}
body DhcpPDHost::get_summary_stats {} {
set tag "body DhcpPDHost::get_summary_stats [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "root $root"
#set view [ lindex [ ixNet getF $root/statistics view -caption "dhcpPerRangeView" ] 0 ]
set view {::ixNet::OBJ-/statistics/view:"DHCPv6Client"}
if { $view == "" } {
if { [ catch {
set view [ CreateDhcpPerRangeView ]
} ] } {
return [ GetErrorReturnHeader "Can't fetch stats view, please make sure the session starting correctly." ]
}
}
set captionList [ ixNet getA $view/page -columnCaptions ]
set rangeIndex [ lsearch -exact $captionList {Range Name} ]
Deputs "index:$rangeIndex"
set solicitsSentIndex [ lsearch -exact $captionList {Solicits Sent} ]
Deputs "index:$solicitsSentIndex"
set repliesRecIndex [ lsearch -exact $captionList {Replies Received} ]
Deputs "index:$repliesRecIndex"
set reqSentIndex [ lsearch -exact $captionList {Requests Sent} ]
Deputs "index:$reqSentIndex"
set advRecIndex [ lsearch -exact $captionList {Advertisements Received} ]
Deputs "index:$advRecIndex"
set advIgnoreIndex [ lsearch -exact $captionList {Advertisements Ignored} ]
Deputs "index:$advIgnoreIndex"
set releaseSentIndex [ lsearch -exact $captionList {Releases Sent} ]
Deputs "index:$releaseSentIndex"
set renewSentIndex [ lsearch -exact $captionList {Renews Sent} ]
Deputs "index:$renewSentIndex"
set retriedSentIndex [ lsearch -exact $captionList {Rebinds Sent} ]
Deputs "index:$retriedSentIndex"
Deputs "handle:$handle"
set dhcpRange [ixNet getList $handle dhcpHostsRange]
Deputs "dhcpRange:$dhcpRange"
set rangeName [ ixNet getA $dhcpRange -name ]
Deputs "range name:$rangeName"
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set rangeFound 0
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "range index:$rangeIndex"
set rowRangeName [ lindex $row $rangeIndex ]
Deputs "row range name:$rowRangeName"
if { [ regexp $rowRangeName $rangeName ] } {
set rangeFound 1
break
}
}
set ret "Status : true\nLog : \n"
if { $rangeFound } {
set statsItem "tx_solicit_count "
set statsVal [ lindex $row $solicitsSentIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_request_count"
set statsVal [ lindex $row $reqSentIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
#--temp variable to save current stats
set rangeStats(requestSent) $statsVal
set statsItem "tx_confirm_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_info_request_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_rebind_count "
set statsVal [ lindex $row $retriedSentIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_release_count"
set statsVal [ lindex $row $releaseSentIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
#--temp variable to save current stats
set rangeStats(releaseSent) $statsVal
set statsItem "tx_renew_count"
set statsVal [ lindex $row $renewSentIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
#--temp variable to save current stats
set rangeStats(releaseSent) $statsVal
set statsItem "rx_advertise_count "
set statsVal [ lindex $row $advRecIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
#--temp variable to save current stats
set rangeStats(releaseSent) $statsVal
set statsItem "rx_reconfigure_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_reply_count"
set statsVal [ lindex $row $repliesRecIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
#--temp variable to save current stats
set rangeStats(releaseSent) $statsVal
}
Deputs "ret:$ret"
return $ret
}
body DhcpPDHost::get_detailed_stats {} {
set tag "body DhcpPDHost::get_detailed_stats [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set view [ lindex [ ixNet getF $root/statistics view -caption "dhcpPerSessionView" ] 0 ]
Deputs "view:$view"
if { $view == "" } {
if { [ catch {
set view [ CreateDhcpPerSessionView ]
} ] } {
return [ GetErrorReturnHeader "Can't fetch stats view, please make sure the session starting correctly." ]
}
}
set captionList [ ixNet getA $view/page -columnCaptions ]
set rangeIndex [ lsearch -exact $captionList {Session Name} ]
set discoverSentIndex [ lsearch -exact $captionList {Discovers Sent} ]
set offerRecIndex [ lsearch -exact $captionList {Offers Received} ]
set reqSentIndex [ lsearch -exact $captionList {Requests Sent} ]
set ackRecIndex [ lsearch -exact $captionList {ACKs Received} ]
set nackRecIndex [ lsearch -exact $captionList {NACKs Received} ]
set releaseSentIndex [ lsearch -exact $captionList {Release Sent} ]
set declineSentIndex [ lsearch -exact $captionList {Declines Sent} ]
set ipIndex [ lsearch -exact $captionList {IP Address} ]
set gwIndex [ lsearch -exact $captionList {Gateway Address} ]
set leaseIndex [ lsearch -exact $captionList {Lease Time} ]
Deputs "handle:$handle"
set dhcpRange [ixNet getList $handle dhcpRange]
Deputs "dhcpRange:$dhcpRange"
set rangeName [ ixNet getA $dhcpRange -name ]
Deputs "range name:$rangeName"
set ret "Status : true\nLog : \n"
set pageCount [ ixNet getA $view/page -totalPages ]
for { set index 1 } { $index <= $pageCount } { incr index } {
ixNet setA $view/page -currentPage $index
ixNet commit
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
foreach row $stats {
set ret "$ret\{\n"
eval {set row} $row
Deputs "row:$row"
set statsItem "disc_resp_time"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "status_code"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "host_state"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "ipv6_addr"
set statsVal [ lindex $row $ipIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "lease_left"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "lease_rx"
set statsVal [ lindex $row $leaseIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "mac_addr"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "request_resp_time"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "prefix_len"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "vlan_id"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set ret "$ret\}\n"
}
Deputs "ret:$ret"
}
ixNet remove $view
ixNet commit
return $ret
}
body DhcpPDHost::set_dhcp_msg_option { args } {
global errorInfo
global errNumber
set tag "body DhcpPDHost::set_dhcp_msg_option [info script]"
Deputs "----- TAG: $tag -----"
set EMsgType [ list discover request solicit ]
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-msg_type {
set value [ string tolower $value ]
if { [ lsearch -exact $EMsgType $value ] >= 0 } {
set msg_type $value
} else {
return [GetErrorReturnHeader "Unsupported functionality."]
}
}
-option_type {
if { [ string is integer $value ] && ( $value >= 1 ) && ( $value <= 65535 ) } {
set option_type $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-enable_hex_value {
if { $value == "true" } {
set optionType hexadecimal
}
}
-payload {
set payload $value
}
}
}
set flagTypeDefined 0
foreach tlv [ ixNet getL $optionSet dhcpOptionTlv ] {
if { [ ixNet getA $tlv -code ] == $option_type } {
set flagTypeDefined 1
}
}
if { ( $option_type == "53" ) || ( $option_type == "61" ) || ( $option_type == "57" ) } {
return [ GetErrorReturnHeader "Not customized option:$option_type, IXIA has already added this option on defaultly."]
}
if { $option_type == "51" } {
set global [ ixNet getL $root/globals/protocolStack dhcpGlobals ]
ixNet setA $global -dhcp4AddrLeaseTime $payload
ixNet commit
set flagTypeDefined 1
}
Deputs "option type 51"
if { $option_type == "55" } {
set payloadLen [ string length $payload ]
set requestList ""
for { set index 0 } { $index < $payloadLen } { incr index 2 } {
Deputs "index:$index"
Deputs "requestList :$requestList"
set requestHex [ string range $payload $index [ expr $index + 1 ] ]
Deputs "requestHex:$requestHex"
if { [ string tolower $requestHex ] == "0x" } {
continue
}
set requestInt [ format %i 0x$requestHex ]
Deputs "requestInt:$requestInt"
if { $requestList != "" } {
set requestList "${requestList}\;${requestInt}"
} else {
set requestList ${requestList}${requestInt}
}
}
Deputs "requestList final:$requestList"
ixNet setA $handle/dhcpRange -dhcp4ParamRequestList $requestList
ixNet commit
set flagTypeDefined 1
}
Deputs "option type 55"
if { $option_type == "82" } {
set payloadLen [ string length $payload ]
Deputs "payloadLen is: $payloadLen"
if {[string range $payload 0 1] == 01} {
set circuitLenHex [string range $payload 2 3]
set circuitLenInt [expr [ format %i 0x$circuitLenHex ]*2 ]
Deputs "circuitLenInt is: $circuitLenInt"
set circuitLenTotal [expr 4 + $circuitLenInt ]
Deputs "circuitLenTotal is: $circuitLenTotal"
if {$circuitLenTotal == $payloadLen} {
set circuitValue 0x[ string range $payload 4 end ]
Deputs "circuitValue is: $circuitValue"
ixNet setM $handle/dhcpRange \
-useTrustedNetworkElement True \
-relayUseCircuitId True \
-relayCircuitId $circuitValue
} elseif {$circuitLenTotal < $payloadLen && [string range $payload [expr $circuitLenInt + 4] [expr $circuitLenInt + 5]] == 02} {
set circuitValue 0x[ string range $payload 4 [expr $circuitLenInt + 3] ]
Deputs "circuitValue is: $circuitValue"
set remoteLenHex [string range $payload [expr $circuitLenInt + 6] [expr $circuitLenInt + 7]]
Deputs "remoteLenHex is: $remoteLenHex"
set remoteLenInt [expr [ format %i 0x$remoteLenHex ]*2 ]
Deputs "remoteLenInt is: $remoteLenInt"
set remoteValue 0x[ string range $payload [expr $circuitLenInt + 8] [expr $circuitLenInt + $remoteLenInt + 7]]
Deputs "remoteValue is: $remoteValue"
ixNet setM $handle/dhcpRange \
-useTrustedNetworkElement True \
-relayUseCircuitId True \
-relayCircuitId $circuitValue \
-relayUseRemoteId True \
-relayRemoteId $remoteValue
} else {
error "error option82 format input, please refer to RFC3046"
}
} elseif {[string range $payload 0 1] == 02} {
set remoteLenInt [string range $payload 2 3]
set remoteLenInt [expr [ format %i 0x$remoteLenInt ]*2 ]
Deputs "remoteLenInt is: $remoteLenInt"
set remoteLenTotal [expr 4 + $remoteLenInt ]
Deputs "remoteLenTotal is: $remoteLenTotal"
if {$remoteLenTotal == $payloadLen} {
set remoteValue 0x[ string range $payload 4 end]
Deputs "remoteValue is: $remoteValue"
ixNet setM $handle/dhcpRange \
-useTrustedNetworkElement True \
-relayUseRemoteId True \
-relayRemoteId $remoteValue
} else {
error "error option82 format input, please refer to RFC3046"
}
} else {
error "error option82 format input, please refer to RFC3046"
}
ixNet commit
set flagTypeDefined 1
}
if { $flagTypeDefined == 0 && [ info exists option_type ] } {
switch $msg_type {
discover -
solicit {
Deputs "customized TLV"
if { [info exists optionType] == 0 } {
set optionType string
}
set tlv [ ixNet add $optionSet dhcpOptionTlv ]
if { [ info exists payload ] == 0 } {
set payload 0
} else {
if { [ IsIPv6Address $payload ] } {
set optionType ipv6Address
}
if { [ IsIPv4Address $payload ] } {
set optionType ipv4Address
}
}
if { [ info exists option_type ] == 0 } {
error "$errNumber(2) option_type"
}
ixNet setM $tlv -type $optionType -value $payload -code $option_type -name Option[clock click]
ixNet commit
}
request {
if { [ string tolower [ ixNet getA $handle/dhcpRange -ipType ] ] == "ipv4" } {
set cmd -dhcp4ParamRequestList
} else {
set cmd -dhcp6ParamRequestList
}
set reqList [ ixNet getA $handle/dhcpRange $cmd ]
set reqIndex [ string first $option_type $reqList ]
if { $reqIndex >= 0 && [ string index [ expr $reqIndex + 1 ] ] == ";" } {
Deputs "request exist..."
} else {
append reqList ";$option_type"
Deputs "request list:$reqList"
ixNet setA $handle/dhcpRange $cmd $reqList
ixNet commit
}
}
}
}
return [ GetStandardReturnHeader ]
}
body DhcpPDHost::get_port_summary_stats { view } {
set tag "body DhcpPDHost::get_port_summary_stats [info script]"
Deputs "----- TAG: $tag -----"
#set view ::ixNet::OBJ-/statistics/view:\"DHCPv6\"
set captionList [ ixNet getA $view/page -columnCaptions ]
set nameIndex [ lsearch -exact $captionList {Stat Name} ]
Deputs "index:$nameIndex"
set ackRcvIndex [ lsearch -exact $captionList {ACKs Received} ]
Deputs "index:$ackRcvIndex"
set addDiscIndex [ lsearch -exact $captionList {Addresses Discovered} ]
Deputs "index:$addDiscIndex"
set declineSntIndex [ lsearch -exact $captionList {Declines Sent} ]
Deputs "index:$declineSntIndex"
set discSntIndex [ lsearch -exact $captionList {Discovers Sent} ]
Deputs "index:$discSntIndex"
set nakRcvIndex [ lsearch -exact $captionList {NACKs Received} ]
Deputs "index:$nakRcvIndex"
set offerRcvIndex [ lsearch -exact $captionList {Offers Received} ]
Deputs "index:$offerRcvIndex"
set releaseSntIndex [ lsearch -exact $captionList {Releases Sent} ]
Deputs "index:$releaseSntIndex"
set reqSntIndex [ lsearch -exact $captionList {Requests Sent} ]
Deputs "index:$reqSntIndex"
set sessFailIndex [ lsearch -exact $captionList {Sessions Failed} ]
Deputs "index:$sessFailIndex"
set sessInitIndex [ lsearch -exact $captionList {Sessions Initiated} ]
Deputs "index:$sessInitIndex"
set sessSuccIndex [ lsearch -exact $captionList {Sessions Succeeded} ]
Deputs "index:$sessSuccIndex"
set succRateIndex [ lsearch -exact $captionList {Setup Success Rate} ]
Deputs "index:$succRateIndex"
set ret [ GetStandardReturnHeader ]
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set connectionInfo [ ixNet getA [$portObj cget -handle] -connectionInfo ]
Deputs "connectionInfo :$connectionInfo"
regexp -nocase {chassis=\"([0-9\.]+)\" card=\"([0-9\.]+)\" port=\"([0-9\.]+)\"} $connectionInfo match chassis card port
Deputs "chas:$chassis card:$card port$port"
if { [ string length $card ] == 1 } { set card "0$card" }
if { [ string length $port ] == 1 } { set port "0$port" }
set statsName "${chassis}/Card${card}/Port${port}"
Deputs "statsName:$statsName"
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
set statsVal [ lindex $row $nameIndex ]
if { $statsVal != $statsName } {
Deputs "stats skipped: $statsVal != $statsName"
continue
}
set statsItem "tx_discover_count"
set statsVal [ lindex $row $discSntIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_discover_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_offer_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_offer_count"
set statsVal [ lindex $row $offerRcvIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_request_count"
set statsVal [ lindex $row $reqSntIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_request_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_decline_count"
set statsVal [ lindex $row $declineSntIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_decline_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_ack_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_ack_count"
set statsVal [ lindex $row $ackRcvIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_nak_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_nak_count"
set statsVal [ lindex $row $nakRcvIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_release_count"
set statsVal [ lindex $row $releaseSntIndex ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_release_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_all_packet_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_all_packet_count"