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 | */ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 564 | if omciTxRequest.withFramePrint { |
| 565 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 566 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 567 | "device-id": oo.deviceID, |
| 568 | "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType, |
| 569 | "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID}) |
| 570 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 571 | omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame} |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 572 | if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 573 | ic.InterAdapterMessageType_OMCI_REQUEST, |
Matteo Scandolo | efbec27 | 2020-11-17 10:33:09 -0800 | [diff] [blame] | 574 | //fromTopic,toType,toDevId, ProxyDevId |
| 575 | oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 576 | oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 577 | 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] | 578 | return sendErr |
| 579 | } |
| 580 | oo.txQueue.Remove(queueElement) // Dequeue |
| 581 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 582 | return nil |
| 583 | } |
| 584 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 585 | func (oo *omciCC) getNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 586 | var next uint16 |
| 587 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 588 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 589 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 590 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 591 | if oo.hpTid < 0x8000 { |
| 592 | oo.hpTid = 0x8000 |
| 593 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 594 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 595 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 596 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 597 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 598 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 599 | if oo.tid >= 0x8000 { |
| 600 | oo.tid = 1 |
| 601 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 602 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 603 | } |
| 604 | return next |
| 605 | } |
| 606 | |
| 607 | // ################################################################################### |
| 608 | // # utility methods provided to work on OMCI messages |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 609 | 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] | 610 | omciLayer := &omci.OMCI{ |
| 611 | TransactionID: tid, |
| 612 | MessageType: msgType, |
| 613 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 614 | return serializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 615 | } |
| 616 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 617 | 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] | 618 | var options gopacket.SerializeOptions |
| 619 | options.FixLengths = true |
| 620 | |
| 621 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 622 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 623 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 624 | 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] | 625 | return nil, err |
| 626 | } |
| 627 | return buffer.Bytes(), nil |
| 628 | } |
| 629 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 630 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 631 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 632 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 633 | hex.Encode(dst, omciPkt) |
| 634 | return dst, nil |
| 635 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 636 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 637 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 638 | //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] | 639 | 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] | 640 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 641 | 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] | 642 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 643 | |
| 644 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 645 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 646 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 647 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 651 | // 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] | 652 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 653 | Type: OMCI, |
| 654 | Data: OmciMessage{ |
| 655 | OmciMsg: omciMsg, |
| 656 | OmciPacket: packet, |
| 657 | }, |
| 658 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 659 | //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] | 660 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 661 | |
| 662 | return nil |
| 663 | } |
| 664 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 665 | func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 666 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 667 | 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] | 668 | request := &omci.MibResetRequest{ |
| 669 | MeBasePacket: omci.MeBasePacket{ |
| 670 | EntityClass: me.OnuDataClassID, |
| 671 | }, |
| 672 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 673 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 674 | pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 675 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 676 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 677 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 678 | return err |
| 679 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 680 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 681 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 682 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 683 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 684 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 685 | } |
| 686 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 687 | 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] | 688 | logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 689 | request := &omci.RebootRequest{ |
| 690 | MeBasePacket: omci.MeBasePacket{ |
| 691 | EntityClass: me.OnuGClassID, |
| 692 | }, |
| 693 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 694 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 695 | pkt, err := serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 696 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 697 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 698 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 699 | return err |
| 700 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 701 | omciRxCallbackPair := callbackPair{ |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 702 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 703 | cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 704 | } |
| 705 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 706 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 707 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 708 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 709 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 710 | return err |
| 711 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 712 | err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 713 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 714 | logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 715 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 716 | return err |
| 717 | } |
| 718 | return nil |
| 719 | } |
| 720 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 721 | func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 722 | 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] | 723 | request := &omci.MibUploadRequest{ |
| 724 | MeBasePacket: omci.MeBasePacket{ |
| 725 | EntityClass: me.OnuDataClassID, |
| 726 | }, |
| 727 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 728 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 729 | pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 730 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 731 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 732 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 733 | return err |
| 734 | } |
| 735 | oo.uploadSequNo = 0 |
| 736 | oo.uploadNoOfCmds = 0 |
| 737 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 738 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 739 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 740 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 741 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 742 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 743 | } |
| 744 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 745 | func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 746 | 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] | 747 | request := &omci.MibUploadNextRequest{ |
| 748 | MeBasePacket: omci.MeBasePacket{ |
| 749 | EntityClass: me.OnuDataClassID, |
| 750 | }, |
| 751 | CommandSequenceNumber: oo.uploadSequNo, |
| 752 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 753 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 754 | pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 755 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 756 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 757 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 758 | return err |
| 759 | } |
| 760 | oo.uploadSequNo++ |
| 761 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 762 | omciRxCallbackPair := callbackPair{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 763 | cbKey: tid, |
| 764 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 765 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 766 | // compare also software upgrade download section handling |
| 767 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, false}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 768 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 769 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 770 | } |
| 771 | |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 772 | func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error { |
| 773 | logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID}) |
| 774 | request := &omci.GetAllAlarmsRequest{ |
| 775 | MeBasePacket: omci.MeBasePacket{ |
| 776 | EntityClass: me.OnuDataClassID, |
| 777 | }, |
| 778 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 779 | } |
| 780 | tid := oo.getNextTid(highPrio) |
| 781 | pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid) |
| 782 | if err != nil { |
| 783 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{ |
| 784 | "Err": err, "device-id": oo.deviceID}) |
| 785 | return err |
| 786 | } |
| 787 | oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo = 0 |
| 788 | oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadNoOfCmds = 0 |
| 789 | |
| 790 | omciRxCallbackPair := callbackPair{ |
| 791 | cbKey: tid, |
| 792 | cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, |
| 793 | oo.receiveOmciResponse, true}, |
| 794 | } |
| 795 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 796 | } |
| 797 | |
| 798 | func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error { |
| 799 | alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo |
| 800 | logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID, |
| 801 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
| 802 | request := &omci.GetAllAlarmsNextRequest{ |
| 803 | MeBasePacket: omci.MeBasePacket{ |
| 804 | EntityClass: me.OnuDataClassID, |
| 805 | }, |
| 806 | CommandSequenceNumber: alarmUploadSeqNo, |
| 807 | } |
| 808 | tid := oo.getNextTid(highPrio) |
| 809 | pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid) |
| 810 | if err != nil { |
| 811 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{ |
| 812 | "Err": err, "device-id": oo.deviceID}) |
| 813 | return err |
| 814 | } |
| 815 | oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo++ |
| 816 | |
| 817 | omciRxCallbackPair := callbackPair{ |
| 818 | cbKey: tid, |
| 819 | cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true}, |
| 820 | } |
| 821 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 822 | } |
| 823 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 824 | func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 825 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 826 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 827 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 828 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 829 | meParams := me.ParamData{ |
| 830 | EntityID: galEthernetEID, |
| 831 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 832 | } |
| 833 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 834 | if omciErr.GetError() == nil { |
| 835 | //all setByCreate parameters already set, no default option required ... |
| 836 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 837 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 838 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 839 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 840 | return nil |
| 841 | } |
| 842 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 843 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 844 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 845 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 846 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 847 | return nil |
| 848 | } |
| 849 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 850 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 851 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 852 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 853 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 854 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 855 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 856 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 857 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 858 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 859 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 860 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 861 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 862 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 863 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 864 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 865 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 866 | } |
| 867 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 868 | // 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] | 869 | func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 870 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 871 | 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] | 872 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 873 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 874 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 875 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 876 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 877 | // read ONU-2G from DB ???? //TODO!!! |
| 878 | meParams := me.ParamData{ |
| 879 | EntityID: 0, |
| 880 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 881 | } |
| 882 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 883 | if omciErr.GetError() == nil { |
| 884 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 885 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 886 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 887 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 888 | return nil |
| 889 | } |
| 890 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 891 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 892 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 893 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 894 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 895 | return nil |
| 896 | } |
| 897 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 898 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 899 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 900 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 901 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 902 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 903 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 904 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 905 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 906 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 907 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 908 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 909 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 910 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 911 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 912 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 913 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 914 | } |
| 915 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 916 | func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context, |
| 917 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 918 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 919 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 920 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 921 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 922 | |
| 923 | meParams := me.ParamData{ |
| 924 | EntityID: instID, |
| 925 | Attributes: me.AttributeValueMap{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 926 | "Priority": 0x8000, |
| 927 | "MaxAge": 20 * 256, //20s |
| 928 | "HelloTime": 2 * 256, //2s |
| 929 | "ForwardDelay": 15 * 256, //15s |
| 930 | "DynamicFilteringAgeingTime": 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 931 | }, |
| 932 | } |
| 933 | |
| 934 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 935 | if omciErr.GetError() == nil { |
| 936 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 937 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 938 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 939 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 940 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 941 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 942 | return nil |
| 943 | } |
| 944 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 945 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 946 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 947 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 948 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 949 | return nil |
| 950 | } |
| 951 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 952 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 953 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 954 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 955 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 956 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 957 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 958 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 959 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 960 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 961 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 962 | logger.Debug(ctx, "send MBSP-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 963 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 964 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 965 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 966 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 967 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 968 | } |
| 969 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 970 | func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context, |
| 971 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 972 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 973 | instID := macBridgePortAniEID + aPUniPort.entityID |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 974 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 975 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 976 | |
| 977 | meParams := me.ParamData{ |
| 978 | EntityID: instID, |
| 979 | Attributes: me.AttributeValueMap{ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 980 | "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo), |
| 981 | "PortNum": aPUniPort.macBpNo, |
| 982 | "TpType": uint8(aPUniPort.portType), |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 983 | "TpPointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 984 | }, |
| 985 | } |
| 986 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 987 | if omciErr.GetError() == nil { |
| 988 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 989 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 990 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 991 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 992 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 993 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 994 | return nil |
| 995 | } |
| 996 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 997 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 998 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 999 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1000 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1001 | return nil |
| 1002 | } |
| 1003 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1004 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1005 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1006 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1007 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1008 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1009 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1010 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1011 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1012 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1013 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1014 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1015 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1016 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1017 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1018 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1019 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1022 | func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context, |
| 1023 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 1024 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1025 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1026 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1027 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1028 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1029 | |
| 1030 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1031 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1032 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1033 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1034 | if aPUniPort.portType == uniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1035 | assType = uint8(10) // for VEIP |
| 1036 | } |
| 1037 | meParams := me.ParamData{ |
| 1038 | EntityID: instID, |
| 1039 | Attributes: me.AttributeValueMap{ |
| 1040 | "AssociationType": assType, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1041 | "AssociatedMePointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1042 | }, |
| 1043 | } |
| 1044 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1045 | if omciErr.GetError() == nil { |
| 1046 | //all setByCreate parameters already set, no default option required ... |
| 1047 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 1048 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1049 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1050 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1051 | return nil |
| 1052 | } |
| 1053 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1054 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1055 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1056 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1057 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1058 | return nil |
| 1059 | } |
| 1060 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1061 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1062 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1063 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1064 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1065 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1066 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1067 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1068 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1069 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1070 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1071 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1072 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1073 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1074 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1075 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1076 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1077 | } |
| 1078 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1079 | func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1080 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1081 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1082 | 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] | 1083 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1084 | |
| 1085 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1086 | meParams := me.ParamData{ |
| 1087 | EntityID: 0, |
| 1088 | Attributes: requestedAttributes, |
| 1089 | } |
| 1090 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1091 | if omciErr.GetError() == nil { |
| 1092 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1093 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1094 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1095 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1096 | return nil |
| 1097 | } |
| 1098 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1099 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1100 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1101 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1102 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1103 | return nil |
| 1104 | } |
| 1105 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1106 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1107 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1108 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1109 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1110 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1111 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1112 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1113 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1114 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1115 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1116 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1117 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1118 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1119 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1120 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1121 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1122 | } |
| 1123 | |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1124 | func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
| 1125 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 1126 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1127 | 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] | 1128 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1129 | |
| 1130 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1131 | meParams := me.ParamData{ |
| 1132 | EntityID: aInstNo, |
| 1133 | Attributes: requestedAttributes, |
| 1134 | } |
| 1135 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1136 | if omciErr.GetError() == nil { |
| 1137 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1138 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1139 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1140 | "Err": err, "device-id": oo.deviceID}) |
| 1141 | return nil |
| 1142 | } |
| 1143 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1144 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1145 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1146 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1147 | "Err": err, "device-id": oo.deviceID}) |
| 1148 | return nil |
| 1149 | } |
| 1150 | |
| 1151 | omciRxCallbackPair := callbackPair{ |
| 1152 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1153 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1154 | } |
| 1155 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1156 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1157 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1158 | "Err": err, "device-id": oo.deviceID}) |
| 1159 | return nil |
| 1160 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1161 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1162 | return meInstance |
| 1163 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1164 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1165 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1166 | return nil |
| 1167 | } |
| 1168 | |
| 1169 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1170 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1171 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1172 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1173 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1174 | 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] | 1175 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1176 | |
| 1177 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1178 | meParams := me.ParamData{ |
| 1179 | EntityID: aInstNo, |
| 1180 | Attributes: requestedAttributes, |
| 1181 | } |
| 1182 | meInstance, omciErr := me.NewUniG(meParams) |
| 1183 | if omciErr.GetError() == nil { |
| 1184 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1185 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1186 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1187 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1188 | return nil |
| 1189 | } |
| 1190 | |
| 1191 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1192 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1193 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1194 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1195 | return nil |
| 1196 | } |
| 1197 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1198 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1199 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1200 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1201 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1202 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1203 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1204 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1205 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1206 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1207 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1208 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1209 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1210 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1211 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1212 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1213 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1214 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1215 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1216 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1217 | func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1218 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1219 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1220 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1221 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1222 | |
| 1223 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1224 | meParams := me.ParamData{ |
| 1225 | EntityID: aInstNo, |
| 1226 | Attributes: requestedAttributes, |
| 1227 | } |
| 1228 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1229 | if omciErr.GetError() == nil { |
| 1230 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1231 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1232 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1233 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1234 | return nil |
| 1235 | } |
| 1236 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1237 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1238 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1239 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1240 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1241 | return nil |
| 1242 | } |
| 1243 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1244 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1245 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1246 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1247 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1248 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1249 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1250 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1251 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1252 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1253 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1254 | logger.Debug(ctx, "send VEIP-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1255 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1256 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1257 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1258 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1259 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1260 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1261 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1262 | 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] | 1263 | timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1264 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1265 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1266 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1267 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1268 | |
| 1269 | meParams := me.ParamData{ |
| 1270 | EntityID: entityID, |
| 1271 | Attributes: requestedAttributes, |
| 1272 | } |
| 1273 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1274 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1275 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1276 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid)) |
| 1277 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1278 | 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] | 1279 | return nil |
| 1280 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1281 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1282 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1283 | 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] | 1284 | return nil |
| 1285 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1286 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1287 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1288 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1289 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1290 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
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 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] | 1293 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1294 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1295 | 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] | 1296 | return meInstance |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1297 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1298 | 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] | 1299 | return nil |
| 1300 | } |
| 1301 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1302 | func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1303 | aInstID uint16, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1304 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1305 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1306 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1307 | |
| 1308 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1309 | EntityID: aInstID, |
| 1310 | Attributes: me.AttributeValueMap{ |
| 1311 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
| 1312 | "TpPointer": 0xFFFF, |
| 1313 | "InterworkTpPointerForPBitPriority0": 0xFFFF, |
| 1314 | "InterworkTpPointerForPBitPriority1": 0xFFFF, |
| 1315 | "InterworkTpPointerForPBitPriority2": 0xFFFF, |
| 1316 | "InterworkTpPointerForPBitPriority3": 0xFFFF, |
| 1317 | "InterworkTpPointerForPBitPriority4": 0xFFFF, |
| 1318 | "InterworkTpPointerForPBitPriority5": 0xFFFF, |
| 1319 | "InterworkTpPointerForPBitPriority6": 0xFFFF, |
| 1320 | "InterworkTpPointerForPBitPriority7": 0xFFFF, |
| 1321 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1322 | } |
| 1323 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1324 | if omciErr.GetError() == nil { |
| 1325 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1326 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1327 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1328 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1329 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1330 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1331 | return nil |
| 1332 | } |
| 1333 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1334 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1335 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1336 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1337 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1338 | return nil |
| 1339 | } |
| 1340 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1341 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1342 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1343 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1344 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1345 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1346 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1347 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1348 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1349 | return nil |
| 1350 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1351 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1352 | return meInstance |
| 1353 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1354 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1355 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1356 | return nil |
| 1357 | } |
| 1358 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1359 | func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1360 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1361 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1362 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1363 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1364 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1365 | |
| 1366 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1367 | if omciErr.GetError() == nil { |
| 1368 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1369 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1370 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1371 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1372 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1373 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1374 | return nil |
| 1375 | } |
| 1376 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1377 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1378 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1379 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1380 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1381 | return nil |
| 1382 | } |
| 1383 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1384 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1385 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1386 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1387 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1388 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1389 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1390 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1391 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1392 | return nil |
| 1393 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1394 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1395 | return meInstance |
| 1396 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1397 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1398 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1399 | return nil |
| 1400 | } |
| 1401 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1402 | func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1403 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1404 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1405 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1406 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1407 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1408 | |
| 1409 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1410 | if omciErr.GetError() == nil { |
| 1411 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1412 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1413 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1414 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1415 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1416 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1417 | return nil |
| 1418 | } |
| 1419 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1420 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1421 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1422 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1423 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1424 | return nil |
| 1425 | } |
| 1426 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1427 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1428 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1429 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1430 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1431 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1432 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1433 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1434 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1435 | return nil |
| 1436 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1437 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1438 | return meInstance |
| 1439 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1440 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1441 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1442 | return nil |
| 1443 | } |
| 1444 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1445 | func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1446 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1447 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1448 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1449 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1450 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1451 | |
| 1452 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1453 | if omciErr.GetError() == nil { |
| 1454 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1455 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1456 | omci.TransactionID(tid)) |
| 1457 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1458 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1459 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1460 | return nil |
| 1461 | } |
| 1462 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1463 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1464 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1465 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1466 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1467 | return nil |
| 1468 | } |
| 1469 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1470 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1471 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1472 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1473 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1474 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1475 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1476 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1477 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1478 | return nil |
| 1479 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1480 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1481 | return meInstance |
| 1482 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1483 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1484 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1485 | return nil |
| 1486 | } |
| 1487 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1488 | func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1489 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1490 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1491 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1492 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1493 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1494 | |
| 1495 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1496 | if omciErr.GetError() == nil { |
| 1497 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1498 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1499 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1500 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1501 | return nil |
| 1502 | } |
| 1503 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1504 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1505 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1506 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1507 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1508 | return nil |
| 1509 | } |
| 1510 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1511 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1512 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1513 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1514 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1515 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1516 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1517 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1518 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1519 | return nil |
| 1520 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1521 | logger.Debug(ctx, "send TCont-set msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1522 | return meInstance |
| 1523 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1524 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1525 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1526 | return nil |
| 1527 | } |
| 1528 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1529 | func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1530 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1531 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1532 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1533 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1534 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1535 | |
| 1536 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1537 | if omciErr.GetError() == nil { |
| 1538 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1539 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1540 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1541 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1542 | return nil |
| 1543 | } |
| 1544 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1545 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1546 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1547 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1548 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1549 | return nil |
| 1550 | } |
| 1551 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1552 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1553 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1554 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1555 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1556 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1557 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1558 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1559 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1560 | return nil |
| 1561 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1562 | logger.Debug(ctx, "send PrioQueue-set msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1563 | return meInstance |
| 1564 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1565 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1566 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1567 | return nil |
| 1568 | } |
| 1569 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1570 | func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1571 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1572 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1573 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1574 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1575 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1576 | |
| 1577 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1578 | if omciErr.GetError() == nil { |
| 1579 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1580 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1581 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1582 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1583 | return nil |
| 1584 | } |
| 1585 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1586 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1587 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1588 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1589 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1590 | return nil |
| 1591 | } |
| 1592 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1593 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1594 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1595 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1596 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1597 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1598 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1599 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1600 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1601 | return nil |
| 1602 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1603 | logger.Debug(ctx, "send 1PMapper-set msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1604 | return meInstance |
| 1605 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1606 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1607 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1608 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1609 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1610 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1611 | func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1612 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1613 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1614 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1615 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1616 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1617 | |
| 1618 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1619 | if omciErr.GetError() == nil { |
| 1620 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1621 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1622 | omci.TransactionID(tid)) |
| 1623 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1624 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1625 | "Err": err, "device-id": oo.deviceID}) |
| 1626 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1627 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1628 | // (relevant to all used sendXX() methods and their error conditions) |
| 1629 | return nil |
| 1630 | } |
| 1631 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1632 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1633 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1634 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1635 | "Err": err, "device-id": oo.deviceID}) |
| 1636 | return nil |
| 1637 | } |
| 1638 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1639 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1640 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1641 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1642 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1643 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1644 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1645 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1646 | "Err": err, "device-id": oo.deviceID}) |
| 1647 | return nil |
| 1648 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1649 | logger.Debug(ctx, "send VTFD-Create-msg done") |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1650 | return meInstance |
| 1651 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1652 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1653 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1654 | return nil |
| 1655 | } |
| 1656 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1657 | // nolint: unused |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1658 | func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
| 1659 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1660 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1661 | 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] | 1662 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1663 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1664 | |
| 1665 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1666 | if omciErr.GetError() == nil { |
| 1667 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, |
| 1668 | omci.TransactionID(tid)) |
| 1669 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1670 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1671 | "Err": err, "device-id": oo.deviceID}) |
| 1672 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1673 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1674 | // (relevant to all used sendXX() methods and their error conditions) |
| 1675 | return nil |
| 1676 | } |
| 1677 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1678 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1679 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1680 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1681 | "Err": err, "device-id": oo.deviceID}) |
| 1682 | return nil |
| 1683 | } |
| 1684 | |
| 1685 | omciRxCallbackPair := callbackPair{ |
| 1686 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1687 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1688 | } |
| 1689 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1690 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1691 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1692 | "Err": err, "device-id": oo.deviceID}) |
| 1693 | return nil |
| 1694 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1695 | logger.Debug(ctx, "send VTFD-Set-msg done") |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1696 | return meInstance |
| 1697 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1698 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1699 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1700 | return nil |
| 1701 | } |
| 1702 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1703 | func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
| 1704 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1705 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1706 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1707 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1708 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1709 | |
| 1710 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1711 | if omciErr.GetError() == nil { |
| 1712 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 1713 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1714 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1715 | "Err": err, "device-id": oo.deviceID}) |
| 1716 | return nil |
| 1717 | } |
| 1718 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1719 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1720 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1721 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1722 | "Err": err, "device-id": oo.deviceID}) |
| 1723 | return nil |
| 1724 | } |
| 1725 | |
| 1726 | omciRxCallbackPair := callbackPair{ |
| 1727 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1728 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1729 | } |
| 1730 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1731 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1732 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1733 | "Err": err, "device-id": oo.deviceID}) |
| 1734 | return nil |
| 1735 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1736 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1737 | return meInstance |
| 1738 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1739 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1740 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1741 | return nil |
| 1742 | } |
| 1743 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1744 | func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1745 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1746 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1747 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1748 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1749 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1750 | |
| 1751 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1752 | if omciErr.GetError() == nil { |
| 1753 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1754 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1755 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1756 | "Err": err, "device-id": oo.deviceID}) |
| 1757 | return nil |
| 1758 | } |
| 1759 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1760 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1761 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1762 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1763 | "Err": err, "device-id": oo.deviceID}) |
| 1764 | return nil |
| 1765 | } |
| 1766 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1767 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1768 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1769 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1770 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1771 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1772 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1773 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1774 | "Err": err, "device-id": oo.deviceID}) |
| 1775 | return nil |
| 1776 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1777 | logger.Debug(ctx, "send EVTOCD-set msg done") |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1778 | return meInstance |
| 1779 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1780 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1781 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1782 | return nil |
| 1783 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1784 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1785 | func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
| 1786 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1787 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1788 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1789 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1790 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1791 | |
| 1792 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1793 | if omciErr.GetError() == nil { |
| 1794 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid)) |
| 1795 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1796 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1797 | "Err": err, "device-id": oo.deviceID}) |
| 1798 | return nil |
| 1799 | } |
| 1800 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1801 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1802 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1803 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1804 | "Err": err, "device-id": oo.deviceID}) |
| 1805 | return nil |
| 1806 | } |
| 1807 | |
| 1808 | omciRxCallbackPair := callbackPair{ |
| 1809 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1810 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1811 | } |
| 1812 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1813 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1814 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1815 | "Err": err, "device-id": oo.deviceID}) |
| 1816 | return nil |
| 1817 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1818 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1819 | return meInstance |
| 1820 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1821 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1822 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1823 | return nil |
| 1824 | } |
| 1825 | |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1826 | func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
| 1827 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1828 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1829 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1830 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1831 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1832 | |
| 1833 | meParams := me.ParamData{EntityID: aInstID} |
| 1834 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 1835 | if omciErr.GetError() == nil { |
| 1836 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1837 | omci.TransactionID(tid)) |
| 1838 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1839 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1840 | "Err": err, "device-id": oo.deviceID}) |
| 1841 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1842 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1843 | // (relevant to all used sendXX() methods and their error conditions) |
| 1844 | return nil |
| 1845 | } |
| 1846 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1847 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1848 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1849 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1850 | "Err": err, "device-id": oo.deviceID}) |
| 1851 | return nil |
| 1852 | } |
| 1853 | |
| 1854 | omciRxCallbackPair := callbackPair{ |
| 1855 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 1856 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1857 | } |
| 1858 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1859 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1860 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1861 | "Err": err, "device-id": oo.deviceID}) |
| 1862 | return nil |
| 1863 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1864 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1865 | return meInstance |
| 1866 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1867 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1868 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1869 | return nil |
| 1870 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1871 | |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 1872 | // nolint: unused |
| 1873 | func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool, |
| 1874 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1875 | tid := oo.getNextTid(highPrio) |
| 1876 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1877 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1878 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1879 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 1880 | if omciErr.GetError() == nil { |
| 1881 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 1882 | if err != nil { |
| 1883 | logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1884 | return nil |
| 1885 | } |
| 1886 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1887 | if err != nil { |
| 1888 | logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1889 | return nil |
| 1890 | } |
| 1891 | omciRxCallbackPair := callbackPair{ |
| 1892 | cbKey: tid, |
| 1893 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 1894 | } |
| 1895 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1896 | if err != nil { |
| 1897 | logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1898 | return nil |
| 1899 | } |
| 1900 | logger.Debug(ctx, "send TD-Create-msg done") |
| 1901 | return meInstance |
| 1902 | } |
| 1903 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1904 | return nil |
| 1905 | } |
| 1906 | |
| 1907 | // nolint: unused |
| 1908 | func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
| 1909 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1910 | tid := oo.getNextTid(highPrio) |
| 1911 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1912 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1913 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1914 | |
| 1915 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 1916 | if omciErr.GetError() == nil { |
| 1917 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1918 | if err != nil { |
| 1919 | logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1920 | return nil |
| 1921 | } |
| 1922 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1923 | if err != nil { |
| 1924 | logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1925 | return nil |
| 1926 | } |
| 1927 | omciRxCallbackPair := callbackPair{ |
| 1928 | cbKey: tid, |
| 1929 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 1930 | } |
| 1931 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1932 | if err != nil { |
| 1933 | logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1934 | return nil |
| 1935 | } |
| 1936 | logger.Debug(ctx, "send TD-Set-msg done") |
| 1937 | return meInstance |
| 1938 | } |
| 1939 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1940 | return nil |
| 1941 | |
| 1942 | } |
| 1943 | |
| 1944 | // nolint: unused |
| 1945 | func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
| 1946 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1947 | tid := oo.getNextTid(highPrio) |
| 1948 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1949 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1950 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1951 | |
| 1952 | meParams := me.ParamData{EntityID: aInstID} |
| 1953 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 1954 | if omciErr.GetError() == nil { |
| 1955 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid)) |
| 1956 | if err != nil { |
| 1957 | logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1958 | return nil |
| 1959 | } |
| 1960 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1961 | if err != nil { |
| 1962 | logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1963 | return nil |
| 1964 | } |
| 1965 | omciRxCallbackPair := callbackPair{ |
| 1966 | cbKey: tid, |
| 1967 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 1968 | } |
| 1969 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1970 | if err != nil { |
| 1971 | logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1972 | return nil |
| 1973 | } |
| 1974 | logger.Debug(ctx, "send TD-Delete-msg done") |
| 1975 | return meInstance |
| 1976 | } |
| 1977 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1978 | return nil |
| 1979 | |
| 1980 | } |
| 1981 | |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1982 | func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
| 1983 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1984 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1985 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1986 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1987 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1988 | |
| 1989 | meParams := me.ParamData{EntityID: aInstID} |
| 1990 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 1991 | if omciErr.GetError() == nil { |
| 1992 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1993 | omci.TransactionID(tid)) |
| 1994 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1995 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 1996 | "Err": err, "device-id": oo.deviceID}) |
| 1997 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1998 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1999 | // (relevant to all used sendXX() methods and their error conditions) |
| 2000 | return nil |
| 2001 | } |
| 2002 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2003 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2004 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2005 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2006 | "Err": err, "device-id": oo.deviceID}) |
| 2007 | return nil |
| 2008 | } |
| 2009 | |
| 2010 | omciRxCallbackPair := callbackPair{ |
| 2011 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2012 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2013 | } |
| 2014 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2015 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2016 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2017 | "Err": err, "device-id": oo.deviceID}) |
| 2018 | return nil |
| 2019 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2020 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2021 | return meInstance |
| 2022 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2023 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2024 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2025 | return nil |
| 2026 | } |
| 2027 | |
| 2028 | func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
| 2029 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 2030 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2031 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2032 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2033 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2034 | |
| 2035 | meParams := me.ParamData{EntityID: aInstID} |
| 2036 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2037 | if omciErr.GetError() == nil { |
| 2038 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2039 | omci.TransactionID(tid)) |
| 2040 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2041 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2042 | "Err": err, "device-id": oo.deviceID}) |
| 2043 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2044 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2045 | // (relevant to all used sendXX() methods and their error conditions) |
| 2046 | return nil |
| 2047 | } |
| 2048 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2049 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2050 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2051 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2052 | "Err": err, "device-id": oo.deviceID}) |
| 2053 | return nil |
| 2054 | } |
| 2055 | |
| 2056 | omciRxCallbackPair := callbackPair{ |
| 2057 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2058 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2059 | } |
| 2060 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2061 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2062 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2063 | "Err": err, "device-id": oo.deviceID}) |
| 2064 | return nil |
| 2065 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2066 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2067 | return meInstance |
| 2068 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2069 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2070 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2071 | return nil |
| 2072 | } |
| 2073 | |
| 2074 | func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
| 2075 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 2076 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2077 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2078 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2079 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2080 | |
| 2081 | meParams := me.ParamData{EntityID: aInstID} |
| 2082 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2083 | if omciErr.GetError() == nil { |
| 2084 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2085 | omci.TransactionID(tid)) |
| 2086 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2087 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2088 | "Err": err, "device-id": oo.deviceID}) |
| 2089 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2090 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2091 | // (relevant to all used sendXX() methods and their error conditions) |
| 2092 | return nil |
| 2093 | } |
| 2094 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2095 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2096 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2097 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2098 | "Err": err, "device-id": oo.deviceID}) |
| 2099 | return nil |
| 2100 | } |
| 2101 | |
| 2102 | omciRxCallbackPair := callbackPair{ |
| 2103 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2104 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2105 | } |
| 2106 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2107 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2108 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2109 | "Err": err, "device-id": oo.deviceID}) |
| 2110 | return nil |
| 2111 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2112 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2113 | return meInstance |
| 2114 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2115 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2116 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2117 | return nil |
| 2118 | } |
| 2119 | |
| 2120 | func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 2121 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 2122 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2123 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2124 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2125 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2126 | |
| 2127 | meParams := me.ParamData{EntityID: aInstID} |
| 2128 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2129 | if omciErr.GetError() == nil { |
| 2130 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2131 | omci.TransactionID(tid)) |
| 2132 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2133 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2134 | "Err": err, "device-id": oo.deviceID}) |
| 2135 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2136 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2137 | // (relevant to all used sendXX() methods and their error conditions) |
| 2138 | return nil |
| 2139 | } |
| 2140 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2141 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2142 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2143 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2144 | "Err": err, "device-id": oo.deviceID}) |
| 2145 | return nil |
| 2146 | } |
| 2147 | |
| 2148 | omciRxCallbackPair := callbackPair{ |
| 2149 | cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2150 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2151 | } |
| 2152 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2153 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2154 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2155 | "Err": err, "device-id": oo.deviceID}) |
| 2156 | return nil |
| 2157 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2158 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2159 | return meInstance |
| 2160 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2161 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2162 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2163 | return nil |
| 2164 | } |
| 2165 | |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2166 | func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 2167 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2168 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2169 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2170 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2171 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2172 | |
| 2173 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2174 | if omciErr.GetError() == nil { |
| 2175 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2176 | omci.AddDefaults(true)) |
| 2177 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2178 | 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] | 2179 | return nil |
| 2180 | } |
| 2181 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2182 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2183 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2184 | 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] | 2185 | return nil |
| 2186 | } |
| 2187 | |
| 2188 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2189 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2190 | } |
| 2191 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2192 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2193 | 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] | 2194 | return nil |
| 2195 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2196 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2197 | return meInstance |
| 2198 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2199 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2200 | "device-id": oo.deviceID}) |
| 2201 | return nil |
| 2202 | } |
| 2203 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2204 | func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 2205 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2206 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2207 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2208 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2209 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2210 | |
| 2211 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2212 | if omciErr.GetError() == nil { |
| 2213 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid), |
| 2214 | omci.AddDefaults(true)) |
| 2215 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2216 | 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] | 2217 | return nil |
| 2218 | } |
| 2219 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2220 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2221 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2222 | 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] | 2223 | return nil |
| 2224 | } |
| 2225 | |
| 2226 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2227 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2228 | } |
| 2229 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2230 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2231 | 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] | 2232 | return nil |
| 2233 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2234 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2235 | return meInstance |
| 2236 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2237 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2238 | "device-id": oo.deviceID}) |
| 2239 | return nil |
| 2240 | } |
| 2241 | |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2242 | func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 2243 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2244 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2245 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2246 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2247 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2248 | |
| 2249 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2250 | if omciErr.GetError() == nil { |
| 2251 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2252 | omci.AddDefaults(true)) |
| 2253 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2254 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2255 | "device-id": oo.deviceID}) |
| 2256 | return nil |
| 2257 | } |
| 2258 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2259 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2260 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2261 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2262 | "device-id": oo.deviceID}) |
| 2263 | return nil |
| 2264 | } |
| 2265 | |
| 2266 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2267 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2268 | } |
| 2269 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2270 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2271 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2272 | "device-id": oo.deviceID}) |
| 2273 | return nil |
| 2274 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2275 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2276 | return meInstance |
| 2277 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2278 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2279 | "device-id": oo.deviceID}) |
| 2280 | return nil |
| 2281 | } |
| 2282 | |
| 2283 | func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 2284 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2285 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2286 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2287 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2288 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2289 | |
| 2290 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2291 | if omciErr.GetError() == nil { |
| 2292 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid), |
| 2293 | omci.AddDefaults(true)) |
| 2294 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2295 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2296 | "device-id": oo.deviceID}) |
| 2297 | return nil |
| 2298 | } |
| 2299 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2300 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2301 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2302 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2303 | "device-id": oo.deviceID}) |
| 2304 | return nil |
| 2305 | } |
| 2306 | |
| 2307 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2308 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2309 | } |
| 2310 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2311 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2312 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2313 | "device-id": oo.deviceID}) |
| 2314 | return nil |
| 2315 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2316 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2317 | return meInstance |
| 2318 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2319 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2320 | "device-id": oo.deviceID}) |
| 2321 | return nil |
| 2322 | } |
| 2323 | |
| 2324 | func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
| 2325 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 2326 | tid := oo.getNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2327 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2328 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2329 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2330 | |
| 2331 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2332 | if omciErr.GetError() == nil { |
| 2333 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2334 | omci.AddDefaults(true)) |
| 2335 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2336 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2337 | "device-id": oo.deviceID}) |
| 2338 | return nil |
| 2339 | } |
| 2340 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2341 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2342 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2343 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2344 | "device-id": oo.deviceID}) |
| 2345 | return nil |
| 2346 | } |
| 2347 | |
| 2348 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2349 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2350 | } |
| 2351 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2352 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2353 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2354 | "device-id": oo.deviceID}) |
| 2355 | return nil |
| 2356 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2357 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2358 | return meInstance |
| 2359 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2360 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2361 | "device-id": oo.deviceID}) |
| 2362 | return nil |
| 2363 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2364 | |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2365 | func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 2366 | tid := oo.getNextTid(highPrio) |
| 2367 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 2368 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 2369 | |
| 2370 | omciLayer := &omci.OMCI{ |
| 2371 | TransactionID: tid, |
| 2372 | MessageType: omci.SynchronizeTimeRequestType, |
| 2373 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2374 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2375 | } |
| 2376 | utcTime := time.Now().UTC() |
| 2377 | request := &omci.SynchronizeTimeRequest{ |
| 2378 | MeBasePacket: omci.MeBasePacket{ |
| 2379 | EntityClass: me.OnuGClassID, |
| 2380 | // Default Instance ID is 0 |
| 2381 | }, |
| 2382 | Year: uint16(utcTime.Year()), |
| 2383 | Month: uint8(utcTime.Month()), |
| 2384 | Day: uint8(utcTime.Day()), |
| 2385 | Hour: uint8(utcTime.Hour()), |
| 2386 | Minute: uint8(utcTime.Minute()), |
| 2387 | Second: uint8(utcTime.Second()), |
| 2388 | } |
| 2389 | |
| 2390 | pkt, err := serializeOmciLayer(ctx, omciLayer, request) |
| 2391 | if err != nil { |
| 2392 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 2393 | "device-id": oo.deviceID}) |
| 2394 | return err |
| 2395 | } |
| 2396 | |
| 2397 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2398 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2399 | } |
| 2400 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2401 | if err != nil { |
| 2402 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 2403 | "device-id": oo.deviceID}) |
| 2404 | return err |
| 2405 | } |
| 2406 | logger.Debug(ctx, "send synchronize time request done") |
| 2407 | return nil |
| 2408 | } |
| 2409 | |
| 2410 | func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2411 | upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2412 | tid := oo.getNextTid(highPrio) |
| 2413 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2414 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 2415 | meParam := me.ParamData{EntityID: entityID} |
| 2416 | var meInstance *me.ManagedEntity |
| 2417 | var omciErr me.OmciErrors |
| 2418 | if upstream { |
| 2419 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 2420 | } else { |
| 2421 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 2422 | } |
| 2423 | if omciErr.GetError() == nil { |
| 2424 | var omciLayer *omci.OMCI |
| 2425 | var msgLayer gopacket.SerializableLayer |
| 2426 | var err error |
| 2427 | if create { |
| 2428 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2429 | omci.AddDefaults(true)) |
| 2430 | } else { |
| 2431 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2432 | omci.AddDefaults(true)) |
| 2433 | } |
| 2434 | if err != nil { |
| 2435 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 2436 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2437 | return nil |
| 2438 | } |
| 2439 | |
| 2440 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2441 | if err != nil { |
| 2442 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 2443 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2444 | return nil |
| 2445 | } |
| 2446 | |
| 2447 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2448 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2449 | } |
| 2450 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2451 | if err != nil { |
| 2452 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 2453 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2454 | return nil |
| 2455 | } |
| 2456 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 2457 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2458 | return meInstance |
| 2459 | } |
| 2460 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 2461 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2462 | return nil |
| 2463 | } |
| 2464 | |
| 2465 | func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2466 | create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2467 | tid := oo.getNextTid(highPrio) |
| 2468 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2469 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 2470 | meParam := me.ParamData{EntityID: entityID} |
| 2471 | var meInstance *me.ManagedEntity |
| 2472 | var omciErr me.OmciErrors |
| 2473 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 2474 | |
| 2475 | if omciErr.GetError() == nil { |
| 2476 | var omciLayer *omci.OMCI |
| 2477 | var msgLayer gopacket.SerializableLayer |
| 2478 | var err error |
| 2479 | if create { |
| 2480 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2481 | omci.AddDefaults(true)) |
| 2482 | } else { |
| 2483 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2484 | omci.AddDefaults(true)) |
| 2485 | } |
| 2486 | if err != nil { |
| 2487 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 2488 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2489 | return nil |
| 2490 | } |
| 2491 | |
| 2492 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2493 | if err != nil { |
| 2494 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 2495 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2496 | return nil |
| 2497 | } |
| 2498 | |
| 2499 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2500 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 2501 | } |
| 2502 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2503 | if err != nil { |
| 2504 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 2505 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2506 | return nil |
| 2507 | } |
| 2508 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 2509 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2510 | return meInstance |
| 2511 | } |
| 2512 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 2513 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2514 | return nil |
| 2515 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 2516 | |
| 2517 | func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2518 | create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2519 | tid := oo.getNextTid(highPrio) |
| 2520 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2521 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 2522 | meParam := me.ParamData{EntityID: entityID} |
| 2523 | var meInstance *me.ManagedEntity |
| 2524 | var omciErr me.OmciErrors |
| 2525 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 2526 | |
| 2527 | if omciErr.GetError() == nil { |
| 2528 | var omciLayer *omci.OMCI |
| 2529 | var msgLayer gopacket.SerializableLayer |
| 2530 | var err error |
| 2531 | if create { |
| 2532 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2533 | omci.AddDefaults(true)) |
| 2534 | } else { |
| 2535 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2536 | omci.AddDefaults(true)) |
| 2537 | } |
| 2538 | if err != nil { |
| 2539 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 2540 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2541 | return nil |
| 2542 | } |
| 2543 | |
| 2544 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2545 | if err != nil { |
| 2546 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 2547 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2548 | return nil |
| 2549 | } |
| 2550 | |
| 2551 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2552 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 2553 | } |
| 2554 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2555 | if err != nil { |
| 2556 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 2557 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2558 | return nil |
| 2559 | } |
| 2560 | logger.Debugw(ctx, "send fec history data ME done", |
| 2561 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2562 | return meInstance |
| 2563 | } |
| 2564 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 2565 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2566 | return nil |
| 2567 | } |
| 2568 | |
| 2569 | func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
| 2570 | create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity { |
| 2571 | tid := oo.getNextTid(highPrio) |
| 2572 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 2573 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 2574 | meParam := me.ParamData{EntityID: entityID} |
| 2575 | var meInstance *me.ManagedEntity |
| 2576 | var omciErr me.OmciErrors |
| 2577 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 2578 | |
| 2579 | if omciErr.GetError() == nil { |
| 2580 | var omciLayer *omci.OMCI |
| 2581 | var msgLayer gopacket.SerializableLayer |
| 2582 | var err error |
| 2583 | if create { |
| 2584 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 2585 | omci.AddDefaults(true)) |
| 2586 | } else { |
| 2587 | omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid), |
| 2588 | omci.AddDefaults(true)) |
| 2589 | } |
| 2590 | if err != nil { |
| 2591 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 2592 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2593 | return nil |
| 2594 | } |
| 2595 | |
| 2596 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2597 | if err != nil { |
| 2598 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 2599 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2600 | return nil |
| 2601 | } |
| 2602 | |
| 2603 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2604 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 2605 | } |
| 2606 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 2607 | if err != nil { |
| 2608 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 2609 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2610 | return nil |
| 2611 | } |
| 2612 | logger.Debugw(ctx, "send gemport history data ME done", |
| 2613 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2614 | return meInstance |
| 2615 | } |
| 2616 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 2617 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 2618 | return nil |
| 2619 | } |
| 2620 | |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2621 | func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
| 2622 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error { |
| 2623 | tid := oo.getNextTid(highPrio) |
| 2624 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 2625 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2626 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2627 | |
| 2628 | omciLayer := &omci.OMCI{ |
| 2629 | TransactionID: tid, |
| 2630 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 2631 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2632 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2633 | } |
| 2634 | request := &omci.StartSoftwareDownloadRequest{ |
| 2635 | MeBasePacket: omci.MeBasePacket{ |
| 2636 | EntityClass: me.SoftwareImageClassID, |
| 2637 | EntityInstance: aImageMeID, //inactive image |
| 2638 | }, |
| 2639 | WindowSize: aDownloadWindowSize, |
| 2640 | ImageSize: aFileLen, |
| 2641 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 2642 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 2643 | } |
| 2644 | |
| 2645 | var options gopacket.SerializeOptions |
| 2646 | options.FixLengths = true |
| 2647 | buffer := gopacket.NewSerializeBuffer() |
| 2648 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2649 | if err != nil { |
| 2650 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 2651 | "device-id": oo.deviceID}) |
| 2652 | return err |
| 2653 | } |
| 2654 | outgoingPacket := buffer.Bytes() |
| 2655 | |
| 2656 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2657 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2658 | } |
| 2659 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2660 | if err != nil { |
| 2661 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 2662 | "device-id": oo.deviceID}) |
| 2663 | return err |
| 2664 | } |
| 2665 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2666 | return nil |
| 2667 | } |
| 2668 | |
| 2669 | func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool, |
| 2670 | rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error { |
| 2671 | tid := oo.getNextTid(highPrio) |
| 2672 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 2673 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2674 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2675 | |
| 2676 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 2677 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2678 | msgType := omci.DownloadSectionRequestType |
| 2679 | if aAckRequest > 0 { |
| 2680 | msgType = omci.DownloadSectionRequestWithResponseType |
| 2681 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2682 | omciLayer := &omci.OMCI{ |
| 2683 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2684 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2685 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2686 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2687 | } |
Girish Gowdra | 8a7b456 | 2021-02-23 16:27:42 -0800 | [diff] [blame] | 2688 | var localSectionData [31]byte |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2689 | 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] | 2690 | request := &omci.DownloadSectionRequest{ |
| 2691 | MeBasePacket: omci.MeBasePacket{ |
| 2692 | EntityClass: me.SoftwareImageClassID, |
| 2693 | EntityInstance: aImageMeID, //inactive image |
| 2694 | }, |
| 2695 | SectionNumber: aDownloadSectionNo, |
| 2696 | SectionData: localSectionData, |
| 2697 | } |
| 2698 | |
| 2699 | var options gopacket.SerializeOptions |
| 2700 | options.FixLengths = true |
| 2701 | buffer := gopacket.NewSerializeBuffer() |
| 2702 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2703 | if err != nil { |
| 2704 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 2705 | "device-id": oo.deviceID}) |
| 2706 | return err |
| 2707 | } |
| 2708 | outgoingPacket := buffer.Bytes() |
| 2709 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2710 | //for initial debug purpose overrule the requested print state for some frames |
| 2711 | printFrame := aPrint |
| 2712 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 2713 | printFrame = true |
| 2714 | } |
| 2715 | |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2716 | omciRxCallbackPair := callbackPair{cbKey: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2717 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2718 | } |
| 2719 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2720 | if err != nil { |
| 2721 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 2722 | "device-id": oo.deviceID}) |
| 2723 | return err |
| 2724 | } |
| 2725 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2726 | return nil |
| 2727 | } |
| 2728 | |
| 2729 | func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
| 2730 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error { |
| 2731 | tid := oo.getNextTid(highPrio) |
| 2732 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 2733 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2734 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2735 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2736 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2737 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2738 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2739 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2740 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2741 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2742 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2743 | MeBasePacket: omci.MeBasePacket{ |
| 2744 | EntityClass: me.SoftwareImageClassID, |
| 2745 | EntityInstance: aImageMeID, //inactive image |
| 2746 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2747 | CRC32: aImageCrc, |
| 2748 | ImageSize: aFileLen, |
| 2749 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 2750 | 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] | 2751 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2752 | |
| 2753 | var options gopacket.SerializeOptions |
| 2754 | options.FixLengths = true |
| 2755 | buffer := gopacket.NewSerializeBuffer() |
| 2756 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2757 | if err != nil { |
| 2758 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2759 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2760 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2761 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2762 | outgoingPacket := buffer.Bytes() |
| 2763 | |
| 2764 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2765 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2766 | } |
| 2767 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2768 | if err != nil { |
| 2769 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 2770 | "device-id": oo.deviceID}) |
| 2771 | return err |
| 2772 | } |
| 2773 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2774 | return nil |
| 2775 | } |
| 2776 | |
| 2777 | func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
| 2778 | rxChan chan Message, aImageMeID uint16) error { |
| 2779 | tid := oo.getNextTid(highPrio) |
| 2780 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 2781 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2782 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2783 | |
| 2784 | omciLayer := &omci.OMCI{ |
| 2785 | TransactionID: tid, |
| 2786 | MessageType: omci.ActivateSoftwareRequestType, |
| 2787 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2788 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2789 | } |
| 2790 | request := &omci.ActivateSoftwareRequest{ |
| 2791 | MeBasePacket: omci.MeBasePacket{ |
| 2792 | EntityClass: me.SoftwareImageClassID, |
| 2793 | EntityInstance: aImageMeID, //inactive image |
| 2794 | }, |
| 2795 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 2796 | } |
| 2797 | |
| 2798 | var options gopacket.SerializeOptions |
| 2799 | options.FixLengths = true |
| 2800 | buffer := gopacket.NewSerializeBuffer() |
| 2801 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2802 | if err != nil { |
| 2803 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 2804 | "device-id": oo.deviceID}) |
| 2805 | return err |
| 2806 | } |
| 2807 | outgoingPacket := buffer.Bytes() |
| 2808 | |
| 2809 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2810 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2811 | } |
| 2812 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2813 | if err != nil { |
| 2814 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 2815 | "device-id": oo.deviceID}) |
| 2816 | return err |
| 2817 | } |
| 2818 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2819 | return nil |
| 2820 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2821 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2822 | func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
| 2823 | rxChan chan Message, aImageMeID uint16) error { |
| 2824 | tid := oo.getNextTid(highPrio) |
| 2825 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 2826 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2827 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 2828 | |
| 2829 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2830 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2831 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2832 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 2833 | // Length: 0x28, // Optional, defaults to 40 octets |
| 2834 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2835 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2836 | MeBasePacket: omci.MeBasePacket{ |
| 2837 | EntityClass: me.SoftwareImageClassID, |
| 2838 | EntityInstance: aImageMeID, //inactive image |
| 2839 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2840 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2841 | |
| 2842 | var options gopacket.SerializeOptions |
| 2843 | options.FixLengths = true |
| 2844 | buffer := gopacket.NewSerializeBuffer() |
| 2845 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 2846 | if err != nil { |
| 2847 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2848 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2849 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2850 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 2851 | outgoingPacket := buffer.Bytes() |
| 2852 | |
| 2853 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 2854 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2855 | } |
| 2856 | err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
| 2857 | if err != nil { |
| 2858 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 2859 | "device-id": oo.deviceID}) |
| 2860 | return err |
| 2861 | } |
| 2862 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 2863 | return nil |
| 2864 | } |
| 2865 | |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 2866 | func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool { |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2867 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 2868 | if v == omciMsg.MessageType { |
| 2869 | nextLayer, _ := omci.MsgTypeToNextLayer(v) |
| 2870 | msgLayer := (*packet).Layer(nextLayer) |
| 2871 | switch nextLayer { |
| 2872 | case omci.LayerTypeCreateResponse: |
| 2873 | if msgLayer.(*omci.CreateResponse).Result == me.Success { |
| 2874 | return true |
| 2875 | } |
| 2876 | case omci.LayerTypeDeleteResponse: |
| 2877 | if msgLayer.(*omci.DeleteResponse).Result == me.Success { |
| 2878 | return true |
| 2879 | } |
| 2880 | case omci.LayerTypeSetResponse: |
| 2881 | if msgLayer.(*omci.SetResponse).Result == me.Success { |
| 2882 | return true |
| 2883 | } |
| 2884 | case omci.LayerTypeStartSoftwareDownloadResponse: |
| 2885 | if msgLayer.(*omci.StartSoftwareDownloadResponse).Result == me.Success { |
| 2886 | return true |
| 2887 | } |
| 2888 | case omci.LayerTypeEndSoftwareDownloadResponse: |
| 2889 | if msgLayer.(*omci.EndSoftwareDownloadResponse).Result == me.Success { |
| 2890 | return true |
| 2891 | } |
| 2892 | case omci.LayerTypeActivateSoftwareResponse: |
| 2893 | if msgLayer.(*omci.ActivateSoftwareResponse).Result == me.Success { |
| 2894 | return true |
| 2895 | } |
| 2896 | case omci.LayerTypeCommitSoftwareResponse: |
| 2897 | if msgLayer.(*omci.CommitSoftwareResponse).Result == me.Success { |
| 2898 | return true |
| 2899 | } |
| 2900 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2901 | } |
| 2902 | } |
| 2903 | return false |
| 2904 | } |