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