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