blob: b450b87931f52211b0a3caf266f88246bf406aa5 [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"
Elia Battistonac63b112022-01-12 18:40:49 +010023 "math/rand"
24 "strconv"
25
Matteo Scandolof9d43412021-01-12 11:11:34 -080026 "github.com/google/gopacket"
Holger Hildebrandtb9a3dd02022-05-12 08:20:41 +000027 "github.com/opencord/bbsim/internal/common"
Andrea Campanella10426e22021-10-15 17:58:04 +020028 "github.com/opencord/omci-lib-go/v2"
29 me "github.com/opencord/omci-lib-go/v2/generated"
David K. Bainbridgec415efe2021-08-19 13:05:21 +000030 "github.com/opencord/voltha-protos/v5/go/openolt"
Matteo Scandolof9d43412021-01-12 11:11:34 -080031 log "github.com/sirupsen/logrus"
Matteo Scandolof9d43412021-01-12 11:11:34 -080032)
33
34func ParseGetRequest(omciPkt gopacket.Packet) (*omci.GetRequest, error) {
35 msgLayer := omciPkt.Layer(omci.LayerTypeGetRequest)
36 if msgLayer == nil {
37 err := "omci Msg layer could not be detected for LayerTypeGetRequest"
38 omciLogger.Error(err)
39 return nil, errors.New(err)
40 }
41 msgObj, msgOk := msgLayer.(*omci.GetRequest)
42 if !msgOk {
43 err := "omci Msg layer could not be assigned for LayerTypeGetRequest"
44 omciLogger.Error(err)
45 return nil, errors.New(err)
46 }
47 return msgObj, nil
48}
49
Matteo Scandoloc00e97a2021-05-27 11:45:27 -070050func CreateGetResponse(omciPkt gopacket.Packet, omciMsg *omci.OMCI, onuSn *openolt.SerialNumber, mds uint8,
51 activeImageEntityId uint16, committedImageEntityId uint16, standbyImageVersion string, activeImageVersion string,
52 committedImageVersion string, onuDown bool) ([]byte, error) {
Matteo Scandolof9d43412021-01-12 11:11:34 -080053 msgObj, err := ParseGetRequest(omciPkt)
Matteo Scandolof9d43412021-01-12 11:11:34 -080054 if err != nil {
55 return nil, err
56 }
Matteo Scandolof9d43412021-01-12 11:11:34 -080057 omciLogger.WithFields(log.Fields{
Holger Hildebrandt02101a62022-04-06 13:00:51 +000058 "DeviceIdent": omciMsg.DeviceIdentifier,
Matteo Scandolof9d43412021-01-12 11:11:34 -080059 "EntityClass": msgObj.EntityClass,
60 "EntityInstance": msgObj.EntityInstance,
61 "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask),
Matteo Scandolo992a23e2021-02-04 15:35:04 -080062 }).Trace("received-omci-get-request")
Matteo Scandolof9d43412021-01-12 11:11:34 -080063
64 var response *omci.GetResponse
Holger Hildebrandt02101a62022-04-06 13:00:51 +000065
66 isExtended := false
67 if omciMsg.DeviceIdentifier == omci.ExtendedIdent {
68 isExtended = true
69 }
Matteo Scandolof9d43412021-01-12 11:11:34 -080070 switch msgObj.EntityClass {
71 case me.Onu2GClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000072 response = createOnu2gResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Matteo Scandolof9d43412021-01-12 11:11:34 -080073 case me.OnuGClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000074 response = createOnugResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuSn)
Matteo Scandolof9d43412021-01-12 11:11:34 -080075 case me.SoftwareImageClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000076 response = createSoftwareImageResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance,
Matteo Scandoloc00e97a2021-05-27 11:45:27 -070077 activeImageEntityId, committedImageEntityId, standbyImageVersion, activeImageVersion, committedImageVersion)
Matteo Scandolof9d43412021-01-12 11:11:34 -080078 case me.IpHostConfigDataClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000079 response = createIpHostResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Elia Battistonac63b112022-01-12 18:40:49 +010080 case me.VoipConfigDataClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000081 response = createVoipConfigDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Matteo Scandolof9d43412021-01-12 11:11:34 -080082 case me.UniGClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000083 response = createUnigResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
Matteo Scandolof9d43412021-01-12 11:11:34 -080084 case me.PhysicalPathTerminationPointEthernetUniClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000085 response = createPptpEthernetResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
Elia Battistonac63b112022-01-12 18:40:49 +010086 case me.PhysicalPathTerminationPointPotsUniClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000087 response = createPptpPotsResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuDown)
Matteo Scandolof9d43412021-01-12 11:11:34 -080088 case me.AniGClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000089 response = createAnigResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Matteo Scandolof9d43412021-01-12 11:11:34 -080090 case me.OnuDataClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000091 response = createOnuDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, mds)
Girish Gowdraa539f522021-02-15 23:00:45 -080092 case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000093 response = createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Girish Gowdraa539f522021-02-15 23:00:45 -080094 case me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000095 response = createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Girish Gowdraa539f522021-02-15 23:00:45 -080096 case me.EthernetPerformanceMonitoringHistoryDataClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000097 response = createEthernetPerformanceMonitoringHistoryDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Girish Gowdra6d9a1a42021-03-05 16:07:15 -080098 case me.FecPerformanceMonitoringHistoryDataClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +000099 response = createFecPerformanceMonitoringHistoryDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800100 case me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000101 response = createGemPortNetworkCtpPerformanceMonitoringHistoryData(isExtended, msgObj.AttributeMask, msgObj.EntityInstance)
Himani Chawla6bd190a2021-07-09 15:31:01 +0530102 case me.EthernetFrameExtendedPmClassID,
103 me.EthernetFrameExtendedPm64BitClassID:
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000104 response = createEthernetFrameExtendedPmGetResponse(isExtended, msgObj.EntityClass, msgObj.AttributeMask, msgObj.EntityInstance)
Matteo Scandolof9d43412021-01-12 11:11:34 -0800105 default:
106 omciLogger.WithFields(log.Fields{
107 "EntityClass": msgObj.EntityClass,
108 "EntityInstance": msgObj.EntityInstance,
109 "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask),
110 }).Warnf("do-not-know-how-to-handle-get-request-for-me-class")
111 return nil, nil
112 }
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000113 omciLayer := &omci.OMCI{
114 TransactionID: omciMsg.TransactionID,
115 MessageType: omci.GetResponseType,
116 DeviceIdentifier: omciMsg.DeviceIdentifier,
117 }
118 var options gopacket.SerializeOptions
119 options.FixLengths = true
Matteo Scandolof9d43412021-01-12 11:11:34 -0800120
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000121 buffer := gopacket.NewSerializeBuffer()
122 err = gopacket.SerializeLayers(buffer, options, omciLayer, response)
Matteo Scandolof9d43412021-01-12 11:11:34 -0800123 if err != nil {
124 omciLogger.WithFields(log.Fields{
125 "Err": err,
126 "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
Matteo Scandolo78d5ee12021-04-14 11:11:32 -0700127 }).Error("cannot-Serialize-GetResponse")
Matteo Scandolof9d43412021-01-12 11:11:34 -0800128 return nil, err
129 }
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000130 pkt := buffer.Bytes()
Matteo Scandolof9d43412021-01-12 11:11:34 -0800131
132 log.WithFields(log.Fields{
133 "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
134 "pkt": hex.EncodeToString(pkt),
135 }).Trace("omci-get-response")
136
137 return pkt, nil
138}
139
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000140func createOnu2gResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Matteo Scandolof9d43412021-01-12 11:11:34 -0800141
142 managedEntity, meErr := me.NewOnu2G(me.ParamData{
143 EntityID: entityID,
144 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100145 me.ManagedEntityID: entityID,
146 me.Onu2G_EquipmentId: ToOctets("12345123451234512345", 20),
Holger Hildebrandtb9a3dd02022-05-12 08:20:41 +0000147 me.Onu2G_OpticalNetworkUnitManagementAndControlChannelOmccVersion: common.Config.BBSim.OmccVersion,
Elia Battiston9bfe1102022-02-03 10:38:03 +0100148 me.Onu2G_VendorProductCode: 0,
149 me.Onu2G_SecurityCapability: 1,
150 me.Onu2G_SecurityMode: 1,
151 me.Onu2G_TotalPriorityQueueNumber: 1,
152 me.Onu2G_TotalTrafficSchedulerNumber: 1,
153 me.Onu2G_Deprecated: 1,
154 me.Onu2G_TotalGemPortIdNumber: 32,
155 me.Onu2G_Sysuptime: 319389947, // NOTE need to be smarter?
156 me.Onu2G_ConnectivityCapability: 127,
157 me.Onu2G_CurrentConnectivityMode: 5,
158 me.Onu2G_QualityOfServiceQosConfigurationFlexibility: 48,
159 me.Onu2G_PriorityQueueScaleFactor: 1,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800160 },
161 })
162
163 if meErr.GetError() != nil {
164 omciLogger.Errorf("NewOnu2G %v", meErr.Error())
165 return nil
166 }
167
168 return &omci.GetResponse{
169 MeBasePacket: omci.MeBasePacket{
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000170 EntityClass: me.Onu2GClassID,
171 EntityInstance: entityID,
172 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800173 },
174 Attributes: managedEntity.GetAttributeValueMap(),
175 AttributeMask: attributeMask,
176 Result: me.Success,
177 }
178}
179
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000180func createOnugResponse(isExtended bool, attributeMask uint16, entityID uint16, onuSn *openolt.SerialNumber) *omci.GetResponse {
Matteo Scandolo5863f002021-02-08 08:08:14 -0800181
182 managedEntity, meErr := me.NewOnuG(me.ParamData{
183 EntityID: entityID,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800184 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100185 me.ManagedEntityID: entityID,
186 me.OnuG_VendorId: ToOctets("BBSM", 4),
187 me.OnuG_Version: ToOctets("v0.0.1", 14),
188 me.OnuG_SerialNumber: append(onuSn.VendorId, onuSn.VendorSpecific...),
189 me.OnuG_TrafficManagementOption: 0,
190 me.OnuG_Deprecated: 0,
191 me.OnuG_BatteryBackup: 0,
192 me.OnuG_AdministrativeState: 0,
193 me.OnuG_OperationalState: 0,
194 me.OnuG_OnuSurvivalTime: 10,
195 me.OnuG_LogicalOnuId: ToOctets("BBSM", 24),
196 me.OnuG_LogicalPassword: ToOctets("BBSM", 12),
197 me.OnuG_CredentialsStatus: 0,
198 me.OnuG_ExtendedTcLayerOptions: 0,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800199 },
Matteo Scandolo5863f002021-02-08 08:08:14 -0800200 })
201
202 if meErr.GetError() != nil {
203 omciLogger.Errorf("NewOnu2G %v", meErr.Error())
204 return nil
Matteo Scandolof9d43412021-01-12 11:11:34 -0800205 }
Matteo Scandolo5863f002021-02-08 08:08:14 -0800206
207 return &omci.GetResponse{
208 MeBasePacket: omci.MeBasePacket{
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000209 EntityClass: me.OnuGClassID,
210 EntityInstance: entityID,
211 Extended: isExtended,
Matteo Scandolo5863f002021-02-08 08:08:14 -0800212 },
213 Attributes: managedEntity.GetAttributeValueMap(),
214 AttributeMask: attributeMask,
215 Result: me.Success,
216 }
Matteo Scandolof9d43412021-01-12 11:11:34 -0800217}
218
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000219func createSoftwareImageResponse(isExtended bool, attributeMask uint16, entityInstance uint16, activeImageEntityId uint16,
Matteo Scandoloc00e97a2021-05-27 11:45:27 -0700220 committedImageEntityId uint16, standbyImageVersion string, activeImageVersion string, committedImageVersion string) *omci.GetResponse {
Matteo Scandolocedde462021-03-09 17:37:16 -0800221
222 omciLogger.WithFields(log.Fields{
223 "EntityInstance": entityInstance,
Matteo Scandoloc00e97a2021-05-27 11:45:27 -0700224 "AttributeMask": attributeMask,
Matteo Scandolo21195d62021-04-07 14:31:23 -0700225 }).Trace("received-get-software-image-request")
Matteo Scandolocedde462021-03-09 17:37:16 -0800226
227 // Only one image can be active and committed
228 committed := 0
229 active := 0
Matteo Scandoloc00e97a2021-05-27 11:45:27 -0700230 version := standbyImageVersion
Matteo Scandolocedde462021-03-09 17:37:16 -0800231 if entityInstance == activeImageEntityId {
232 active = 1
Matteo Scandoloc00e97a2021-05-27 11:45:27 -0700233 version = activeImageVersion
Matteo Scandolocedde462021-03-09 17:37:16 -0800234 }
235 if entityInstance == committedImageEntityId {
236 committed = 1
Matteo Scandoloc00e97a2021-05-27 11:45:27 -0700237 version = committedImageVersion
238 }
239
240 imageHash, err := hex.DecodeString(hex.EncodeToString([]byte(version)))
241 if err != nil {
242 omciLogger.WithFields(log.Fields{
243 "entityId": entityInstance,
244 "active": active,
245 "committed": committed,
246 "err": err,
247 }).Error("cannot-generate-image-hash")
Matteo Scandolocedde462021-03-09 17:37:16 -0800248 }
249
Matteo Scandolof9d43412021-01-12 11:11:34 -0800250 // NOTE that we need send the response for the correct ME Instance or the adapter won't process it
Matteo Scandolocedde462021-03-09 17:37:16 -0800251 res := &omci.GetResponse{
Matteo Scandolof9d43412021-01-12 11:11:34 -0800252 MeBasePacket: omci.MeBasePacket{
253 EntityClass: me.SoftwareImageClassID,
254 EntityInstance: entityInstance,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000255 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800256 },
257 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100258 me.ManagedEntityID: 0,
259 me.SoftwareImage_Version: ToOctets(version, 14),
260 me.SoftwareImage_IsCommitted: committed,
261 me.SoftwareImage_IsActive: active,
262 me.SoftwareImage_IsValid: 1,
263 me.SoftwareImage_ProductCode: ToOctets("BBSIM-ONU", 25),
264 me.SoftwareImage_ImageHash: imageHash,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800265 },
266 Result: me.Success,
267 AttributeMask: attributeMask,
268 }
Matteo Scandolocedde462021-03-09 17:37:16 -0800269
270 omciLogger.WithFields(log.Fields{
271 "omciMessage": res,
272 "entityId": entityInstance,
273 "active": active,
274 "committed": committed,
Matteo Scandolo21195d62021-04-07 14:31:23 -0700275 }).Trace("Reporting SoftwareImage")
Matteo Scandolocedde462021-03-09 17:37:16 -0800276
277 return res
Matteo Scandolof9d43412021-01-12 11:11:34 -0800278}
279
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000280func createIpHostResponse(isExtended bool, attributeMask uint16, entityInstance uint16) *omci.GetResponse {
Matteo Scandolof9d43412021-01-12 11:11:34 -0800281 return &omci.GetResponse{
282 MeBasePacket: omci.MeBasePacket{
283 EntityClass: me.IpHostConfigDataClassID,
284 EntityInstance: entityInstance,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000285 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800286 },
287 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100288 me.ManagedEntityID: 0,
289 me.IpHostConfigData_MacAddress: ToOctets("aabbcc", 6),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800290 },
291 Result: me.Success,
292 AttributeMask: attributeMask,
293 }
294}
295
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000296func createVoipConfigDataResponse(isExtended bool, attributeMask uint16, entityInstance uint16) *omci.GetResponse {
Elia Battistonac63b112022-01-12 18:40:49 +0100297 return &omci.GetResponse{
298 MeBasePacket: omci.MeBasePacket{
299 EntityClass: me.VoipConfigDataClassID,
300 EntityInstance: entityInstance,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000301 Extended: isExtended,
Elia Battistonac63b112022-01-12 18:40:49 +0100302 },
303 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100304 me.ManagedEntityID: 0,
305 me.VoipConfigData_AvailableSignallingProtocols: 1,
306 me.VoipConfigData_SignallingProtocolUsed: 1,
307 me.VoipConfigData_AvailableVoipConfigurationMethods: 1,
308 me.VoipConfigData_VoipConfigurationMethodUsed: 1,
309 me.VoipConfigData_VoipConfigurationAddressPointer: 0xFFFF,
310 me.VoipConfigData_VoipConfigurationState: 0,
311 me.VoipConfigData_RetrieveProfile: 0,
312 me.VoipConfigData_ProfileVersion: 0,
Elia Battistonac63b112022-01-12 18:40:49 +0100313 },
314 Result: me.Success,
315 AttributeMask: attributeMask,
316 }
317}
318
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000319func createUnigResponse(isExtended bool, attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
Girish Gowdra996d81e2021-04-21 16:16:27 -0700320 // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks)
321 omciAdminState := 1
322 if !onuDown {
323 omciAdminState = 0
324 }
Matteo Scandolof9d43412021-01-12 11:11:34 -0800325 managedEntity, meErr := me.NewUniG(me.ParamData{
326 EntityID: entityID,
327 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100328 me.ManagedEntityID: entityID,
329 me.UniG_Deprecated: 0,
330 me.UniG_AdministrativeState: omciAdminState,
331 me.UniG_ManagementCapability: 0,
332 me.UniG_NonOmciManagementIdentifier: 1,
333 me.UniG_RelayAgentOptions: 1,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800334 },
335 })
336
337 if meErr.GetError() != nil {
338 omciLogger.Errorf("NewUniG %v", meErr.Error())
339 return nil
340 }
341
342 return &omci.GetResponse{
343 MeBasePacket: omci.MeBasePacket{
Girish Gowdrac3fd50c2021-03-12 16:14:44 -0800344 EntityClass: me.UniGClassID,
345 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000346 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800347 },
348 Attributes: managedEntity.GetAttributeValueMap(),
349 AttributeMask: attributeMask,
350 Result: me.Success,
351 }
352}
353
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000354func createPptpEthernetResponse(isExtended bool, attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
Girish Gowdra996d81e2021-04-21 16:16:27 -0700355 // Valid values for oper_state are 0 (enabled) and 1 (disabled)
356 // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks)
357 onuAdminState := 1
358 if !onuDown {
359 onuAdminState = 0
360 }
361 onuOperState := onuAdminState // For now make the assumption that oper state reflects the admin state
Matteo Scandolof9d43412021-01-12 11:11:34 -0800362 managedEntity, meErr := me.NewPhysicalPathTerminationPointEthernetUni(me.ParamData{
363 EntityID: entityID,
364 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100365 me.ManagedEntityID: entityID,
366 me.PhysicalPathTerminationPointEthernetUni_ExpectedType: 0,
367 me.PhysicalPathTerminationPointEthernetUni_SensedType: 0,
368 me.PhysicalPathTerminationPointEthernetUni_AutoDetectionConfiguration: 0,
369 me.PhysicalPathTerminationPointEthernetUni_EthernetLoopbackConfiguration: 0,
370 me.PhysicalPathTerminationPointEthernetUni_AdministrativeState: onuAdminState,
371 me.PhysicalPathTerminationPointEthernetUni_OperationalState: onuOperState,
372 me.PhysicalPathTerminationPointEthernetUni_ConfigurationInd: 0,
373 me.PhysicalPathTerminationPointEthernetUni_MaxFrameSize: 0,
374 me.PhysicalPathTerminationPointEthernetUni_DteOrDceInd: 0,
375 me.PhysicalPathTerminationPointEthernetUni_PauseTime: 0,
376 me.PhysicalPathTerminationPointEthernetUni_BridgedOrIpInd: 0,
377 me.PhysicalPathTerminationPointEthernetUni_Arc: 0,
378 me.PhysicalPathTerminationPointEthernetUni_ArcInterval: 0,
379 me.PhysicalPathTerminationPointEthernetUni_PppoeFilter: 0,
380 me.PhysicalPathTerminationPointEthernetUni_PowerControl: 0,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800381 },
382 })
383
384 if meErr.GetError() != nil {
385 omciLogger.Errorf("NewPhysicalPathTerminationPointEthernetUni %v", meErr.Error())
386 return nil
387 }
388
389 return &omci.GetResponse{
390 MeBasePacket: omci.MeBasePacket{
Girish Gowdrac3fd50c2021-03-12 16:14:44 -0800391 EntityClass: me.PhysicalPathTerminationPointEthernetUniClassID,
392 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000393 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800394 },
395 Attributes: managedEntity.GetAttributeValueMap(),
396 AttributeMask: attributeMask,
397 Result: me.Success,
398 }
399}
400
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000401func createPptpPotsResponse(isExtended bool, attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse {
Elia Battistonac63b112022-01-12 18:40:49 +0100402 // Valid values for oper_state are 0 (enabled) and 1 (disabled)
403 // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks)
404 onuAdminState := 1
405 if !onuDown {
406 onuAdminState = 0
407 }
408 onuOperState := onuAdminState // For now make the assumption that oper state reflects the admin state
409 managedEntity, meErr := me.NewPhysicalPathTerminationPointPotsUni(me.ParamData{
410 EntityID: entityID,
411 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100412 me.ManagedEntityID: entityID,
413 me.PhysicalPathTerminationPointPotsUni_AdministrativeState: onuAdminState,
414 me.PhysicalPathTerminationPointPotsUni_Deprecated: 0,
415 me.PhysicalPathTerminationPointPotsUni_Arc: 0,
416 me.PhysicalPathTerminationPointPotsUni_ArcInterval: 0,
417 me.PhysicalPathTerminationPointPotsUni_Impedance: 0,
418 me.PhysicalPathTerminationPointPotsUni_TransmissionPath: 0,
419 me.PhysicalPathTerminationPointPotsUni_RxGain: 0,
420 me.PhysicalPathTerminationPointPotsUni_TxGain: 0,
421 me.PhysicalPathTerminationPointPotsUni_OperationalState: onuOperState,
422 me.PhysicalPathTerminationPointPotsUni_HookState: 0,
423 me.PhysicalPathTerminationPointPotsUni_PotsHoldoverTime: 0,
424 me.PhysicalPathTerminationPointPotsUni_NominalFeedVoltage: 0,
425 me.PhysicalPathTerminationPointPotsUni_LossOfSoftswitch: 0,
Elia Battistonac63b112022-01-12 18:40:49 +0100426 },
427 })
428
429 if meErr.GetError() != nil {
430 omciLogger.Errorf("NewPhysicalPathTerminationPointPotsUni %v", meErr.Error())
431 return nil
432 }
433
434 return &omci.GetResponse{
435 MeBasePacket: omci.MeBasePacket{
436 EntityClass: me.PhysicalPathTerminationPointPotsUniClassID,
437 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000438 Extended: isExtended,
Elia Battistonac63b112022-01-12 18:40:49 +0100439 },
440 Attributes: managedEntity.GetAttributeValueMap(),
441 AttributeMask: attributeMask,
442 Result: me.Success,
443 }
444}
445
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000446func createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Girish Gowdraa539f522021-02-15 23:00:45 -0800447 managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(me.ParamData{
Matteo Scandolof9d43412021-01-12 11:11:34 -0800448 EntityID: entityID,
449 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100450 me.ManagedEntityID: entityID,
451 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
452 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_ThresholdData12Id: 0,
453 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_DropEvents: rand.Intn(100),
454 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Octets: rand.Intn(100),
455 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets: rand.Intn(100),
456 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_BroadcastPackets: rand.Intn(100),
457 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_MulticastPackets: rand.Intn(100),
458 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_CrcErroredPackets: rand.Intn(100),
459 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_UndersizePackets: rand.Intn(100),
460 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_OversizePackets: rand.Intn(100),
461 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets64Octets: rand.Intn(100),
462 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets65To127Octets: rand.Intn(100),
463 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets128To255Octets: rand.Intn(100),
464 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets256To511Octets: rand.Intn(100),
465 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets512To1023Octets: rand.Intn(100),
466 me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets1024To1518Octets: rand.Intn(100),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800467 },
468 })
469
470 if meErr.GetError() != nil {
Girish Gowdraa539f522021-02-15 23:00:45 -0800471 omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataUpstream %v", meErr.Error())
Matteo Scandolof9d43412021-01-12 11:11:34 -0800472 return nil
473 }
474
475 return &omci.GetResponse{
476 MeBasePacket: omci.MeBasePacket{
Girish Gowdraa539f522021-02-15 23:00:45 -0800477 EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
478 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000479 Extended: isExtended,
Girish Gowdraa539f522021-02-15 23:00:45 -0800480 },
481 Attributes: managedEntity.GetAttributeValueMap(),
482 AttributeMask: attributeMask,
483 Result: me.Success,
484 }
485}
486
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000487func createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Girish Gowdraa539f522021-02-15 23:00:45 -0800488 managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(me.ParamData{
489 EntityID: entityID,
490 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100491 me.ManagedEntityID: entityID,
492 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
493 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_ThresholdData12Id: 0,
494 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_DropEvents: rand.Intn(100),
495 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Octets: rand.Intn(100),
496 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets: rand.Intn(100),
497 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_BroadcastPackets: rand.Intn(100),
498 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_MulticastPackets: rand.Intn(100),
499 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_CrcErroredPackets: rand.Intn(100),
500 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_UndersizePackets: rand.Intn(100),
501 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_OversizePackets: rand.Intn(100),
502 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets64Octets: rand.Intn(100),
503 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets65To127Octets: rand.Intn(100),
504 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets128To255Octets: rand.Intn(100),
505 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets256To511Octets: rand.Intn(100),
506 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets512To1023Octets: rand.Intn(100),
507 me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets1024To1518Octets: rand.Intn(100),
Girish Gowdraa539f522021-02-15 23:00:45 -0800508 },
509 })
510
511 if meErr.GetError() != nil {
512 omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataDownstream %v", meErr.Error())
513 return nil
514 }
515
Girish Gowdraa539f522021-02-15 23:00:45 -0800516 return &omci.GetResponse{
517 MeBasePacket: omci.MeBasePacket{
518 EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
519 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000520 Extended: isExtended,
Girish Gowdraa539f522021-02-15 23:00:45 -0800521 },
522 Attributes: managedEntity.GetAttributeValueMap(),
523 AttributeMask: attributeMask,
524 Result: me.Success,
525 }
526}
527
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000528func createEthernetPerformanceMonitoringHistoryDataResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Girish Gowdraa539f522021-02-15 23:00:45 -0800529 managedEntity, meErr := me.NewEthernetPerformanceMonitoringHistoryData(me.ParamData{
530 EntityID: entityID,
531 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100532 me.ManagedEntityID: entityID,
533 me.EthernetPerformanceMonitoringHistoryData_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
534 me.EthernetPerformanceMonitoringHistoryData_ThresholdData12Id: 0,
535 me.EthernetPerformanceMonitoringHistoryData_FcsErrors: rand.Intn(100),
536 me.EthernetPerformanceMonitoringHistoryData_ExcessiveCollisionCounter: rand.Intn(100),
537 me.EthernetPerformanceMonitoringHistoryData_LateCollisionCounter: rand.Intn(100),
538 me.EthernetPerformanceMonitoringHistoryData_FramesTooLong: rand.Intn(100),
539 me.EthernetPerformanceMonitoringHistoryData_BufferOverflowsOnReceive: rand.Intn(100),
540 me.EthernetPerformanceMonitoringHistoryData_BufferOverflowsOnTransmit: rand.Intn(100),
541 me.EthernetPerformanceMonitoringHistoryData_SingleCollisionFrameCounter: rand.Intn(100),
542 me.EthernetPerformanceMonitoringHistoryData_MultipleCollisionsFrameCounter: rand.Intn(100),
543 me.EthernetPerformanceMonitoringHistoryData_SqeCounter: rand.Intn(100),
544 me.EthernetPerformanceMonitoringHistoryData_DeferredTransmissionCounter: rand.Intn(100),
545 me.EthernetPerformanceMonitoringHistoryData_InternalMacTransmitErrorCounter: rand.Intn(100),
546 me.EthernetPerformanceMonitoringHistoryData_CarrierSenseErrorCounter: rand.Intn(100),
547 me.EthernetPerformanceMonitoringHistoryData_AlignmentErrorCounter: rand.Intn(100),
548 me.EthernetPerformanceMonitoringHistoryData_InternalMacReceiveErrorCounter: rand.Intn(100),
Girish Gowdraa539f522021-02-15 23:00:45 -0800549 },
550 })
551
552 if meErr.GetError() != nil {
553 omciLogger.Errorf("NewEthernetPerformanceMonitoringHistoryData %v", meErr.Error())
554 return nil
555 }
556
Girish Gowdraa539f522021-02-15 23:00:45 -0800557 return &omci.GetResponse{
558 MeBasePacket: omci.MeBasePacket{
559 EntityClass: me.EthernetPerformanceMonitoringHistoryDataClassID,
560 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000561 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800562 },
563 Attributes: managedEntity.GetAttributeValueMap(),
564 AttributeMask: attributeMask,
565 Result: me.Success,
566 }
567}
568
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000569func createFecPerformanceMonitoringHistoryDataResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800570 managedEntity, meErr := me.NewFecPerformanceMonitoringHistoryData(me.ParamData{
571 EntityID: entityID,
572 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100573 me.ManagedEntityID: entityID,
574 me.FecPerformanceMonitoringHistoryData_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
575 me.FecPerformanceMonitoringHistoryData_ThresholdData12Id: 0,
576 me.FecPerformanceMonitoringHistoryData_CorrectedBytes: rand.Intn(100),
577 me.FecPerformanceMonitoringHistoryData_CorrectedCodeWords: rand.Intn(100),
578 me.FecPerformanceMonitoringHistoryData_UncorrectableCodeWords: rand.Intn(100),
579 me.FecPerformanceMonitoringHistoryData_TotalCodeWords: rand.Intn(100),
580 me.FecPerformanceMonitoringHistoryData_FecSeconds: rand.Intn(100),
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800581 },
582 })
583
584 if meErr.GetError() != nil {
585 omciLogger.Errorf("NewFecPerformanceMonitoringHistoryData %v", meErr.Error())
586 return nil
587 }
588
589 // FEC History counter fits within single gem payload.
590 // No need of the logical we use in other Ethernet History counters or Gem Port History counters
591
592 return &omci.GetResponse{
593 MeBasePacket: omci.MeBasePacket{
594 EntityClass: me.FecPerformanceMonitoringHistoryDataClassID,
595 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000596 Extended: isExtended,
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800597 },
598 Attributes: managedEntity.GetAttributeValueMap(),
599 AttributeMask: attributeMask,
600 Result: me.Success,
601 }
602}
603
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000604func createGemPortNetworkCtpPerformanceMonitoringHistoryData(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800605 managedEntity, meErr := me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(me.ParamData{
606 EntityID: entityID,
607 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100608 me.ManagedEntityID: entityID,
609 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now.
610 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_ThresholdData12Id: 0,
611 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_TransmittedGemFrames: rand.Intn(100),
612 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_ReceivedGemFrames: rand.Intn(100),
613 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_ReceivedPayloadBytes: rand.Intn(100),
614 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_TransmittedPayloadBytes: rand.Intn(100),
615 me.GemPortNetworkCtpPerformanceMonitoringHistoryData_EncryptionKeyErrors: rand.Intn(100),
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800616 },
617 })
618
619 if meErr.GetError() != nil {
620 omciLogger.Errorf("NewGemPortNetworkCtpPerformanceMonitoringHistoryData %v", meErr.Error())
621 return nil
622 }
623
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800624 return &omci.GetResponse{
625 MeBasePacket: omci.MeBasePacket{
626 EntityClass: me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID,
627 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000628 Extended: isExtended,
Girish Gowdra6d9a1a42021-03-05 16:07:15 -0800629 },
630 Attributes: managedEntity.GetAttributeValueMap(),
631 AttributeMask: attributeMask,
632 Result: me.Success,
633 }
634}
635
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000636func createOnuDataResponse(isExtended bool, attributeMask uint16, entityID uint16, mds uint8) *omci.GetResponse {
Matteo Scandolof9d43412021-01-12 11:11:34 -0800637 managedEntity, meErr := me.NewOnuData(me.ParamData{
638 EntityID: entityID,
639 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100640 me.ManagedEntityID: entityID,
641 me.OnuData_MibDataSync: mds,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800642 },
643 })
644
645 if meErr.GetError() != nil {
646 omciLogger.Errorf("NewOnuData %v", meErr.Error())
647 return nil
648 }
649
650 return &omci.GetResponse{
651 MeBasePacket: omci.MeBasePacket{
Girish Gowdraa539f522021-02-15 23:00:45 -0800652 EntityClass: me.OnuDataClassID,
653 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000654 Extended: isExtended,
Girish Gowdraa539f522021-02-15 23:00:45 -0800655 },
656 Attributes: managedEntity.GetAttributeValueMap(),
657 AttributeMask: attributeMask,
658 Result: me.Success,
659 }
660}
661
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000662func createAnigResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse {
Girish Gowdraa539f522021-02-15 23:00:45 -0800663 managedEntity, meErr := me.NewAniG(me.ParamData{
664 EntityID: entityID,
665 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100666 me.ManagedEntityID: entityID,
667 me.AniG_SrIndication: 0,
668 me.AniG_TotalTcontNumber: 0,
669 me.AniG_GemBlockLength: 0,
670 me.AniG_PiggybackDbaReporting: 0,
671 me.AniG_Deprecated: 0,
672 me.AniG_SignalFailThreshold: 0,
673 me.AniG_SignalDegradeThreshold: 0,
674 me.AniG_Arc: 0,
675 me.AniG_ArcInterval: 0,
676 me.AniG_OpticalSignalLevel: rand.Intn(16000), // generate some random power level than defaulting to 0
677 me.AniG_LowerOpticalThreshold: 0,
678 me.AniG_UpperOpticalThreshold: 0,
679 me.AniG_OnuResponseTime: 0,
680 me.AniG_TransmitOpticalLevel: rand.Intn(16000), // generate some random power level than defaulting to 0
681 me.AniG_LowerTransmitPowerThreshold: 0,
682 me.AniG_UpperTransmitPowerThreshold: 0,
Girish Gowdraa539f522021-02-15 23:00:45 -0800683 },
684 })
685
686 if meErr.GetError() != nil {
687 omciLogger.Errorf("NewAniG %v", meErr.Error())
688 return nil
689 }
690
691 return &omci.GetResponse{
692 MeBasePacket: omci.MeBasePacket{
693 EntityClass: me.AniGClassID,
694 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000695 Extended: isExtended,
Matteo Scandolof9d43412021-01-12 11:11:34 -0800696 },
697 Attributes: managedEntity.GetAttributeValueMap(),
698 AttributeMask: attributeMask,
699 Result: me.Success,
700 }
701}
702
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000703func createEthernetFrameExtendedPmGetResponse(isExtended bool, meClass me.ClassID, attributeMask uint16, entityID uint16) *omci.GetResponse {
Himani Chawla6bd190a2021-07-09 15:31:01 +0530704
705 callback := me.NewEthernetFrameExtendedPm
706 if meClass != me.EthernetFrameExtendedPmClassID {
707 callback = me.NewEthernetFrameExtendedPm64Bit
708 }
Elia Battiston9bfe1102022-02-03 10:38:03 +0100709
710 //The names of these attributes are left as strings
711 //rather than constants of a particular ME because
712 //they can be used with both the MEs in the lines above
Himani Chawla908a1f52022-01-27 14:39:44 +0530713 attr := me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +0100714 me.ManagedEntityID: entityID,
Himani Chawla908a1f52022-01-27 14:39:44 +0530715 "DropEvents": 100,
716 "Octets": 101,
717 "Frames": 102,
718 "BroadcastFrames": 103,
719 "MulticastFrames": 104,
720 "CrcErroredFrames": 105,
721 "UndersizeFrames": 106,
722 "OversizeFrames": 107,
723 "Frames64Octets": 108,
724 "Frames65To127Octets": 109,
725 "Frames128To255Octets": 110,
726 "Frames256To511Octets": 111,
727 "Frames512To1023Octets": 112,
728 "Frames1024To1518Octets": 113,
729 }
Himani Chawla6bd190a2021-07-09 15:31:01 +0530730 managedEntity, meErr := callback(me.ParamData{
Himani Chawla908a1f52022-01-27 14:39:44 +0530731 EntityID: entityID,
732 Attributes: attr,
Himani Chawla6bd190a2021-07-09 15:31:01 +0530733 })
734
735 if meErr.GetError() != nil {
736 omciLogger.Errorf("NewEthernetFrameExtendedPm %v", meErr.Error())
737 return nil
738 }
739
740 return &omci.GetResponse{
741 MeBasePacket: omci.MeBasePacket{
742 EntityClass: meClass,
743 EntityInstance: entityID,
Holger Hildebrandt02101a62022-04-06 13:00:51 +0000744 Extended: isExtended,
Himani Chawla6bd190a2021-07-09 15:31:01 +0530745 },
746 Attributes: managedEntity.GetAttributeValueMap(),
747 AttributeMask: attributeMask,
748 Result: me.Success,
749 }
750}
751
Matteo Scandoloef4e8f82021-05-17 11:20:49 -0700752func ToOctets(str string, size int) []byte {
Matteo Scandolof9d43412021-01-12 11:11:34 -0800753 asciiBytes := []byte(str)
754
755 if len(asciiBytes) < size {
756 missing := size - len(asciiBytes)
757 for i := 0; i < missing; i++ {
758 asciiBytes = append(asciiBytes, []byte{0x00}[0])
759 }
760 }
761 return asciiBytes
762}