blob: 15188fabd56dc9a60bd7025d7434dcd0e9eddeae [file] [log] [blame]
Zdravko Bozakov3d762142019-07-15 16:57:17 +02001package core
2
3type PerformanceMonitoringHistoryData int
4
5const (
6 _ = iota
7 IntervalEndTime PerformanceMonitoringHistoryData = 0x8000
8 ThresholdDataId PerformanceMonitoringHistoryData = 0x4000
9 FCSErrors PerformanceMonitoringHistoryData = 0x2000
10 ExcessiveCollisionCounter PerformanceMonitoringHistoryData = 0x1000
11 LateCollisionCounter PerformanceMonitoringHistoryData = 0x0800
12 FrameTooLong PerformanceMonitoringHistoryData = 0x0400
13 BufferOverflowOnReceive PerformanceMonitoringHistoryData = 0x0200
14 BufferOverflowOnTransmit PerformanceMonitoringHistoryData = 0x0100
15 SingleCollisionFrameCounter PerformanceMonitoringHistoryData = 0x0080
16 MultipleCollisionFrameCounter PerformanceMonitoringHistoryData = 0x0040
17 SQECounter PerformanceMonitoringHistoryData = 0x0020
18 DeferredTransmissionCounter PerformanceMonitoringHistoryData = 0x0010
19 InternalMACTransmitErrorCounter PerformanceMonitoringHistoryData = 0x0008
20 CarrierSenseErrorCounter PerformanceMonitoringHistoryData = 0x0004
21 AllignmentErrorCounter PerformanceMonitoringHistoryData = 0x0002
22 InternalMACReceiveErrorCounter PerformanceMonitoringHistoryData = 0x0001
23)
24
25type PMHistoryAttributeHandler func(*uint, []byte) ([]byte, error)
26
27var PMHistoryAttributeHandlers = map[PerformanceMonitoringHistoryData]ANIGAttributeHandler{
28 IntervalEndTime : GetIntervalEndTime,
29 ThresholdDataId: GetThresholdDataId,
30 FCSErrors: GetFCSErrors,
31 ExcessiveCollisionCounter: GetExcessiveCollisionCounter,
32 LateCollisionCounter: GetLateCollisionCounter,
33 FrameTooLong: GetFrameTooLong,
34 BufferOverflowOnReceive: GetBufferOverflowOnReceive,
35 BufferOverflowOnTransmit: GetBufferOverflowOnTransmit,
36 SingleCollisionFrameCounter: GetSingleCollisionFrameCounter,
37 MultipleCollisionFrameCounter: GetMultipleCollisionFrameCounter,
38 SQECounter: GetSQECounter,
39 DeferredTransmissionCounter: GetDeferredTransmissionCounter,
40 InternalMACTransmitErrorCounter: GetInternalMACTransmitErrorCounter,
41 CarrierSenseErrorCounter: GetCarrierSenseErrorCounter,
42 AllignmentErrorCounter: GetAllignmentErrorCounter,
43 InternalMACReceiveErrorCounter: GetInternalMACReceiveErrorCounter,
44}
45
46func GetEthernetPMHistoryDataAttributes(pos *uint, pkt []byte, content OmciContent) ([]byte, error) {
47 AttributesMask := getAttributeMask(content)
48
49 for index := uint(16); index>=1 ; index-- {
50 Attribute := 1 << (index - 1)
51 reqAttribute := Attribute & AttributesMask
52
53 if reqAttribute != 0 {
54 pkt, _ = PMHistoryAttributeHandlers[PerformanceMonitoringHistoryData(reqAttribute)](pos, pkt)
55 }
56 }
57
58 pkt[8] = 0x00 // Command Processed Successfully
59 pkt[9] = uint8(AttributesMask >> 8)
60 pkt[10] = uint8(AttributesMask & 0x00FF)
61
62 return pkt, nil
63
64}
65
66func GetIntervalEndTime(pos *uint, pkt []byte) ([]byte, error) {
67 // With the hardware, it is seen that all attributes are 0x00
68 // Nevertheless these functions are made to provide specific values in future if required
69 *pos++
70 return pkt, nil
71}
72
73func GetThresholdDataId(pos *uint, pkt []byte) ([]byte, error) {
74 *pos++
75 *pos++
76 return pkt, nil
77}
78
79func GetFCSErrors(pos *uint, pkt []byte) ([]byte, error) {
80 *pos++
81 *pos++
82 *pos++
83 *pos++
84 return pkt, nil
85}
86
87func GetExcessiveCollisionCounter(pos *uint, pkt []byte) ([]byte, error) {
88 *pos++
89 *pos++
90 *pos++
91 *pos++
92 return pkt, nil
93}
94
95func GetLateCollisionCounter(pos *uint, pkt []byte) ([]byte, error) {
96 *pos++
97 *pos++
98 *pos++
99 *pos++
100 return pkt, nil
101}
102
103func GetFrameTooLong(pos *uint, pkt []byte) ([]byte, error) {
104 *pos++
105 *pos++
106 *pos++
107 *pos++
108 return pkt, nil
109}
110
111func GetBufferOverflowOnReceive(pos *uint, pkt []byte) ([]byte, error) {
112 *pos++
113 *pos++
114 *pos++
115 *pos++
116 return pkt, nil
117}
118
119func GetBufferOverflowOnTransmit(pos *uint, pkt []byte) ([]byte, error) {
120 *pos++
121 *pos++
122 *pos++
123 *pos++
124 return pkt, nil
125}
126
127func GetSingleCollisionFrameCounter(pos *uint, pkt []byte) ([]byte, error) {
128 *pos++
129 *pos++
130 *pos++
131 *pos++
132 return pkt, nil
133}
134
135func GetMultipleCollisionFrameCounter(pos *uint, pkt []byte) ([]byte, error) {
136 *pos++
137 *pos++
138 *pos++
139 *pos++
140 return pkt, nil
141}
142
143func GetSQECounter(pos *uint, pkt []byte) ([]byte, error) {
144 *pos++
145 *pos++
146 *pos++
147 *pos++
148 return pkt, nil
149}
150
151func GetDeferredTransmissionCounter(pos *uint, pkt []byte) ([]byte, error) {
152 *pos++
153 *pos++
154 *pos++
155 *pos++
156 return pkt, nil
157}
158
159func GetInternalMACTransmitErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
160 *pos++
161 *pos++
162 *pos++
163 *pos++
164 return pkt, nil
165}
166
167func GetCarrierSenseErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
168 *pos++
169 *pos++
170 *pos++
171 *pos++
172 return pkt, nil
173}
174
175func GetAllignmentErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
176 *pos++
177 *pos++
178 *pos++
179 *pos++
180 return pkt, nil
181}
182
183func GetInternalMACReceiveErrorCounter(pos *uint, pkt []byte) ([]byte, error) {
184 *pos++
185 *pos++
186 *pos++
187 *pos++
188 return pkt, nil
189}
190
191