blob: f6f32dfb56a985b0b512a9439367d14bd8613bd3 [file] [log] [blame]
Matteo Scandolof9d43412021-01-12 11:11:34 -08001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package omci
18
19import (
20 "encoding/hex"
21 "errors"
22 "fmt"
23 "github.com/google/gopacket"
24 "github.com/opencord/omci-lib-go"
25 me "github.com/opencord/omci-lib-go/generated"
Matteo Scandolo5863f002021-02-08 08:08:14 -080026 "github.com/opencord/voltha-protos/v4/go/openolt"
Matteo Scandolof9d43412021-01-12 11:11:34 -080027 log "github.com/sirupsen/logrus"
Girish Gowdraa539f522021-02-15 23:00:45 -080028 "math/rand"
Matteo Scandolof9d43412021-01-12 11:11:34 -080029 "strconv"
30)
31
32func ParseGetRequest(omciPkt gopacket.Packet) (*omci.GetRequest, error) {
33 msgLayer := omciPkt.Layer(omci.LayerTypeGetRequest)
34 if msgLayer == nil {
35 err := "omci Msg layer could not be detected for LayerTypeGetRequest"
36 omciLogger.Error(err)
37 return nil, errors.New(err)
38 }
39 msgObj, msgOk := msgLayer.(*omci.GetRequest)
40 if !msgOk {
41 err := "omci Msg layer could not be assigned for LayerTypeGetRequest"
42 omciLogger.Error(err)
43 return nil, errors.New(err)
44 }
45 return msgObj, nil
46}
47
Matteo Scandolo992a23e2021-02-04 15:35:04 -080048func CreateGetResponse(omciPkt gopacket.Packet, omciMsg *omci.OMCI, onuSn *openolt.SerialNumber, mds uint8) ([]byte, error) {
Matteo Scandolof9d43412021-01-12 11:11:34 -080049
50 msgObj, err := ParseGetRequest(omciPkt)
51
52 if err != nil {
53 return nil, err
54 }
55
56 omciLogger.WithFields(log.Fields{
57 "EntityClass": msgObj.EntityClass,
58 "EntityInstance": msgObj.EntityInstance,
59 "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask),
Matteo Scandolo992a23e2021-02-04 15:35:04 -080060 }).Trace("received-omci-get-request")
Matteo Scandolof9d43412021-01-12 11:11:34 -080061
62 var response *omci.GetResponse
63 switch msgObj.EntityClass {
64 case me.Onu2GClassID:
65 response = createOnu2gResponse(msgObj.AttributeMask, msgObj.EntityInstance)
66 case me.OnuGClassID:
Matteo Scandolo5863f002021-02-08 08:08:14 -080067 response = createOnugResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuSn)
Matteo Scandolof9d43412021-01-12 11:11:34 -080068 case me.SoftwareImageClassID:
69 response = createSoftwareImageResponse(msgObj.AttributeMask, msgObj.EntityInstance)
70 case me.IpHostConfigDataClassID:
71 response = createIpHostResponse(msgObj.AttributeMask, msgObj.EntityInstance)
72 case me.UniGClassID:
73 response = createUnigResponse(msgObj.AttributeMask, msgObj.EntityInstance)
74 case me.PhysicalPathTerminationPointEthernetUniClassID:
75 response = createPptpResponse(msgObj.AttributeMask, msgObj.EntityInstance)
76 case me.AniGClassID:
77 response = createAnigResponse(msgObj.AttributeMask, msgObj.EntityInstance)
78 case me.OnuDataClassID:
Matteo Scandolo992a23e2021-02-04 15:35:04 -080079 response = createOnuDataResponse(msgObj.AttributeMask, msgObj.EntityInstance, mds)
Girish Gowdraa539f522021-02-15 23:00:45 -080080 case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID:
81 response = createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(msgObj.AttributeMask, msgObj.EntityInstance)
82 case me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID:
83 response = createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(msgObj.AttributeMask, msgObj.EntityInstance)
84 case me.EthernetPerformanceMonitoringHistoryDataClassID:
85 response = createEthernetPerformanceMonitoringHistoryDataResponse(msgObj.AttributeMask, msgObj.EntityInstance)
Matteo Scandolof9d43412021-01-12 11:11:34 -080086 default:
87 omciLogger.WithFields(log.Fields{
88 "EntityClass": msgObj.EntityClass,
89 "EntityInstance": msgObj.EntityInstance,
90 "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask),
91 }).Warnf("do-not-know-how-to-handle-get-request-for-me-class")
92 return nil, nil
93 }
94
Matteo Scandolo992a23e2021-02-04 15:35:04 -080095 pkt, err := Serialize(omci.GetResponseType, response, omciMsg.TransactionID)
Matteo Scandolof9d43412021-01-12 11:11:34 -080096 if err != nil {
97 omciLogger.WithFields(log.Fields{
98 "Err": err,
99 "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
Matteo Scandolo992a23e2021-02-04 15:35:04 -0800100 }).Error("cannot-Serialize-Onu2gResponse")
Matteo Scandolof9d43412021-01-12 11:11:34 -0800101 return nil, err
102 }
103
104 log.WithFields(log.Fields{
105 "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
106 "pkt": hex.EncodeToString(pkt),
107 }).Trace("omci-get-response")
108
109 return pkt, nil
110}
111
112func createOnu2gResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
113
114 managedEntity, meErr := me.NewOnu2G(me.ParamData{
115 EntityID: entityID,
116 Attributes: me.AttributeValueMap{
117 "ManagedEntityId": entityID,
Matteo Scandolo9a1842d2021-02-08 16:00:17 -0800118 "EquipmentId": toOctets("12345123451234512345", 20),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800119 "OpticalNetworkUnitManagementAndControlChannelOmccVersion": 180,
120 "VendorProductCode": 0,
121 "SecurityCapability": 1,
122 "SecurityMode": 1,
123 "TotalPriorityQueueNumber": 1,
124 "TotalTrafficSchedulerNumber": 1,
125 "Deprecated": 1,
126 "TotalGemPortIdNumber": 32,
127 "Sysuptime": 319389947, // NOTE need to be smarter?
128 "ConnectivityCapability": 127,
129 "CurrentConnectivityMode": 5,
130 "QualityOfServiceQosConfigurationFlexibility": 48,
131 "PriorityQueueScaleFactor": 1,
132 },
133 })
134
135 if meErr.GetError() != nil {
136 omciLogger.Errorf("NewOnu2G %v", meErr.Error())
137 return nil
138 }
139
140 return &omci.GetResponse{
141 MeBasePacket: omci.MeBasePacket{
142 EntityClass: me.Onu2GClassID,
143 },
144 Attributes: managedEntity.GetAttributeValueMap(),
145 AttributeMask: attributeMask,
146 Result: me.Success,
147 }
148}
149
Matteo Scandolo5863f002021-02-08 08:08:14 -0800150func createOnugResponse(attributeMask uint16, entityID uint16, onuSn *openolt.SerialNumber) *omci.GetResponse {
151
152 managedEntity, meErr := me.NewOnuG(me.ParamData{
153 EntityID: entityID,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800154 Attributes: me.AttributeValueMap{
155 "ManagedEntityId": entityID,
156 "VendorId": toOctets("BBSM", 4),
157 "Version": toOctets("v0.0.1", 14),
Matteo Scandolo5863f002021-02-08 08:08:14 -0800158 "SerialNumber": append(onuSn.VendorId, onuSn.VendorSpecific...),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800159 "TrafficManagementOption": 0,
160 "Deprecated": 0,
161 "BatteryBackup": 0,
162 "AdministrativeState": 0,
163 "OperationalState": 0,
164 "OnuSurvivalTime": 10,
165 "LogicalOnuId": toOctets("BBSM", 24),
166 "LogicalPassword": toOctets("BBSM", 12),
167 "CredentialsStatus": 0,
168 "ExtendedTcLayerOptions": 0,
169 },
Matteo Scandolo5863f002021-02-08 08:08:14 -0800170 })
171
172 if meErr.GetError() != nil {
173 omciLogger.Errorf("NewOnu2G %v", meErr.Error())
174 return nil
Matteo Scandolof9d43412021-01-12 11:11:34 -0800175 }
Matteo Scandolo5863f002021-02-08 08:08:14 -0800176
177 return &omci.GetResponse{
178 MeBasePacket: omci.MeBasePacket{
179 EntityClass: me.OnuGClassID,
180 },
181 Attributes: managedEntity.GetAttributeValueMap(),
182 AttributeMask: attributeMask,
183 Result: me.Success,
184 }
185
186 //return &omci.GetResponse{
187 // MeBasePacket: omci.MeBasePacket{
188 // EntityClass: me.OnuGClassID,
189 // EntityInstance: entityID,
190 // },
191 // Attributes: me.AttributeValueMap{
192 //
193 // },
194 // Result: me.Success,
195 // AttributeMask: attributeMask,
196 //}
Matteo Scandolof9d43412021-01-12 11:11:34 -0800197}
198
199func createSoftwareImageResponse(attributeMask uint16, entityInstance uint16) *omci.GetResponse {
200 // NOTE that we need send the response for the correct ME Instance or the adapter won't process it
201 return &omci.GetResponse{
202 MeBasePacket: omci.MeBasePacket{
203 EntityClass: me.SoftwareImageClassID,
204 EntityInstance: entityInstance,
205 },
206 Attributes: me.AttributeValueMap{
207 "ManagedEntityId": 0,
Matteo Scandolo9a1842d2021-02-08 16:00:17 -0800208 "Version": toOctets("00000000000001", 14),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800209 "IsCommitted": 1,
210 "IsActive": 1,
211 "IsValid": 1,
212 "ProductCode": toOctets("product-code", 25),
213 "ImageHash": toOctets("broadband-sim", 16),
214 },
215 Result: me.Success,
216 AttributeMask: attributeMask,
217 }
218}
219
220func createIpHostResponse(attributeMask uint16, entityInstance uint16) *omci.GetResponse {
221 return &omci.GetResponse{
222 MeBasePacket: omci.MeBasePacket{
223 EntityClass: me.IpHostConfigDataClassID,
224 EntityInstance: entityInstance,
225 },
226 Attributes: me.AttributeValueMap{
227 "ManagedEntityId": 0,
228 "MacAddress": toOctets("aabbcc", 6),
229 },
230 Result: me.Success,
231 AttributeMask: attributeMask,
232 }
233}
234
235func createUnigResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
236 managedEntity, meErr := me.NewUniG(me.ParamData{
237 EntityID: entityID,
238 Attributes: me.AttributeValueMap{
239 "ManagedEntityId": entityID,
240 "Deprecated": 0,
241 "AdministrativeState": 0,
242 "ManagementCapability": 0,
243 "NonOmciManagementIdentifier": 1,
244 "RelayAgentOptions": 1,
245 },
246 })
247
248 if meErr.GetError() != nil {
249 omciLogger.Errorf("NewUniG %v", meErr.Error())
250 return nil
251 }
252
253 return &omci.GetResponse{
254 MeBasePacket: omci.MeBasePacket{
255 EntityClass: me.UniGClassID,
256 },
257 Attributes: managedEntity.GetAttributeValueMap(),
258 AttributeMask: attributeMask,
259 Result: me.Success,
260 }
261}
262
263func createPptpResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
264 managedEntity, meErr := me.NewPhysicalPathTerminationPointEthernetUni(me.ParamData{
265 EntityID: entityID,
266 Attributes: me.AttributeValueMap{
267 "ManagedEntityId": entityID,
268 "ExpectedType": 0,
269 "SensedType": 0,
270 "AutoDetectionConfiguration": 0,
271 "EthernetLoopbackConfiguration": 0,
272 "AdministrativeState": 0,
273 "OperationalState": 0,
274 "ConfigurationInd": 0,
275 "MaxFrameSize": 0,
276 "DteOrDceInd": 0,
277 "PauseTime": 0,
278 "BridgedOrIpInd": 0,
279 "Arc": 0,
280 "ArcInterval": 0,
281 "PppoeFilter": 0,
282 "PowerControl": 0,
283 },
284 })
285
286 if meErr.GetError() != nil {
287 omciLogger.Errorf("NewPhysicalPathTerminationPointEthernetUni %v", meErr.Error())
288 return nil
289 }
290
291 return &omci.GetResponse{
292 MeBasePacket: omci.MeBasePacket{
293 EntityClass: me.PhysicalPathTerminationPointEthernetUniClassID,
294 },
295 Attributes: managedEntity.GetAttributeValueMap(),
296 AttributeMask: attributeMask,
297 Result: me.Success,
298 }
299}
300
Girish Gowdraa539f522021-02-15 23:00:45 -0800301func createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
302 fmt.Printf("createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse attribute mask = %v", attributeMask)
303 managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(me.ParamData{
Matteo Scandolof9d43412021-01-12 11:11:34 -0800304 EntityID: entityID,
305 Attributes: me.AttributeValueMap{
Girish Gowdraa539f522021-02-15 23:00:45 -0800306 "ManagedEntityId": entityID,
307 "IntervalEndTime": 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
308 "ThresholdData12Id": 0,
309 "DropEvents": rand.Intn(100),
310 "Octets": rand.Intn(100),
311 "Packets": rand.Intn(100),
312 "BroadcastPackets": rand.Intn(100),
313 "MulticastPackets": rand.Intn(100),
314 "CrcErroredPackets": rand.Intn(100),
315 "UndersizePackets": rand.Intn(100),
316 "OversizePackets": rand.Intn(100),
317 "Packets64Octets": rand.Intn(100),
318 "Packets65To127Octets": rand.Intn(100),
319 "Packets128To255Octets": rand.Intn(100),
320 "Packets256To511Octets": rand.Intn(100),
321 "Packets512To1023Octets": rand.Intn(100),
322 "Packets1024To1518Octets": rand.Intn(100),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800323 },
324 })
325
326 if meErr.GetError() != nil {
Girish Gowdraa539f522021-02-15 23:00:45 -0800327 omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataUpstream %v", meErr.Error())
Matteo Scandolof9d43412021-01-12 11:11:34 -0800328 return nil
329 }
330
Girish Gowdraa539f522021-02-15 23:00:45 -0800331 // L2 PM counters MEs exceed max allowed OMCI payload size.
332 // So the request/responses are always multipart.
333 // First identify the attributes that are not requested in the current GET request.
334 // Then filter out those attributes from the responses in the current GET response.
335 unwantedAttributeMask := ^attributeMask
336 var i uint16
337 for i = 1; i <= 16; i++ { // 1 and 16 because they are allowed valid min and max index keys in AttributeValueMap.
338 // We leave out 0 because that is ManagedEntity and that is a default IE in the map
339 if (1<<(16-i))&unwantedAttributeMask > 0 {
340 if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
341 omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
342 }
343 }
344 }
345
Matteo Scandolof9d43412021-01-12 11:11:34 -0800346 return &omci.GetResponse{
347 MeBasePacket: omci.MeBasePacket{
Girish Gowdraa539f522021-02-15 23:00:45 -0800348 EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
349 EntityInstance: entityID,
350 },
351 Attributes: managedEntity.GetAttributeValueMap(),
352 AttributeMask: attributeMask,
353 Result: me.Success,
354 }
355}
356
357func createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
358 fmt.Printf("createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse attribute mask = %v", attributeMask)
359 managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(me.ParamData{
360 EntityID: entityID,
361 Attributes: me.AttributeValueMap{
362 "ManagedEntityId": entityID,
363 "IntervalEndTime": 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
364 "ThresholdData12Id": 0,
365 "DropEvents": rand.Intn(100),
366 "Octets": rand.Intn(100),
367 "Packets": rand.Intn(100),
368 "BroadcastPackets": rand.Intn(100),
369 "MulticastPackets": rand.Intn(100),
370 "CrcErroredPackets": rand.Intn(100),
371 "UndersizePackets": rand.Intn(100),
372 "OversizePackets": rand.Intn(100),
373 "Packets64Octets": rand.Intn(100),
374 "Packets65To127Octets": rand.Intn(100),
375 "Packets128To255Octets": rand.Intn(100),
376 "Packets256To511Octets": rand.Intn(100),
377 "Packets512To1023Octets": rand.Intn(100),
378 "Packets1024To1518Octets": rand.Intn(100),
379 },
380 })
381
382 if meErr.GetError() != nil {
383 omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataDownstream %v", meErr.Error())
384 return nil
385 }
386
387 // L2 PM counters MEs exceed max allowed OMCI payload size.
388 // So the request/responses are always multipart.
389 // First identify the attributes that are not requested in the current GET request.
390 // Then filter out those attributes from the responses in the current GET response.
391 unwantedAttributeMask := ^attributeMask
392 var i uint16
393 for i = 1; i <= 16; i++ { // 1 and 16 because they are allowed valid min and max index keys in AttributeValueMap.
394 // We leave out 0 because that is ManagedEntity and that is a default IE in the map
395 if (1<<(16-i))&unwantedAttributeMask > 0 {
396 if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
397 omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
398 }
399 }
400 }
401
402 return &omci.GetResponse{
403 MeBasePacket: omci.MeBasePacket{
404 EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
405 EntityInstance: entityID,
406 },
407 Attributes: managedEntity.GetAttributeValueMap(),
408 AttributeMask: attributeMask,
409 Result: me.Success,
410 }
411}
412
413func createEthernetPerformanceMonitoringHistoryDataResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
414 fmt.Printf("createEthernetPerformanceMonitoringHistoryDataResponse attribute mask = %v", attributeMask)
415 managedEntity, meErr := me.NewEthernetPerformanceMonitoringHistoryData(me.ParamData{
416 EntityID: entityID,
417 Attributes: me.AttributeValueMap{
418 "ManagedEntityId": entityID,
419 "IntervalEndTime": 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
420 "ThresholdData12Id": 0,
421 "FcsErrors": rand.Intn(100),
422 "ExcessiveCollisionCounter": rand.Intn(100),
423 "LateCollisionCounter": rand.Intn(100),
424 "FramesTooLong": rand.Intn(100),
425 "BufferOverflowsOnReceive": rand.Intn(100),
426 "BufferOverflowsOnTransmit": rand.Intn(100),
427 "SingleCollisionFrameCounter": rand.Intn(100),
428 "MultipleCollisionsFrameCounter": rand.Intn(100),
429 "SqeCounter": rand.Intn(100),
430 "DeferredTransmissionCounter": rand.Intn(100),
431 "InternalMacTransmitErrorCounter": rand.Intn(100),
432 "CarrierSenseErrorCounter": rand.Intn(100),
433 "AlignmentErrorCounter": rand.Intn(100),
434 "InternalMacReceiveErrorCounter": rand.Intn(100),
435 },
436 })
437
438 if meErr.GetError() != nil {
439 omciLogger.Errorf("NewEthernetPerformanceMonitoringHistoryData %v", meErr.Error())
440 return nil
441 }
442
443 // L2 PM counters MEs exceed max allowed OMCI payload size.
444 // So the request/responses are always multipart.
445 // First identify the attributes that are not requested in the current GET request.
446 // Then filter out those attributes from the responses in the current GET response.
447 unwantedAttributeMask := ^attributeMask
448 var i uint16
449 for i = 1; i <= 16; i++ { // 1 and 16 because they are allowed valid min and max index keys in AttributeValueMap.
450 // We leave out 0 because that is ManagedEntity and that is a default IE in the map
451 if (1<<(16-i))&unwantedAttributeMask > 0 {
452 if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
453 omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
454 }
455 }
456 }
457
458 return &omci.GetResponse{
459 MeBasePacket: omci.MeBasePacket{
460 EntityClass: me.EthernetPerformanceMonitoringHistoryDataClassID,
461 EntityInstance: entityID,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800462 },
463 Attributes: managedEntity.GetAttributeValueMap(),
464 AttributeMask: attributeMask,
465 Result: me.Success,
466 }
467}
468
Matteo Scandolo992a23e2021-02-04 15:35:04 -0800469func createOnuDataResponse(attributeMask uint16, entityID uint16, mds uint8) *omci.GetResponse {
Matteo Scandolof9d43412021-01-12 11:11:34 -0800470 managedEntity, meErr := me.NewOnuData(me.ParamData{
471 EntityID: entityID,
472 Attributes: me.AttributeValueMap{
473 "ManagedEntityId": entityID,
Matteo Scandolo992a23e2021-02-04 15:35:04 -0800474 "MibDataSync": mds,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800475 },
476 })
477
478 if meErr.GetError() != nil {
479 omciLogger.Errorf("NewOnuData %v", meErr.Error())
480 return nil
481 }
482
483 return &omci.GetResponse{
484 MeBasePacket: omci.MeBasePacket{
Girish Gowdraa539f522021-02-15 23:00:45 -0800485 EntityClass: me.OnuDataClassID,
486 EntityInstance: entityID,
487 },
488 Attributes: managedEntity.GetAttributeValueMap(),
489 AttributeMask: attributeMask,
490 Result: me.Success,
491 }
492}
493
494func createAnigResponse(attributeMask uint16, entityID uint16) *omci.GetResponse {
495 managedEntity, meErr := me.NewAniG(me.ParamData{
496 EntityID: entityID,
497 Attributes: me.AttributeValueMap{
498 "ManagedEntityId": entityID,
499 "SrIndication": 0,
500 "TotalTcontNumber": 0,
501 "GemBlockLength": 0,
502 "PiggybackDbaReporting": 0,
503 "Deprecated": 0,
504 "SignalFailThreshold": 0,
505 "SignalDegradeThreshold": 0,
506 "Arc": 0,
507 "ArcInterval": 0,
508 "OpticalSignalLevel": rand.Intn(16000), // generate some random power level than defaulting to 0
509 "LowerOpticalThreshold": 0,
510 "UpperOpticalThreshold": 0,
511 "OnuResponseTime": 0,
512 "TransmitOpticalLevel": rand.Intn(16000), // generate some random power level than defaulting to 0
513 "LowerTransmitPowerThreshold": 0,
514 "UpperTransmitPowerThreshold": 0,
515 },
516 })
517
518 if meErr.GetError() != nil {
519 omciLogger.Errorf("NewAniG %v", meErr.Error())
520 return nil
521 }
522
523 return &omci.GetResponse{
524 MeBasePacket: omci.MeBasePacket{
525 EntityClass: me.AniGClassID,
526 EntityInstance: entityID,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800527 },
528 Attributes: managedEntity.GetAttributeValueMap(),
529 AttributeMask: attributeMask,
530 Result: me.Success,
531 }
532}
533
534func toOctets(str string, size int) []byte {
535 asciiBytes := []byte(str)
536
537 if len(asciiBytes) < size {
538 missing := size - len(asciiBytes)
539 for i := 0; i < missing; i++ {
540 asciiBytes = append(asciiBytes, []byte{0x00}[0])
541 }
542 }
543 return asciiBytes
544}