Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-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 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 17 | //Package adaptercoreonu provides the utility for onu devices, flows and statistics |
| 18 | package adaptercoreonu |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "container/list" |
| 22 | "context" |
| 23 | "encoding/binary" |
| 24 | "encoding/hex" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 25 | "fmt" |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 26 | "strconv" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 27 | "sync" |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 28 | "time" //by now for testing |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 29 | |
| 30 | "github.com/google/gopacket" |
| 31 | // TODO!!! Some references could be resolved auto, but some need specific context .... |
| 32 | gp "github.com/google/gopacket" |
| 33 | |
| 34 | "github.com/opencord/omci-lib-go" |
| 35 | me "github.com/opencord/omci-lib-go/generated" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 36 | "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 37 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 38 | //"github.com/opencord/voltha-lib-go/v4/pkg/kafka" |
| 39 | "github.com/opencord/voltha-lib-go/v4/pkg/log" |
| 40 | ic "github.com/opencord/voltha-protos/v4/go/inter_container" |
| 41 | //"github.com/opencord/voltha-protos/v4/go/openflow_13" |
| 42 | //"github.com/opencord/voltha-protos/v4/go/voltha" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 43 | ) |
| 44 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 45 | // ### global test related tag ##### |
| 46 | const cbSwUpgradeRespSim = false |
| 47 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 48 | // ### OMCI related definitions - retrieved from Python adapter code/trace #### |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 49 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 50 | const galEthernetEID = uint16(1) |
| 51 | const maxGemPayloadSize = uint16(48) |
| 52 | const connectivityModeValue = uint8(5) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 53 | |
| 54 | //const defaultTPID = uint16(0x8100) |
| 55 | //const broadComDefaultVID = uint16(4091) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 56 | const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning |
| 57 | const ieeeMapperServiceProfileEID = uint16(0x8001) |
| 58 | const macBridgePortAniEID = uint16(0x2102) |
| 59 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 60 | const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems |
| 61 | |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 62 | const cOmciBaseMessageTrailerLen = 40 |
| 63 | |
| 64 | // tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format) |
| 65 | type tOmciReceiveError uint8 |
| 66 | |
| 67 | const ( |
| 68 | // cOmciMessageReceiveNoError - default start state |
| 69 | cOmciMessageReceiveNoError tOmciReceiveError = iota |
| 70 | // Error indication wrong trailer length within the message |
| 71 | cOmciMessageReceiveErrorTrailerLen |
| 72 | // Error indication missing trailer within the message |
| 73 | cOmciMessageReceiveErrorMissTrailer |
| 74 | ) |
| 75 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 76 | // ### OMCI related definitions - end |
| 77 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 78 | //callbackPairEntry to be used for OMCI send/receive correlation |
| 79 | type callbackPairEntry struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 80 | cbRespChannel chan Message |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 81 | cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 82 | framePrint bool //true for printing |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 85 | //callbackPair to be used for ReceiveCallback init |
| 86 | type callbackPair struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 87 | cbKey uint16 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 88 | cbEntry callbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | type omciTransferStructure struct { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 92 | txFrame []byte |
| 93 | timeout int |
| 94 | retry int |
| 95 | highPrio bool |
| 96 | withFramePrint bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 99 | //omciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 100 | type omciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 101 | enabled bool |
| 102 | pOnuDeviceEntry *OnuDeviceEntry |
| 103 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 104 | pBaseDeviceHandler *deviceHandler |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 105 | coreProxy adapterif.CoreProxy |
| 106 | adapterProxy adapterif.AdapterProxy |
| 107 | supportExtMsg bool |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 108 | rxOmciFrameError tOmciReceiveError |
| 109 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 110 | txFrames, txOnuFrames uint32 |
| 111 | rxFrames, rxOnuFrames, rxOnuDiscards uint32 |
| 112 | |
| 113 | // OMCI params |
| 114 | mutexTid sync.Mutex |
| 115 | tid uint16 |
| 116 | mutexHpTid sync.Mutex |
| 117 | hpTid uint16 |
| 118 | uploadSequNo uint16 |
| 119 | uploadNoOfCmds uint16 |
| 120 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 121 | mutexTxQueue sync.Mutex |
| 122 | txQueue *list.List |
| 123 | mutexRxSchedMap sync.Mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 124 | rxSchedulerMap map[uint16]callbackPairEntry |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 125 | pLastTxMeInstance *me.ManagedEntity |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 128 | var responsesWithMibDataSync = []omci.MessageType{ |
| 129 | omci.CreateResponseType, |
| 130 | omci.DeleteResponseType, |
| 131 | omci.SetResponseType, |
| 132 | omci.StartSoftwareDownloadResponseType, |
| 133 | omci.EndSoftwareDownloadResponseType, |
| 134 | omci.ActivateSoftwareResponseType, |
| 135 | omci.CommitSoftwareResponseType, |
| 136 | } |
| 137 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 138 | //newOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 139 | //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 140 | func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry, |
| 141 | deviceID string, deviceHandler *deviceHandler, |
| 142 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 143 | logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 144 | var omciCC omciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 145 | omciCC.enabled = false |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 146 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 147 | omciCC.deviceID = deviceID |
| 148 | omciCC.pBaseDeviceHandler = deviceHandler |
| 149 | omciCC.coreProxy = coreProxy |
| 150 | omciCC.adapterProxy = adapterProxy |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 151 | omciCC.supportExtMsg = false |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 152 | omciCC.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 153 | omciCC.txFrames = 0 |
| 154 | omciCC.txOnuFrames = 0 |
| 155 | omciCC.rxFrames = 0 |
| 156 | omciCC.rxOnuFrames = 0 |
| 157 | omciCC.rxOnuDiscards = 0 |
| 158 | omciCC.tid = 0x1 |
| 159 | omciCC.hpTid = 0x8000 |
| 160 | omciCC.uploadSequNo = 0 |
| 161 | omciCC.uploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 162 | omciCC.txQueue = list.New() |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 163 | omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 164 | |
| 165 | return &omciCC |
| 166 | } |
| 167 | |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 168 | //stop stops/resets the omciCC |
| 169 | func (oo *omciCC) stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 170 | logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 171 | //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests |
| 172 | oo.mutexTxQueue.Lock() |
| 173 | oo.txQueue.Init() // clear the tx queue |
| 174 | oo.mutexTxQueue.Unlock() |
| 175 | oo.mutexRxSchedMap.Lock() |
| 176 | for k := range oo.rxSchedulerMap { |
| 177 | delete(oo.rxSchedulerMap, k) //clear the scheduler map |
| 178 | } |
| 179 | oo.mutexRxSchedMap.Unlock() |
| 180 | oo.mutexHpTid.Lock() |
| 181 | oo.hpTid = 0x8000 //reset the high prio transactionId |
| 182 | oo.mutexHpTid.Unlock() |
| 183 | oo.mutexTid.Lock() |
| 184 | oo.tid = 1 //reset the low prio transactionId |
| 185 | oo.mutexTid.Unlock() |
| 186 | //reset control values |
| 187 | oo.uploadSequNo = 0 |
| 188 | oo.uploadNoOfCmds = 0 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 189 | oo.rxOmciFrameError = cOmciMessageReceiveNoError |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 190 | //reset the stats counter - which might be topic of discussion ... |
| 191 | oo.txFrames = 0 |
| 192 | oo.txOnuFrames = 0 |
| 193 | oo.rxFrames = 0 |
| 194 | oo.rxOnuFrames = 0 |
| 195 | oo.rxOnuDiscards = 0 |
| 196 | |
| 197 | return nil |
| 198 | } |
| 199 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 200 | // Rx handler for omci messages |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 201 | func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 202 | logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 203 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 204 | switch omciMsg.MessageType { |
| 205 | case omci.AlarmNotificationType: |
| 206 | data := OmciMessage{ |
| 207 | OmciMsg: omciMsg, |
| 208 | OmciPacket: packet, |
| 209 | } |
| 210 | go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data) |
| 211 | return nil |
| 212 | default: |
| 213 | return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String()) |
| 214 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 215 | /* |
| 216 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 217 | rxOnuFrames++ |
| 218 | |
| 219 | switch msgType { |
| 220 | case AlarmNotification: |
| 221 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 222 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 223 | // python code was: |
| 224 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 225 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 226 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 227 | // |
| 228 | return errors.New("RxAlarmNotification unimplemented") |
| 229 | } |
| 230 | case AttributeValueChange: |
| 231 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 232 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 233 | // python code was: |
| 234 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 235 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 236 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 237 | // |
| 238 | return errors.New("RxAttributeValueChange unimplemented") |
| 239 | } |
| 240 | case TestResult: |
| 241 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 242 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 243 | // python code was: |
| 244 | //elif msg_type == EntityOperations.TestResult.value: |
| 245 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 246 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 247 | // |
| 248 | return errors.New("RxTestResult unimplemented") |
| 249 | } |
| 250 | default: |
| 251 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 252 | logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 253 | rxOnuDiscards++ |
| 254 | return errors.New("RxOnuMsgType unimplemented") |
| 255 | } |
| 256 | } |
| 257 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 258 | } |
| 259 | |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 260 | func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) { |
| 261 | //assuming omci message content is hex coded! |
| 262 | // with restricted output of 16bytes would be ...rxMsg[:16] |
| 263 | logger.Debugw(ctx, "omci-message-received:", log.Fields{ |
| 264 | "RxOmciMessage": hex.EncodeToString(rxMsg), |
| 265 | "device-id": oo.deviceID}) |
| 266 | } |
| 267 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 268 | // Rx handler for onu messages |
| 269 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 270 | func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 271 | //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 272 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 273 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 274 | // (an extendedFormat message could be destroyed this way!) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 275 | trailerLenData := rxMsg[42:44] |
| 276 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 277 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 278 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 279 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 280 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 281 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 282 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 283 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 284 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 285 | } |
| 286 | } |
| 287 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 288 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 289 | // (an extendedFormat message could be destroyed this way!) |
| 290 | // extend/overwrite with trailer |
| 291 | trailer := make([]byte, 8) |
| 292 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 293 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 294 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 295 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 296 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 297 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 298 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 299 | } |
| 300 | } else { |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 301 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 302 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 303 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 304 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy) |
| 308 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 309 | logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 310 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 311 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 312 | } |
| 313 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 314 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 315 | logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 316 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 317 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 318 | } |
| 319 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 320 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 321 | logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 322 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 323 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 324 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 325 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 326 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier}) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 327 | if byte(omciMsg.MessageType)&me.AK == 0 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 328 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 329 | oo.printRxMessage(ctx, rxMsg) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 330 | logger.Debug(ctx, "RxMsg is no Omci Response Message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 331 | if omciMsg.TransactionID == 0 { |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 332 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 333 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 334 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 335 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 336 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 337 | return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 338 | |
| 339 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 340 | //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester") |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 341 | oo.mutexRxSchedMap.Lock() |
| 342 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
| 343 | if ok && rxCallbackEntry.cbFunction != nil { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 344 | if rxCallbackEntry.framePrint { |
| 345 | oo.printRxMessage(ctx, rxMsg) |
| 346 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 347 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 348 | // how to react on erroneous frame reception, maybe can simply be ignored |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 349 | go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 350 | if isResponseWithMibDataSync(omciMsg.MessageType) { |
| 351 | oo.pOnuDeviceEntry.incrementMibDataSync(ctx) |
| 352 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 353 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 354 | // having posted the response the request is regarded as 'done' |
| 355 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 356 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 357 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 358 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 359 | oo.mutexRxSchedMap.Unlock() |
| 360 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 361 | oo.printRxMessage(ctx, rxMsg) |
| 362 | return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 363 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 364 | /* py code was: |
| 365 | Receive and OMCI message from the proxy channel to the OLT. |
| 366 | |
| 367 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 368 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 369 | """ |
| 370 | if not self.enabled: |
| 371 | return |
| 372 | |
| 373 | try: |
| 374 | now = arrow.utcnow() |
| 375 | d = None |
| 376 | |
| 377 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 378 | # save the current value of the entity_id_to_class_map, then |
| 379 | # replace it with our custom one before decode, and then finally |
| 380 | # restore it later. Tried other ways but really made the code messy. |
| 381 | saved_me_map = omci_entities.entity_id_to_class_map |
| 382 | omci_entities.entity_id_to_class_map = self._me_map |
| 383 | |
| 384 | try: |
| 385 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 386 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 387 | except KeyError as e: |
| 388 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 389 | self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 390 | rx_frame = self._decode_unknown_me(msg) |
| 391 | self._rx_unknown_me += 1 |
| 392 | |
| 393 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 394 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 395 | return |
| 396 | |
| 397 | finally: |
| 398 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 399 | |
| 400 | rx_tid = rx_frame.fields['transaction_id'] |
| 401 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 402 | self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 403 | # Filter the Test Result frame and route through receive onu |
| 404 | # message method. |
| 405 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 406 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 407 | return self._receive_onu_message(rx_frame) |
| 408 | |
| 409 | # Previously unreachable if this is the very first round-trip Rx or we |
| 410 | # have been running consecutive errors |
| 411 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 412 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 413 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 414 | |
| 415 | self._rx_frames += 1 |
| 416 | self._consecutive_errors = 0 |
| 417 | |
| 418 | try: |
| 419 | high_priority = self._tid_is_high_priority(rx_tid) |
| 420 | index = self._get_priority_index(high_priority) |
| 421 | |
| 422 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 423 | last_tx_tuple = self._tx_request[index] |
| 424 | |
| 425 | if last_tx_tuple is None or \ |
| 426 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 427 | # Possible late Rx on a message that timed-out |
| 428 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 429 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 430 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 431 | self._rx_unknown_tid += 1 |
| 432 | self._rx_late += 1 |
| 433 | return |
| 434 | |
| 435 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 436 | if dc is not None and not dc.cancelled and not dc.called: |
| 437 | dc.cancel() |
| 438 | |
| 439 | _secs = self._update_rx_tx_stats(now, ts) |
| 440 | |
| 441 | # Late arrival already serviced by a timeout? |
| 442 | if d.called: |
| 443 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 444 | self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 445 | return |
| 446 | |
| 447 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 448 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 449 | if d is not None: |
| 450 | return d.errback(failure.Failure(e)) |
| 451 | return |
| 452 | |
| 453 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 454 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 455 | tx_tid = tx_frame.fields['transaction_id']) |
| 456 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 457 | |
| 458 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 459 | self._rx_response[index] = rx_frame |
| 460 | d.callback(rx_frame) |
| 461 | |
| 462 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 463 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 464 | */ |
| 465 | } |
| 466 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 467 | /* |
| 468 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 469 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 470 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 471 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 472 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 473 | |
| 474 | //Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 475 | func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 476 | receiveCallbackPair callbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 477 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 478 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 479 | // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ... |
| 480 | oo.mutexRxSchedMap.Lock() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 481 | oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 482 | printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 483 | oo.mutexRxSchedMap.Unlock() |
| 484 | |
| 485 | //just use a simple list for starting - might need some more effort, especially for multi source write access |
| 486 | omciTxRequest := omciTransferStructure{ |
| 487 | txFrame, |
| 488 | timeout, |
| 489 | retry, |
| 490 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 491 | printFrame, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 492 | } |
| 493 | oo.mutexTxQueue.Lock() |
| 494 | oo.txQueue.PushBack(omciTxRequest) // enqueue |
| 495 | oo.mutexTxQueue.Unlock() |
| 496 | |
| 497 | // for first test just bypass and send directly: |
| 498 | go oo.sendNextRequest(ctx) |
| 499 | return nil |
| 500 | } |
| 501 | |
| 502 | //Pull next tx request and send it |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 503 | func (oo *omciCC) sendNextRequest(ctx context.Context) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 504 | // return errors.New("sendNextRequest unimplemented") |
| 505 | |
| 506 | // just try to get something transferred !! |
| 507 | // avoid accessing the txQueue from parallel send requests |
| 508 | // block parallel omci send requests at least until SendIAP is 'committed' |
| 509 | // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed |
| 510 | oo.mutexTxQueue.Lock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 511 | defer oo.mutexTxQueue.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 512 | for oo.txQueue.Len() > 0 { |
| 513 | queueElement := oo.txQueue.Front() // First element |
| 514 | omciTxRequest := queueElement.Value.(omciTransferStructure) |
| 515 | /* compare olt device handler code: |
| 516 | func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 517 | logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 518 | var deviceType string |
| 519 | var deviceID string |
| 520 | var proxyDeviceID string |
| 521 | |
| 522 | onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId) |
| 523 | |
| 524 | if onuInCache, ok := dh.onus.Load(onuKey); !ok { |
| 525 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 526 | logger.Debugw(ctx,"omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 527 | ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT) |
| 528 | kwargs := make(map[string]interface{}) |
| 529 | kwargs["onu_id"] = omciInd.OnuId |
| 530 | kwargs["parent_port_no"] = ponPort |
| 531 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 532 | onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 533 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 534 | logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 535 | return |
| 536 | } |
| 537 | deviceType = onuDevice.Type |
| 538 | deviceID = onuDevice.Id |
| 539 | proxyDeviceID = onuDevice.ProxyAddress.DeviceId |
| 540 | //if not exist in cache, then add to cache. |
| 541 | dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID)) |
| 542 | } else { |
| 543 | //found in cache |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 544 | logger.Debugw(ctx,"omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 545 | deviceType = onuInCache.(*OnuDevice).deviceType |
| 546 | deviceID = onuInCache.(*OnuDevice).deviceID |
| 547 | proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID |
| 548 | } |
| 549 | */ |
| 550 | /* and compare onu_adapter py code: |
| 551 | omci_msg = InterAdapterOmciMessage( |
| 552 | message=bytes(frame), |
| 553 | proxy_address=self._proxy_address, |
| 554 | connect_status=self._device.connect_status) |
| 555 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 556 | self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame))) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 557 | |
| 558 | yield self._adapter_proxy.send_inter_adapter_message( |
| 559 | msg=omci_msg, |
| 560 | type=InterAdapterMessageType.OMCI_REQUEST, |
| 561 | from_adapter=self._device.type, |
| 562 | to_adapter=self._proxy_address.device_type, |
| 563 | to_device_id=self._device_id, |
| 564 | proxy_device_id=self._proxy_address.device_id |
| 565 | ) |
| 566 | */ |
| 567 | device, err := oo.coreProxy.GetDevice(ctx, |
| 568 | oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child |
| 569 | if err != nil || device == nil { |
| 570 | /*TODO: needs to handle error scenarios */ |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 571 | logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 572 | "ChildId": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 573 | return fmt.Errorf("failed to fetch device %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 574 | } |
| 575 | |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 576 | if omciTxRequest.withFramePrint { |
| 577 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 578 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 579 | "device-id": oo.deviceID, |
| 580 | "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType, |
| 581 | "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID}) |
| 582 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 583 | omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame} |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 584 | if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 585 | ic.InterAdapterMessageType_OMCI_REQUEST, |
Matteo Scandolo | efbec27 | 2020-11-17 10:33:09 -0800 | [diff] [blame] | 586 | //fromTopic,toType,toDevId, ProxyDevId |
| 587 | oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 588 | oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 589 | logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 590 | return sendErr |
| 591 | } |
| 592 | oo.txQueue.Remove(queueElement) // Dequeue |
| 593 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 594 | return nil |
| 595 | } |
| 596 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 597 | func (oo *omciCC) getNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 598 | var next uint16 |
| 599 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 600 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 601 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 602 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 603 | if oo.hpTid < 0x8000 { |
| 604 | oo.hpTid = 0x8000 |
| 605 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 606 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 607 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 608 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 609 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 610 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 611 | if oo.tid >= 0x8000 { |
| 612 | oo.tid = 1 |
| 613 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 614 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 615 | } |
| 616 | return next |
| 617 | } |
| 618 | |
| 619 | // ################################################################################### |
| 620 | // # utility methods provided to work on OMCI messages |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 621 | func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 622 | omciLayer := &omci.OMCI{ |
| 623 | TransactionID: tid, |
| 624 | MessageType: msgType, |
| 625 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 626 | return serializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 627 | } |
| 628 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 629 | func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 630 | var options gopacket.SerializeOptions |
| 631 | options.FixLengths = true |
| 632 | |
| 633 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 634 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 635 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 636 | logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 637 | return nil, err |
| 638 | } |
| 639 | return buffer.Bytes(), nil |
| 640 | } |
| 641 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 642 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 643 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 644 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 645 | hex.Encode(dst, omciPkt) |
| 646 | return dst, nil |
| 647 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 648 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 649 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 650 | //supply a response handler for omci response messages to be transferred to the requested FSM |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 651 | func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 652 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 653 | logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType, |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 654 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 655 | |
| 656 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 657 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 658 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 659 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 663 | // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 664 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 665 | Type: OMCI, |
| 666 | Data: OmciMessage{ |
| 667 | OmciMsg: omciMsg, |
| 668 | OmciPacket: packet, |
| 669 | }, |
| 670 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 671 | //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 672 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 673 | |
| 674 | return nil |
| 675 | } |
| 676 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 677 | func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 678 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 679 | logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 680 | request := &omci.MibResetRequest{ |
| 681 | MeBasePacket: omci.MeBasePacket{ |
| 682 | EntityClass: me.OnuDataClassID, |
| 683 | }, |
| 684 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 685 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 686 | pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 687 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 688 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 689 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 690 | return err |
| 691 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 692 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 693 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 694 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 695 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 696 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 697 | } |
| 698 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 699 | func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 700 | logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 701 | request := &omci.RebootRequest{ |
| 702 | MeBasePacket: omci.MeBasePacket{ |
| 703 | EntityClass: me.OnuGClassID, |
| 704 | }, |
| 705 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 706 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 707 | pkt, err := serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 708 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 709 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 710 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 711 | return err |
| 712 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 713 | omciRxCallbackPair := callbackPair{ |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 714 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 715 | cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 716 | } |
| 717 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 718 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 719 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 720 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 721 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 722 | return err |
| 723 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 724 | err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 725 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 726 | logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 727 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 728 | return err |
| 729 | } |
| 730 | return nil |
| 731 | } |
| 732 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 733 | func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 734 | logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 735 | request := &omci.MibUploadRequest{ |
| 736 | MeBasePacket: omci.MeBasePacket{ |
| 737 | EntityClass: me.OnuDataClassID, |
| 738 | }, |
| 739 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 740 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 741 | pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 742 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 743 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 744 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 745 | return err |
| 746 | } |
| 747 | oo.uploadSequNo = 0 |
| 748 | oo.uploadNoOfCmds = 0 |
| 749 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 750 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 751 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 752 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 753 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 754 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 755 | } |
| 756 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 757 | func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 758 | logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 759 | request := &omci.MibUploadNextRequest{ |
| 760 | MeBasePacket: omci.MeBasePacket{ |
| 761 | EntityClass: me.OnuDataClassID, |
| 762 | }, |
| 763 | CommandSequenceNumber: oo.uploadSequNo, |
| 764 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 765 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 766 | pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 767 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 768 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 769 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 770 | return err |
| 771 | } |
| 772 | oo.uploadSequNo++ |
| 773 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 774 | omciRxCallbackPair := callbackPair{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 775 | cbKey: tid, |
| 776 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 777 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 778 | // compare also software upgrade download section handling |
| 779 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, false}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 780 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 781 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 782 | } |
| 783 | |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 784 | func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error { |
| 785 | logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID}) |
| 786 | request := &omci.GetAllAlarmsRequest{ |
| 787 | MeBasePacket: omci.MeBasePacket{ |
| 788 | EntityClass: me.OnuDataClassID, |
| 789 | }, |
| 790 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 791 | } |
| 792 | tid := oo.getNextTid(highPrio) |
| 793 | pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid) |
| 794 | if err != nil { |
| 795 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{ |
| 796 | "Err": err, "device-id": oo.deviceID}) |
| 797 | return err |
| 798 | } |
| 799 | oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo = 0 |
| 800 | oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadNoOfCmds = 0 |
| 801 | |
| 802 | omciRxCallbackPair := callbackPair{ |
| 803 | cbKey: tid, |
| 804 | cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, |
| 805 | oo.receiveOmciResponse, true}, |
| 806 | } |
| 807 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 808 | } |
| 809 | |
| 810 | func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error { |
| 811 | alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo |
| 812 | logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID, |
| 813 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
| 814 | request := &omci.GetAllAlarmsNextRequest{ |
| 815 | MeBasePacket: omci.MeBasePacket{ |
| 816 | EntityClass: me.OnuDataClassID, |
| 817 | }, |
| 818 | CommandSequenceNumber: alarmUploadSeqNo, |
| 819 | } |
| 820 | tid := oo.getNextTid(highPrio) |
| 821 | pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid) |
| 822 | if err != nil { |
| 823 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{ |
| 824 | "Err": err, "device-id": oo.deviceID}) |
| 825 | return err |
| 826 | } |
| 827 | oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo++ |
| 828 | |
| 829 | omciRxCallbackPair := callbackPair{ |
| 830 | cbKey: tid, |
| 831 | cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true}, |
| 832 | } |
| 833 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 834 | } |
| 835 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 836 | func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 837 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 838 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 839 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 840 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 841 | meParams := me.ParamData{ |
| 842 | EntityID: galEthernetEID, |
| 843 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 844 | } |
| 845 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 846 | if omciErr.GetError() == nil { |
| 847 | //all setByCreate parameters already set, no default option required ... |
| 848 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 849 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 850 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 851 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 852 | return nil |
| 853 | } |
| 854 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 855 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 856 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 857 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 858 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 859 | return nil |
| 860 | } |
| 861 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 862 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 863 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 864 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 865 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 866 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 867 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 868 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 869 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 870 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 871 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 872 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 873 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 874 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 875 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 876 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 877 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 878 | } |
| 879 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 880 | // might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!! |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 881 | func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 882 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 883 | logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 884 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 885 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 886 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 887 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 888 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 889 | // read ONU-2G from DB ???? //TODO!!! |
| 890 | meParams := me.ParamData{ |
| 891 | EntityID: 0, |
| 892 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 893 | } |
| 894 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 895 | if omciErr.GetError() == nil { |
| 896 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 897 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 898 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 899 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 900 | return nil |
| 901 | } |
| 902 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 903 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 904 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 905 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 906 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 907 | return nil |
| 908 | } |
| 909 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 910 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 911 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 912 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 913 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 914 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 915 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 916 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 917 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 918 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 919 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 920 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 921 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 922 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 923 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 924 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 925 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 926 | } |
| 927 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 928 | func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context, |
| 929 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 930 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 931 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 932 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 933 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 934 | |
| 935 | meParams := me.ParamData{ |
| 936 | EntityID: instID, |
| 937 | Attributes: me.AttributeValueMap{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 938 | "Priority": 0x8000, |
| 939 | "MaxAge": 20 * 256, //20s |
| 940 | "HelloTime": 2 * 256, //2s |
| 941 | "ForwardDelay": 15 * 256, //15s |
| 942 | "DynamicFilteringAgeingTime": 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 943 | }, |
| 944 | } |
| 945 | |
| 946 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 947 | if omciErr.GetError() == nil { |
| 948 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 949 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 950 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 951 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 952 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 953 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 954 | return nil |
| 955 | } |
| 956 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 957 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 958 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 959 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 960 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 961 | return nil |
| 962 | } |
| 963 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 964 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 965 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 966 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 967 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 968 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 969 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 970 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 971 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 972 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 973 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 974 | logger.Debug(ctx, "send MBSP-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 975 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 976 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 977 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 978 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 979 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 980 | } |
| 981 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 982 | func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context, |
| 983 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 984 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 985 | instID := macBridgePortAniEID + aPUniPort.entityID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 986 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 987 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 988 | |
| 989 | meParams := me.ParamData{ |
| 990 | EntityID: instID, |
| 991 | Attributes: me.AttributeValueMap{ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 992 | "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo), |
| 993 | "PortNum": aPUniPort.macBpNo, |
| 994 | "TpType": uint8(aPUniPort.portType), |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 995 | "TpPointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 996 | }, |
| 997 | } |
| 998 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 999 | if omciErr.GetError() == nil { |
| 1000 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1001 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1002 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1003 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1004 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1005 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1006 | return nil |
| 1007 | } |
| 1008 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1009 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1010 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1011 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1012 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1013 | return nil |
| 1014 | } |
| 1015 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1016 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1017 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1018 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1019 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1020 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1021 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1022 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1023 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1024 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1025 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1026 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1027 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1028 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1029 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1030 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1031 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1034 | func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context, |
| 1035 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 1036 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1037 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1038 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1039 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1040 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1041 | |
| 1042 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1043 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1044 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1045 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1046 | if aPUniPort.portType == uniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1047 | assType = uint8(10) // for VEIP |
| 1048 | } |
| 1049 | meParams := me.ParamData{ |
| 1050 | EntityID: instID, |
| 1051 | Attributes: me.AttributeValueMap{ |
| 1052 | "AssociationType": assType, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1053 | "AssociatedMePointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1054 | }, |
| 1055 | } |
| 1056 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1057 | if omciErr.GetError() == nil { |
| 1058 | //all setByCreate parameters already set, no default option required ... |
| 1059 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 1060 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1061 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1062 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1063 | return nil |
| 1064 | } |
| 1065 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1066 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1067 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1068 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1069 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1070 | return nil |
| 1071 | } |
| 1072 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1073 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1074 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1075 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1076 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1077 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1078 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1079 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1080 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1081 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1082 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1083 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1084 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1085 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1086 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1087 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1088 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1089 | } |
| 1090 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1091 | func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1092 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1093 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1094 | logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1095 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1096 | |
| 1097 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1098 | meParams := me.ParamData{ |
| 1099 | EntityID: 0, |
| 1100 | Attributes: requestedAttributes, |
| 1101 | } |
| 1102 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1103 | if omciErr.GetError() == nil { |
| 1104 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1105 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1106 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1107 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1108 | return nil |
| 1109 | } |
| 1110 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1111 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1112 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1113 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1114 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1115 | return nil |
| 1116 | } |
| 1117 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1118 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1119 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1120 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1121 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1122 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1123 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1124 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1125 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1126 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1127 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1128 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1129 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1130 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1131 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1132 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1133 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1136 | func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
| 1137 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 1138 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1139 | logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1140 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1141 | |
| 1142 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1143 | meParams := me.ParamData{ |
| 1144 | EntityID: aInstNo, |
| 1145 | Attributes: requestedAttributes, |
| 1146 | } |
| 1147 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1148 | if omciErr.GetError() == nil { |
| 1149 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1150 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1151 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1152 | "Err": err, "device-id": oo.deviceID}) |
| 1153 | return nil |
| 1154 | } |
| 1155 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1156 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1157 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1158 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1159 | "Err": err, "device-id": oo.deviceID}) |
| 1160 | return nil |
| 1161 | } |
| 1162 | |
| 1163 | omciRxCallbackPair := callbackPair{ |
| 1164 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1165 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1166 | } |
| 1167 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1168 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1169 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1170 | "Err": err, "device-id": oo.deviceID}) |
| 1171 | return nil |
| 1172 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1173 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1174 | return meInstance |
| 1175 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1176 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1177 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1178 | return nil |
| 1179 | } |
| 1180 | |
| 1181 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1182 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1183 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1184 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1185 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1186 | logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1187 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1188 | |
| 1189 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1190 | meParams := me.ParamData{ |
| 1191 | EntityID: aInstNo, |
| 1192 | Attributes: requestedAttributes, |
| 1193 | } |
| 1194 | meInstance, omciErr := me.NewUniG(meParams) |
| 1195 | if omciErr.GetError() == nil { |
| 1196 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1197 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1198 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1199 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1200 | return nil |
| 1201 | } |
| 1202 | |
| 1203 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1204 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1205 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1206 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1207 | return nil |
| 1208 | } |
| 1209 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1210 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1211 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1212 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1213 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1214 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1215 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1216 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1217 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1218 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1219 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1220 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1221 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1222 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1223 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1224 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1225 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1226 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1227 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1228 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1229 | func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1230 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1231 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1232 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1233 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1234 | |
| 1235 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1236 | meParams := me.ParamData{ |
| 1237 | EntityID: aInstNo, |
| 1238 | Attributes: requestedAttributes, |
| 1239 | } |
| 1240 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1241 | if omciErr.GetError() == nil { |
| 1242 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1243 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1244 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1245 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1246 | return nil |
| 1247 | } |
| 1248 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1249 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1250 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1251 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1252 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1253 | return nil |
| 1254 | } |
| 1255 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1256 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1257 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1258 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1259 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1260 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1261 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1262 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1263 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1264 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1265 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1266 | logger.Debug(ctx, "send VEIP-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1267 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1268 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1269 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1270 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1271 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1272 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1273 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1274 | func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
Girish Gowdra | e09a620 | 2021-01-12 18:10:59 -0800 | [diff] [blame] | 1275 | timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1276 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1277 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1278 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1279 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1280 | |
| 1281 | meParams := me.ParamData{ |
| 1282 | EntityID: entityID, |
| 1283 | Attributes: requestedAttributes, |
| 1284 | } |
| 1285 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1286 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1287 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1288 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid)) |
| 1289 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1290 | logger.Errorf(ctx, "Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1291 | return nil |
| 1292 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1293 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1294 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1295 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1296 | return nil |
| 1297 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1298 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1299 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1300 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1301 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1302 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1303 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1304 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1305 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1306 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1307 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1308 | return meInstance |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1309 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1310 | logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1311 | return nil |
| 1312 | } |
| 1313 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1314 | func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1315 | aInstID uint16, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1316 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1317 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1318 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1319 | |
| 1320 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1321 | EntityID: aInstID, |
| 1322 | Attributes: me.AttributeValueMap{ |
| 1323 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
| 1324 | "TpPointer": 0xFFFF, |
| 1325 | "InterworkTpPointerForPBitPriority0": 0xFFFF, |
| 1326 | "InterworkTpPointerForPBitPriority1": 0xFFFF, |
| 1327 | "InterworkTpPointerForPBitPriority2": 0xFFFF, |
| 1328 | "InterworkTpPointerForPBitPriority3": 0xFFFF, |
| 1329 | "InterworkTpPointerForPBitPriority4": 0xFFFF, |
| 1330 | "InterworkTpPointerForPBitPriority5": 0xFFFF, |
| 1331 | "InterworkTpPointerForPBitPriority6": 0xFFFF, |
| 1332 | "InterworkTpPointerForPBitPriority7": 0xFFFF, |
| 1333 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1334 | } |
| 1335 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1336 | if omciErr.GetError() == nil { |
| 1337 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1338 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1339 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1340 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1341 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1342 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1343 | return nil |
| 1344 | } |
| 1345 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1346 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1347 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1348 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1349 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1350 | return nil |
| 1351 | } |
| 1352 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1353 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1354 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1355 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1356 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1357 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1358 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1359 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1360 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1361 | return nil |
| 1362 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1363 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1364 | return meInstance |
| 1365 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1366 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1367 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1368 | return nil |
| 1369 | } |
| 1370 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1371 | func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1372 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1373 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1374 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1375 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1376 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1377 | |
| 1378 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1379 | if omciErr.GetError() == nil { |
| 1380 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1381 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1382 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1383 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1384 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1385 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1386 | return nil |
| 1387 | } |
| 1388 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1389 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1390 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1391 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1392 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1393 | return nil |
| 1394 | } |
| 1395 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1396 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1397 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1398 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1399 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1400 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1401 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1402 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1403 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1404 | return nil |
| 1405 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1406 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1407 | return meInstance |
| 1408 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1409 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1410 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1411 | return nil |
| 1412 | } |
| 1413 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1414 | func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1415 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1416 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1417 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1418 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1419 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1420 | |
| 1421 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1422 | if omciErr.GetError() == nil { |
| 1423 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1424 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1425 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1426 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1427 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1428 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1429 | return nil |
| 1430 | } |
| 1431 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1432 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1433 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1434 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1435 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1436 | return nil |
| 1437 | } |
| 1438 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1439 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1440 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1441 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1442 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1443 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1444 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1445 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1446 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1447 | return nil |
| 1448 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1449 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1450 | return meInstance |
| 1451 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1452 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1453 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1454 | return nil |
| 1455 | } |
| 1456 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1457 | func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1458 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1459 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1460 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1461 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1462 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1463 | |
| 1464 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1465 | if omciErr.GetError() == nil { |
| 1466 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1467 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1468 | omci.TransactionID(tid)) |
| 1469 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1470 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1471 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1472 | return nil |
| 1473 | } |
| 1474 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1475 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1476 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1477 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1478 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1479 | return nil |
| 1480 | } |
| 1481 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1482 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1483 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1484 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1485 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1486 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1487 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1488 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1489 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1490 | return nil |
| 1491 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1492 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1493 | return meInstance |
| 1494 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1495 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1496 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1497 | return nil |
| 1498 | } |
| 1499 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1500 | func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1501 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1502 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1503 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1504 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1505 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1506 | |
| 1507 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1508 | if omciErr.GetError() == nil { |
| 1509 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1510 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1511 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1512 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1513 | return nil |
| 1514 | } |
| 1515 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1516 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1517 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1518 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1519 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1520 | return nil |
| 1521 | } |
| 1522 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1523 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1524 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1525 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1526 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1527 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1528 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1529 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1530 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1531 | return nil |
| 1532 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1533 | logger.Debug(ctx, "send TCont-set msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1534 | return meInstance |
| 1535 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1536 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1537 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1538 | return nil |
| 1539 | } |
| 1540 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1541 | func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1542 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1543 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1544 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1545 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1546 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1547 | |
| 1548 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1549 | if omciErr.GetError() == nil { |
| 1550 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1551 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1552 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1553 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1554 | return nil |
| 1555 | } |
| 1556 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1557 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1558 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1559 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1560 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1561 | return nil |
| 1562 | } |
| 1563 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1564 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1565 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1566 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1567 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1568 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1569 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1570 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1571 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1572 | return nil |
| 1573 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1574 | logger.Debug(ctx, "send PrioQueue-set msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1575 | return meInstance |
| 1576 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1577 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1578 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1579 | return nil |
| 1580 | } |
| 1581 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1582 | func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1583 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1584 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1585 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1586 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1587 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1588 | |
| 1589 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1590 | if omciErr.GetError() == nil { |
| 1591 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1592 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1593 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1594 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1595 | return nil |
| 1596 | } |
| 1597 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1598 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1599 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1600 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1601 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1602 | return nil |
| 1603 | } |
| 1604 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1605 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1606 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1607 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1608 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1609 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1610 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1611 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1612 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1613 | return nil |
| 1614 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1615 | logger.Debug(ctx, "send 1PMapper-set msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1616 | return meInstance |
| 1617 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1618 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1619 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1620 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1621 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1622 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1623 | func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1624 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1625 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1626 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1627 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1628 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1629 | |
| 1630 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1631 | if omciErr.GetError() == nil { |
| 1632 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1633 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1634 | omci.TransactionID(tid)) |
| 1635 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1636 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1637 | "Err": err, "device-id": oo.deviceID}) |
| 1638 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1639 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1640 | // (relevant to all used sendXX() methods and their error conditions) |
| 1641 | return nil |
| 1642 | } |
| 1643 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1644 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1645 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1646 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1647 | "Err": err, "device-id": oo.deviceID}) |
| 1648 | return nil |
| 1649 | } |
| 1650 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1651 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1652 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1653 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1654 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1655 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1656 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1657 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1658 | "Err": err, "device-id": oo.deviceID}) |
| 1659 | return nil |
| 1660 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1661 | logger.Debug(ctx, "send VTFD-Create-msg done") |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1662 | return meInstance |
| 1663 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1664 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1665 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1666 | return nil |
| 1667 | } |
| 1668 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1669 | // nolint: unused |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1670 | func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
| 1671 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1672 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1673 | logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1674 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1675 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1676 | |
| 1677 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1678 | if omciErr.GetError() == nil { |
| 1679 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, |
| 1680 | omci.TransactionID(tid)) |
| 1681 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1682 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1683 | "Err": err, "device-id": oo.deviceID}) |
| 1684 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1685 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1686 | // (relevant to all used sendXX() methods and their error conditions) |
| 1687 | return nil |
| 1688 | } |
| 1689 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1690 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1691 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1692 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1693 | "Err": err, "device-id": oo.deviceID}) |
| 1694 | return nil |
| 1695 | } |
| 1696 | |
| 1697 | omciRxCallbackPair := callbackPair{ |
| 1698 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1699 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1700 | } |
| 1701 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1702 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1703 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1704 | "Err": err, "device-id": oo.deviceID}) |
| 1705 | return nil |
| 1706 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1707 | logger.Debug(ctx, "send VTFD-Set-msg done") |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1708 | return meInstance |
| 1709 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1710 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1711 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1712 | return nil |
| 1713 | } |
| 1714 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1715 | func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
| 1716 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1717 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1718 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1719 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1720 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1721 | |
| 1722 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1723 | if omciErr.GetError() == nil { |
| 1724 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 1725 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1726 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1727 | "Err": err, "device-id": oo.deviceID}) |
| 1728 | return nil |
| 1729 | } |
| 1730 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1731 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1732 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1733 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1734 | "Err": err, "device-id": oo.deviceID}) |
| 1735 | return nil |
| 1736 | } |
| 1737 | |
| 1738 | omciRxCallbackPair := callbackPair{ |
| 1739 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1740 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1741 | } |
| 1742 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1743 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1744 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1745 | "Err": err, "device-id": oo.deviceID}) |
| 1746 | return nil |
| 1747 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1748 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1749 | return meInstance |
| 1750 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1751 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1752 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1753 | return nil |
| 1754 | } |
| 1755 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1756 | func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1757 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1758 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1759 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1760 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1761 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1762 | |
| 1763 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1764 | if omciErr.GetError() == nil { |
| 1765 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1766 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1767 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1768 | "Err": err, "device-id": oo.deviceID}) |
| 1769 | return nil |
| 1770 | } |
| 1771 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1772 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1773 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1774 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1775 | "Err": err, "device-id": oo.deviceID}) |
| 1776 | return nil |
| 1777 | } |
| 1778 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1779 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1780 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1781 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1782 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1783 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1784 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1785 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1786 | "Err": err, "device-id": oo.deviceID}) |
| 1787 | return nil |
| 1788 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1789 | logger.Debug(ctx, "send EVTOCD-set msg done") |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1790 | return meInstance |
| 1791 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1792 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1793 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1794 | return nil |
| 1795 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1796 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1797 | func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
| 1798 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1799 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1800 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1801 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1802 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1803 | |
| 1804 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1805 | if omciErr.GetError() == nil { |
| 1806 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid)) |
| 1807 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1808 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1809 | "Err": err, "device-id": oo.deviceID}) |
| 1810 | return nil |
| 1811 | } |
| 1812 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1813 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1814 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1815 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1816 | "Err": err, "device-id": oo.deviceID}) |
| 1817 | return nil |
| 1818 | } |
| 1819 | |
| 1820 | omciRxCallbackPair := callbackPair{ |
| 1821 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1822 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1823 | } |
| 1824 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1825 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1826 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1827 | "Err": err, "device-id": oo.deviceID}) |
| 1828 | return nil |
| 1829 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1830 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1831 | return meInstance |
| 1832 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1833 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1834 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1835 | return nil |
| 1836 | } |
| 1837 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1838 | func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
| 1839 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1840 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1841 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1842 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1843 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1844 | |
| 1845 | meParams := me.ParamData{EntityID: aInstID} |
| 1846 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 1847 | if omciErr.GetError() == nil { |
| 1848 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1849 | omci.TransactionID(tid)) |
| 1850 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1851 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1852 | "Err": err, "device-id": oo.deviceID}) |
| 1853 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1854 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1855 | // (relevant to all used sendXX() methods and their error conditions) |
| 1856 | return nil |
| 1857 | } |
| 1858 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1859 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1860 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1861 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1862 | "Err": err, "device-id": oo.deviceID}) |
| 1863 | return nil |
| 1864 | } |
| 1865 | |
| 1866 | omciRxCallbackPair := callbackPair{ |
| 1867 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1868 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1869 | } |
| 1870 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1871 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1872 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1873 | "Err": err, "device-id": oo.deviceID}) |
| 1874 | return nil |
| 1875 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1876 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1877 | return meInstance |
| 1878 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1879 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1880 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1881 | return nil |
| 1882 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1883 | |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 1884 | // nolint: unused |
| 1885 | func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool, |
| 1886 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1887 | tid := oo.getNextTid(highPrio) |
| 1888 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1889 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1890 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1891 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 1892 | if omciErr.GetError() == nil { |
| 1893 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 1894 | if err != nil { |
| 1895 | logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1896 | return nil |
| 1897 | } |
| 1898 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1899 | if err != nil { |
| 1900 | logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1901 | return nil |
| 1902 | } |
| 1903 | omciRxCallbackPair := callbackPair{ |
| 1904 | cbKey: tid, |
| 1905 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 1906 | } |
| 1907 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1908 | if err != nil { |
| 1909 | logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1910 | return nil |
| 1911 | } |
| 1912 | logger.Debug(ctx, "send TD-Create-msg done") |
| 1913 | return meInstance |
| 1914 | } |
| 1915 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1916 | return nil |
| 1917 | } |
| 1918 | |
| 1919 | // nolint: unused |
| 1920 | func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
| 1921 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1922 | tid := oo.getNextTid(highPrio) |
| 1923 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1924 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1925 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1926 | |
| 1927 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 1928 | if omciErr.GetError() == nil { |
| 1929 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1930 | if err != nil { |
| 1931 | logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1932 | return nil |
| 1933 | } |
| 1934 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1935 | if err != nil { |
| 1936 | logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1937 | return nil |
| 1938 | } |
| 1939 | omciRxCallbackPair := callbackPair{ |
| 1940 | cbKey: tid, |
| 1941 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 1942 | } |
| 1943 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1944 | if err != nil { |
| 1945 | logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1946 | return nil |
| 1947 | } |
| 1948 | logger.Debug(ctx, "send TD-Set-msg done") |
| 1949 | return meInstance |
| 1950 | } |
| 1951 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1952 | return nil |
| 1953 | |
| 1954 | } |
| 1955 | |
| 1956 | // nolint: unused |
| 1957 | func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
| 1958 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1959 | tid := oo.getNextTid(highPrio) |
| 1960 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1961 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1962 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1963 | |
| 1964 | meParams := me.ParamData{EntityID: aInstID} |
| 1965 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 1966 | if omciErr.GetError() == nil { |
| 1967 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid)) |
| 1968 | if err != nil { |
| 1969 | logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1970 | return nil |
| 1971 | } |
| 1972 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1973 | if err != nil { |
| 1974 | logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1975 | return nil |
| 1976 | } |
| 1977 | omciRxCallbackPair := callbackPair{ |
| 1978 | cbKey: tid, |
| 1979 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 1980 | } |
| 1981 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1982 | if err != nil { |
| 1983 | logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1984 | return nil |
| 1985 | } |
| 1986 | logger.Debug(ctx, "send TD-Delete-msg done") |
| 1987 | return meInstance |
| 1988 | } |
| 1989 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1990 | return nil |
| 1991 | |
| 1992 | } |
| 1993 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1994 | func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
| 1995 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1996 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1997 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1998 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1999 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2000 | |
| 2001 | meParams := me.ParamData{EntityID: aInstID} |
| 2002 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2003 | if omciErr.GetError() == nil { |
| 2004 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2005 | omci.TransactionID(tid)) |
| 2006 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2007 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2008 | "Err": err, "device-id": oo.deviceID}) |
| 2009 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2010 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2011 | // (relevant to all used sendXX() methods and their error conditions) |
| 2012 | return nil |
| 2013 | } |
| 2014 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2015 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2016 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2017 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2018 | "Err": err, "device-id": oo.deviceID}) |
| 2019 | return nil |
| 2020 | } |
| 2021 | |
| 2022 | omciRxCallbackPair := callbackPair{ |
| 2023 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2024 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2025 | } |
| 2026 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2027 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2028 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2029 | "Err": err, "device-id": oo.deviceID}) |
| 2030 | return nil |
| 2031 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2032 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2033 | return meInstance |
| 2034 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2035 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2036 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2037 | return nil |
| 2038 | } |
| 2039 | |
| 2040 | func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
| 2041 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 2042 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2043 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2044 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2045 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2046 | |
| 2047 | meParams := me.ParamData{EntityID: aInstID} |
| 2048 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2049 | if omciErr.GetError() == nil { |
| 2050 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2051 | omci.TransactionID(tid)) |
| 2052 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2053 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2054 | "Err": err, "device-id": oo.deviceID}) |
| 2055 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2056 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2057 | // (relevant to all used sendXX() methods and their error conditions) |
| 2058 | return nil |
| 2059 | } |
| 2060 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2061 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2062 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2063 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2064 | "Err": err, "device-id": oo.deviceID}) |
| 2065 | return nil |
| 2066 | } |
| 2067 | |
| 2068 | omciRxCallbackPair := callbackPair{ |
| 2069 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2070 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2071 | } |
| 2072 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2073 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2074 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2075 | "Err": err, "device-id": oo.deviceID}) |
| 2076 | return nil |
| 2077 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2078 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2079 | return meInstance |
| 2080 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2081 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2082 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2083 | return nil |
| 2084 | } |
| 2085 | |
| 2086 | func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
| 2087 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 2088 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2089 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2090 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2091 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2092 | |
| 2093 | meParams := me.ParamData{EntityID: aInstID} |
| 2094 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2095 | if omciErr.GetError() == nil { |
| 2096 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2097 | omci.TransactionID(tid)) |
| 2098 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2099 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2100 | "Err": err, "device-id": oo.deviceID}) |
| 2101 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2102 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2103 | // (relevant to all used sendXX() methods and their error conditions) |
| 2104 | return nil |
| 2105 | } |
| 2106 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2107 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2108 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2109 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2110 | "Err": err, "device-id": oo.deviceID}) |
| 2111 | return nil |
| 2112 | } |
| 2113 | |
| 2114 | omciRxCallbackPair := callbackPair{ |
| 2115 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2116 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2117 | } |
| 2118 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2119 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2120 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2121 | "Err": err, "device-id": oo.deviceID}) |
| 2122 | return nil |
| 2123 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2124 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2125 | return meInstance |
| 2126 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2127 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2128 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2129 | return nil |
| 2130 | } |
| 2131 | |
| 2132 | func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 2133 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 2134 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2135 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2136 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2137 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2138 | |
| 2139 | meParams := me.ParamData{EntityID: aInstID} |
| 2140 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2141 | if omciErr.GetError() == nil { |
| 2142 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2143 | omci.TransactionID(tid)) |
| 2144 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2145 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2146 | "Err": err, "device-id": oo.deviceID}) |
| 2147 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2148 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2149 | // (relevant to all used sendXX() methods and their error conditions) |
| 2150 | return nil |
| 2151 | } |
| 2152 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2153 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2154 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2155 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2156 | "Err": err, "device-id": oo.deviceID}) |
| 2157 | return nil |
| 2158 | } |
| 2159 | |
| 2160 | omciRxCallbackPair := callbackPair{ |
| 2161 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2162 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2163 | } |
| 2164 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2165 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2166 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2167 | "Err": err, "device-id": oo.deviceID}) |
| 2168 | return nil |
| 2169 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2170 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2171 | return meInstance |
| 2172 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2173 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2174 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2175 | return nil |
| 2176 | } |
| 2177 | |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2178 | func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 2179 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2180 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2181 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2182 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2183 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2184 | |
| 2185 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2186 | if omciErr.GetError() == nil { |
| 2187 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2188 | omci.AddDefaults(true)) |
| 2189 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2190 | logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2191 | return nil |
| 2192 | } |
| 2193 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2194 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2195 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2196 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2197 | return nil |
| 2198 | } |
| 2199 | |
| 2200 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2201 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2202 | } |
| 2203 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2204 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2205 | logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2206 | return nil |
| 2207 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2208 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2209 | return meInstance |
| 2210 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2211 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2212 | "device-id": oo.deviceID}) |
| 2213 | return nil |
| 2214 | } |
| 2215 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2216 | func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 2217 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2218 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2219 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2220 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2221 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2222 | |
| 2223 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2224 | if omciErr.GetError() == nil { |
| 2225 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid), |
| 2226 | omci.AddDefaults(true)) |
| 2227 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2228 | logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2229 | return nil |
| 2230 | } |
| 2231 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2232 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2233 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2234 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2235 | return nil |
| 2236 | } |
| 2237 | |
| 2238 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2239 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2240 | } |
| 2241 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2242 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2243 | logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2244 | return nil |
| 2245 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2246 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2247 | return meInstance |
| 2248 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2249 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2250 | "device-id": oo.deviceID}) |
| 2251 | return nil |
| 2252 | } |
| 2253 | |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2254 | func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 2255 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2256 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2257 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2258 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2259 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2260 | |
| 2261 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2262 | if omciErr.GetError() == nil { |
| 2263 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2264 | omci.AddDefaults(true)) |
| 2265 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2266 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2267 | "device-id": oo.deviceID}) |
| 2268 | return nil |
| 2269 | } |
| 2270 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2271 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2272 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2273 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2274 | "device-id": oo.deviceID}) |
| 2275 | return nil |
| 2276 | } |
| 2277 | |
| 2278 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2279 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2280 | } |
| 2281 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2282 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2283 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2284 | "device-id": oo.deviceID}) |
| 2285 | return nil |
| 2286 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2287 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2288 | return meInstance |
| 2289 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2290 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2291 | "device-id": oo.deviceID}) |
| 2292 | return nil |
| 2293 | } |
| 2294 | |
| 2295 | func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 2296 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2297 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2298 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2299 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2300 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2301 | |
| 2302 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2303 | if omciErr.GetError() == nil { |
| 2304 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid), |
| 2305 | omci.AddDefaults(true)) |
| 2306 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2307 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2308 | "device-id": oo.deviceID}) |
| 2309 | return nil |
| 2310 | } |
| 2311 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2312 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2313 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2314 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2315 | "device-id": oo.deviceID}) |
| 2316 | return nil |
| 2317 | } |
| 2318 | |
| 2319 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2320 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2321 | } |
| 2322 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2323 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2324 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2325 | "device-id": oo.deviceID}) |
| 2326 | return nil |
| 2327 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2328 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2329 | return meInstance |
| 2330 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2331 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2332 | "device-id": oo.deviceID}) |
| 2333 | return nil |
| 2334 | } |
| 2335 | |
| 2336 | func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
| 2337 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2338 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2339 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2340 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2341 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2342 | |
| 2343 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2344 | if omciErr.GetError() == nil { |
| 2345 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2346 | omci.AddDefaults(true)) |
| 2347 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2348 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2349 | "device-id": oo.deviceID}) |
| 2350 | return nil |
| 2351 | } |
| 2352 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2353 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2354 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2355 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2356 | "device-id": oo.deviceID}) |
| 2357 | return nil |
| 2358 | } |
| 2359 | |
| 2360 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2361 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2362 | } |
| 2363 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2364 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2365 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2366 | "device-id": oo.deviceID}) |
| 2367 | return nil |
| 2368 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2369 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2370 | return meInstance |
| 2371 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2372 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2373 | "device-id": oo.deviceID}) |
| 2374 | return nil |
| 2375 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2376 | |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2377 | func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 2378 | tid := oo.getNextTid(highPrio) |
| 2379 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 2380 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 2381 | |
| 2382 | omciLayer := &omci.OMCI{ |
| 2383 | TransactionID: tid, |
| 2384 | MessageType: omci.SynchronizeTimeRequestType, |
| 2385 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2386 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2387 | } |
| 2388 | utcTime := time.Now().UTC() |
| 2389 | request := &omci.SynchronizeTimeRequest{ |
| 2390 | MeBasePacket: omci.MeBasePacket{ |
| 2391 | EntityClass: me.OnuGClassID, |
| 2392 | // Default Instance ID is 0 |
| 2393 | }, |
| 2394 | Year: uint16(utcTime.Year()), |
| 2395 | Month: uint8(utcTime.Month()), |
| 2396 | Day: uint8(utcTime.Day()), |
| 2397 | Hour: uint8(utcTime.Hour()), |
| 2398 | Minute: uint8(utcTime.Minute()), |
| 2399 | Second: uint8(utcTime.Second()), |
| 2400 | } |
| 2401 | |
| 2402 | pkt, err := serializeOmciLayer(ctx, omciLayer, request) |
| 2403 | if err != nil { |
| 2404 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 2405 | "device-id": oo.deviceID}) |
| 2406 | return err |
| 2407 | } |
| 2408 | |
| 2409 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2410 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2411 | } |
| 2412 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2413 | if err != nil { |
| 2414 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 2415 | "device-id": oo.deviceID}) |
| 2416 | return err |
| 2417 | } |
| 2418 | logger.Debug(ctx, "send synchronize time request done") |
| 2419 | return nil |
| 2420 | } |
| 2421 | |
| 2422 | func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2423 | upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2424 | tid := oo.getNextTid(highPrio) |
| 2425 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2426 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 2427 | meParam := me.ParamData{EntityID: entityID} |
| 2428 | var meInstance *me.ManagedEntity |
| 2429 | var omciErr me.OmciErrors |
| 2430 | if upstream { |
| 2431 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 2432 | } else { |
| 2433 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 2434 | } |
| 2435 | if omciErr.GetError() == nil { |
| 2436 | var omciLayer *omci.OMCI |
| 2437 | var msgLayer gopacket.SerializableLayer |
| 2438 | var err error |
| 2439 | if create { |
| 2440 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2441 | omci.AddDefaults(true)) |
| 2442 | } else { |
| 2443 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2444 | omci.AddDefaults(true)) |
| 2445 | } |
| 2446 | if err != nil { |
| 2447 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 2448 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2449 | return nil |
| 2450 | } |
| 2451 | |
| 2452 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2453 | if err != nil { |
| 2454 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 2455 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2456 | return nil |
| 2457 | } |
| 2458 | |
| 2459 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2460 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2461 | } |
| 2462 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2463 | if err != nil { |
| 2464 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 2465 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2466 | return nil |
| 2467 | } |
| 2468 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 2469 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2470 | return meInstance |
| 2471 | } |
| 2472 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 2473 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2474 | return nil |
| 2475 | } |
| 2476 | |
| 2477 | func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2478 | create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2479 | tid := oo.getNextTid(highPrio) |
| 2480 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2481 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 2482 | meParam := me.ParamData{EntityID: entityID} |
| 2483 | var meInstance *me.ManagedEntity |
| 2484 | var omciErr me.OmciErrors |
| 2485 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 2486 | |
| 2487 | if omciErr.GetError() == nil { |
| 2488 | var omciLayer *omci.OMCI |
| 2489 | var msgLayer gopacket.SerializableLayer |
| 2490 | var err error |
| 2491 | if create { |
| 2492 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2493 | omci.AddDefaults(true)) |
| 2494 | } else { |
| 2495 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2496 | omci.AddDefaults(true)) |
| 2497 | } |
| 2498 | if err != nil { |
| 2499 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 2500 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2501 | return nil |
| 2502 | } |
| 2503 | |
| 2504 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2505 | if err != nil { |
| 2506 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 2507 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2508 | return nil |
| 2509 | } |
| 2510 | |
| 2511 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2512 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2513 | } |
| 2514 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2515 | if err != nil { |
| 2516 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 2517 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2518 | return nil |
| 2519 | } |
| 2520 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 2521 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2522 | return meInstance |
| 2523 | } |
| 2524 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 2525 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2526 | return nil |
| 2527 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 2528 | |
| 2529 | func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2530 | create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2531 | tid := oo.getNextTid(highPrio) |
| 2532 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2533 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 2534 | meParam := me.ParamData{EntityID: entityID} |
| 2535 | var meInstance *me.ManagedEntity |
| 2536 | var omciErr me.OmciErrors |
| 2537 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 2538 | |
| 2539 | if omciErr.GetError() == nil { |
| 2540 | var omciLayer *omci.OMCI |
| 2541 | var msgLayer gopacket.SerializableLayer |
| 2542 | var err error |
| 2543 | if create { |
| 2544 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2545 | omci.AddDefaults(true)) |
| 2546 | } else { |
| 2547 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2548 | omci.AddDefaults(true)) |
| 2549 | } |
| 2550 | if err != nil { |
| 2551 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 2552 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2553 | return nil |
| 2554 | } |
| 2555 | |
| 2556 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2557 | if err != nil { |
| 2558 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 2559 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2560 | return nil |
| 2561 | } |
| 2562 | |
| 2563 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2564 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 2565 | } |
| 2566 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2567 | if err != nil { |
| 2568 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 2569 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2570 | return nil |
| 2571 | } |
| 2572 | logger.Debugw(ctx, "send fec history data ME done", |
| 2573 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2574 | return meInstance |
| 2575 | } |
| 2576 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 2577 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2578 | return nil |
| 2579 | } |
| 2580 | |
| 2581 | func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2582 | create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2583 | tid := oo.getNextTid(highPrio) |
| 2584 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2585 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 2586 | meParam := me.ParamData{EntityID: entityID} |
| 2587 | var meInstance *me.ManagedEntity |
| 2588 | var omciErr me.OmciErrors |
| 2589 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 2590 | |
| 2591 | if omciErr.GetError() == nil { |
| 2592 | var omciLayer *omci.OMCI |
| 2593 | var msgLayer gopacket.SerializableLayer |
| 2594 | var err error |
| 2595 | if create { |
| 2596 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2597 | omci.AddDefaults(true)) |
| 2598 | } else { |
| 2599 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2600 | omci.AddDefaults(true)) |
| 2601 | } |
| 2602 | if err != nil { |
| 2603 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 2604 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2605 | return nil |
| 2606 | } |
| 2607 | |
| 2608 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2609 | if err != nil { |
| 2610 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 2611 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2612 | return nil |
| 2613 | } |
| 2614 | |
| 2615 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2616 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 2617 | } |
| 2618 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2619 | if err != nil { |
| 2620 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 2621 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2622 | return nil |
| 2623 | } |
| 2624 | logger.Debugw(ctx, "send gemport history data ME done", |
| 2625 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2626 | return meInstance |
| 2627 | } |
| 2628 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 2629 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2630 | return nil |
| 2631 | } |
| 2632 | |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2633 | func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
| 2634 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error { |
| 2635 | tid := oo.getNextTid(highPrio) |
| 2636 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 2637 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2638 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2639 | |
| 2640 | omciLayer := &omci.OMCI{ |
| 2641 | TransactionID: tid, |
| 2642 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 2643 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2644 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2645 | } |
| 2646 | request := &omci.StartSoftwareDownloadRequest{ |
| 2647 | MeBasePacket: omci.MeBasePacket{ |
| 2648 | EntityClass: me.SoftwareImageClassID, |
| 2649 | EntityInstance: aImageMeID, //inactive image |
| 2650 | }, |
| 2651 | WindowSize: aDownloadWindowSize, |
| 2652 | ImageSize: aFileLen, |
| 2653 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 2654 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 2655 | } |
| 2656 | |
| 2657 | var options gopacket.SerializeOptions |
| 2658 | options.FixLengths = true |
| 2659 | buffer := gopacket.NewSerializeBuffer() |
| 2660 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2661 | if err != nil { |
| 2662 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 2663 | "device-id": oo.deviceID}) |
| 2664 | return err |
| 2665 | } |
| 2666 | outgoingPacket := buffer.Bytes() |
| 2667 | |
| 2668 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2669 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2670 | } |
| 2671 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2672 | if err != nil { |
| 2673 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 2674 | "device-id": oo.deviceID}) |
| 2675 | return err |
| 2676 | } |
| 2677 | logger.Debug(ctx, "send StartSwDlRequest done") |
| 2678 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 2679 | if cbSwUpgradeRespSim == true { |
| 2680 | go func() { |
| 2681 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start ***** |
| 2682 | time.Sleep(time.Millisecond * 50) //give some response time |
| 2683 | respOmciLayer := &omci.OMCI{ |
| 2684 | TransactionID: tid, |
| 2685 | MessageType: omci.StartSoftwareDownloadResponseType, |
| 2686 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2687 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2688 | } |
| 2689 | response := &omci.StartSoftwareDownloadResponse{ |
| 2690 | MeBasePacket: omci.MeBasePacket{ |
| 2691 | EntityClass: me.SoftwareImageClassID, |
| 2692 | EntityInstance: aImageMeID, //inactive image |
| 2693 | }, |
| 2694 | Result: 0, |
| 2695 | WindowSize: aDownloadWindowSize, |
| 2696 | NumberOfInstances: 0, //seems at the moment I can only generate 0 instances, using 1 here panics as MeResult can not be set below |
| 2697 | //MeResults: cannot set here: downloadResults type not exported from omci-lib! |
| 2698 | } |
| 2699 | var respOptions gopacket.SerializeOptions |
| 2700 | respOptions.FixLengths = true |
| 2701 | respBuffer := gopacket.NewSerializeBuffer() |
| 2702 | respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response) |
| 2703 | if respErr != nil { |
| 2704 | logger.Errorw(ctx, "Cannot serialize StartSwDlResponse", log.Fields{"Err": respErr, |
| 2705 | "device-id": oo.deviceID}) |
| 2706 | return |
| 2707 | } |
| 2708 | respPacket := respBuffer.Bytes() |
| 2709 | logger.Debugw(ctx, "simulate StartSwDlResponse", log.Fields{"device-id": oo.deviceID, |
| 2710 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2711 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), |
| 2712 | "windowSize": aDownloadWindowSize}) |
| 2713 | go func(oo *omciCC) { |
| 2714 | _ = oo.receiveMessage(ctx, respPacket) |
| 2715 | }(oo) |
| 2716 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop ***** |
| 2717 | }() |
| 2718 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2719 | return nil |
| 2720 | } |
| 2721 | |
| 2722 | func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool, |
| 2723 | rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error { |
| 2724 | tid := oo.getNextTid(highPrio) |
| 2725 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 2726 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2727 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2728 | |
| 2729 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 2730 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2731 | msgType := omci.DownloadSectionRequestType |
| 2732 | if aAckRequest > 0 { |
| 2733 | msgType = omci.DownloadSectionRequestWithResponseType |
| 2734 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2735 | omciLayer := &omci.OMCI{ |
| 2736 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2737 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2738 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2739 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2740 | } |
Girish Gowdra | 8a7b456 | 2021-02-23 16:27:42 -0800 | [diff] [blame] | 2741 | var localSectionData [31]byte |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2742 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2743 | request := &omci.DownloadSectionRequest{ |
| 2744 | MeBasePacket: omci.MeBasePacket{ |
| 2745 | EntityClass: me.SoftwareImageClassID, |
| 2746 | EntityInstance: aImageMeID, //inactive image |
| 2747 | }, |
| 2748 | SectionNumber: aDownloadSectionNo, |
| 2749 | SectionData: localSectionData, |
| 2750 | } |
| 2751 | |
| 2752 | var options gopacket.SerializeOptions |
| 2753 | options.FixLengths = true |
| 2754 | buffer := gopacket.NewSerializeBuffer() |
| 2755 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2756 | if err != nil { |
| 2757 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 2758 | "device-id": oo.deviceID}) |
| 2759 | return err |
| 2760 | } |
| 2761 | outgoingPacket := buffer.Bytes() |
| 2762 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2763 | //for initial debug purpose overrule the requested print state for some frames |
| 2764 | printFrame := aPrint |
| 2765 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 2766 | printFrame = true |
| 2767 | } |
| 2768 | |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2769 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2770 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2771 | } |
| 2772 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2773 | if err != nil { |
| 2774 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 2775 | "device-id": oo.deviceID}) |
| 2776 | return err |
| 2777 | } |
| 2778 | logger.Debug(ctx, "send DlSectionRequest done") |
| 2779 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 2780 | if cbSwUpgradeRespSim == true { |
| 2781 | go func() { |
| 2782 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start ***** |
| 2783 | if aAckRequest > 0 { |
| 2784 | time.Sleep(time.Millisecond * 50) //give some response time |
| 2785 | respOmciLayer := &omci.OMCI{ |
| 2786 | TransactionID: tid, |
| 2787 | MessageType: omci.DownloadSectionResponseType, |
| 2788 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2789 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2790 | } |
| 2791 | response := &omci.DownloadSectionResponse{ |
| 2792 | MeBasePacket: omci.MeBasePacket{ |
| 2793 | EntityClass: me.SoftwareImageClassID, |
| 2794 | EntityInstance: aImageMeID, //inactive image |
| 2795 | }, |
| 2796 | Result: 0, |
| 2797 | SectionNumber: aDownloadSectionNo, |
| 2798 | } |
| 2799 | var respOptions gopacket.SerializeOptions |
| 2800 | respOptions.FixLengths = true |
| 2801 | respBuffer := gopacket.NewSerializeBuffer() |
| 2802 | respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response) |
| 2803 | if respErr != nil { |
| 2804 | logger.Errorw(ctx, "Cannot serialize DlSectionResponse", log.Fields{"Err": respErr, |
| 2805 | "device-id": oo.deviceID}) |
| 2806 | return |
| 2807 | } |
| 2808 | respPacket := respBuffer.Bytes() |
| 2809 | if aPrint { |
| 2810 | logger.Debugw(ctx, "simulate DlSectionResponse", log.Fields{"device-id": oo.deviceID, |
| 2811 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2812 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), |
| 2813 | "packet": hex.EncodeToString(respPacket)}) |
| 2814 | } else { |
| 2815 | logger.Debugw(ctx, "simulate DlSectionResponse", log.Fields{"device-id": oo.deviceID, |
| 2816 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2817 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2818 | } |
| 2819 | go func(oo *omciCC) { |
| 2820 | _ = oo.receiveMessage(ctx, respPacket) |
| 2821 | }(oo) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2822 | } |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 2823 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop ***** |
| 2824 | }() |
| 2825 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2826 | return nil |
| 2827 | } |
| 2828 | |
| 2829 | func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
| 2830 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error { |
| 2831 | tid := oo.getNextTid(highPrio) |
| 2832 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 2833 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2834 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2835 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2836 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2837 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2838 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2839 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2840 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2841 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2842 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2843 | MeBasePacket: omci.MeBasePacket{ |
| 2844 | EntityClass: me.SoftwareImageClassID, |
| 2845 | EntityInstance: aImageMeID, //inactive image |
| 2846 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2847 | CRC32: aImageCrc, |
| 2848 | ImageSize: aFileLen, |
| 2849 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 2850 | ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2851 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2852 | |
| 2853 | var options gopacket.SerializeOptions |
| 2854 | options.FixLengths = true |
| 2855 | buffer := gopacket.NewSerializeBuffer() |
| 2856 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2857 | if err != nil { |
| 2858 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2859 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2860 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2861 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2862 | outgoingPacket := buffer.Bytes() |
| 2863 | |
| 2864 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2865 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2866 | } |
| 2867 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2868 | if err != nil { |
| 2869 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 2870 | "device-id": oo.deviceID}) |
| 2871 | return err |
| 2872 | } |
| 2873 | logger.Debug(ctx, "send EndSwDlRequest done") |
| 2874 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 2875 | if cbSwUpgradeRespSim == true { |
| 2876 | go func() { |
| 2877 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start ***** |
| 2878 | time.Sleep(time.Millisecond * 50) //give some response time |
| 2879 | respOmciLayer := &omci.OMCI{ |
| 2880 | TransactionID: tid, |
| 2881 | MessageType: omci.EndSoftwareDownloadResponseType, |
| 2882 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2883 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2884 | } |
| 2885 | response := &omci.EndSoftwareDownloadResponse{ |
| 2886 | MeBasePacket: omci.MeBasePacket{ |
| 2887 | EntityClass: me.SoftwareImageClassID, |
| 2888 | EntityInstance: aImageMeID, //inactive image |
| 2889 | }, |
| 2890 | Result: 0, //simulate done, option would be busy |
| 2891 | NumberOfInstances: 0, //basic ONU-G instance |
| 2892 | } |
| 2893 | var respOptions gopacket.SerializeOptions |
| 2894 | respOptions.FixLengths = true |
| 2895 | respBuffer := gopacket.NewSerializeBuffer() |
| 2896 | respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response) |
| 2897 | if respErr != nil { |
| 2898 | logger.Errorw(ctx, "Cannot serialize EndSwDlResponse", log.Fields{"Err": respErr, |
| 2899 | "device-id": oo.deviceID}) |
| 2900 | return |
| 2901 | } |
| 2902 | respPacket := respBuffer.Bytes() |
| 2903 | logger.Debugw(ctx, "simulate EndSwDlResponse", log.Fields{"device-id": oo.deviceID, |
| 2904 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2905 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), |
| 2906 | "result": 0}) |
| 2907 | go func(oo *omciCC) { |
| 2908 | _ = oo.receiveMessage(ctx, respPacket) |
| 2909 | }(oo) |
| 2910 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop ***** |
| 2911 | }() |
| 2912 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2913 | return nil |
| 2914 | } |
| 2915 | |
| 2916 | func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
| 2917 | rxChan chan Message, aImageMeID uint16) error { |
| 2918 | tid := oo.getNextTid(highPrio) |
| 2919 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 2920 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2921 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2922 | |
| 2923 | omciLayer := &omci.OMCI{ |
| 2924 | TransactionID: tid, |
| 2925 | MessageType: omci.ActivateSoftwareRequestType, |
| 2926 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2927 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2928 | } |
| 2929 | request := &omci.ActivateSoftwareRequest{ |
| 2930 | MeBasePacket: omci.MeBasePacket{ |
| 2931 | EntityClass: me.SoftwareImageClassID, |
| 2932 | EntityInstance: aImageMeID, //inactive image |
| 2933 | }, |
| 2934 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 2935 | } |
| 2936 | |
| 2937 | var options gopacket.SerializeOptions |
| 2938 | options.FixLengths = true |
| 2939 | buffer := gopacket.NewSerializeBuffer() |
| 2940 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2941 | if err != nil { |
| 2942 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 2943 | "device-id": oo.deviceID}) |
| 2944 | return err |
| 2945 | } |
| 2946 | outgoingPacket := buffer.Bytes() |
| 2947 | |
| 2948 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2949 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2950 | } |
| 2951 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2952 | if err != nil { |
| 2953 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 2954 | "device-id": oo.deviceID}) |
| 2955 | return err |
| 2956 | } |
| 2957 | logger.Debug(ctx, "send ActivateSwRequest done") |
| 2958 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 2959 | if cbSwUpgradeRespSim == true { |
| 2960 | go func() { |
| 2961 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start ***** |
| 2962 | time.Sleep(time.Millisecond * 50) //give some response time |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2963 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 2964 | respOmciLayer := &omci.OMCI{ |
| 2965 | TransactionID: tid, |
| 2966 | MessageType: omci.ActivateSoftwareResponseType, |
| 2967 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2968 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2969 | } |
| 2970 | response := &omci.ActivateSoftwareResponse{ |
| 2971 | MeBasePacket: omci.MeBasePacket{ |
| 2972 | EntityClass: me.SoftwareImageClassID, |
| 2973 | EntityInstance: aImageMeID, //inactive image |
| 2974 | }, |
| 2975 | Result: 0, //simulate done, option would be busy |
| 2976 | } |
| 2977 | var respOptions gopacket.SerializeOptions |
| 2978 | respOptions.FixLengths = true |
| 2979 | respBuffer := gopacket.NewSerializeBuffer() |
| 2980 | respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response) |
| 2981 | if respErr != nil { |
| 2982 | logger.Errorw(ctx, "Cannot serialize ActivateSwResponse", log.Fields{"Err": respErr, |
| 2983 | "device-id": oo.deviceID}) |
| 2984 | return |
| 2985 | } |
| 2986 | respPacket := respBuffer.Bytes() |
| 2987 | logger.Debugw(ctx, "simulate ActivateSwResponse", log.Fields{"device-id": oo.deviceID, |
| 2988 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2989 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), |
| 2990 | "result": 0}) |
| 2991 | go func(oo *omciCC) { |
| 2992 | _ = oo.receiveMessage(ctx, respPacket) |
| 2993 | }(oo) |
| 2994 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop ***** |
| 2995 | }() |
| 2996 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2997 | return nil |
| 2998 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2999 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 3000 | func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
| 3001 | rxChan chan Message, aImageMeID uint16) error { |
| 3002 | tid := oo.getNextTid(highPrio) |
| 3003 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 3004 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3005 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 3006 | |
| 3007 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3008 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 3009 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3010 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 3011 | // Length: 0x28, // Optional, defaults to 40 octets |
| 3012 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 3013 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3014 | MeBasePacket: omci.MeBasePacket{ |
| 3015 | EntityClass: me.SoftwareImageClassID, |
| 3016 | EntityInstance: aImageMeID, //inactive image |
| 3017 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3018 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 3019 | |
| 3020 | var options gopacket.SerializeOptions |
| 3021 | options.FixLengths = true |
| 3022 | buffer := gopacket.NewSerializeBuffer() |
| 3023 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 3024 | if err != nil { |
| 3025 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3026 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 3027 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3028 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 3029 | outgoingPacket := buffer.Bytes() |
| 3030 | |
| 3031 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 3032 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3033 | } |
| 3034 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 3035 | if err != nil { |
| 3036 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 3037 | "device-id": oo.deviceID}) |
| 3038 | return err |
| 3039 | } |
| 3040 | logger.Debug(ctx, "send CommitSwRequest done") |
| 3041 | |
mpagenko | 02cf1b2 | 2021-03-12 17:30:30 +0000 | [diff] [blame] | 3042 | if cbSwUpgradeRespSim == true { |
| 3043 | go func() { |
| 3044 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start ***** |
| 3045 | time.Sleep(time.Millisecond * 50) //give some response time |
| 3046 | respOmciLayer := &omci.OMCI{ |
| 3047 | TransactionID: tid, |
| 3048 | MessageType: omci.CommitSoftwareResponseType, |
| 3049 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 3050 | // Length: 0x28, // Optional, defaults to 40 octets |
| 3051 | } |
| 3052 | response := &omci.CommitSoftwareResponse{ |
| 3053 | MeBasePacket: omci.MeBasePacket{ |
| 3054 | EntityClass: me.SoftwareImageClassID, |
| 3055 | EntityInstance: aImageMeID, //inactive image |
| 3056 | }, |
| 3057 | //TODO: Not yet supported by omci-lib Result: 0, //simulate done |
| 3058 | } |
| 3059 | var respOptions gopacket.SerializeOptions |
| 3060 | respOptions.FixLengths = true |
| 3061 | respBuffer := gopacket.NewSerializeBuffer() |
| 3062 | respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response) |
| 3063 | if respErr != nil { |
| 3064 | logger.Errorw(ctx, "Cannot serialize CommitSwResponse", log.Fields{"Err": respErr, |
| 3065 | "device-id": oo.deviceID}) |
| 3066 | return |
| 3067 | } |
| 3068 | respPacket := respBuffer.Bytes() |
| 3069 | logger.Debugw(ctx, "simulate CommitSwResponse", log.Fields{"device-id": oo.deviceID, |
| 3070 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3071 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), |
| 3072 | "result": 0}) |
| 3073 | go func(oo *omciCC) { |
| 3074 | _ = oo.receiveMessage(ctx, respPacket) |
| 3075 | }(oo) |
| 3076 | //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop ***** |
| 3077 | }() |
| 3078 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 3079 | return nil |
| 3080 | } |
| 3081 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 3082 | func isResponseWithMibDataSync(msgType omci.MessageType) bool { |
| 3083 | for _, v := range responsesWithMibDataSync { |
| 3084 | if v == msgType { |
| 3085 | return true |
| 3086 | } |
| 3087 | } |
| 3088 | return false |
| 3089 | } |