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