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" |
| 25 | "errors" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 26 | "fmt" |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 27 | "strconv" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 28 | "sync" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 29 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 30 | //"time" |
| 31 | |
| 32 | "github.com/google/gopacket" |
| 33 | // TODO!!! Some references could be resolved auto, but some need specific context .... |
| 34 | gp "github.com/google/gopacket" |
| 35 | |
| 36 | "github.com/opencord/omci-lib-go" |
| 37 | me "github.com/opencord/omci-lib-go/generated" |
| 38 | "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif" |
| 39 | |
| 40 | //"github.com/opencord/voltha-lib-go/v3/pkg/kafka" |
| 41 | "github.com/opencord/voltha-lib-go/v3/pkg/log" |
| 42 | ic "github.com/opencord/voltha-protos/v3/go/inter_container" |
| 43 | //"github.com/opencord/voltha-protos/v3/go/openflow_13" |
| 44 | //"github.com/opencord/voltha-protos/v3/go/voltha" |
| 45 | ) |
| 46 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 47 | // ### OMCI related definitions - retrieved from Python adapter code/trace #### |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 48 | |
| 49 | //ConstDefaultOmciTimeout - Default OMCI Timeout |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 50 | const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds |
| 51 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 52 | const galEthernetEID = uint16(1) |
| 53 | const maxGemPayloadSize = uint16(48) |
| 54 | const connectivityModeValue = uint8(5) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 55 | |
| 56 | //const defaultTPID = uint16(0x8100) |
| 57 | //const broadComDefaultVID = uint16(4091) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 58 | const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning |
| 59 | const ieeeMapperServiceProfileEID = uint16(0x8001) |
| 60 | const macBridgePortAniEID = uint16(0x2102) |
| 61 | |
| 62 | // ### OMCI related definitions - end |
| 63 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 64 | //callbackPairEntry to be used for OMCI send/receive correlation |
| 65 | type callbackPairEntry struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 66 | cbRespChannel chan Message |
| 67 | cbFunction func(*omci.OMCI, *gp.Packet, chan Message) error |
| 68 | } |
| 69 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 70 | //callbackPair to be used for ReceiveCallback init |
| 71 | type callbackPair struct { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 72 | cbKey uint16 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 73 | cbEntry callbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | type omciTransferStructure struct { |
| 77 | txFrame []byte |
| 78 | timeout int |
| 79 | retry int |
| 80 | highPrio bool |
| 81 | } |
| 82 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 83 | //omciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 84 | type omciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 85 | enabled bool |
| 86 | pOnuDeviceEntry *OnuDeviceEntry |
| 87 | deviceID string |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 88 | pBaseDeviceHandler *deviceHandler |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 89 | coreProxy adapterif.CoreProxy |
| 90 | adapterProxy adapterif.AdapterProxy |
| 91 | supportExtMsg bool |
| 92 | //txRequest |
| 93 | //rxResponse |
| 94 | //pendingRequest |
| 95 | txFrames, txOnuFrames uint32 |
| 96 | rxFrames, rxOnuFrames, rxOnuDiscards uint32 |
| 97 | |
| 98 | // OMCI params |
| 99 | mutexTid sync.Mutex |
| 100 | tid uint16 |
| 101 | mutexHpTid sync.Mutex |
| 102 | hpTid uint16 |
| 103 | uploadSequNo uint16 |
| 104 | uploadNoOfCmds uint16 |
| 105 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 106 | mutexTxQueue sync.Mutex |
| 107 | txQueue *list.List |
| 108 | mutexRxSchedMap sync.Mutex |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 109 | rxSchedulerMap map[uint16]callbackPairEntry |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 110 | pLastTxMeInstance *me.ManagedEntity |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 113 | //newOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 114 | //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] | 115 | func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry, |
| 116 | deviceID string, deviceHandler *deviceHandler, |
| 117 | coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 118 | logger.Infow("init-omciCC", log.Fields{"device-id": deviceID}) |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 119 | var omciCC omciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 120 | omciCC.enabled = false |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 121 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 122 | omciCC.deviceID = deviceID |
| 123 | omciCC.pBaseDeviceHandler = deviceHandler |
| 124 | omciCC.coreProxy = coreProxy |
| 125 | omciCC.adapterProxy = adapterProxy |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 126 | omciCC.supportExtMsg = false |
| 127 | omciCC.txFrames = 0 |
| 128 | omciCC.txOnuFrames = 0 |
| 129 | omciCC.rxFrames = 0 |
| 130 | omciCC.rxOnuFrames = 0 |
| 131 | omciCC.rxOnuDiscards = 0 |
| 132 | omciCC.tid = 0x1 |
| 133 | omciCC.hpTid = 0x8000 |
| 134 | omciCC.uploadSequNo = 0 |
| 135 | omciCC.uploadNoOfCmds = 0 |
| 136 | |
| 137 | omciCC.txQueue = list.New() |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 138 | omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 139 | |
| 140 | return &omciCC |
| 141 | } |
| 142 | |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 143 | //stop stops/resets the omciCC |
| 144 | func (oo *omciCC) stop(ctx context.Context) error { |
| 145 | logger.Debugw("omciCC-stopping", log.Fields{"for device-id": oo.deviceID}) |
| 146 | //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests |
| 147 | oo.mutexTxQueue.Lock() |
| 148 | oo.txQueue.Init() // clear the tx queue |
| 149 | oo.mutexTxQueue.Unlock() |
| 150 | oo.mutexRxSchedMap.Lock() |
| 151 | for k := range oo.rxSchedulerMap { |
| 152 | delete(oo.rxSchedulerMap, k) //clear the scheduler map |
| 153 | } |
| 154 | oo.mutexRxSchedMap.Unlock() |
| 155 | oo.mutexHpTid.Lock() |
| 156 | oo.hpTid = 0x8000 //reset the high prio transactionId |
| 157 | oo.mutexHpTid.Unlock() |
| 158 | oo.mutexTid.Lock() |
| 159 | oo.tid = 1 //reset the low prio transactionId |
| 160 | oo.mutexTid.Unlock() |
| 161 | //reset control values |
| 162 | oo.uploadSequNo = 0 |
| 163 | oo.uploadNoOfCmds = 0 |
| 164 | //reset the stats counter - which might be topic of discussion ... |
| 165 | oo.txFrames = 0 |
| 166 | oo.txOnuFrames = 0 |
| 167 | oo.rxFrames = 0 |
| 168 | oo.rxOnuFrames = 0 |
| 169 | oo.rxOnuDiscards = 0 |
| 170 | |
| 171 | return nil |
| 172 | } |
| 173 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 174 | // Rx handler for omci messages |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 175 | func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 176 | logger.Debugw("rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 177 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
| 178 | /* |
| 179 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 180 | rxOnuFrames++ |
| 181 | |
| 182 | switch msgType { |
| 183 | case AlarmNotification: |
| 184 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 185 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 186 | // python code was: |
| 187 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 188 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 189 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 190 | // |
| 191 | return errors.New("RxAlarmNotification unimplemented") |
| 192 | } |
| 193 | case AttributeValueChange: |
| 194 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 195 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 196 | // python code was: |
| 197 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 198 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 199 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 200 | // |
| 201 | return errors.New("RxAttributeValueChange unimplemented") |
| 202 | } |
| 203 | case TestResult: |
| 204 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 205 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 206 | // python code was: |
| 207 | //elif msg_type == EntityOperations.TestResult.value: |
| 208 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 209 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 210 | // |
| 211 | return errors.New("RxTestResult unimplemented") |
| 212 | } |
| 213 | default: |
| 214 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 215 | logger.Errorw("rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 216 | rxOnuDiscards++ |
| 217 | return errors.New("RxOnuMsgType unimplemented") |
| 218 | } |
| 219 | } |
| 220 | */ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 221 | return errors.New("receiveOnuMessage unimplemented") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | // Rx handler for onu messages |
| 225 | // 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] | 226 | func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 227 | //logger.Debugw("cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 228 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 229 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 230 | // (am extendedFormat message could be destroyed this way!) |
| 231 | trailerLenData := rxMsg[42:44] |
| 232 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
mpagenko | 1cc3cb4 | 2020-07-27 15:24:38 +0000 | [diff] [blame] | 233 | //logger.Debugw("omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 234 | if trailerLen != 40 { // invalid base Format entry -> autocorrect |
| 235 | binary.BigEndian.PutUint16(rxMsg[42:44], 40) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 236 | logger.Debug("cc-corrected-omci-message: trailer len inserted") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 237 | } |
| 238 | } else { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 239 | logger.Errorw("received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 240 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy) |
| 244 | if packet == nil { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 245 | logger.Errorw("omci-message could not be decoded", log.Fields{"deviceID": oo.deviceID}) |
| 246 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 247 | } |
| 248 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 249 | if omciLayer == nil { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 250 | logger.Errorw("omci-message could not decode omci layer", log.Fields{"deviceID": oo.deviceID}) |
| 251 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 252 | } |
| 253 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 254 | if !ok { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 255 | logger.Errorw("omci-message could not assign omci layer", log.Fields{"deviceID": oo.deviceID}) |
| 256 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 257 | } |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 258 | logger.Debugw("omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 259 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier}) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 260 | if byte(omciMsg.MessageType)&me.AK == 0 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 261 | // Not a response |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 262 | logger.Debug("RxMsg is no Omci Response Message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 263 | if omciMsg.TransactionID == 0 { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 264 | return oo.receiveOnuMessage(ctx, omciMsg) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 265 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 266 | logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 267 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
| 268 | "deviceID": oo.deviceID}) |
| 269 | 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] | 270 | |
| 271 | } |
| 272 | //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester") |
| 273 | oo.mutexRxSchedMap.Lock() |
| 274 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
| 275 | if ok && rxCallbackEntry.cbFunction != nil { |
| 276 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 277 | // how to react on erroneous frame reception, maybe can simply be ignored |
| 278 | go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel) |
| 279 | // having posted the response the request is regarded as 'done' |
| 280 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 281 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 282 | } else { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 283 | oo.mutexRxSchedMap.Unlock() |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 284 | logger.Errorw("omci-message-response for not registered transCorrId", log.Fields{"deviceID": oo.deviceID}) |
| 285 | 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] | 286 | } |
| 287 | |
| 288 | return nil |
| 289 | /* py code was: |
| 290 | Receive and OMCI message from the proxy channel to the OLT. |
| 291 | |
| 292 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 293 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 294 | """ |
| 295 | if not self.enabled: |
| 296 | return |
| 297 | |
| 298 | try: |
| 299 | now = arrow.utcnow() |
| 300 | d = None |
| 301 | |
| 302 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 303 | # save the current value of the entity_id_to_class_map, then |
| 304 | # replace it with our custom one before decode, and then finally |
| 305 | # restore it later. Tried other ways but really made the code messy. |
| 306 | saved_me_map = omci_entities.entity_id_to_class_map |
| 307 | omci_entities.entity_id_to_class_map = self._me_map |
| 308 | |
| 309 | try: |
| 310 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 311 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 312 | except KeyError as e: |
| 313 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 314 | 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] | 315 | rx_frame = self._decode_unknown_me(msg) |
| 316 | self._rx_unknown_me += 1 |
| 317 | |
| 318 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 319 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 320 | return |
| 321 | |
| 322 | finally: |
| 323 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 324 | |
| 325 | rx_tid = rx_frame.fields['transaction_id'] |
| 326 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 327 | 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] | 328 | # Filter the Test Result frame and route through receive onu |
| 329 | # message method. |
| 330 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 331 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 332 | return self._receive_onu_message(rx_frame) |
| 333 | |
| 334 | # Previously unreachable if this is the very first round-trip Rx or we |
| 335 | # have been running consecutive errors |
| 336 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 337 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 338 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 339 | |
| 340 | self._rx_frames += 1 |
| 341 | self._consecutive_errors = 0 |
| 342 | |
| 343 | try: |
| 344 | high_priority = self._tid_is_high_priority(rx_tid) |
| 345 | index = self._get_priority_index(high_priority) |
| 346 | |
| 347 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 348 | last_tx_tuple = self._tx_request[index] |
| 349 | |
| 350 | if last_tx_tuple is None or \ |
| 351 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 352 | # Possible late Rx on a message that timed-out |
| 353 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 354 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 355 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 356 | self._rx_unknown_tid += 1 |
| 357 | self._rx_late += 1 |
| 358 | return |
| 359 | |
| 360 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 361 | if dc is not None and not dc.cancelled and not dc.called: |
| 362 | dc.cancel() |
| 363 | |
| 364 | _secs = self._update_rx_tx_stats(now, ts) |
| 365 | |
| 366 | # Late arrival already serviced by a timeout? |
| 367 | if d.called: |
| 368 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 369 | 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] | 370 | return |
| 371 | |
| 372 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 373 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 374 | if d is not None: |
| 375 | return d.errback(failure.Failure(e)) |
| 376 | return |
| 377 | |
| 378 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 379 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 380 | tx_tid = tx_frame.fields['transaction_id']) |
| 381 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 382 | |
| 383 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 384 | self._rx_response[index] = rx_frame |
| 385 | d.callback(rx_frame) |
| 386 | |
| 387 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 388 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 389 | */ |
| 390 | } |
| 391 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 392 | /* |
| 393 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 394 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 395 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 396 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 397 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 398 | |
| 399 | //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] | 400 | func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 401 | receiveCallbackPair callbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 402 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 403 | logger.Debugw("register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 404 | // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ... |
| 405 | oo.mutexRxSchedMap.Lock() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 406 | oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 407 | oo.mutexRxSchedMap.Unlock() |
| 408 | |
| 409 | //just use a simple list for starting - might need some more effort, especially for multi source write access |
| 410 | omciTxRequest := omciTransferStructure{ |
| 411 | txFrame, |
| 412 | timeout, |
| 413 | retry, |
| 414 | highPrio, |
| 415 | } |
| 416 | oo.mutexTxQueue.Lock() |
| 417 | oo.txQueue.PushBack(omciTxRequest) // enqueue |
| 418 | oo.mutexTxQueue.Unlock() |
| 419 | |
| 420 | // for first test just bypass and send directly: |
| 421 | go oo.sendNextRequest(ctx) |
| 422 | return nil |
| 423 | } |
| 424 | |
| 425 | //Pull next tx request and send it |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 426 | func (oo *omciCC) sendNextRequest(ctx context.Context) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 427 | // return errors.New("sendNextRequest unimplemented") |
| 428 | |
| 429 | // just try to get something transferred !! |
| 430 | // avoid accessing the txQueue from parallel send requests |
| 431 | // block parallel omci send requests at least until SendIAP is 'committed' |
| 432 | // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed |
| 433 | oo.mutexTxQueue.Lock() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 434 | defer oo.mutexTxQueue.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 435 | for oo.txQueue.Len() > 0 { |
| 436 | queueElement := oo.txQueue.Front() // First element |
| 437 | omciTxRequest := queueElement.Value.(omciTransferStructure) |
| 438 | /* compare olt device handler code: |
| 439 | func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 440 | logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 441 | var deviceType string |
| 442 | var deviceID string |
| 443 | var proxyDeviceID string |
| 444 | |
| 445 | onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId) |
| 446 | |
| 447 | if onuInCache, ok := dh.onus.Load(onuKey); !ok { |
| 448 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 449 | logger.Debugw("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] | 450 | ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT) |
| 451 | kwargs := make(map[string]interface{}) |
| 452 | kwargs["onu_id"] = omciInd.OnuId |
| 453 | kwargs["parent_port_no"] = ponPort |
| 454 | |
| 455 | onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs) |
| 456 | if err != nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 457 | logger.Errorw("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] | 458 | return |
| 459 | } |
| 460 | deviceType = onuDevice.Type |
| 461 | deviceID = onuDevice.Id |
| 462 | proxyDeviceID = onuDevice.ProxyAddress.DeviceId |
| 463 | //if not exist in cache, then add to cache. |
| 464 | dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID)) |
| 465 | } else { |
| 466 | //found in cache |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 467 | logger.Debugw("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] | 468 | deviceType = onuInCache.(*OnuDevice).deviceType |
| 469 | deviceID = onuInCache.(*OnuDevice).deviceID |
| 470 | proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID |
| 471 | } |
| 472 | */ |
| 473 | /* and compare onu_adapter py code: |
| 474 | omci_msg = InterAdapterOmciMessage( |
| 475 | message=bytes(frame), |
| 476 | proxy_address=self._proxy_address, |
| 477 | connect_status=self._device.connect_status) |
| 478 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 479 | 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] | 480 | |
| 481 | yield self._adapter_proxy.send_inter_adapter_message( |
| 482 | msg=omci_msg, |
| 483 | type=InterAdapterMessageType.OMCI_REQUEST, |
| 484 | from_adapter=self._device.type, |
| 485 | to_adapter=self._proxy_address.device_type, |
| 486 | to_device_id=self._device_id, |
| 487 | proxy_device_id=self._proxy_address.device_id |
| 488 | ) |
| 489 | */ |
| 490 | device, err := oo.coreProxy.GetDevice(ctx, |
| 491 | oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child |
| 492 | if err != nil || device == nil { |
| 493 | /*TODO: needs to handle error scenarios */ |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 494 | logger.Errorw("Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 495 | "ChildId": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 496 | return fmt.Errorf("failed to fetch device %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 497 | } |
| 498 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 499 | logger.Debugw("omci-message-sending", log.Fields{"fromDeviceType": oo.pBaseDeviceHandler.DeviceType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 500 | "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType, |
| 501 | "onuDeviceID": oo.deviceID, "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID}) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 502 | logger.Debugw("omci-message-to-send:", |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 503 | log.Fields{"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame)}) |
| 504 | |
| 505 | omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame} |
| 506 | if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg, |
| 507 | ic.InterAdapterMessageType_OMCI_REQUEST, |
| 508 | //fromType,toType,toDevId, ProxyDevId |
| 509 | oo.pBaseDeviceHandler.DeviceType, oo.pBaseDeviceHandler.ProxyAddressType, |
| 510 | oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 511 | logger.Errorw("send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 512 | return sendErr |
| 513 | } |
| 514 | oo.txQueue.Remove(queueElement) // Dequeue |
| 515 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 516 | return nil |
| 517 | } |
| 518 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 519 | func (oo *omciCC) getNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 520 | var next uint16 |
| 521 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 522 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 523 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 524 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 525 | if oo.hpTid < 0x8000 { |
| 526 | oo.hpTid = 0x8000 |
| 527 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 528 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 529 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 530 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 531 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 532 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 533 | if oo.tid >= 0x8000 { |
| 534 | oo.tid = 1 |
| 535 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 536 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 537 | } |
| 538 | return next |
| 539 | } |
| 540 | |
| 541 | // ################################################################################### |
| 542 | // # utility methods provided to work on OMCI messages |
| 543 | func serialize(msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) { |
| 544 | omciLayer := &omci.OMCI{ |
| 545 | TransactionID: tid, |
| 546 | MessageType: msgType, |
| 547 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 548 | return serializeOmciLayer(omciLayer, request) |
| 549 | } |
| 550 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 551 | func serializeOmciLayer(aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 552 | var options gopacket.SerializeOptions |
| 553 | options.FixLengths = true |
| 554 | |
| 555 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 556 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 557 | if err != nil { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 558 | logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 559 | return nil, err |
| 560 | } |
| 561 | return buffer.Bytes(), nil |
| 562 | } |
| 563 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 564 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 565 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 566 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 567 | hex.Encode(dst, omciPkt) |
| 568 | return dst, nil |
| 569 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 570 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 571 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 572 | //supply a response handler for omci response messages to be transferred to the requested FSM |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 573 | func (oo *omciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 574 | |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 575 | logger.Debugw("omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType, |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 576 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 577 | |
| 578 | if oo.pOnuDeviceEntry == nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 579 | logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 580 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 581 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 585 | // 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] | 586 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 587 | Type: OMCI, |
| 588 | Data: OmciMessage{ |
| 589 | OmciMsg: omciMsg, |
| 590 | OmciPacket: packet, |
| 591 | }, |
| 592 | } |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 593 | //logger.Debugw("Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 594 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 595 | |
| 596 | return nil |
| 597 | } |
| 598 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 599 | func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 600 | |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 601 | logger.Debugw("send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 602 | request := &omci.MibResetRequest{ |
| 603 | MeBasePacket: omci.MeBasePacket{ |
| 604 | EntityClass: me.OnuDataClassID, |
| 605 | }, |
| 606 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 607 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 608 | pkt, err := serialize(omci.MibResetRequestType, request, tid) |
| 609 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 610 | logger.Errorw("Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 611 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 612 | return err |
| 613 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 614 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 615 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 616 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 617 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 618 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 619 | } |
| 620 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 621 | func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 622 | logger.Debugw("send Reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 623 | request := &omci.RebootRequest{ |
| 624 | MeBasePacket: omci.MeBasePacket{ |
| 625 | EntityClass: me.OnuGClassID, |
| 626 | }, |
| 627 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 628 | tid := oo.getNextTid(highPrio) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 629 | pkt, err := serialize(omci.RebootRequestType, request, tid) |
| 630 | if err != nil { |
| 631 | logger.Errorw("Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 632 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 633 | return err |
| 634 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 635 | omciRxCallbackPair := callbackPair{ |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 636 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 637 | cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 638 | } |
| 639 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 640 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 641 | if err != nil { |
| 642 | logger.Errorw("Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 643 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 644 | return err |
| 645 | } |
| 646 | err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel) |
| 647 | if err != nil { |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 648 | logger.Errorw("aborting ONU Reboot!", log.Fields{ |
| 649 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 650 | return err |
| 651 | } |
| 652 | return nil |
| 653 | } |
| 654 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 655 | func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 656 | logger.Debugw("send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 657 | request := &omci.MibUploadRequest{ |
| 658 | MeBasePacket: omci.MeBasePacket{ |
| 659 | EntityClass: me.OnuDataClassID, |
| 660 | }, |
| 661 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 662 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 663 | pkt, err := serialize(omci.MibUploadRequestType, request, tid) |
| 664 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 665 | logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 666 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 667 | return err |
| 668 | } |
| 669 | oo.uploadSequNo = 0 |
| 670 | oo.uploadNoOfCmds = 0 |
| 671 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 672 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 673 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 674 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 675 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 676 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 677 | } |
| 678 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 679 | func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 680 | logger.Debugw("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] | 681 | request := &omci.MibUploadNextRequest{ |
| 682 | MeBasePacket: omci.MeBasePacket{ |
| 683 | EntityClass: me.OnuDataClassID, |
| 684 | }, |
| 685 | CommandSequenceNumber: oo.uploadSequNo, |
| 686 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 687 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 688 | pkt, err := serialize(omci.MibUploadNextRequestType, request, tid) |
| 689 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 690 | logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 691 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 692 | return err |
| 693 | } |
| 694 | oo.uploadSequNo++ |
| 695 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 696 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 697 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 698 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 699 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 700 | return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 703 | func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 704 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 705 | logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 706 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 707 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 708 | meParams := me.ParamData{ |
| 709 | EntityID: galEthernetEID, |
| 710 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 711 | } |
| 712 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 713 | if omciErr.GetError() == nil { |
| 714 | //all setByCreate parameters already set, no default option required ... |
| 715 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 716 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 717 | logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 718 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 719 | return nil |
| 720 | } |
| 721 | |
| 722 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 723 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 724 | logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 725 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 726 | return nil |
| 727 | } |
| 728 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 729 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 730 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 731 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 732 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 733 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 734 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 735 | logger.Errorw("Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 736 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 737 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 738 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 739 | logger.Debug("send GalEnetProfile-Create-msg done") |
| 740 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 741 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 742 | logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 743 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 744 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 745 | } |
| 746 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 747 | // 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] | 748 | func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 749 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 750 | logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 751 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 752 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 753 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 754 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 755 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 756 | // read ONU-2G from DB ???? //TODO!!! |
| 757 | meParams := me.ParamData{ |
| 758 | EntityID: 0, |
| 759 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 760 | } |
| 761 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 762 | if omciErr.GetError() == nil { |
| 763 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 764 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 765 | logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 766 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 767 | return nil |
| 768 | } |
| 769 | |
| 770 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 771 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 772 | logger.Errorw("Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 773 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 774 | return nil |
| 775 | } |
| 776 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 777 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 778 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 779 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 780 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 781 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 782 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 783 | logger.Errorw("Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 784 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 785 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 786 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 787 | logger.Debug("send ONU2-G-Set-msg done") |
| 788 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 789 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 790 | logger.Errorw("Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 791 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 792 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 793 | } |
| 794 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 795 | func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context, |
| 796 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 797 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 798 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 799 | logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 800 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 801 | |
| 802 | meParams := me.ParamData{ |
| 803 | EntityID: instID, |
| 804 | Attributes: me.AttributeValueMap{ |
| 805 | "Priority": 0x8000, |
| 806 | "MaxAge": 20 * 256, //20s |
| 807 | "HelloTime": 2 * 256, //2s |
| 808 | "ForwardDelay": 15 * 256, //15s |
| 809 | //note: DynamicFilteringAgeingTime is taken from omci lib default as |
| 810 | // which is obviously different from default value used in python lib, |
| 811 | // where the value seems to be 0 (ONU defined) - to be considered in case of test artifacts ... |
| 812 | }, |
| 813 | } |
| 814 | |
| 815 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 816 | if omciErr.GetError() == nil { |
| 817 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 818 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 819 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 820 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 821 | logger.Errorw("Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 822 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 823 | return nil |
| 824 | } |
| 825 | |
| 826 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 827 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 828 | logger.Errorw("Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 829 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 830 | return nil |
| 831 | } |
| 832 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 833 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 834 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 835 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 836 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 837 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 838 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 839 | logger.Errorw("Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 840 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 841 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 842 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 843 | logger.Debug("send MBSP-Create-msg done") |
| 844 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 845 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 846 | logger.Errorw("Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 847 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 848 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 851 | func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context, |
| 852 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 853 | tid := oo.getNextTid(highPrio) |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 854 | instID := macBridgePortAniEID + aPUniPort.entityID |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 855 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 856 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 857 | |
| 858 | meParams := me.ParamData{ |
| 859 | EntityID: instID, |
| 860 | Attributes: me.AttributeValueMap{ |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 861 | "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo), |
| 862 | "PortNum": aPUniPort.macBpNo, |
| 863 | "TpType": uint8(aPUniPort.portType), |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 864 | "TpPointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 865 | }, |
| 866 | } |
| 867 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 868 | if omciErr.GetError() == nil { |
| 869 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 870 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 871 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 872 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 873 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 874 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 875 | return nil |
| 876 | } |
| 877 | |
| 878 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 879 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 880 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 881 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 882 | return nil |
| 883 | } |
| 884 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 885 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 886 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 887 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 888 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 889 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 890 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 891 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 892 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 893 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 894 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 895 | logger.Debug("send MBPCD-Create-msg done") |
| 896 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 897 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 898 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 899 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 900 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 901 | } |
| 902 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 903 | func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context, |
| 904 | aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 905 | tid := oo.getNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 906 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 907 | instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 908 | logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 909 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 910 | |
| 911 | // compare python adapter code WA VOL-1311: this is not done here! |
| 912 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 913 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 914 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 915 | if aPUniPort.portType == uniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 916 | assType = uint8(10) // for VEIP |
| 917 | } |
| 918 | meParams := me.ParamData{ |
| 919 | EntityID: instID, |
| 920 | Attributes: me.AttributeValueMap{ |
| 921 | "AssociationType": assType, |
Himani Chawla | 26e555c | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 922 | "AssociatedMePointer": aPUniPort.entityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 923 | }, |
| 924 | } |
| 925 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 926 | if omciErr.GetError() == nil { |
| 927 | //all setByCreate parameters already set, no default option required ... |
| 928 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 929 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 930 | logger.Errorw("Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 931 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 932 | return nil |
| 933 | } |
| 934 | |
| 935 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 936 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 937 | logger.Errorw("Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 938 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 939 | return nil |
| 940 | } |
| 941 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 942 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 943 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 944 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 945 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 946 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 947 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 948 | logger.Errorw("Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 949 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 950 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 951 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 952 | logger.Debug("send EVTOCD-Create-msg done") |
| 953 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 954 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 955 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 956 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 957 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 958 | } |
| 959 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 960 | func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 961 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 962 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 963 | logger.Debugw("send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 964 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 965 | |
| 966 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 967 | meParams := me.ParamData{ |
| 968 | EntityID: 0, |
| 969 | Attributes: requestedAttributes, |
| 970 | } |
| 971 | meInstance, omciErr := me.NewOnuG(meParams) |
| 972 | if omciErr.GetError() == nil { |
| 973 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 974 | if err != nil { |
| 975 | logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 976 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 977 | return nil |
| 978 | } |
| 979 | |
| 980 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 981 | if err != nil { |
| 982 | logger.Errorw("Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 983 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 984 | return nil |
| 985 | } |
| 986 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 987 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 988 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 989 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 990 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 991 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 992 | if err != nil { |
| 993 | logger.Errorw("Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 994 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 995 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 996 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 997 | logger.Debug("send ONU-G-Set-msg done") |
| 998 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 999 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1000 | logger.Errorw("Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1001 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1002 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1003 | } |
| 1004 | |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1005 | func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
| 1006 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 1007 | tid := oo.getNextTid(highPrio) |
| 1008 | logger.Debugw("send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1009 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1010 | |
| 1011 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1012 | meParams := me.ParamData{ |
| 1013 | EntityID: aInstNo, |
| 1014 | Attributes: requestedAttributes, |
| 1015 | } |
| 1016 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1017 | if omciErr.GetError() == nil { |
| 1018 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1019 | if err != nil { |
| 1020 | logger.Errorw("Cannot encode PPTPEthUni instance for set", log.Fields{ |
| 1021 | "Err": err, "device-id": oo.deviceID}) |
| 1022 | return nil |
| 1023 | } |
| 1024 | |
| 1025 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1026 | if err != nil { |
| 1027 | logger.Errorw("Cannot serialize PPTPEthUni-Set", log.Fields{ |
| 1028 | "Err": err, "device-id": oo.deviceID}) |
| 1029 | return nil |
| 1030 | } |
| 1031 | |
| 1032 | omciRxCallbackPair := callbackPair{ |
| 1033 | cbKey: tid, |
| 1034 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1035 | } |
| 1036 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1037 | if err != nil { |
| 1038 | logger.Errorw("Cannot send PPTPEthUni-Set", log.Fields{ |
| 1039 | "Err": err, "device-id": oo.deviceID}) |
| 1040 | return nil |
| 1041 | } |
| 1042 | logger.Debug("send PPTPEthUni-Set-msg done") |
| 1043 | return meInstance |
| 1044 | } |
| 1045 | logger.Errorw("Cannot generate PPTPEthUni", log.Fields{ |
| 1046 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1047 | return nil |
| 1048 | } |
| 1049 | |
| 1050 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1051 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1052 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1053 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1054 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1055 | logger.Debugw("send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1056 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1057 | |
| 1058 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1059 | meParams := me.ParamData{ |
| 1060 | EntityID: aInstNo, |
| 1061 | Attributes: requestedAttributes, |
| 1062 | } |
| 1063 | meInstance, omciErr := me.NewUniG(meParams) |
| 1064 | if omciErr.GetError() == nil { |
| 1065 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1066 | if err != nil { |
| 1067 | logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1068 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1069 | return nil |
| 1070 | } |
| 1071 | |
| 1072 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1073 | if err != nil { |
| 1074 | logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1075 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1076 | return nil |
| 1077 | } |
| 1078 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1079 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1080 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1081 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1082 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1083 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1084 | if err != nil { |
| 1085 | logger.Errorw("Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1086 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1087 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1088 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1089 | logger.Debug("send UNI-G-Set-msg done") |
| 1090 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1091 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1092 | logger.Errorw("Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1093 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1094 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1095 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1096 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1097 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1098 | func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1099 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1100 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1101 | logger.Debugw("send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1102 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1103 | |
| 1104 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1105 | meParams := me.ParamData{ |
| 1106 | EntityID: aInstNo, |
| 1107 | Attributes: requestedAttributes, |
| 1108 | } |
| 1109 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1110 | if omciErr.GetError() == nil { |
| 1111 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1112 | if err != nil { |
| 1113 | logger.Errorw("Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1114 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1115 | return nil |
| 1116 | } |
| 1117 | |
| 1118 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1119 | if err != nil { |
| 1120 | logger.Errorw("Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1121 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1122 | return nil |
| 1123 | } |
| 1124 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1125 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1126 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1127 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1128 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1129 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1130 | if err != nil { |
| 1131 | logger.Errorw("Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1132 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1133 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1134 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1135 | logger.Debug("send VEIP-Set-msg done") |
| 1136 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1137 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1138 | logger.Errorw("Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1139 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1140 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1141 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1142 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1143 | func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1144 | timeout int, highPrio bool) *me.ManagedEntity { |
| 1145 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1146 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1147 | logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1148 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1149 | |
| 1150 | meParams := me.ParamData{ |
| 1151 | EntityID: entityID, |
| 1152 | Attributes: requestedAttributes, |
| 1153 | } |
| 1154 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1155 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1156 | meClassIDName := meInstance.GetName() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1157 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid)) |
| 1158 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1159 | logger.Errorf("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] | 1160 | return nil |
| 1161 | } |
| 1162 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1163 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1164 | logger.Errorw("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] | 1165 | return nil |
| 1166 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1167 | omciRxCallbackPair := callbackPair{ |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1168 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1169 | cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1170 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1171 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1172 | if err != nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1173 | logger.Errorw("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] | 1174 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1175 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1176 | logger.Debugw("send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1177 | return meInstance |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1178 | } |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1179 | logger.Errorw("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] | 1180 | return nil |
| 1181 | } |
| 1182 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1183 | func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1184 | aInstID uint16, rxChan chan Message) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1185 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1186 | logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1187 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1188 | |
| 1189 | meParams := me.ParamData{ |
| 1190 | EntityID: aInstID, |
| 1191 | Attributes: me.AttributeValueMap{}, |
| 1192 | } |
| 1193 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1194 | if omciErr.GetError() == nil { |
| 1195 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1196 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1197 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1198 | if err != nil { |
| 1199 | logger.Errorw("Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1200 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1201 | return nil |
| 1202 | } |
| 1203 | |
| 1204 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1205 | if err != nil { |
| 1206 | logger.Errorw("Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1207 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1208 | return nil |
| 1209 | } |
| 1210 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1211 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1212 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1213 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1214 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1215 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1216 | if err != nil { |
| 1217 | logger.Errorw("Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1218 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1219 | return nil |
| 1220 | } |
| 1221 | logger.Debug("send .1pMapper-create-msg done") |
| 1222 | return meInstance |
| 1223 | } |
| 1224 | logger.Errorw("Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1225 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1226 | return nil |
| 1227 | } |
| 1228 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1229 | func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1230 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1231 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1232 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1233 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1234 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1235 | |
| 1236 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1237 | if omciErr.GetError() == nil { |
| 1238 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1239 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1240 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1241 | if err != nil { |
| 1242 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1243 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1244 | return nil |
| 1245 | } |
| 1246 | |
| 1247 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1248 | if err != nil { |
| 1249 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1250 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1251 | return nil |
| 1252 | } |
| 1253 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1254 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1255 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1256 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1257 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1258 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1259 | if err != nil { |
| 1260 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1261 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1262 | return nil |
| 1263 | } |
| 1264 | logger.Debug("send MBPCD-Create-msg done") |
| 1265 | return meInstance |
| 1266 | } |
| 1267 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1268 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1269 | return nil |
| 1270 | } |
| 1271 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1272 | func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1273 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1274 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1275 | logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1276 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1277 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1278 | |
| 1279 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1280 | if omciErr.GetError() == nil { |
| 1281 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1282 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1283 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1284 | if err != nil { |
| 1285 | logger.Errorw("Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1286 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1287 | return nil |
| 1288 | } |
| 1289 | |
| 1290 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1291 | if err != nil { |
| 1292 | logger.Errorw("Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1293 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1294 | return nil |
| 1295 | } |
| 1296 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1297 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1298 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1299 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1300 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1301 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1302 | if err != nil { |
| 1303 | logger.Errorw("Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1304 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1305 | return nil |
| 1306 | } |
| 1307 | logger.Debug("send GemNCTP-Create-msg done") |
| 1308 | return meInstance |
| 1309 | } |
| 1310 | logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1311 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1312 | return nil |
| 1313 | } |
| 1314 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1315 | func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1316 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1317 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1318 | logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1319 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1320 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1321 | |
| 1322 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1323 | if omciErr.GetError() == nil { |
| 1324 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1325 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1326 | omci.TransactionID(tid)) |
| 1327 | if err != nil { |
| 1328 | logger.Errorw("Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1329 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1330 | return nil |
| 1331 | } |
| 1332 | |
| 1333 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1334 | if err != nil { |
| 1335 | logger.Errorw("Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1336 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1337 | return nil |
| 1338 | } |
| 1339 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1340 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1341 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1342 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1343 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1344 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1345 | if err != nil { |
| 1346 | logger.Errorw("Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1347 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1348 | return nil |
| 1349 | } |
| 1350 | logger.Debug("send GemIwTp-Create-msg done") |
| 1351 | return meInstance |
| 1352 | } |
| 1353 | logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1354 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1355 | return nil |
| 1356 | } |
| 1357 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1358 | func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1359 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1360 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1361 | logger.Debugw("send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1362 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1363 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1364 | |
| 1365 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1366 | if omciErr.GetError() == nil { |
| 1367 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1368 | if err != nil { |
| 1369 | logger.Errorw("Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1370 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1371 | return nil |
| 1372 | } |
| 1373 | |
| 1374 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1375 | if err != nil { |
| 1376 | logger.Errorw("Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1377 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1378 | return nil |
| 1379 | } |
| 1380 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1381 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1382 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1383 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1384 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1385 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1386 | if err != nil { |
| 1387 | logger.Errorw("Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1388 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1389 | return nil |
| 1390 | } |
| 1391 | logger.Debug("send TCont-set msg done") |
| 1392 | return meInstance |
| 1393 | } |
| 1394 | logger.Errorw("Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1395 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1396 | return nil |
| 1397 | } |
| 1398 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1399 | func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1400 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1401 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1402 | logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1403 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1404 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1405 | |
| 1406 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1407 | if omciErr.GetError() == nil { |
| 1408 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1409 | if err != nil { |
| 1410 | logger.Errorw("Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1411 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1412 | return nil |
| 1413 | } |
| 1414 | |
| 1415 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1416 | if err != nil { |
| 1417 | logger.Errorw("Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1418 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1419 | return nil |
| 1420 | } |
| 1421 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1422 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1423 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1424 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1425 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1426 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1427 | if err != nil { |
| 1428 | logger.Errorw("Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1429 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1430 | return nil |
| 1431 | } |
| 1432 | logger.Debug("send PrioQueue-set msg done") |
| 1433 | return meInstance |
| 1434 | } |
| 1435 | logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1436 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1437 | return nil |
| 1438 | } |
| 1439 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1440 | func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1441 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1442 | tid := oo.getNextTid(highPrio) |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1443 | logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1444 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1445 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1446 | |
| 1447 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1448 | if omciErr.GetError() == nil { |
| 1449 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1450 | if err != nil { |
| 1451 | logger.Errorw("Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1452 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1453 | return nil |
| 1454 | } |
| 1455 | |
| 1456 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1457 | if err != nil { |
| 1458 | logger.Errorw("Cannot serialize 1PMapper set", 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 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1463 | omciRxCallbackPair := callbackPair{ |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1464 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1465 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1466 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1467 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1468 | if err != nil { |
| 1469 | logger.Errorw("Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1470 | "Err": err, "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1471 | return nil |
| 1472 | } |
| 1473 | logger.Debug("send 1PMapper-set msg done") |
| 1474 | return meInstance |
| 1475 | } |
| 1476 | logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1477 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1478 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1479 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1480 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1481 | func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1482 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1483 | tid := oo.getNextTid(highPrio) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1484 | logger.Debugw("send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1485 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1486 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1487 | |
| 1488 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1489 | if omciErr.GetError() == nil { |
| 1490 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1491 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1492 | omci.TransactionID(tid)) |
| 1493 | if err != nil { |
| 1494 | logger.Errorw("Cannot encode VTFD for create", log.Fields{ |
| 1495 | "Err": err, "device-id": oo.deviceID}) |
| 1496 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1497 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1498 | // (relevant to all used sendXX() methods and their error conditions) |
| 1499 | return nil |
| 1500 | } |
| 1501 | |
| 1502 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1503 | if err != nil { |
| 1504 | logger.Errorw("Cannot serialize VTFD create", log.Fields{ |
| 1505 | "Err": err, "device-id": oo.deviceID}) |
| 1506 | return nil |
| 1507 | } |
| 1508 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1509 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1510 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1511 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1512 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1513 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1514 | if err != nil { |
| 1515 | logger.Errorw("Cannot send VTFD create", log.Fields{ |
| 1516 | "Err": err, "device-id": oo.deviceID}) |
| 1517 | return nil |
| 1518 | } |
| 1519 | logger.Debug("send VTFD-Create-msg done") |
| 1520 | return meInstance |
| 1521 | } |
| 1522 | logger.Errorw("Cannot generate VTFD Instance", log.Fields{ |
| 1523 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1524 | return nil |
| 1525 | } |
| 1526 | |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1527 | func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
| 1528 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1529 | tid := oo.getNextTid(highPrio) |
| 1530 | logger.Debugw("send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1531 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1532 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1533 | |
| 1534 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1535 | if omciErr.GetError() == nil { |
| 1536 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, |
| 1537 | omci.TransactionID(tid)) |
| 1538 | if err != nil { |
| 1539 | logger.Errorw("Cannot encode VTFD for set", log.Fields{ |
| 1540 | "Err": err, "device-id": oo.deviceID}) |
| 1541 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1542 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1543 | // (relevant to all used sendXX() methods and their error conditions) |
| 1544 | return nil |
| 1545 | } |
| 1546 | |
| 1547 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1548 | if err != nil { |
| 1549 | logger.Errorw("Cannot serialize VTFD set", log.Fields{ |
| 1550 | "Err": err, "device-id": oo.deviceID}) |
| 1551 | return nil |
| 1552 | } |
| 1553 | |
| 1554 | omciRxCallbackPair := callbackPair{ |
| 1555 | cbKey: tid, |
| 1556 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1557 | } |
| 1558 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1559 | if err != nil { |
| 1560 | logger.Errorw("Cannot send VTFD set", log.Fields{ |
| 1561 | "Err": err, "device-id": oo.deviceID}) |
| 1562 | return nil |
| 1563 | } |
| 1564 | logger.Debug("send VTFD-Set-msg done") |
| 1565 | return meInstance |
| 1566 | } |
| 1567 | logger.Errorw("Cannot generate VTFD Instance", log.Fields{ |
| 1568 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1569 | return nil |
| 1570 | } |
| 1571 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1572 | func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1573 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1574 | tid := oo.getNextTid(highPrio) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1575 | logger.Debugw("send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1576 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1577 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1578 | |
| 1579 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1580 | if omciErr.GetError() == nil { |
| 1581 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1582 | if err != nil { |
| 1583 | logger.Errorw("Cannot encode EVTOCD for set", log.Fields{ |
| 1584 | "Err": err, "device-id": oo.deviceID}) |
| 1585 | return nil |
| 1586 | } |
| 1587 | |
| 1588 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1589 | if err != nil { |
| 1590 | logger.Errorw("Cannot serialize EVTOCD set", log.Fields{ |
| 1591 | "Err": err, "device-id": oo.deviceID}) |
| 1592 | return nil |
| 1593 | } |
| 1594 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1595 | omciRxCallbackPair := callbackPair{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1596 | cbKey: tid, |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1597 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1598 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1599 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1600 | if err != nil { |
| 1601 | logger.Errorw("Cannot send EVTOCD set", log.Fields{ |
| 1602 | "Err": err, "device-id": oo.deviceID}) |
| 1603 | return nil |
| 1604 | } |
| 1605 | logger.Debug("send EVTOCD-set msg done") |
| 1606 | return meInstance |
| 1607 | } |
| 1608 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
| 1609 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1610 | return nil |
| 1611 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1612 | |
| 1613 | func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
| 1614 | rxChan chan Message, aInstID uint16) *me.ManagedEntity { |
| 1615 | tid := oo.getNextTid(highPrio) |
| 1616 | logger.Debugw("send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 1617 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1618 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1619 | |
| 1620 | meParams := me.ParamData{EntityID: aInstID} |
| 1621 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 1622 | if omciErr.GetError() == nil { |
| 1623 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 1624 | omci.TransactionID(tid)) |
| 1625 | if err != nil { |
| 1626 | logger.Errorw("Cannot encode VTFD for delete", log.Fields{ |
| 1627 | "Err": err, "device-id": oo.deviceID}) |
| 1628 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1629 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1630 | // (relevant to all used sendXX() methods and their error conditions) |
| 1631 | return nil |
| 1632 | } |
| 1633 | |
| 1634 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1635 | if err != nil { |
| 1636 | logger.Errorw("Cannot serialize VTFD delete", log.Fields{ |
| 1637 | "Err": err, "device-id": oo.deviceID}) |
| 1638 | return nil |
| 1639 | } |
| 1640 | |
| 1641 | omciRxCallbackPair := callbackPair{ |
| 1642 | cbKey: tid, |
| 1643 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1644 | } |
| 1645 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1646 | if err != nil { |
| 1647 | logger.Errorw("Cannot send VTFD delete", log.Fields{ |
| 1648 | "Err": err, "device-id": oo.deviceID}) |
| 1649 | return nil |
| 1650 | } |
| 1651 | logger.Debug("send VTFD-Delete-msg done") |
| 1652 | return meInstance |
| 1653 | } |
| 1654 | logger.Errorw("Cannot generate VTFD Instance for delete", log.Fields{ |
| 1655 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1656 | return nil |
| 1657 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1658 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1659 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1660 | func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 1661 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1662 | tid := oo.getNextTid(highPrio) |
| 1663 | logger.Debugw("send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1664 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1665 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1666 | |
| 1667 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 1668 | if omciErr.GetError() == nil { |
| 1669 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 1670 | omci.AddDefaults(true)) |
| 1671 | if err != nil { |
| 1672 | logger.Errorw("Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1673 | return nil |
| 1674 | } |
| 1675 | |
| 1676 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1677 | if err != nil { |
| 1678 | logger.Errorw("Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1679 | return nil |
| 1680 | } |
| 1681 | |
| 1682 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1683 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1684 | } |
| 1685 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1686 | if err != nil { |
| 1687 | logger.Errorw("Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
| 1688 | return nil |
| 1689 | } |
| 1690 | logger.Debug("send MulticastGEMIWTP-create-msg done") |
| 1691 | return meInstance |
| 1692 | } |
| 1693 | logger.Errorw("Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 1694 | "device-id": oo.deviceID}) |
| 1695 | return nil |
| 1696 | } |
| 1697 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1698 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1699 | func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 1700 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1701 | tid := oo.getNextTid(highPrio) |
| 1702 | logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1703 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1704 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1705 | |
| 1706 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 1707 | if omciErr.GetError() == nil { |
| 1708 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 1709 | omci.AddDefaults(true)) |
| 1710 | if err != nil { |
| 1711 | logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
| 1712 | "device-id": oo.deviceID}) |
| 1713 | return nil |
| 1714 | } |
| 1715 | |
| 1716 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1717 | if err != nil { |
| 1718 | logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
| 1719 | "device-id": oo.deviceID}) |
| 1720 | return nil |
| 1721 | } |
| 1722 | |
| 1723 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1724 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1725 | } |
| 1726 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1727 | if err != nil { |
| 1728 | logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
| 1729 | "device-id": oo.deviceID}) |
| 1730 | return nil |
| 1731 | } |
| 1732 | logger.Debug("send MulticastOperationProfile-create-msg done") |
| 1733 | return meInstance |
| 1734 | } |
| 1735 | logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 1736 | "device-id": oo.deviceID}) |
| 1737 | return nil |
| 1738 | } |
| 1739 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1740 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1741 | func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
| 1742 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1743 | tid := oo.getNextTid(highPrio) |
| 1744 | logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1745 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1746 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1747 | |
| 1748 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 1749 | if omciErr.GetError() == nil { |
| 1750 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid), |
| 1751 | omci.AddDefaults(true)) |
| 1752 | if err != nil { |
| 1753 | logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
| 1754 | "device-id": oo.deviceID}) |
| 1755 | return nil |
| 1756 | } |
| 1757 | |
| 1758 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1759 | if err != nil { |
| 1760 | logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
| 1761 | "device-id": oo.deviceID}) |
| 1762 | return nil |
| 1763 | } |
| 1764 | |
| 1765 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1766 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1767 | } |
| 1768 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1769 | if err != nil { |
| 1770 | logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
| 1771 | "device-id": oo.deviceID}) |
| 1772 | return nil |
| 1773 | } |
| 1774 | logger.Debug("send MulticastOperationProfile-create-msg done") |
| 1775 | return meInstance |
| 1776 | } |
| 1777 | logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 1778 | "device-id": oo.deviceID}) |
| 1779 | return nil |
| 1780 | } |
| 1781 | |
mpagenko | fc4f56e | 2020-11-04 17:17:49 +0000 | [diff] [blame] | 1782 | // nolint: unused |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 1783 | func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
| 1784 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1785 | tid := oo.getNextTid(highPrio) |
| 1786 | logger.Debugw("send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 1787 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1788 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1789 | |
| 1790 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 1791 | if omciErr.GetError() == nil { |
| 1792 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid), |
| 1793 | omci.AddDefaults(true)) |
| 1794 | if err != nil { |
| 1795 | logger.Errorw("Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
| 1796 | "device-id": oo.deviceID}) |
| 1797 | return nil |
| 1798 | } |
| 1799 | |
| 1800 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1801 | if err != nil { |
| 1802 | logger.Errorw("Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
| 1803 | "device-id": oo.deviceID}) |
| 1804 | return nil |
| 1805 | } |
| 1806 | |
| 1807 | omciRxCallbackPair := callbackPair{cbKey: tid, |
| 1808 | cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1809 | } |
| 1810 | err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1811 | if err != nil { |
| 1812 | logger.Errorw("Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
| 1813 | "device-id": oo.deviceID}) |
| 1814 | return nil |
| 1815 | } |
| 1816 | logger.Debug("send MulticastSubConfigInfo-create-msg done") |
| 1817 | return meInstance |
| 1818 | } |
| 1819 | logger.Errorw("Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
| 1820 | "device-id": oo.deviceID}) |
| 1821 | return nil |
| 1822 | } |