Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package omci |
| 18 | |
| 19 | import ( |
| 20 | "encoding/hex" |
| 21 | "errors" |
| 22 | "fmt" |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 23 | "math/rand" |
| 24 | "strconv" |
| 25 | |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 26 | "github.com/google/gopacket" |
Andrea Campanella | 10426e2 | 2021-10-15 17:58:04 +0200 | [diff] [blame] | 27 | "github.com/opencord/omci-lib-go/v2" |
| 28 | me "github.com/opencord/omci-lib-go/v2/generated" |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 29 | "github.com/opencord/voltha-protos/v5/go/openolt" |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 30 | log "github.com/sirupsen/logrus" |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 31 | ) |
| 32 | |
| 33 | func ParseGetRequest(omciPkt gopacket.Packet) (*omci.GetRequest, error) { |
| 34 | msgLayer := omciPkt.Layer(omci.LayerTypeGetRequest) |
| 35 | if msgLayer == nil { |
| 36 | err := "omci Msg layer could not be detected for LayerTypeGetRequest" |
| 37 | omciLogger.Error(err) |
| 38 | return nil, errors.New(err) |
| 39 | } |
| 40 | msgObj, msgOk := msgLayer.(*omci.GetRequest) |
| 41 | if !msgOk { |
| 42 | err := "omci Msg layer could not be assigned for LayerTypeGetRequest" |
| 43 | omciLogger.Error(err) |
| 44 | return nil, errors.New(err) |
| 45 | } |
| 46 | return msgObj, nil |
| 47 | } |
| 48 | |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 49 | func CreateGetResponse(omciPkt gopacket.Packet, omciMsg *omci.OMCI, onuSn *openolt.SerialNumber, mds uint8, |
| 50 | activeImageEntityId uint16, committedImageEntityId uint16, standbyImageVersion string, activeImageVersion string, |
| 51 | committedImageVersion string, onuDown bool) ([]byte, error) { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 52 | msgObj, err := ParseGetRequest(omciPkt) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 56 | omciLogger.WithFields(log.Fields{ |
| 57 | "EntityClass": msgObj.EntityClass, |
| 58 | "EntityInstance": msgObj.EntityInstance, |
| 59 | "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask), |
Matteo Scandolo | 992a23e | 2021-02-04 15:35:04 -0800 | [diff] [blame] | 60 | }).Trace("received-omci-get-request") |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 61 | |
| 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 Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 67 | response = createOnugResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuSn) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 68 | case me.SoftwareImageClassID: |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 69 | response = createSoftwareImageResponse(msgObj.AttributeMask, msgObj.EntityInstance, |
| 70 | activeImageEntityId, committedImageEntityId, standbyImageVersion, activeImageVersion, committedImageVersion) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 71 | case me.IpHostConfigDataClassID: |
| 72 | response = createIpHostResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 73 | case me.VoipConfigDataClassID: |
| 74 | response = createVoipConfigDataResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 75 | case me.UniGClassID: |
Girish Gowdra | 996d81e | 2021-04-21 16:16:27 -0700 | [diff] [blame] | 76 | response = createUnigResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 77 | case me.PhysicalPathTerminationPointEthernetUniClassID: |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 78 | response = createPptpEthernetResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown) |
| 79 | case me.PhysicalPathTerminationPointPotsUniClassID: |
| 80 | response = createPptpPotsResponse(msgObj.AttributeMask, msgObj.EntityInstance, onuDown) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 81 | case me.AniGClassID: |
| 82 | response = createAnigResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
| 83 | case me.OnuDataClassID: |
Matteo Scandolo | 992a23e | 2021-02-04 15:35:04 -0800 | [diff] [blame] | 84 | response = createOnuDataResponse(msgObj.AttributeMask, msgObj.EntityInstance, mds) |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 85 | case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID: |
| 86 | response = createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
| 87 | case me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID: |
| 88 | response = createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
| 89 | case me.EthernetPerformanceMonitoringHistoryDataClassID: |
| 90 | response = createEthernetPerformanceMonitoringHistoryDataResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 91 | case me.FecPerformanceMonitoringHistoryDataClassID: |
| 92 | response = createFecPerformanceMonitoringHistoryDataResponse(msgObj.AttributeMask, msgObj.EntityInstance) |
| 93 | case me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID: |
| 94 | response = createGemPortNetworkCtpPerformanceMonitoringHistoryData(msgObj.AttributeMask, msgObj.EntityInstance) |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 95 | case me.EthernetFrameExtendedPmClassID, |
| 96 | me.EthernetFrameExtendedPm64BitClassID: |
| 97 | response = createEthernetFrameExtendedPmGetResponse(msgObj.EntityClass, msgObj.AttributeMask, msgObj.EntityInstance) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 98 | default: |
| 99 | omciLogger.WithFields(log.Fields{ |
| 100 | "EntityClass": msgObj.EntityClass, |
| 101 | "EntityInstance": msgObj.EntityInstance, |
| 102 | "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask), |
| 103 | }).Warnf("do-not-know-how-to-handle-get-request-for-me-class") |
| 104 | return nil, nil |
| 105 | } |
| 106 | |
Matteo Scandolo | 992a23e | 2021-02-04 15:35:04 -0800 | [diff] [blame] | 107 | pkt, err := Serialize(omci.GetResponseType, response, omciMsg.TransactionID) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 108 | if err != nil { |
| 109 | omciLogger.WithFields(log.Fields{ |
| 110 | "Err": err, |
| 111 | "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
Matteo Scandolo | 78d5ee1 | 2021-04-14 11:11:32 -0700 | [diff] [blame] | 112 | }).Error("cannot-Serialize-GetResponse") |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 113 | return nil, err |
| 114 | } |
| 115 | |
| 116 | log.WithFields(log.Fields{ |
| 117 | "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
| 118 | "pkt": hex.EncodeToString(pkt), |
| 119 | }).Trace("omci-get-response") |
| 120 | |
| 121 | return pkt, nil |
| 122 | } |
| 123 | |
| 124 | func createOnu2gResponse(attributeMask uint16, entityID uint16) *omci.GetResponse { |
| 125 | |
| 126 | managedEntity, meErr := me.NewOnu2G(me.ParamData{ |
| 127 | EntityID: entityID, |
| 128 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 129 | me.ManagedEntityID: entityID, |
| 130 | me.Onu2G_EquipmentId: ToOctets("12345123451234512345", 20), |
| 131 | me.Onu2G_OpticalNetworkUnitManagementAndControlChannelOmccVersion: 180, |
| 132 | me.Onu2G_VendorProductCode: 0, |
| 133 | me.Onu2G_SecurityCapability: 1, |
| 134 | me.Onu2G_SecurityMode: 1, |
| 135 | me.Onu2G_TotalPriorityQueueNumber: 1, |
| 136 | me.Onu2G_TotalTrafficSchedulerNumber: 1, |
| 137 | me.Onu2G_Deprecated: 1, |
| 138 | me.Onu2G_TotalGemPortIdNumber: 32, |
| 139 | me.Onu2G_Sysuptime: 319389947, // NOTE need to be smarter? |
| 140 | me.Onu2G_ConnectivityCapability: 127, |
| 141 | me.Onu2G_CurrentConnectivityMode: 5, |
| 142 | me.Onu2G_QualityOfServiceQosConfigurationFlexibility: 48, |
| 143 | me.Onu2G_PriorityQueueScaleFactor: 1, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 144 | }, |
| 145 | }) |
| 146 | |
| 147 | if meErr.GetError() != nil { |
| 148 | omciLogger.Errorf("NewOnu2G %v", meErr.Error()) |
| 149 | return nil |
| 150 | } |
| 151 | |
| 152 | return &omci.GetResponse{ |
| 153 | MeBasePacket: omci.MeBasePacket{ |
| 154 | EntityClass: me.Onu2GClassID, |
| 155 | }, |
| 156 | Attributes: managedEntity.GetAttributeValueMap(), |
| 157 | AttributeMask: attributeMask, |
| 158 | Result: me.Success, |
| 159 | } |
| 160 | } |
| 161 | |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 162 | func createOnugResponse(attributeMask uint16, entityID uint16, onuSn *openolt.SerialNumber) *omci.GetResponse { |
| 163 | |
| 164 | managedEntity, meErr := me.NewOnuG(me.ParamData{ |
| 165 | EntityID: entityID, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 166 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 167 | me.ManagedEntityID: entityID, |
| 168 | me.OnuG_VendorId: ToOctets("BBSM", 4), |
| 169 | me.OnuG_Version: ToOctets("v0.0.1", 14), |
| 170 | me.OnuG_SerialNumber: append(onuSn.VendorId, onuSn.VendorSpecific...), |
| 171 | me.OnuG_TrafficManagementOption: 0, |
| 172 | me.OnuG_Deprecated: 0, |
| 173 | me.OnuG_BatteryBackup: 0, |
| 174 | me.OnuG_AdministrativeState: 0, |
| 175 | me.OnuG_OperationalState: 0, |
| 176 | me.OnuG_OnuSurvivalTime: 10, |
| 177 | me.OnuG_LogicalOnuId: ToOctets("BBSM", 24), |
| 178 | me.OnuG_LogicalPassword: ToOctets("BBSM", 12), |
| 179 | me.OnuG_CredentialsStatus: 0, |
| 180 | me.OnuG_ExtendedTcLayerOptions: 0, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 181 | }, |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 182 | }) |
| 183 | |
| 184 | if meErr.GetError() != nil { |
| 185 | omciLogger.Errorf("NewOnu2G %v", meErr.Error()) |
| 186 | return nil |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 187 | } |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 188 | |
| 189 | return &omci.GetResponse{ |
| 190 | MeBasePacket: omci.MeBasePacket{ |
| 191 | EntityClass: me.OnuGClassID, |
| 192 | }, |
| 193 | Attributes: managedEntity.GetAttributeValueMap(), |
| 194 | AttributeMask: attributeMask, |
| 195 | Result: me.Success, |
| 196 | } |
| 197 | |
| 198 | //return &omci.GetResponse{ |
| 199 | // MeBasePacket: omci.MeBasePacket{ |
| 200 | // EntityClass: me.OnuGClassID, |
| 201 | // EntityInstance: entityID, |
| 202 | // }, |
| 203 | // Attributes: me.AttributeValueMap{ |
| 204 | // |
| 205 | // }, |
| 206 | // Result: me.Success, |
| 207 | // AttributeMask: attributeMask, |
| 208 | //} |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 209 | } |
| 210 | |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 211 | func createSoftwareImageResponse(attributeMask uint16, entityInstance uint16, activeImageEntityId uint16, |
| 212 | committedImageEntityId uint16, standbyImageVersion string, activeImageVersion string, committedImageVersion string) *omci.GetResponse { |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 213 | |
| 214 | omciLogger.WithFields(log.Fields{ |
| 215 | "EntityInstance": entityInstance, |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 216 | "AttributeMask": attributeMask, |
Matteo Scandolo | 21195d6 | 2021-04-07 14:31:23 -0700 | [diff] [blame] | 217 | }).Trace("received-get-software-image-request") |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 218 | |
| 219 | // Only one image can be active and committed |
| 220 | committed := 0 |
| 221 | active := 0 |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 222 | version := standbyImageVersion |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 223 | if entityInstance == activeImageEntityId { |
| 224 | active = 1 |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 225 | version = activeImageVersion |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 226 | } |
| 227 | if entityInstance == committedImageEntityId { |
| 228 | committed = 1 |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 229 | version = committedImageVersion |
| 230 | } |
| 231 | |
| 232 | imageHash, err := hex.DecodeString(hex.EncodeToString([]byte(version))) |
| 233 | if err != nil { |
| 234 | omciLogger.WithFields(log.Fields{ |
| 235 | "entityId": entityInstance, |
| 236 | "active": active, |
| 237 | "committed": committed, |
| 238 | "err": err, |
| 239 | }).Error("cannot-generate-image-hash") |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 240 | } |
| 241 | |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 242 | // NOTE that we need send the response for the correct ME Instance or the adapter won't process it |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 243 | res := &omci.GetResponse{ |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 244 | MeBasePacket: omci.MeBasePacket{ |
| 245 | EntityClass: me.SoftwareImageClassID, |
| 246 | EntityInstance: entityInstance, |
| 247 | }, |
| 248 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 249 | me.ManagedEntityID: 0, |
| 250 | me.SoftwareImage_Version: ToOctets(version, 14), |
| 251 | me.SoftwareImage_IsCommitted: committed, |
| 252 | me.SoftwareImage_IsActive: active, |
| 253 | me.SoftwareImage_IsValid: 1, |
| 254 | me.SoftwareImage_ProductCode: ToOctets("BBSIM-ONU", 25), |
| 255 | me.SoftwareImage_ImageHash: imageHash, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 256 | }, |
| 257 | Result: me.Success, |
| 258 | AttributeMask: attributeMask, |
| 259 | } |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 260 | |
| 261 | omciLogger.WithFields(log.Fields{ |
| 262 | "omciMessage": res, |
| 263 | "entityId": entityInstance, |
| 264 | "active": active, |
| 265 | "committed": committed, |
Matteo Scandolo | 21195d6 | 2021-04-07 14:31:23 -0700 | [diff] [blame] | 266 | }).Trace("Reporting SoftwareImage") |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 267 | |
| 268 | return res |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | func createIpHostResponse(attributeMask uint16, entityInstance uint16) *omci.GetResponse { |
| 272 | return &omci.GetResponse{ |
| 273 | MeBasePacket: omci.MeBasePacket{ |
| 274 | EntityClass: me.IpHostConfigDataClassID, |
| 275 | EntityInstance: entityInstance, |
| 276 | }, |
| 277 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 278 | me.ManagedEntityID: 0, |
| 279 | me.IpHostConfigData_MacAddress: ToOctets("aabbcc", 6), |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 280 | }, |
| 281 | Result: me.Success, |
| 282 | AttributeMask: attributeMask, |
| 283 | } |
| 284 | } |
| 285 | |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 286 | func createVoipConfigDataResponse(attributeMask uint16, entityInstance uint16) *omci.GetResponse { |
| 287 | return &omci.GetResponse{ |
| 288 | MeBasePacket: omci.MeBasePacket{ |
| 289 | EntityClass: me.VoipConfigDataClassID, |
| 290 | EntityInstance: entityInstance, |
| 291 | }, |
| 292 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 293 | me.ManagedEntityID: 0, |
| 294 | me.VoipConfigData_AvailableSignallingProtocols: 1, |
| 295 | me.VoipConfigData_SignallingProtocolUsed: 1, |
| 296 | me.VoipConfigData_AvailableVoipConfigurationMethods: 1, |
| 297 | me.VoipConfigData_VoipConfigurationMethodUsed: 1, |
| 298 | me.VoipConfigData_VoipConfigurationAddressPointer: 0xFFFF, |
| 299 | me.VoipConfigData_VoipConfigurationState: 0, |
| 300 | me.VoipConfigData_RetrieveProfile: 0, |
| 301 | me.VoipConfigData_ProfileVersion: 0, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 302 | }, |
| 303 | Result: me.Success, |
| 304 | AttributeMask: attributeMask, |
| 305 | } |
| 306 | } |
| 307 | |
Girish Gowdra | 996d81e | 2021-04-21 16:16:27 -0700 | [diff] [blame] | 308 | func createUnigResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse { |
| 309 | // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks) |
| 310 | omciAdminState := 1 |
| 311 | if !onuDown { |
| 312 | omciAdminState = 0 |
| 313 | } |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 314 | managedEntity, meErr := me.NewUniG(me.ParamData{ |
| 315 | EntityID: entityID, |
| 316 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 317 | me.ManagedEntityID: entityID, |
| 318 | me.UniG_Deprecated: 0, |
| 319 | me.UniG_AdministrativeState: omciAdminState, |
| 320 | me.UniG_ManagementCapability: 0, |
| 321 | me.UniG_NonOmciManagementIdentifier: 1, |
| 322 | me.UniG_RelayAgentOptions: 1, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 323 | }, |
| 324 | }) |
| 325 | |
| 326 | if meErr.GetError() != nil { |
| 327 | omciLogger.Errorf("NewUniG %v", meErr.Error()) |
| 328 | return nil |
| 329 | } |
| 330 | |
| 331 | return &omci.GetResponse{ |
| 332 | MeBasePacket: omci.MeBasePacket{ |
Girish Gowdra | c3fd50c | 2021-03-12 16:14:44 -0800 | [diff] [blame] | 333 | EntityClass: me.UniGClassID, |
| 334 | EntityInstance: entityID, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 335 | }, |
| 336 | Attributes: managedEntity.GetAttributeValueMap(), |
| 337 | AttributeMask: attributeMask, |
| 338 | Result: me.Success, |
| 339 | } |
| 340 | } |
| 341 | |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 342 | func createPptpEthernetResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse { |
Girish Gowdra | 996d81e | 2021-04-21 16:16:27 -0700 | [diff] [blame] | 343 | // Valid values for oper_state are 0 (enabled) and 1 (disabled) |
| 344 | // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks) |
| 345 | onuAdminState := 1 |
| 346 | if !onuDown { |
| 347 | onuAdminState = 0 |
| 348 | } |
| 349 | onuOperState := onuAdminState // For now make the assumption that oper state reflects the admin state |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 350 | managedEntity, meErr := me.NewPhysicalPathTerminationPointEthernetUni(me.ParamData{ |
| 351 | EntityID: entityID, |
| 352 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 353 | me.ManagedEntityID: entityID, |
| 354 | me.PhysicalPathTerminationPointEthernetUni_ExpectedType: 0, |
| 355 | me.PhysicalPathTerminationPointEthernetUni_SensedType: 0, |
| 356 | me.PhysicalPathTerminationPointEthernetUni_AutoDetectionConfiguration: 0, |
| 357 | me.PhysicalPathTerminationPointEthernetUni_EthernetLoopbackConfiguration: 0, |
| 358 | me.PhysicalPathTerminationPointEthernetUni_AdministrativeState: onuAdminState, |
| 359 | me.PhysicalPathTerminationPointEthernetUni_OperationalState: onuOperState, |
| 360 | me.PhysicalPathTerminationPointEthernetUni_ConfigurationInd: 0, |
| 361 | me.PhysicalPathTerminationPointEthernetUni_MaxFrameSize: 0, |
| 362 | me.PhysicalPathTerminationPointEthernetUni_DteOrDceInd: 0, |
| 363 | me.PhysicalPathTerminationPointEthernetUni_PauseTime: 0, |
| 364 | me.PhysicalPathTerminationPointEthernetUni_BridgedOrIpInd: 0, |
| 365 | me.PhysicalPathTerminationPointEthernetUni_Arc: 0, |
| 366 | me.PhysicalPathTerminationPointEthernetUni_ArcInterval: 0, |
| 367 | me.PhysicalPathTerminationPointEthernetUni_PppoeFilter: 0, |
| 368 | me.PhysicalPathTerminationPointEthernetUni_PowerControl: 0, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 369 | }, |
| 370 | }) |
| 371 | |
| 372 | if meErr.GetError() != nil { |
| 373 | omciLogger.Errorf("NewPhysicalPathTerminationPointEthernetUni %v", meErr.Error()) |
| 374 | return nil |
| 375 | } |
| 376 | |
| 377 | return &omci.GetResponse{ |
| 378 | MeBasePacket: omci.MeBasePacket{ |
Girish Gowdra | c3fd50c | 2021-03-12 16:14:44 -0800 | [diff] [blame] | 379 | EntityClass: me.PhysicalPathTerminationPointEthernetUniClassID, |
| 380 | EntityInstance: entityID, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 381 | }, |
| 382 | Attributes: managedEntity.GetAttributeValueMap(), |
| 383 | AttributeMask: attributeMask, |
| 384 | Result: me.Success, |
| 385 | } |
| 386 | } |
| 387 | |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 388 | func createPptpPotsResponse(attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse { |
| 389 | // Valid values for oper_state are 0 (enabled) and 1 (disabled) |
| 390 | // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks) |
| 391 | onuAdminState := 1 |
| 392 | if !onuDown { |
| 393 | onuAdminState = 0 |
| 394 | } |
| 395 | onuOperState := onuAdminState // For now make the assumption that oper state reflects the admin state |
| 396 | managedEntity, meErr := me.NewPhysicalPathTerminationPointPotsUni(me.ParamData{ |
| 397 | EntityID: entityID, |
| 398 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 399 | me.ManagedEntityID: entityID, |
| 400 | me.PhysicalPathTerminationPointPotsUni_AdministrativeState: onuAdminState, |
| 401 | me.PhysicalPathTerminationPointPotsUni_Deprecated: 0, |
| 402 | me.PhysicalPathTerminationPointPotsUni_Arc: 0, |
| 403 | me.PhysicalPathTerminationPointPotsUni_ArcInterval: 0, |
| 404 | me.PhysicalPathTerminationPointPotsUni_Impedance: 0, |
| 405 | me.PhysicalPathTerminationPointPotsUni_TransmissionPath: 0, |
| 406 | me.PhysicalPathTerminationPointPotsUni_RxGain: 0, |
| 407 | me.PhysicalPathTerminationPointPotsUni_TxGain: 0, |
| 408 | me.PhysicalPathTerminationPointPotsUni_OperationalState: onuOperState, |
| 409 | me.PhysicalPathTerminationPointPotsUni_HookState: 0, |
| 410 | me.PhysicalPathTerminationPointPotsUni_PotsHoldoverTime: 0, |
| 411 | me.PhysicalPathTerminationPointPotsUni_NominalFeedVoltage: 0, |
| 412 | me.PhysicalPathTerminationPointPotsUni_LossOfSoftswitch: 0, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 413 | }, |
| 414 | }) |
| 415 | |
| 416 | if meErr.GetError() != nil { |
| 417 | omciLogger.Errorf("NewPhysicalPathTerminationPointPotsUni %v", meErr.Error()) |
| 418 | return nil |
| 419 | } |
| 420 | |
| 421 | return &omci.GetResponse{ |
| 422 | MeBasePacket: omci.MeBasePacket{ |
| 423 | EntityClass: me.PhysicalPathTerminationPointPotsUniClassID, |
| 424 | EntityInstance: entityID, |
| 425 | }, |
| 426 | Attributes: managedEntity.GetAttributeValueMap(), |
| 427 | AttributeMask: attributeMask, |
| 428 | Result: me.Success, |
| 429 | } |
| 430 | } |
| 431 | |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 432 | func createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 433 | managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(me.ParamData{ |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 434 | EntityID: entityID, |
| 435 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 436 | me.ManagedEntityID: entityID, |
| 437 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now. |
| 438 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_ThresholdData12Id: 0, |
| 439 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_DropEvents: rand.Intn(100), |
| 440 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Octets: rand.Intn(100), |
| 441 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets: rand.Intn(100), |
| 442 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_BroadcastPackets: rand.Intn(100), |
| 443 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_MulticastPackets: rand.Intn(100), |
| 444 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_CrcErroredPackets: rand.Intn(100), |
| 445 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_UndersizePackets: rand.Intn(100), |
| 446 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_OversizePackets: rand.Intn(100), |
| 447 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets64Octets: rand.Intn(100), |
| 448 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets65To127Octets: rand.Intn(100), |
| 449 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets128To255Octets: rand.Intn(100), |
| 450 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets256To511Octets: rand.Intn(100), |
| 451 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets512To1023Octets: rand.Intn(100), |
| 452 | me.EthernetFramePerformanceMonitoringHistoryDataUpstream_Packets1024To1518Octets: rand.Intn(100), |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 453 | }, |
| 454 | }) |
| 455 | |
| 456 | if meErr.GetError() != nil { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 457 | omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataUpstream %v", meErr.Error()) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 458 | return nil |
| 459 | } |
| 460 | |
| 461 | return &omci.GetResponse{ |
| 462 | MeBasePacket: omci.MeBasePacket{ |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 463 | EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID, |
| 464 | EntityInstance: entityID, |
| 465 | }, |
| 466 | Attributes: managedEntity.GetAttributeValueMap(), |
| 467 | AttributeMask: attributeMask, |
| 468 | Result: me.Success, |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | func createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 473 | managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(me.ParamData{ |
| 474 | EntityID: entityID, |
| 475 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 476 | me.ManagedEntityID: entityID, |
| 477 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now. |
| 478 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_ThresholdData12Id: 0, |
| 479 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_DropEvents: rand.Intn(100), |
| 480 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Octets: rand.Intn(100), |
| 481 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets: rand.Intn(100), |
| 482 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_BroadcastPackets: rand.Intn(100), |
| 483 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_MulticastPackets: rand.Intn(100), |
| 484 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_CrcErroredPackets: rand.Intn(100), |
| 485 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_UndersizePackets: rand.Intn(100), |
| 486 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_OversizePackets: rand.Intn(100), |
| 487 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets64Octets: rand.Intn(100), |
| 488 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets65To127Octets: rand.Intn(100), |
| 489 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets128To255Octets: rand.Intn(100), |
| 490 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets256To511Octets: rand.Intn(100), |
| 491 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets512To1023Octets: rand.Intn(100), |
| 492 | me.EthernetFramePerformanceMonitoringHistoryDataDownstream_Packets1024To1518Octets: rand.Intn(100), |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 493 | }, |
| 494 | }) |
| 495 | |
| 496 | if meErr.GetError() != nil { |
| 497 | omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataDownstream %v", meErr.Error()) |
| 498 | return nil |
| 499 | } |
| 500 | |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 501 | return &omci.GetResponse{ |
| 502 | MeBasePacket: omci.MeBasePacket{ |
| 503 | EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID, |
| 504 | EntityInstance: entityID, |
| 505 | }, |
| 506 | Attributes: managedEntity.GetAttributeValueMap(), |
| 507 | AttributeMask: attributeMask, |
| 508 | Result: me.Success, |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | func createEthernetPerformanceMonitoringHistoryDataResponse(attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 513 | managedEntity, meErr := me.NewEthernetPerformanceMonitoringHistoryData(me.ParamData{ |
| 514 | EntityID: entityID, |
| 515 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 516 | me.ManagedEntityID: entityID, |
| 517 | me.EthernetPerformanceMonitoringHistoryData_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now. |
| 518 | me.EthernetPerformanceMonitoringHistoryData_ThresholdData12Id: 0, |
| 519 | me.EthernetPerformanceMonitoringHistoryData_FcsErrors: rand.Intn(100), |
| 520 | me.EthernetPerformanceMonitoringHistoryData_ExcessiveCollisionCounter: rand.Intn(100), |
| 521 | me.EthernetPerformanceMonitoringHistoryData_LateCollisionCounter: rand.Intn(100), |
| 522 | me.EthernetPerformanceMonitoringHistoryData_FramesTooLong: rand.Intn(100), |
| 523 | me.EthernetPerformanceMonitoringHistoryData_BufferOverflowsOnReceive: rand.Intn(100), |
| 524 | me.EthernetPerformanceMonitoringHistoryData_BufferOverflowsOnTransmit: rand.Intn(100), |
| 525 | me.EthernetPerformanceMonitoringHistoryData_SingleCollisionFrameCounter: rand.Intn(100), |
| 526 | me.EthernetPerformanceMonitoringHistoryData_MultipleCollisionsFrameCounter: rand.Intn(100), |
| 527 | me.EthernetPerformanceMonitoringHistoryData_SqeCounter: rand.Intn(100), |
| 528 | me.EthernetPerformanceMonitoringHistoryData_DeferredTransmissionCounter: rand.Intn(100), |
| 529 | me.EthernetPerformanceMonitoringHistoryData_InternalMacTransmitErrorCounter: rand.Intn(100), |
| 530 | me.EthernetPerformanceMonitoringHistoryData_CarrierSenseErrorCounter: rand.Intn(100), |
| 531 | me.EthernetPerformanceMonitoringHistoryData_AlignmentErrorCounter: rand.Intn(100), |
| 532 | me.EthernetPerformanceMonitoringHistoryData_InternalMacReceiveErrorCounter: rand.Intn(100), |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 533 | }, |
| 534 | }) |
| 535 | |
| 536 | if meErr.GetError() != nil { |
| 537 | omciLogger.Errorf("NewEthernetPerformanceMonitoringHistoryData %v", meErr.Error()) |
| 538 | return nil |
| 539 | } |
| 540 | |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 541 | return &omci.GetResponse{ |
| 542 | MeBasePacket: omci.MeBasePacket{ |
| 543 | EntityClass: me.EthernetPerformanceMonitoringHistoryDataClassID, |
| 544 | EntityInstance: entityID, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 545 | }, |
| 546 | Attributes: managedEntity.GetAttributeValueMap(), |
| 547 | AttributeMask: attributeMask, |
| 548 | Result: me.Success, |
| 549 | } |
| 550 | } |
| 551 | |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 552 | func createFecPerformanceMonitoringHistoryDataResponse(attributeMask uint16, entityID uint16) *omci.GetResponse { |
| 553 | managedEntity, meErr := me.NewFecPerformanceMonitoringHistoryData(me.ParamData{ |
| 554 | EntityID: entityID, |
| 555 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 556 | me.ManagedEntityID: entityID, |
| 557 | me.FecPerformanceMonitoringHistoryData_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now. |
| 558 | me.FecPerformanceMonitoringHistoryData_ThresholdData12Id: 0, |
| 559 | me.FecPerformanceMonitoringHistoryData_CorrectedBytes: rand.Intn(100), |
| 560 | me.FecPerformanceMonitoringHistoryData_CorrectedCodeWords: rand.Intn(100), |
| 561 | me.FecPerformanceMonitoringHistoryData_UncorrectableCodeWords: rand.Intn(100), |
| 562 | me.FecPerformanceMonitoringHistoryData_TotalCodeWords: rand.Intn(100), |
| 563 | me.FecPerformanceMonitoringHistoryData_FecSeconds: rand.Intn(100), |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 564 | }, |
| 565 | }) |
| 566 | |
| 567 | if meErr.GetError() != nil { |
| 568 | omciLogger.Errorf("NewFecPerformanceMonitoringHistoryData %v", meErr.Error()) |
| 569 | return nil |
| 570 | } |
| 571 | |
| 572 | // FEC History counter fits within single gem payload. |
| 573 | // No need of the logical we use in other Ethernet History counters or Gem Port History counters |
| 574 | |
| 575 | return &omci.GetResponse{ |
| 576 | MeBasePacket: omci.MeBasePacket{ |
| 577 | EntityClass: me.FecPerformanceMonitoringHistoryDataClassID, |
| 578 | EntityInstance: entityID, |
| 579 | }, |
| 580 | Attributes: managedEntity.GetAttributeValueMap(), |
| 581 | AttributeMask: attributeMask, |
| 582 | Result: me.Success, |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | func createGemPortNetworkCtpPerformanceMonitoringHistoryData(attributeMask uint16, entityID uint16) *omci.GetResponse { |
| 587 | managedEntity, meErr := me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(me.ParamData{ |
| 588 | EntityID: entityID, |
| 589 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 590 | me.ManagedEntityID: entityID, |
| 591 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_IntervalEndTime: 0, // This ideally should increment by 1 every collection interval, but staying 0 for simulation is Ok for now. |
| 592 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_ThresholdData12Id: 0, |
| 593 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_TransmittedGemFrames: rand.Intn(100), |
| 594 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_ReceivedGemFrames: rand.Intn(100), |
| 595 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_ReceivedPayloadBytes: rand.Intn(100), |
| 596 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_TransmittedPayloadBytes: rand.Intn(100), |
| 597 | me.GemPortNetworkCtpPerformanceMonitoringHistoryData_EncryptionKeyErrors: rand.Intn(100), |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 598 | }, |
| 599 | }) |
| 600 | |
| 601 | if meErr.GetError() != nil { |
| 602 | omciLogger.Errorf("NewGemPortNetworkCtpPerformanceMonitoringHistoryData %v", meErr.Error()) |
| 603 | return nil |
| 604 | } |
| 605 | |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 606 | return &omci.GetResponse{ |
| 607 | MeBasePacket: omci.MeBasePacket{ |
| 608 | EntityClass: me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID, |
| 609 | EntityInstance: entityID, |
| 610 | }, |
| 611 | Attributes: managedEntity.GetAttributeValueMap(), |
| 612 | AttributeMask: attributeMask, |
| 613 | Result: me.Success, |
| 614 | } |
| 615 | } |
| 616 | |
Matteo Scandolo | 992a23e | 2021-02-04 15:35:04 -0800 | [diff] [blame] | 617 | func createOnuDataResponse(attributeMask uint16, entityID uint16, mds uint8) *omci.GetResponse { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 618 | managedEntity, meErr := me.NewOnuData(me.ParamData{ |
| 619 | EntityID: entityID, |
| 620 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 621 | me.ManagedEntityID: entityID, |
| 622 | me.OnuData_MibDataSync: mds, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 623 | }, |
| 624 | }) |
| 625 | |
| 626 | if meErr.GetError() != nil { |
| 627 | omciLogger.Errorf("NewOnuData %v", meErr.Error()) |
| 628 | return nil |
| 629 | } |
| 630 | |
| 631 | return &omci.GetResponse{ |
| 632 | MeBasePacket: omci.MeBasePacket{ |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 633 | EntityClass: me.OnuDataClassID, |
| 634 | EntityInstance: entityID, |
| 635 | }, |
| 636 | Attributes: managedEntity.GetAttributeValueMap(), |
| 637 | AttributeMask: attributeMask, |
| 638 | Result: me.Success, |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | func createAnigResponse(attributeMask uint16, entityID uint16) *omci.GetResponse { |
| 643 | managedEntity, meErr := me.NewAniG(me.ParamData{ |
| 644 | EntityID: entityID, |
| 645 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 646 | me.ManagedEntityID: entityID, |
| 647 | me.AniG_SrIndication: 0, |
| 648 | me.AniG_TotalTcontNumber: 0, |
| 649 | me.AniG_GemBlockLength: 0, |
| 650 | me.AniG_PiggybackDbaReporting: 0, |
| 651 | me.AniG_Deprecated: 0, |
| 652 | me.AniG_SignalFailThreshold: 0, |
| 653 | me.AniG_SignalDegradeThreshold: 0, |
| 654 | me.AniG_Arc: 0, |
| 655 | me.AniG_ArcInterval: 0, |
| 656 | me.AniG_OpticalSignalLevel: rand.Intn(16000), // generate some random power level than defaulting to 0 |
| 657 | me.AniG_LowerOpticalThreshold: 0, |
| 658 | me.AniG_UpperOpticalThreshold: 0, |
| 659 | me.AniG_OnuResponseTime: 0, |
| 660 | me.AniG_TransmitOpticalLevel: rand.Intn(16000), // generate some random power level than defaulting to 0 |
| 661 | me.AniG_LowerTransmitPowerThreshold: 0, |
| 662 | me.AniG_UpperTransmitPowerThreshold: 0, |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 663 | }, |
| 664 | }) |
| 665 | |
| 666 | if meErr.GetError() != nil { |
| 667 | omciLogger.Errorf("NewAniG %v", meErr.Error()) |
| 668 | return nil |
| 669 | } |
| 670 | |
| 671 | return &omci.GetResponse{ |
| 672 | MeBasePacket: omci.MeBasePacket{ |
| 673 | EntityClass: me.AniGClassID, |
| 674 | EntityInstance: entityID, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 675 | }, |
| 676 | Attributes: managedEntity.GetAttributeValueMap(), |
| 677 | AttributeMask: attributeMask, |
| 678 | Result: me.Success, |
| 679 | } |
| 680 | } |
| 681 | |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 682 | func createEthernetFrameExtendedPmGetResponse(meClass me.ClassID, attributeMask uint16, entityID uint16) *omci.GetResponse { |
| 683 | |
| 684 | callback := me.NewEthernetFrameExtendedPm |
| 685 | if meClass != me.EthernetFrameExtendedPmClassID { |
| 686 | callback = me.NewEthernetFrameExtendedPm64Bit |
| 687 | } |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 688 | |
| 689 | //The names of these attributes are left as strings |
| 690 | //rather than constants of a particular ME because |
| 691 | //they can be used with both the MEs in the lines above |
Himani Chawla | 908a1f5 | 2022-01-27 14:39:44 +0530 | [diff] [blame] | 692 | attr := me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 693 | me.ManagedEntityID: entityID, |
Himani Chawla | 908a1f5 | 2022-01-27 14:39:44 +0530 | [diff] [blame] | 694 | "DropEvents": 100, |
| 695 | "Octets": 101, |
| 696 | "Frames": 102, |
| 697 | "BroadcastFrames": 103, |
| 698 | "MulticastFrames": 104, |
| 699 | "CrcErroredFrames": 105, |
| 700 | "UndersizeFrames": 106, |
| 701 | "OversizeFrames": 107, |
| 702 | "Frames64Octets": 108, |
| 703 | "Frames65To127Octets": 109, |
| 704 | "Frames128To255Octets": 110, |
| 705 | "Frames256To511Octets": 111, |
| 706 | "Frames512To1023Octets": 112, |
| 707 | "Frames1024To1518Octets": 113, |
| 708 | } |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 709 | managedEntity, meErr := callback(me.ParamData{ |
Himani Chawla | 908a1f5 | 2022-01-27 14:39:44 +0530 | [diff] [blame] | 710 | EntityID: entityID, |
| 711 | Attributes: attr, |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 712 | }) |
| 713 | |
| 714 | if meErr.GetError() != nil { |
| 715 | omciLogger.Errorf("NewEthernetFrameExtendedPm %v", meErr.Error()) |
| 716 | return nil |
| 717 | } |
| 718 | |
| 719 | return &omci.GetResponse{ |
| 720 | MeBasePacket: omci.MeBasePacket{ |
| 721 | EntityClass: meClass, |
| 722 | EntityInstance: entityID, |
| 723 | }, |
| 724 | Attributes: managedEntity.GetAttributeValueMap(), |
| 725 | AttributeMask: attributeMask, |
| 726 | Result: me.Success, |
| 727 | } |
| 728 | } |
| 729 | |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 730 | func ToOctets(str string, size int) []byte { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 731 | asciiBytes := []byte(str) |
| 732 | |
| 733 | if len(asciiBytes) < size { |
| 734 | missing := size - len(asciiBytes) |
| 735 | for i := 0; i < missing; i++ { |
| 736 | asciiBytes = append(asciiBytes, []byte{0x00}[0]) |
| 737 | } |
| 738 | } |
| 739 | return asciiBytes |
| 740 | } |