forked from keysightgems/Huawei_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIxia_NetNgpfDcbx.tcl
More file actions
1230 lines (1039 loc) · 29.9 KB
/
Ixia_NetNgpfDcbx.tcl
File metadata and controls
1230 lines (1039 loc) · 29.9 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.1
# 1. Create
# Version 1.2.3.5
# 2. Add multiSession support in reborn
class LldpDcbxHost {
inherit ProtocolStackObject
constructor { port } { chain $port } {}
method reborn {} {}
method config { args } {}
method pause {} {}
method resume {} {}
method get_lldp_host_stats {} {}
method get_lldp_neighbor_stats {} {}
public variable hDcbx
}
body LldpDcbxHost::reborn {} {
set tag "body LldpDcbxHost::reborn [info script]"
Deputs "----- TAG: $tag -----"
set root [ ixNet getRoot ]
if { [ llength [ixNet getL $root/globals/protocolStack dcbxGlobals] ] > 0 } {
set dcbGlobal [ lindex [ixNet getL $root/globals/protocolStack dcbxGlobals] 0 ]
} else {
set dcbGlobal [ixNet add $root/globals/protocolStack dcbxGlobals]
ixNet commit
set dcbGlobal [ixNet remapIds $dcbGlobal]
}
Deputs "dcb global:$dcbGlobal"
ixNet setA $dcbGlobal -allowMultipleSessions True
ixNet commit
chain
set stackLen [ llength [ ixNet getL $hPort/protocolStack ethernet ] ]
if { $stackLen == 0 } {
#chain
#-- add dcbx endpoint stack
set sg_dcbxEndpoint [ixNet add $stack dcbxEndpoint]
ixNet setA $sg_dcbxEndpoint -name $this
ixNet commit
set sg_dcbxEndpoint [lindex [ixNet remapIds $sg_dcbxEndpoint] 0]
set hDcbx $sg_dcbxEndpoint
} else {
set stack [ lindex [ ixNet getL $hPort/protocolStack ethernet ] 0 ]
set sg_dcbxEndpoint [ lindex [ ixNet getL $stack dcbxEndpoint ] 0 ]
}
Deputs "stack:$stack"
Deputs "sg_dcbxEndpoint:$sg_dcbxEndpoint"
#-- add range
set sg_range [ixNet add $sg_dcbxEndpoint range]
ixNet setMultiAttrs $sg_range/macRange \
-enabled True
ixNet setMultiAttrs $sg_range/vlanRange \
-enabled False \
ixNet setMultiAttrs $sg_range/dcbxRange \
-name $this \
-enabled True
ixNet commit
set sg_range [ixNet remapIds $sg_range]
set handle $sg_range
}
body LldpDcbxHost::config { args } {
set tag "body LldpDcbxHost::config [info script]"
Deputs "----- TAG: $tag -----"
# reborn
if { $handle == "" } {
reborn
}
eval chain $args
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-host_cnt {
set host_cnt $value
}
-msg_tx_interval {
set msg_tx_interval $value
}
-msg_tx_hold_multiplier {
set msg_tx_hold_multiplier $value
}
-reinit_delay {
set reinit_delay $value
}
-tx_delay {
set tx_delay $value
}
-dst_mac_addr {
set dst_mac_addr $value
}
-enable_vlan {
set enable_vlan $value
}
-tlv_list {
set tlv_list $value
}
}
}
if { [ info exists msg_tx_interval ] } {
ixNet setA $handle/dcbxRange -txInterval $msg_tx_interval
}
if { [ info exists msg_tx_hold_multiplier ] } {
ixNet setA $handle/dcbxRange -holdTime $msg_tx_hold_multiplier
}
if { [ info exists tx_delay ] } {
ixNet setA $handle/dcbxRange -txDelay $tx_delay
}
if { [ info exists dst_mac_addr ] } {
ixNet setA $handle/dcbxRange -destMacAddress $dst_mac_addr
}
if { [ info exists enable_vlan ] } {
ixNet setA $handle/vlanRange -enabled True
}
set notSupportFlag 0
set log ""
if { [ info exists tlv_list ] } {
set subTlv [list]
#-- for lldp Tlv
foreach tlv $tlv_list {
Deputs "tlv:$tlv"
if { [ $tlv isa LldpTlv ] == 0 } {
error "$errNumber(1) key:tlv_list value:$tlv"
}
set tlv_type [ $tlv cget -tlv_type ]
Deputs "tlv_type:$tlv_type"
switch $tlv_type {
ignore {
continue
}
chasid {
set chassis_id [ $tlv cget -chassis_id ]
Deputs "chassis_id : $chassis_id"
if { $chassis_id != "" && $chassis_id != "<undefined>" } {
if { [ IsMacAddress [ MacTrans $chassis_id ] ] == 0 } {
set notSupportFlag 1
set log "Only MAC address tlv_type is supported."
} else {
ixNet setA $handle/dcbxRange -chassisId $chassis_id
}
}
}
portid {
set port_id [ string tolower [ $tlv cget -port_id ] ]
set port_id_type [ string tolower [ $tlv cget -port_id_type ] ]
Deputs "port_id_type: $port_id_type"
Deputs "port_id: $port_id"
if { $port_id != "" && $port_id != "<undefined>" } {
switch $port_id_type {
interface_name {
ixNet setA $handle/dcbxRange -portIdSubType 1
ixNet setA $handle/dcbxRange -portIdInterfaceName $port_id
}
mac_addr {
ixNet setA $handle/dcbxRange -portIdSubType 0
ixNet setA $handle/dcbxRange -portIdMacAddress $port_id
}
default {
set notSupportFlag 1
set log "Only interface_name & mac_addr type are supported."
}
}
}
}
subtype {
set oui [ $tlv cget -oui ]
set ouidot [ string range $oui 0 1 ].[ string range $oui 2 3 ].[ string range $oui 4 5 ]
set org [ $tlv cget -org ]
lappend subTlv [ $tlv cget -val ]
Deputs "oui:$ouidot org:$org"
ixNet setA $handle/dcbxRange -oui $ouidot
ixNet setA $handle/dcbxRange -dcbxSubtype $org
}
ets -
app_pri -
pbfc {
set org 3
ixNet setA $handle/dcbxRange -dcbxSubtype $org
lappend subTlv $tlv
}
}
}
ixNet commit
if { [ llength $subTlv ] == 1 } {
eval set subTlv $subTlv
}
Deputs "subTlv:$subTlv len:[llength $subTlv]"
#-- remove all dcbx Tlv
if { [ llength $subTlv ] > 0 } {
switch $org {
1 -
2 {
set dcbxTlvList [ ixNet getL $handle/dcbxRange dcbxTlv ]
}
3 {
set dcbxTlvList [ ixNet getL $handle/dcbxRange dcbxTlvQaz ]
}
}
foreach dcbxRemove $dcbxTlvList {
ixNet remove $dcbxRemove
ixNet commit
}
}
#-- add new dcbx Tlv
Deputs "handle:$handle"
foreach tlv $subTlv {
Deputs "tlv:$tlv"
if { [ $tlv isa DcbxTlv ] == 0 } {
error "$errNumber(1) key:tlv_list value:$tlv"
}
switch $org {
1 -
2 {
set dcbxTlv [ ixNet add $handle/dcbxRange dcbxTlv ]
}
3 {
set dcbxTlv [ ixNet add $handle/dcbxRange dcbxTlvQaz ]
}
}
ixNet commit
set dcbxTlv [ ixNet remapIds $dcbxTlv ]
#Deputs "dcbxTlv:$dcbxTlv"
set tlv_type [ $tlv cget -tlv_type ]
Deputs "tlv_type:$tlv_type"
switch $tlv_type {
ignore {
ixNet remove $dcbxTlv
ixNet commit
continue
}
pg {
ixNet setM $dcbxTlv \
-featureType 2 \
-featureEnable True
ixNet commit
set bgw_pct [ $tlv cget -bgw_pct ]
Deputs "bgw_pct:$bgw_pct"
array set pg_attr [ $tlv getPG ]
Deputs "pg_attr: [array names pg_attr]"
switch $org {
1 {
set pgTlv $dcbxTlv/tlvSettings/dcbxTlvPgIntel
for { set index 0 } { $index < 8 } { incr index } {
set attr [ lindex [ ixNet getL $pgTlv dcbxBandwidthAtt ] $index ]
if { [ info exists pg_attr($index,id) ] } {
ixNet setA $attr -bwGroupId $pg_attr($index,id)
}
if { [ info exists pg_attr($index,pri) ] } {
ixNet setA $attr -strictPriority $pg_attr($index,pri)
}
if { [ info exists pg_attr($index,pct) ] } {
Deputs "pg pct:$pg_attr($index,pct)"
ixNet setA $attr -bwPercentage $pg_attr($index,pct)
}
}
Deputs "bgw_pct:$bgw_pct"
Deputs "pgTlv:$pgTlv"
ixNet setA $pgTlv -bwGroupPercentageMap $bgw_pct
Deputs "[ixNet getA $pgTlv -bwGroupPercentageMap]"
}
2 {
set num_tcs_supported [ $tlv cget -num_tcs_supported ]
set pgTlv $dcbxTlv/tlvSettings/dcbxTlvPgIeee
Deputs "[ixNet help $pgTlv]"
set pgId [ list ]
for { set index 0 } { $index < 8 } { incr index } {
if { [ info exists pg_attr($index,id) ] } {
lappend pgId $pg_attr($index,id)
} else {
lappend pgId 0
}
}
Deputs "pgId:$pgId"
ixNet setM $pgTlv \
-tcsSupported $num_tcs_supported \
-priorityGroupPercentageMap $bgw_pct \
-priorityGroupIdMap $pgId
}
}
ixNet commit
}
pfc {
ixNet setM $dcbxTlv \
-featureType 3 \
-featureEnable True
ixNet commit
switch $org {
1 {
set pfcTlv $dcbxTlv/tlvSettings/dcbxTlvPfcIntel
}
2 {
set pfcTlv $dcbxTlv/tlvSettings/dcbxTlvPfcIeee
set num_tcs_supported [ $tlv cget -num_tcs_supported ]
ixNet setA $dcbxTlv -tcsSupported $num_tcs_supported
}
}
set pe [ $tlv cget -pe ]
Deputs "pe:$pe"
Deputs "dcbxTlv:$dcbxTlv"
ixNet setA $pfcTlv -priorityMap $pe
ixNet commit
}
custom {
set hdr_type [ $tlv cget -hdr_type ]
ixNet setM $dcbxTlv \
-featureType $hdr_type \
-featureEnable True
set customTlv $dcbxTlv/tlvSettings/dcbxTlvCustom
set featureVal [ $tlv cget -val ]
ixNet setA $customTlv -featureTlv $featureVal
ixNet commit
}
app {
ixNet setM $dcbxTlv \
-featureType 4 \
-featureEnable True
ixNet commit
set appTlv $dcbxTlv/tlvSettings/dcbxTlvFcoeIeee
array set app_array [ $tlv get_app ]
Deputs "app array:[ array names app_array]"
if { [ info exists app_array(index) ] } {
set appIndex $app_array(index)
set tlvAttr [ ixNet getL $appTlv dcbxAppProtocolAtt ]
for { set index 1 } { $index <= 8 } { incr index } {
set attrIndex [ expr $index - 1 ]
set attr [ lindex $tlvAttr $attrIndex ]
if { [ lsearch $appIndex $index ] >= 0 } {
ixNet setA $attr -enabled True
if { [ info exists app_array($index,pri) ] } {
set priMap [list]
for { set priIndex 0 } { $priIndex < [ string length $app_array($index,pri) ] } { incr priIndex } {
lappend priMap [ string index $app_array($index,pri) $priIndex ]
}
ixNet setA $attr -priorityMap $priMap
}
if { [ info exists app_array($index,sel) ] } {
set sel 0
switch $app_array($index,sel) {
01 {
set sel 1
}
10 {
set sel 2
}
11 {
set sel 3
}
}
ixNet setA $attr -sel $sel
}
if { [ info exists app_array($index,id) ] } {
ixNet setA $attr -protocolId $app_array($index,id)
}
} else {
ixNet setA $attr -enabled False
}
ixNet commit
}
}
}
app_pri {
ixNet setM $dcbxTlv \
-featureType 12 \
-featureEnable True
ixNet commit
set appTlv $dcbxTlv/tlvSettings/dcbxTlvAppQaz
set ap_list [ $tlv cget -hdr_apppriority_list ]
set index 0
foreach ap $ap_list {
set att [ lindex [ ixNet getL $appTlv dcbxAppPriorityAtt ] $index ]
set priority [ $ap cget -hdr_priority ]
set protocol_id [ $ap cget -hdr_protocol_id ]
set sel [ $ap cget -hdr_sel ]
ixNet setM $att -enabled True \
-priority $priority \
-protocolId $protocol_id \
-sel $sel
incr index
}
}
ets {
ixNet setM $dcbxTlv \
-featureType 10 \
-featureEnable True
ixNet commit
set etsTlv $dcbxTlv/tlvSettings/dcbxTlvEtsQaz
set factory [ $tlv cget -factory ]
switch $factory {
configuration {
set restrict 1
}
recommendation {
set restrict 2
}
default {
set restrict 1
}
}
set pri [ $tlv cget -pri ]
set tcg [ $tlv cget -tcg ]
set tsa [ $tlv cget -tsa ]
ixNet setM $etsTlv \
-tlvSendRestriction $restrict \
-tcGroupPriorityMap $pri \
-tcGroupTsaMap $tsa \
-tcGroupBwPercentMap $tcg
ixNet commit
}
pbfc {
ixNet setM $dcbxTlv \
-featureType 11 \
-featureEnable True
ixNet commit
set pbfcTlv $dcbxTlv/tlvSettings/dcbxTlvPfcQaz
Deputs "pbfcTlv: $pbfcTlv"
set pe [ $tlv cget -pe ]
set hdr_pfc_cap [ $tlv cget -hdr_pfc_cap ]
set hdr_mbc [ $tlv cget -hdr_mbc ]
Deputs "pe:$pe hdr_pfc_cap:$hdr_pfc_cap hdr_mbc:$hdr_mbc"
ixNet setM $pbfcTlv \
-mbc $hdr_mbc \
-pfcCapability $hdr_pfc_cap \
-pfcEnableVector $pe
ixNet commit
}
}
if { $org != 3 } {
set hdr_en [ $tlv cget -hdr_en ]
set hdr_willing [ $tlv cget -hdr_willing ]
set hdr_err [ $tlv cget -hdr_err ]
set hdr_sub_type [ $tlv cget -hdr_sub_type ]
set hdr_max_ver [ $tlv cget -hdr_max_ver ]
ixNet setM $dcbxTlv \
-errorOveride True \
-error $hdr_err \
-maxVersion $hdr_max_ver \
-subType $hdr_sub_type \
-featureEnable $hdr_en \
-willing $hdr_en
ixNet commit
}
}
}
ixNet commit
if { $notSupportFlag } {
return [ GetErrorReturnHeader $log ]
}
return [ GetStandardReturnHeader ]
}
body LldpDcbxHost::pause {} {
set tag "body LldpDcbxHost::pause [info script]"
Deputs "----- TAG: $tag -----"
return [ GetErrorReturnHeader "Method not supported yet." ]
}
body LldpDcbxHost::resume {} {
set tag "body LldpDcbxHost::resume [info script]"
Deputs "----- TAG: $tag -----"
return [ GetErrorReturnHeader "Method not supported yet." ]
}
body LldpDcbxHost::get_lldp_host_stats {} {
set tag "body LldpDcbxHost::get_lldp_host_stats [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set view {::ixNet::OBJ-/statistics/view:"DCBX"}
Deputs "view:$view"
set captionList [ ixNet getA $view/page -columnCaptions ]
Deputs "caption list:$captionList"
set port_name [ lsearch -exact $captionList {Stat Name} ]
set rx_age_outs_count [ lsearch -exact $captionList {LLDP Age Out Count} ]
set rx_error_frame_count [ lsearch -exact $captionList {LLDP Error Rx} ]
set rx_frame_count [ lsearch -exact $captionList {LLDP Rx} ]
# set rx_frame_discarded_count [ lsearch -exact $captionList {NA} ]
# set rx_tlvs_discarded_count [ lsearch -exact $captionList {NA} ]
set rx_tlvs_unrecognized_count [ lsearch -exact $captionList {LLDP Unrecognized TLV Rx} ]
set tx_frame_count [ lsearch -exact $captionList {LLDP Tx} ]
set ret [ GetStandardReturnHeader ]
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 statsItem "rx_age_outs_count"
set statsVal [ lindex $row $rx_age_outs_count ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_error_frame_count"
set statsVal [ lindex $row $rx_error_frame_count ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_frame_count"
set statsVal [ lindex $row $rx_frame_count ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_frame_discarded_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_tlvs_discarded_count"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_tlvs_unrecognized_count"
set statsVal [ lindex $row $rx_tlvs_unrecognized_count ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_frame_count"
set statsVal [ lindex $row $tx_frame_count ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
Deputs "ret:$ret"
}
return $ret
}
###---
# valid tlv_type:
# ignore
# chasid
# portid
class LldpTlv {
inherit Tlv
}
class LldpEndTlv {
inherit LldpTlv
}
class LldpTtlTlv {
inherit LldpTlv
}
class LldpCustomTlv {
inherit LldpTlv
}
class LldpChassisIdTlv {
inherit LldpTlv
public variable chassis_id_type
public variable chassis_id
constructor {} { chain chasid } {}
method config { args } {}
}
body LldpChassisIdTlv::config { args } {
global errorInfo
global errNumber
set tag "body LldpChassisIdTlv::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-chassis_id {
set chassis_id $value
}
-chassis_id_type {
set chassis_id_type $value
}
}
}
return [GetStandardReturnHeader]
}
class LldpPortIdTlv {
inherit LldpTlv
public variable port_id_type
public variable port_id
constructor {} { chain portid } {
set port_id_type mac_addr
}
method config { args } {}
}
body LldpPortIdTlv::config { args } {
global errorInfo
global errNumber
set tag "body LldpPortIdTlv::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-port_id {
set port_id $value
}
-port_id_type {
set port_id_type $value
}
}
}
return [GetStandardReturnHeader]
}
###---
# valid tlv_type:
# ignore
# subtype
# pg
class DcbxTlv {
inherit LldpTlv
public variable hdr_en
public variable hdr_willing
public variable hdr_err
public variable hdr_sub_type
public variable hdr_max_ver
method config { args } {
global errorInfo
global errNumber
set tag "body DcbxTlv::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-hdr_en {
set hdr_en $value
}
-hdr_willing {
set hdr_willing $value
}
-hdr_err {
set hdr_err $value
}
-hdr_sub_type -
-subtype {
set hdr_sub_type $value
}
-hdr_max_ver -
-max_ver {
set hdr_max_ver $value
}
}
}
return [GetStandardReturnHeader]
}
}
class DcbxSubTypeTlv {
inherit DcbxTlv
public variable oui
public variable org
method config { args } {}
}
body DcbxSubTypeTlv::config { args } {
global errorInfo
global errNumber
set tag "body LldpSubTypeTlv::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-oui {
set oui $value
}
-value {
set val $value
}
}
}
eval chain $args
return [GetStandardReturnHeader]
}
class DcbxSubType1Tlv {
inherit DcbxSubTypeTlv
constructor {} { chain subtype } {
set org 1
set oui 001b21
}
}
class DcbxSubType2Tlv {
inherit DcbxSubTypeTlv
constructor {} { chain subtype } {
set org 2
set oui 001b21
}
}
class DcbxValueControlTlv {
inherit DcbxTlv
}
class DcbxValuePgFeatureTlv {
inherit DcbxTlv
public variable bwg_pct_array
public variable bgw_pct
public variable pg_attr
public variable num_tcs_supported
constructor {} { chain pg } {
array set bwg_pct_array [ list ]
array set pg_attr [ list ]
}
method config { args } {}
method getPG {} {
return [ array get pg_attr ]
}
method getBWG {} {
return [ array get bwg_pct_array ]
}
}
body DcbxValuePgFeatureTlv::config { args } {
global errorInfo
global errNumber
set tag "body DcbxValuePgFeatureTlv::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
eval chain $args
array set bwg_pct_array [list]
array set pg_attr [list]
foreach { key value } $args {
set key [string tolower $key]
if { [ regexp -- {-bwg_pct([0-7])} $key match index ] } {
set bwg_pct_array($index) $value
}
if { [ regexp -- {-pri([0-7])_bwg_id} $key match index ] } {
set pg_attr($index,id) $value
}
if { [ regexp -- {-pri([0-7])_strict_pri} $key match index ] } {
set pg_attr($index,pri) $value
}
if { [ regexp -- {-pri([0-7])_bwg_pct} $key match index ] } {
set pg_attr($index,pct) $value
}
switch -exact -- $key {
-numtcssupported -
-num_tcs_supported {
set num_tcs_supported $value
}
}
}
set bgw_pct [list]
for { set index 0 } { $index < 8 } { incr index } {
if { [ info exists bwg_pct_array($index) ] } {
lappend bgw_pct $bwg_pct_array($index)
} else {
lappend bgw_pct 0
}
}
return [GetStandardReturnHeader]
}
class DcbxValuePfcFeatureTlv {
inherit DcbxTlv
public variable pe_array
public variable pe
public variable num_tcs_supported
constructor {} { chain pfc } {}
method config { args } {}
method getPE {} {
return [ array get pe_array ]
}
}
body DcbxValuePfcFeatureTlv::config { args } {
global errorInfo
global errNumber
set tag "body DcbxValuePfcFeatureTlv::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
eval chain $args
array set pe_array [list]
foreach { key value } $args {
set key [string tolower $key]
if { [ regexp -- {-pe([0-7])} $key match index ] } {
set pe_array($index) $value
}
switch -exact -- $key {
-tcpfc_num {
set num_tcs_supported $value
}
}
}
set pe [list]
for { set index 0 } { $index < 8 } { incr index } {
if { [ info exists pe_array($index) ] } {
lappend pe $pe_array($index)
} else {
lappend pe 0
}
}
return [GetStandardReturnHeader]
}
class DcbxValueAppFeatureTlv {
inherit DcbxTlv
public variable app_array
constructor {} { chain app } {}
method config { args } {}
method get_app {} {
return [ array get app_array ]
}
}
body DcbxValueAppFeatureTlv::config { args } {
global errorInfo
global errNumber
set tag "body DcbxValueAppFeatureTlv::config [info script]"
Deputs "----- TAG: $tag -----"
eval chain $args
array set app_array [list]
foreach { key value } $args {
set key [string tolower $key]
if { [ regexp -- {-pri_map([1-8])} $key match index ] } {
if { [ info exists app_array(index) ] == 0 } {
lappend app_array(index) $index
} else {
if { [ lsearch $app_array(index) $index ] < 0 } {
lappend app_array(index) $index
}
}
set app_array($index,pri) $value
}
if { [ regexp -- {-app([1-8])_id} $key match index ] } {
if { [ info exists app_array(index) ] == 0 } {
lappend app_array(index) $index
} else {
if { [ lsearch $app_array(index) $index ] < 0 } {
lappend app_array(index) $index
}
}
set app_array($index,id) $value
}
if { [ regexp -- {-app([1-8])_selector} $key match index ] } {
if { [ info exists app_array(index) ] == 0 } {
lappend app_array(index) $index
} else {
if { [ lsearch $app_array(index) $index ] < 0 } {
lappend app_array(index) $index
}
}
set app_array($index,sel) $value
}
}
Deputs "app: [ array names app_array ]"
return [GetStandardReturnHeader]
}
class DcbxValueCustomFeatureTlv {
inherit DcbxTlv
public variable hdr_type
constructor {} { chain custom } {}
method config { args } {}
}
body DcbxValueCustomFeatureTlv::config { args } {
global errorInfo
global errNumber