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" |
Holger Hildebrandt | b9a3dd0 | 2022-05-12 08:20:41 +0000 | [diff] [blame] | 27 | "github.com/opencord/bbsim/internal/common" |
Andrea Campanella | 10426e2 | 2021-10-15 17:58:04 +0200 | [diff] [blame] | 28 | "github.com/opencord/omci-lib-go/v2" |
| 29 | me "github.com/opencord/omci-lib-go/v2/generated" |
David K. Bainbridge | c415efe | 2021-08-19 13:05:21 +0000 | [diff] [blame] | 30 | "github.com/opencord/voltha-protos/v5/go/openolt" |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 31 | log "github.com/sirupsen/logrus" |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 32 | ) |
| 33 | |
| 34 | func 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 Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 50 | func 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 53 | msgObj, err := ParseGetRequest(omciPkt) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 54 | if err != nil { |
| 55 | return nil, err |
| 56 | } |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 57 | omciLogger.WithFields(log.Fields{ |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 58 | "DeviceIdent": omciMsg.DeviceIdentifier, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 59 | "EntityClass": msgObj.EntityClass, |
| 60 | "EntityInstance": msgObj.EntityInstance, |
| 61 | "AttributeMask": fmt.Sprintf("%x", msgObj.AttributeMask), |
Matteo Scandolo | 992a23e | 2021-02-04 15:35:04 -0800 | [diff] [blame] | 62 | }).Trace("received-omci-get-request") |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 63 | |
| 64 | var response *omci.GetResponse |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 65 | |
| 66 | isExtended := false |
| 67 | if omciMsg.DeviceIdentifier == omci.ExtendedIdent { |
| 68 | isExtended = true |
| 69 | } |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 70 | switch msgObj.EntityClass { |
| 71 | case me.Onu2GClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 72 | response = createOnu2gResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 73 | case me.OnuGClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 74 | response = createOnugResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuSn) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 75 | case me.SoftwareImageClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 76 | response = createSoftwareImageResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 77 | activeImageEntityId, committedImageEntityId, standbyImageVersion, activeImageVersion, committedImageVersion) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 78 | case me.IpHostConfigDataClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 79 | response = createIpHostResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 80 | case me.VoipConfigDataClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 81 | response = createVoipConfigDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 82 | case me.UniGClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 83 | response = createUnigResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuDown) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 84 | case me.PhysicalPathTerminationPointEthernetUniClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 85 | response = createPptpEthernetResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuDown) |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 86 | case me.PhysicalPathTerminationPointPotsUniClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 87 | response = createPptpPotsResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, onuDown) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 88 | case me.AniGClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 89 | response = createAnigResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 90 | case me.OnuDataClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 91 | response = createOnuDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance, mds) |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 92 | case me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 93 | response = createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 94 | case me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 95 | response = createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 96 | case me.EthernetPerformanceMonitoringHistoryDataClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 97 | response = createEthernetPerformanceMonitoringHistoryDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 98 | case me.FecPerformanceMonitoringHistoryDataClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 99 | response = createFecPerformanceMonitoringHistoryDataResponse(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 100 | case me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 101 | response = createGemPortNetworkCtpPerformanceMonitoringHistoryData(isExtended, msgObj.AttributeMask, msgObj.EntityInstance) |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 102 | case me.EthernetFrameExtendedPmClassID, |
| 103 | me.EthernetFrameExtendedPm64BitClassID: |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 104 | response = createEthernetFrameExtendedPmGetResponse(isExtended, msgObj.EntityClass, msgObj.AttributeMask, msgObj.EntityInstance) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 105 | 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 113 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 120 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 121 | buffer := gopacket.NewSerializeBuffer() |
| 122 | err = gopacket.SerializeLayers(buffer, options, omciLayer, response) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 123 | if err != nil { |
| 124 | omciLogger.WithFields(log.Fields{ |
| 125 | "Err": err, |
| 126 | "TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16), |
Matteo Scandolo | 78d5ee1 | 2021-04-14 11:11:32 -0700 | [diff] [blame] | 127 | }).Error("cannot-Serialize-GetResponse") |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 128 | return nil, err |
| 129 | } |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 130 | pkt := buffer.Bytes() |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 131 | |
| 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 140 | func createOnu2gResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 141 | |
| 142 | managedEntity, meErr := me.NewOnu2G(me.ParamData{ |
| 143 | EntityID: entityID, |
| 144 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 145 | me.ManagedEntityID: entityID, |
| 146 | me.Onu2G_EquipmentId: ToOctets("12345123451234512345", 20), |
Holger Hildebrandt | b9a3dd0 | 2022-05-12 08:20:41 +0000 | [diff] [blame] | 147 | me.Onu2G_OpticalNetworkUnitManagementAndControlChannelOmccVersion: common.Config.BBSim.OmccVersion, |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 148 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 160 | }, |
| 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 170 | EntityClass: me.Onu2GClassID, |
| 171 | EntityInstance: entityID, |
| 172 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 173 | }, |
| 174 | Attributes: managedEntity.GetAttributeValueMap(), |
| 175 | AttributeMask: attributeMask, |
| 176 | Result: me.Success, |
| 177 | } |
| 178 | } |
| 179 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 180 | func createOnugResponse(isExtended bool, attributeMask uint16, entityID uint16, onuSn *openolt.SerialNumber) *omci.GetResponse { |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 181 | |
| 182 | managedEntity, meErr := me.NewOnuG(me.ParamData{ |
| 183 | EntityID: entityID, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 184 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 185 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 199 | }, |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 200 | }) |
| 201 | |
| 202 | if meErr.GetError() != nil { |
| 203 | omciLogger.Errorf("NewOnu2G %v", meErr.Error()) |
| 204 | return nil |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 205 | } |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 206 | |
| 207 | return &omci.GetResponse{ |
| 208 | MeBasePacket: omci.MeBasePacket{ |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 209 | EntityClass: me.OnuGClassID, |
| 210 | EntityInstance: entityID, |
| 211 | Extended: isExtended, |
Matteo Scandolo | 5863f00 | 2021-02-08 08:08:14 -0800 | [diff] [blame] | 212 | }, |
| 213 | Attributes: managedEntity.GetAttributeValueMap(), |
| 214 | AttributeMask: attributeMask, |
| 215 | Result: me.Success, |
| 216 | } |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 219 | func createSoftwareImageResponse(isExtended bool, attributeMask uint16, entityInstance uint16, activeImageEntityId uint16, |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 220 | committedImageEntityId uint16, standbyImageVersion string, activeImageVersion string, committedImageVersion string) *omci.GetResponse { |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 221 | |
| 222 | omciLogger.WithFields(log.Fields{ |
| 223 | "EntityInstance": entityInstance, |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 224 | "AttributeMask": attributeMask, |
Matteo Scandolo | 21195d6 | 2021-04-07 14:31:23 -0700 | [diff] [blame] | 225 | }).Trace("received-get-software-image-request") |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 226 | |
| 227 | // Only one image can be active and committed |
| 228 | committed := 0 |
| 229 | active := 0 |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 230 | version := standbyImageVersion |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 231 | if entityInstance == activeImageEntityId { |
| 232 | active = 1 |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 233 | version = activeImageVersion |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 234 | } |
| 235 | if entityInstance == committedImageEntityId { |
| 236 | committed = 1 |
Matteo Scandolo | c00e97a | 2021-05-27 11:45:27 -0700 | [diff] [blame] | 237 | 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 Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 248 | } |
| 249 | |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 250 | // 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] | 251 | res := &omci.GetResponse{ |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 252 | MeBasePacket: omci.MeBasePacket{ |
| 253 | EntityClass: me.SoftwareImageClassID, |
| 254 | EntityInstance: entityInstance, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 255 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 256 | }, |
| 257 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 258 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 265 | }, |
| 266 | Result: me.Success, |
| 267 | AttributeMask: attributeMask, |
| 268 | } |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 269 | |
| 270 | omciLogger.WithFields(log.Fields{ |
| 271 | "omciMessage": res, |
| 272 | "entityId": entityInstance, |
| 273 | "active": active, |
| 274 | "committed": committed, |
Matteo Scandolo | 21195d6 | 2021-04-07 14:31:23 -0700 | [diff] [blame] | 275 | }).Trace("Reporting SoftwareImage") |
Matteo Scandolo | cedde46 | 2021-03-09 17:37:16 -0800 | [diff] [blame] | 276 | |
| 277 | return res |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 280 | func createIpHostResponse(isExtended bool, attributeMask uint16, entityInstance uint16) *omci.GetResponse { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 281 | return &omci.GetResponse{ |
| 282 | MeBasePacket: omci.MeBasePacket{ |
| 283 | EntityClass: me.IpHostConfigDataClassID, |
| 284 | EntityInstance: entityInstance, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 285 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 286 | }, |
| 287 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 288 | me.ManagedEntityID: 0, |
| 289 | me.IpHostConfigData_MacAddress: ToOctets("aabbcc", 6), |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 290 | }, |
| 291 | Result: me.Success, |
| 292 | AttributeMask: attributeMask, |
| 293 | } |
| 294 | } |
| 295 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 296 | func createVoipConfigDataResponse(isExtended bool, attributeMask uint16, entityInstance uint16) *omci.GetResponse { |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 297 | return &omci.GetResponse{ |
| 298 | MeBasePacket: omci.MeBasePacket{ |
| 299 | EntityClass: me.VoipConfigDataClassID, |
| 300 | EntityInstance: entityInstance, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 301 | Extended: isExtended, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 302 | }, |
| 303 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 304 | 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 Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 313 | }, |
| 314 | Result: me.Success, |
| 315 | AttributeMask: attributeMask, |
| 316 | } |
| 317 | } |
| 318 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 319 | func createUnigResponse(isExtended bool, attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse { |
Girish Gowdra | 996d81e | 2021-04-21 16:16:27 -0700 | [diff] [blame] | 320 | // Valid values for uni_admin_state are 0 (unlocks) and 1 (locks) |
| 321 | omciAdminState := 1 |
| 322 | if !onuDown { |
| 323 | omciAdminState = 0 |
| 324 | } |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 325 | managedEntity, meErr := me.NewUniG(me.ParamData{ |
| 326 | EntityID: entityID, |
| 327 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 328 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 334 | }, |
| 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 Gowdra | c3fd50c | 2021-03-12 16:14:44 -0800 | [diff] [blame] | 344 | EntityClass: me.UniGClassID, |
| 345 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 346 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 347 | }, |
| 348 | Attributes: managedEntity.GetAttributeValueMap(), |
| 349 | AttributeMask: attributeMask, |
| 350 | Result: me.Success, |
| 351 | } |
| 352 | } |
| 353 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 354 | func createPptpEthernetResponse(isExtended bool, attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse { |
Girish Gowdra | 996d81e | 2021-04-21 16:16:27 -0700 | [diff] [blame] | 355 | // 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 362 | managedEntity, meErr := me.NewPhysicalPathTerminationPointEthernetUni(me.ParamData{ |
| 363 | EntityID: entityID, |
| 364 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 365 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 381 | }, |
| 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 Gowdra | c3fd50c | 2021-03-12 16:14:44 -0800 | [diff] [blame] | 391 | EntityClass: me.PhysicalPathTerminationPointEthernetUniClassID, |
| 392 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 393 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 394 | }, |
| 395 | Attributes: managedEntity.GetAttributeValueMap(), |
| 396 | AttributeMask: attributeMask, |
| 397 | Result: me.Success, |
| 398 | } |
| 399 | } |
| 400 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 401 | func createPptpPotsResponse(isExtended bool, attributeMask uint16, entityID uint16, onuDown bool) *omci.GetResponse { |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 402 | // 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 Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 412 | 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 Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 426 | }, |
| 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 438 | Extended: isExtended, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 439 | }, |
| 440 | Attributes: managedEntity.GetAttributeValueMap(), |
| 441 | AttributeMask: attributeMask, |
| 442 | Result: me.Success, |
| 443 | } |
| 444 | } |
| 445 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 446 | func createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 447 | managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(me.ParamData{ |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 448 | EntityID: entityID, |
| 449 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 450 | 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 Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 467 | }, |
| 468 | }) |
| 469 | |
| 470 | if meErr.GetError() != nil { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 471 | omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataUpstream %v", meErr.Error()) |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 472 | return nil |
| 473 | } |
| 474 | |
| 475 | return &omci.GetResponse{ |
| 476 | MeBasePacket: omci.MeBasePacket{ |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 477 | EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID, |
| 478 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 479 | Extended: isExtended, |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 480 | }, |
| 481 | Attributes: managedEntity.GetAttributeValueMap(), |
| 482 | AttributeMask: attributeMask, |
| 483 | Result: me.Success, |
| 484 | } |
| 485 | } |
| 486 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 487 | func createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 488 | managedEntity, meErr := me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(me.ParamData{ |
| 489 | EntityID: entityID, |
| 490 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 491 | 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 Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 508 | }, |
| 509 | }) |
| 510 | |
| 511 | if meErr.GetError() != nil { |
| 512 | omciLogger.Errorf("NewEthernetFramePerformanceMonitoringHistoryDataDownstream %v", meErr.Error()) |
| 513 | return nil |
| 514 | } |
| 515 | |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 516 | return &omci.GetResponse{ |
| 517 | MeBasePacket: omci.MeBasePacket{ |
| 518 | EntityClass: me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID, |
| 519 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 520 | Extended: isExtended, |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 521 | }, |
| 522 | Attributes: managedEntity.GetAttributeValueMap(), |
| 523 | AttributeMask: attributeMask, |
| 524 | Result: me.Success, |
| 525 | } |
| 526 | } |
| 527 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 528 | func createEthernetPerformanceMonitoringHistoryDataResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 529 | managedEntity, meErr := me.NewEthernetPerformanceMonitoringHistoryData(me.ParamData{ |
| 530 | EntityID: entityID, |
| 531 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 532 | 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 Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 549 | }, |
| 550 | }) |
| 551 | |
| 552 | if meErr.GetError() != nil { |
| 553 | omciLogger.Errorf("NewEthernetPerformanceMonitoringHistoryData %v", meErr.Error()) |
| 554 | return nil |
| 555 | } |
| 556 | |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 557 | return &omci.GetResponse{ |
| 558 | MeBasePacket: omci.MeBasePacket{ |
| 559 | EntityClass: me.EthernetPerformanceMonitoringHistoryDataClassID, |
| 560 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 561 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 562 | }, |
| 563 | Attributes: managedEntity.GetAttributeValueMap(), |
| 564 | AttributeMask: attributeMask, |
| 565 | Result: me.Success, |
| 566 | } |
| 567 | } |
| 568 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 569 | func createFecPerformanceMonitoringHistoryDataResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 570 | managedEntity, meErr := me.NewFecPerformanceMonitoringHistoryData(me.ParamData{ |
| 571 | EntityID: entityID, |
| 572 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 573 | 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 Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 581 | }, |
| 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 596 | Extended: isExtended, |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 597 | }, |
| 598 | Attributes: managedEntity.GetAttributeValueMap(), |
| 599 | AttributeMask: attributeMask, |
| 600 | Result: me.Success, |
| 601 | } |
| 602 | } |
| 603 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 604 | func createGemPortNetworkCtpPerformanceMonitoringHistoryData(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 605 | managedEntity, meErr := me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(me.ParamData{ |
| 606 | EntityID: entityID, |
| 607 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 608 | 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 Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 616 | }, |
| 617 | }) |
| 618 | |
| 619 | if meErr.GetError() != nil { |
| 620 | omciLogger.Errorf("NewGemPortNetworkCtpPerformanceMonitoringHistoryData %v", meErr.Error()) |
| 621 | return nil |
| 622 | } |
| 623 | |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 624 | return &omci.GetResponse{ |
| 625 | MeBasePacket: omci.MeBasePacket{ |
| 626 | EntityClass: me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID, |
| 627 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 628 | Extended: isExtended, |
Girish Gowdra | 6d9a1a4 | 2021-03-05 16:07:15 -0800 | [diff] [blame] | 629 | }, |
| 630 | Attributes: managedEntity.GetAttributeValueMap(), |
| 631 | AttributeMask: attributeMask, |
| 632 | Result: me.Success, |
| 633 | } |
| 634 | } |
| 635 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 636 | func createOnuDataResponse(isExtended bool, attributeMask uint16, entityID uint16, mds uint8) *omci.GetResponse { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 637 | managedEntity, meErr := me.NewOnuData(me.ParamData{ |
| 638 | EntityID: entityID, |
| 639 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 640 | me.ManagedEntityID: entityID, |
| 641 | me.OnuData_MibDataSync: mds, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 642 | }, |
| 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 Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 652 | EntityClass: me.OnuDataClassID, |
| 653 | EntityInstance: entityID, |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 654 | Extended: isExtended, |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 655 | }, |
| 656 | Attributes: managedEntity.GetAttributeValueMap(), |
| 657 | AttributeMask: attributeMask, |
| 658 | Result: me.Success, |
| 659 | } |
| 660 | } |
| 661 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 662 | func createAnigResponse(isExtended bool, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Girish Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 663 | managedEntity, meErr := me.NewAniG(me.ParamData{ |
| 664 | EntityID: entityID, |
| 665 | Attributes: me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 666 | 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 Gowdra | a539f52 | 2021-02-15 23:00:45 -0800 | [diff] [blame] | 683 | }, |
| 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 695 | Extended: isExtended, |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 696 | }, |
| 697 | Attributes: managedEntity.GetAttributeValueMap(), |
| 698 | AttributeMask: attributeMask, |
| 699 | Result: me.Success, |
| 700 | } |
| 701 | } |
| 702 | |
Holger Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 703 | func createEthernetFrameExtendedPmGetResponse(isExtended bool, meClass me.ClassID, attributeMask uint16, entityID uint16) *omci.GetResponse { |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 704 | |
| 705 | callback := me.NewEthernetFrameExtendedPm |
| 706 | if meClass != me.EthernetFrameExtendedPmClassID { |
| 707 | callback = me.NewEthernetFrameExtendedPm64Bit |
| 708 | } |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 709 | |
| 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 Chawla | 908a1f5 | 2022-01-27 14:39:44 +0530 | [diff] [blame] | 713 | attr := me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 714 | me.ManagedEntityID: entityID, |
Himani Chawla | 908a1f5 | 2022-01-27 14:39:44 +0530 | [diff] [blame] | 715 | "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 Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 730 | managedEntity, meErr := callback(me.ParamData{ |
Himani Chawla | 908a1f5 | 2022-01-27 14:39:44 +0530 | [diff] [blame] | 731 | EntityID: entityID, |
| 732 | Attributes: attr, |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 733 | }) |
| 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 Hildebrandt | 02101a6 | 2022-04-06 13:00:51 +0000 | [diff] [blame] | 744 | Extended: isExtended, |
Himani Chawla | 6bd190a | 2021-07-09 15:31:01 +0530 | [diff] [blame] | 745 | }, |
| 746 | Attributes: managedEntity.GetAttributeValueMap(), |
| 747 | AttributeMask: attributeMask, |
| 748 | Result: me.Success, |
| 749 | } |
| 750 | } |
| 751 | |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 752 | func ToOctets(str string, size int) []byte { |
Matteo Scandolo | f9d4341 | 2021-01-12 11:11:34 -0800 | [diff] [blame] | 753 | 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 | } |