Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [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 ( |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 20 | "bytes" |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 21 | "encoding/binary" |
| 22 | "encoding/hex" |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 23 | "github.com/google/gopacket" |
Elia Battiston | b7bea22 | 2022-02-18 16:25:00 +0100 | [diff] [blame] | 24 | "github.com/opencord/bbsim/internal/common" |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 25 | "github.com/opencord/omci-lib-go/v2" |
Andrea Campanella | 10426e2 | 2021-10-15 17:58:04 +0200 | [diff] [blame] | 26 | me "github.com/opencord/omci-lib-go/v2/generated" |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 27 | ) |
| 28 | |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 29 | // MibDbEntry contains all the information needed to build a |
| 30 | // MibUploadNextResponse packet. |
| 31 | // if Packet has a value all the other fields are ignored and the packet is sent as is. |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 32 | type MibDbEntry struct { |
| 33 | classId me.ClassID |
| 34 | entityId EntityID |
| 35 | params me.AttributeValueMap |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 36 | packet []byte |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | type MibDb struct { |
| 40 | NumberOfCommands uint16 |
| 41 | items []MibDbEntry |
| 42 | } |
| 43 | |
| 44 | type EntityID []byte |
| 45 | |
| 46 | func (e EntityID) ToString() string { |
| 47 | return hex.EncodeToString(e) |
| 48 | } |
| 49 | |
| 50 | func (e EntityID) ToUint16() uint16 { |
| 51 | return binary.BigEndian.Uint16(e) |
| 52 | } |
| 53 | |
| 54 | func (e EntityID) ToUint32() uint32 { |
| 55 | return binary.BigEndian.Uint32(e) |
| 56 | } |
| 57 | |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 58 | func (e EntityID) FromUint16(id uint16) EntityID { |
| 59 | buff := new(bytes.Buffer) |
| 60 | err := binary.Write(buff, binary.BigEndian, id) |
| 61 | if err != nil { |
| 62 | panic(err) |
| 63 | } |
| 64 | |
| 65 | return buff.Bytes() |
| 66 | } |
| 67 | |
| 68 | func (e EntityID) Equals(i EntityID) bool { |
| 69 | if res := bytes.Compare(e, i); res == 0 { |
| 70 | return true |
| 71 | } |
| 72 | return false |
| 73 | } |
| 74 | |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 75 | const ( |
| 76 | cardHolderOnuType byte = 0x01 // ONU is a single piece of integrated equipment |
| 77 | ethernetUnitType byte = 0x2f // Ethernet BASE-T |
| 78 | xgsPonUnitType byte = 0xee // XG-PON10G10 |
Elia Battiston | b7bea22 | 2022-02-18 16:25:00 +0100 | [diff] [blame] | 79 | gPonUnitType byte = 0xf5 // GPON12441244 |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 80 | potsUnitType byte = 0x20 // POTS |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 81 | cardHolderSlotID byte = 0x01 |
| 82 | tcontSlotId byte = 0x80 // why is this not the same as the cardHolderSlotID, it does not point to anything |
| 83 | aniGId byte = 0x01 |
| 84 | |
| 85 | upstreamPriorityQueues = 8 // Number of queues for each T-CONT |
| 86 | downstreamPriorityQueues = 16 // Number of queues for each PPTP |
| 87 | tconts = 8 // NOTE will we ever need to configure this? |
| 88 | // trafficSchedulers = 8 // NOTE will we ever need to configure this? |
| 89 | ) |
| 90 | |
| 91 | var ( |
| 92 | cardHolderEntityID = EntityID{cardHolderOnuType, cardHolderSlotID} |
| 93 | circuitPackEntityID = cardHolderEntityID // is the same as that of the cardholder ME containing this circuit pack instance |
| 94 | ) |
| 95 | |
| 96 | func GenerateUniPortEntityId(id uint32) EntityID { |
| 97 | return EntityID{cardHolderSlotID, byte(id)} |
| 98 | } |
| 99 | |
| 100 | // creates a MIB database for a ONU |
| 101 | // CircuitPack and CardHolder are static, everything else can be configured |
Elia Battiston | b7bea22 | 2022-02-18 16:25:00 +0100 | [diff] [blame] | 102 | func GenerateMibDatabase(ethUniPortCount int, potsUniPortCount int, technology common.PonTechnology) (*MibDb, error) { |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 103 | |
| 104 | mibDb := MibDb{ |
| 105 | items: []MibDbEntry{}, |
| 106 | } |
| 107 | |
| 108 | // the first element to return is the ONU-Data |
| 109 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 110 | me.OnuDataClassID, |
| 111 | EntityID{0x00, 0x00}, |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 112 | me.AttributeValueMap{me.OnuData_MibDataSync: 0}, // FIXME this needs to be parametrized before sending the response |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 113 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 114 | }) |
| 115 | |
| 116 | // then we report the CardHolder |
| 117 | // NOTE we have not report it till now, so leave it commented out |
| 118 | //mibDb.items = append(mibDb.items, MibDbEntry{ |
| 119 | // me.CardholderClassID, |
| 120 | // cardHolderEntityID, |
| 121 | // me.AttributeValueMap{ |
| 122 | // "ActualPlugInUnitType": cardHolderOnuType, |
| 123 | // "ExpectedPlugInUnitType": ethernetUnitType, |
| 124 | // }, |
| 125 | //}) |
| 126 | |
Elia Battiston | b7bea22 | 2022-02-18 16:25:00 +0100 | [diff] [blame] | 127 | // ANI circuitPack |
| 128 | var aniCPType byte |
| 129 | |
| 130 | switch technology { |
| 131 | case common.XGSPON: |
| 132 | aniCPType = xgsPonUnitType |
| 133 | case common.GPON: |
| 134 | aniCPType = gPonUnitType |
| 135 | } |
| 136 | |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 137 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 138 | me.CircuitPackClassID, |
| 139 | circuitPackEntityID, |
| 140 | me.AttributeValueMap{ |
Elia Battiston | b7bea22 | 2022-02-18 16:25:00 +0100 | [diff] [blame] | 141 | me.CircuitPack_Type: aniCPType, |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 142 | me.CircuitPack_NumberOfPorts: 1, // NOTE is this the ANI port? must be |
| 143 | me.CircuitPack_SerialNumber: ToOctets("BBSM-Circuit-Pack-ani", 20), |
| 144 | me.CircuitPack_Version: ToOctets("v0.0.1", 20), |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 145 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 146 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 147 | }) |
| 148 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 149 | me.CircuitPackClassID, |
| 150 | circuitPackEntityID, |
| 151 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 152 | me.CircuitPack_VendorId: ToOctets("ONF", 4), |
| 153 | me.CircuitPack_AdministrativeState: 0, |
| 154 | me.CircuitPack_OperationalState: 0, |
| 155 | me.CircuitPack_BridgedOrIpInd: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 156 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 157 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 158 | }) |
| 159 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 160 | me.CircuitPackClassID, |
| 161 | circuitPackEntityID, |
| 162 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 163 | me.CircuitPack_EquipmentId: ToOctets("BBSM-Circuit-Pack", 20), |
| 164 | me.CircuitPack_CardConfiguration: 0, |
| 165 | me.CircuitPack_TotalTContBufferNumber: 8, |
| 166 | me.CircuitPack_TotalPriorityQueueNumber: 8, |
| 167 | me.CircuitPack_TotalTrafficSchedulerNumber: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 168 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 169 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 170 | }) |
| 171 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 172 | me.CircuitPackClassID, |
| 173 | circuitPackEntityID, |
| 174 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 175 | me.CircuitPack_PowerShedOverride: uint32(0), |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 176 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 177 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 178 | }) |
| 179 | |
| 180 | // ANI-G |
| 181 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 182 | me.AniGClassID, |
| 183 | EntityID{tcontSlotId, aniGId}, |
| 184 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 185 | me.AniG_Arc: 0, |
| 186 | me.AniG_ArcInterval: 0, |
| 187 | me.AniG_Deprecated: 0, |
| 188 | me.AniG_GemBlockLength: 48, |
| 189 | me.AniG_LowerOpticalThreshold: 255, |
| 190 | me.AniG_LowerTransmitPowerThreshold: 129, |
| 191 | me.AniG_OnuResponseTime: 0, |
| 192 | me.AniG_OpticalSignalLevel: 57428, |
| 193 | me.AniG_PiggybackDbaReporting: 0, |
| 194 | me.AniG_SignalDegradeThreshold: 9, |
| 195 | me.AniG_SignalFailThreshold: 5, |
| 196 | me.AniG_SrIndication: 1, |
| 197 | me.AniG_TotalTcontNumber: 8, |
| 198 | me.AniG_TransmitOpticalLevel: 3171, |
| 199 | me.AniG_UpperOpticalThreshold: 255, |
| 200 | me.AniG_UpperTransmitPowerThreshold: 129, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 201 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 202 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 203 | }) |
| 204 | |
| 205 | // circuitPack Ethernet |
| 206 | // NOTE the circuit pack is divided in multiple messages as too big to fit in a single one |
| 207 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 208 | me.CircuitPackClassID, |
| 209 | circuitPackEntityID, |
| 210 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 211 | me.CircuitPack_Type: ethernetUnitType, |
| 212 | me.CircuitPack_NumberOfPorts: ethUniPortCount, |
| 213 | me.CircuitPack_SerialNumber: ToOctets("BBSM-Circuit-Pack", 20), |
| 214 | me.CircuitPack_Version: ToOctets("v0.0.1", 20), |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 215 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 216 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 217 | }) |
| 218 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 219 | me.CircuitPackClassID, |
| 220 | circuitPackEntityID, |
| 221 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 222 | me.CircuitPack_VendorId: ToOctets("ONF", 4), |
| 223 | me.CircuitPack_AdministrativeState: 0, |
| 224 | me.CircuitPack_OperationalState: 0, |
| 225 | me.CircuitPack_BridgedOrIpInd: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 226 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 227 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 228 | }) |
| 229 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 230 | me.CircuitPackClassID, |
| 231 | circuitPackEntityID, |
| 232 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 233 | me.CircuitPack_EquipmentId: ToOctets("BBSM-Circuit-Pack", 20), |
| 234 | me.CircuitPack_CardConfiguration: 0, |
| 235 | me.CircuitPack_TotalTContBufferNumber: 8, |
| 236 | me.CircuitPack_TotalPriorityQueueNumber: 8, |
| 237 | me.CircuitPack_TotalTrafficSchedulerNumber: 16, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 238 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 239 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 240 | }) |
| 241 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 242 | me.CircuitPackClassID, |
| 243 | circuitPackEntityID, |
| 244 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 245 | me.CircuitPack_PowerShedOverride: uint32(0), |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 246 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 247 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 248 | }) |
| 249 | |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 250 | if potsUniPortCount > 0 { |
| 251 | // circuitPack POTS |
| 252 | // NOTE the circuit pack is divided in multiple messages as too big to fit in a single one |
| 253 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 254 | me.CircuitPackClassID, |
| 255 | circuitPackEntityID, |
| 256 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 257 | me.CircuitPack_Type: potsUnitType, |
| 258 | me.CircuitPack_NumberOfPorts: potsUniPortCount, |
| 259 | me.CircuitPack_SerialNumber: ToOctets("BBSM-Circuit-Pack", 20), |
| 260 | me.CircuitPack_Version: ToOctets("v0.0.1", 20), |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 261 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 262 | nil, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 263 | }) |
| 264 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 265 | me.CircuitPackClassID, |
| 266 | circuitPackEntityID, |
| 267 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 268 | me.CircuitPack_VendorId: ToOctets("ONF", 4), |
| 269 | me.CircuitPack_AdministrativeState: 0, |
| 270 | me.CircuitPack_OperationalState: 0, |
| 271 | me.CircuitPack_BridgedOrIpInd: 0, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 272 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 273 | nil, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 274 | }) |
| 275 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 276 | me.CircuitPackClassID, |
| 277 | circuitPackEntityID, |
| 278 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 279 | me.CircuitPack_EquipmentId: ToOctets("BBSM-Circuit-Pack", 20), |
| 280 | me.CircuitPack_CardConfiguration: 0, |
| 281 | me.CircuitPack_TotalTContBufferNumber: 8, |
| 282 | me.CircuitPack_TotalPriorityQueueNumber: 8, |
| 283 | me.CircuitPack_TotalTrafficSchedulerNumber: 16, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 284 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 285 | nil, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 286 | }) |
| 287 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 288 | me.CircuitPackClassID, |
| 289 | circuitPackEntityID, |
| 290 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 291 | me.CircuitPack_PowerShedOverride: uint32(0), |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 292 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 293 | nil, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 294 | }) |
| 295 | } |
| 296 | |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 297 | // PPTP and UNI-Gs |
| 298 | // NOTE this are dependent on the number of UNI this ONU supports |
| 299 | // Through an identical ID, the UNI-G ME is implicitly linked to an instance of a PPTP |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 300 | totalPortsCount := ethUniPortCount + potsUniPortCount |
| 301 | for i := 1; i <= totalPortsCount; i++ { |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 302 | uniEntityId := GenerateUniPortEntityId(uint32(i)) |
| 303 | |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 304 | if i <= ethUniPortCount { |
| 305 | // first, create the correct amount of ethernet UNIs, the same is done in onu.go |
| 306 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 307 | me.PhysicalPathTerminationPointEthernetUniClassID, |
| 308 | uniEntityId, |
| 309 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 310 | me.PhysicalPathTerminationPointEthernetUni_ExpectedType: 0, |
| 311 | me.PhysicalPathTerminationPointEthernetUni_SensedType: ethernetUnitType, |
| 312 | me.PhysicalPathTerminationPointEthernetUni_AutoDetectionConfiguration: 0, |
| 313 | me.PhysicalPathTerminationPointEthernetUni_EthernetLoopbackConfiguration: 0, |
| 314 | me.PhysicalPathTerminationPointEthernetUni_AdministrativeState: 0, |
| 315 | me.PhysicalPathTerminationPointEthernetUni_OperationalState: 0, |
| 316 | me.PhysicalPathTerminationPointEthernetUni_ConfigurationInd: 3, |
| 317 | me.PhysicalPathTerminationPointEthernetUni_MaxFrameSize: 1518, |
| 318 | me.PhysicalPathTerminationPointEthernetUni_DteOrDceInd: 0, |
| 319 | me.PhysicalPathTerminationPointEthernetUni_PauseTime: 0, |
| 320 | me.PhysicalPathTerminationPointEthernetUni_BridgedOrIpInd: 2, |
| 321 | me.PhysicalPathTerminationPointEthernetUni_Arc: 0, |
| 322 | me.PhysicalPathTerminationPointEthernetUni_ArcInterval: 0, |
| 323 | me.PhysicalPathTerminationPointEthernetUni_PppoeFilter: 0, |
| 324 | me.PhysicalPathTerminationPointEthernetUni_PowerControl: 0, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 325 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 326 | nil, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 327 | }) |
| 328 | } else { |
| 329 | // the remaining ones are pots UNIs, the same is done in onu.go |
| 330 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 331 | me.PhysicalPathTerminationPointPotsUniClassID, |
| 332 | uniEntityId, |
| 333 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 334 | me.PhysicalPathTerminationPointPotsUni_AdministrativeState: 0, |
| 335 | me.PhysicalPathTerminationPointPotsUni_Deprecated: 0, |
| 336 | me.PhysicalPathTerminationPointPotsUni_Arc: 0, |
| 337 | me.PhysicalPathTerminationPointPotsUni_ArcInterval: 0, |
| 338 | me.PhysicalPathTerminationPointPotsUni_Impedance: 0, |
| 339 | me.PhysicalPathTerminationPointPotsUni_TransmissionPath: 0, |
| 340 | me.PhysicalPathTerminationPointPotsUni_RxGain: 0, |
| 341 | me.PhysicalPathTerminationPointPotsUni_TxGain: 0, |
| 342 | me.PhysicalPathTerminationPointPotsUni_OperationalState: 0, |
| 343 | me.PhysicalPathTerminationPointPotsUni_HookState: 0, |
| 344 | me.PhysicalPathTerminationPointPotsUni_PotsHoldoverTime: 0, |
| 345 | me.PhysicalPathTerminationPointPotsUni_NominalFeedVoltage: 0, |
| 346 | me.PhysicalPathTerminationPointPotsUni_LossOfSoftswitch: 0, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 347 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 348 | nil, |
Elia Battiston | ac63b11 | 2022-01-12 18:40:49 +0100 | [diff] [blame] | 349 | }) |
| 350 | } |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 351 | |
| 352 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 353 | me.UniGClassID, |
| 354 | uniEntityId, |
| 355 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 356 | me.UniG_AdministrativeState: 0, |
| 357 | me.UniG_Deprecated: 0, |
| 358 | me.UniG_ManagementCapability: 0, |
| 359 | me.UniG_NonOmciManagementIdentifier: 0, |
| 360 | me.UniG_RelayAgentOptions: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 361 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 362 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 363 | }) |
| 364 | |
| 365 | // Downstream Queues (related to PPTP) |
| 366 | // 16 priorities queues for each UNI Ports |
| 367 | // EntityID = cardHolderSlotID + Uni EntityID (0101) |
| 368 | for j := 1; j <= downstreamPriorityQueues; j++ { |
| 369 | queueEntityId := EntityID{cardHolderSlotID, byte(j)} |
| 370 | |
| 371 | // we first report the PriorityQueue without any attribute |
| 372 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 373 | me.PriorityQueueClassID, |
| 374 | queueEntityId, //was not reported in the original implementation |
| 375 | me.AttributeValueMap{}, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 376 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 377 | }) |
| 378 | |
| 379 | // then we report it with the required attributes |
| 380 | // In the downstream direction, the first byte is the slot number and the second byte is the port number of the queue's destination port. |
| 381 | relatedPort := append(uniEntityId, 0x00, byte(j)) |
| 382 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 383 | me.PriorityQueueClassID, |
| 384 | queueEntityId, //was not reported in the original implementation |
| 385 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 386 | me.PriorityQueue_QueueConfigurationOption: 0, |
| 387 | me.PriorityQueue_MaximumQueueSize: 100, |
| 388 | me.PriorityQueue_AllocatedQueueSize: 100, |
| 389 | me.PriorityQueue_DiscardBlockCounterResetInterval: 0, |
| 390 | me.PriorityQueue_ThresholdValueForDiscardedBlocksDueToBufferOverflow: 0, |
| 391 | me.PriorityQueue_RelatedPort: relatedPort.ToUint32(), |
| 392 | me.PriorityQueue_TrafficSchedulerPointer: 0, //it was hardcoded to 0x0108 in the current implementation |
| 393 | me.PriorityQueue_Weight: 1, |
| 394 | me.PriorityQueue_BackPressureOperation: 1, |
| 395 | me.PriorityQueue_BackPressureTime: 0, |
| 396 | me.PriorityQueue_BackPressureOccurQueueThreshold: 0, |
| 397 | me.PriorityQueue_BackPressureClearQueueThreshold: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 398 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 399 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 400 | }) |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | // T-CONTS and Traffic Schedulers |
| 405 | for i := 1; i <= tconts; i++ { |
| 406 | tcontEntityId := EntityID{tcontSlotId, byte(i)} |
| 407 | |
| 408 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 409 | me.TContClassID, |
| 410 | tcontEntityId, |
| 411 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 412 | me.TCont_AllocId: 65535, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 413 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 414 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 415 | }) |
| 416 | |
| 417 | tsEntityId := EntityID{cardHolderSlotID, byte(i)} |
| 418 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 419 | me.TrafficSchedulerClassID, |
| 420 | tsEntityId, //was not reported in the original implementation |
| 421 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 422 | me.TrafficScheduler_TContPointer: tcontEntityId.ToUint16(), // was hardcoded to a non-existing t-cont |
| 423 | me.TrafficScheduler_TrafficSchedulerPointer: 0, |
| 424 | me.TrafficScheduler_Policy: 02, |
| 425 | me.TrafficScheduler_PriorityWeight: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 426 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 427 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 428 | }) |
| 429 | |
| 430 | for j := 1; j <= upstreamPriorityQueues; j++ { |
| 431 | queueEntityId := EntityID{tcontSlotId, byte(j)} |
| 432 | // Upstream Queues (related to traffic schedulers) |
| 433 | // 8 priorities queues per TCONT |
| 434 | // EntityID = tcontSlotId + Uni EntityID (8001) |
| 435 | |
| 436 | // we first report the PriorityQueue without any attribute |
| 437 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 438 | me.PriorityQueueClassID, |
| 439 | queueEntityId, //was not reported in the original implementation |
| 440 | me.AttributeValueMap{}, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 441 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 442 | }) |
| 443 | |
| 444 | // then we report it with the required attributes |
| 445 | // In the upstream direction, the first 2 bytes are the ME ID of the associated T- CONT, the first byte of which is a slot number, the second byte a T-CONT number. |
| 446 | relatedPort := append(tcontEntityId, 0x00, byte(j)) |
| 447 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 448 | me.PriorityQueueClassID, |
| 449 | queueEntityId, //was not reported in the original implementation |
| 450 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 451 | me.PriorityQueue_QueueConfigurationOption: 0, |
| 452 | me.PriorityQueue_MaximumQueueSize: 100, |
| 453 | me.PriorityQueue_AllocatedQueueSize: 100, |
| 454 | me.PriorityQueue_DiscardBlockCounterResetInterval: 0, |
| 455 | me.PriorityQueue_ThresholdValueForDiscardedBlocksDueToBufferOverflow: 0, |
| 456 | me.PriorityQueue_RelatedPort: relatedPort.ToUint32(), |
| 457 | me.PriorityQueue_TrafficSchedulerPointer: tsEntityId.ToUint16(), //it was hardcoded to 0x0108 in the current implementation |
| 458 | me.PriorityQueue_Weight: 1, |
| 459 | me.PriorityQueue_BackPressureOperation: 1, |
| 460 | me.PriorityQueue_BackPressureTime: 0, |
| 461 | me.PriorityQueue_BackPressureOccurQueueThreshold: 0, |
| 462 | me.PriorityQueue_BackPressureClearQueueThreshold: 0, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 463 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 464 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 465 | }) |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | // ONU-2g |
| 470 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 471 | me.Onu2GClassID, |
| 472 | EntityID{0x00, 0x00}, |
| 473 | me.AttributeValueMap{ |
Elia Battiston | 9bfe110 | 2022-02-03 10:38:03 +0100 | [diff] [blame] | 474 | me.Onu2G_ConnectivityCapability: 127, |
| 475 | me.Onu2G_CurrentConnectivityMode: 0, |
| 476 | me.Onu2G_Deprecated: 1, |
| 477 | me.Onu2G_PriorityQueueScaleFactor: 1, |
| 478 | me.Onu2G_QualityOfServiceQosConfigurationFlexibility: 63, |
| 479 | me.Onu2G_Sysuptime: 0, |
| 480 | me.Onu2G_TotalGemPortIdNumber: 8, |
| 481 | me.Onu2G_TotalPriorityQueueNumber: 64, |
| 482 | me.Onu2G_TotalTrafficSchedulerNumber: 8, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 483 | }, |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 484 | nil, |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 485 | }) |
| 486 | |
Matteo Scandolo | cfedba4 | 2022-02-14 16:08:54 -0800 | [diff] [blame^] | 487 | if common.Config.BBSim.InjectOmciUnknownAttributes { |
| 488 | // NOTE the TxID is actually replaced |
| 489 | // by SetTxIdInEncodedPacket in CreateMibUploadNextResponse |
| 490 | txId := uint16(33066) |
| 491 | |
| 492 | b := make([]byte, 4) |
| 493 | binary.BigEndian.PutUint16(b, txId) |
| 494 | b[2] = byte(omci.MibUploadNextResponseType) |
| 495 | b[3] = byte(omci.BaselineIdent) |
| 496 | omciHdr := hex.EncodeToString(b) |
| 497 | |
| 498 | //omciHdr := "00032e0a" |
| 499 | msgHdr := "00020000" |
| 500 | reportedMeHdr := "002500018000" |
| 501 | attr := "0102030405060708090A0B0C0D0E0F101112131415161718191A" |
| 502 | trailer := "0000002828ce00e2" |
| 503 | msg := omciHdr + msgHdr + reportedMeHdr + attr + trailer |
| 504 | data, err := hex.DecodeString(msg) |
| 505 | if err != nil { |
| 506 | omciLogger.Fatal("cannot-create-custom-packet") |
| 507 | } |
| 508 | |
| 509 | packet := gopacket.NewPacket(data, omci.LayerTypeOMCI, gopacket.Lazy) |
| 510 | |
| 511 | mibDb.items = append(mibDb.items, MibDbEntry{ |
| 512 | me.ClassID(37), // G.988 "Intentionally left blank" |
| 513 | nil, |
| 514 | me.AttributeValueMap{}, |
| 515 | packet.Data(), |
| 516 | }) |
| 517 | } |
| 518 | |
Matteo Scandolo | ef4e8f8 | 2021-05-17 11:20:49 -0700 | [diff] [blame] | 519 | mibDb.NumberOfCommands = uint16(len(mibDb.items)) |
| 520 | |
| 521 | return &mibDb, nil |
| 522 | } |