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" |
| 28 | |
| 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 { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 114 | logger.Infow("init-omciCC", log.Fields{"deviceId": 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) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 198 | logger.Infow("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 { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +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() |
| 399 | for oo.txQueue.Len() > 0 { |
| 400 | queueElement := oo.txQueue.Front() // First element |
| 401 | omciTxRequest := queueElement.Value.(omciTransferStructure) |
| 402 | /* compare olt device handler code: |
| 403 | func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 404 | logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 405 | var deviceType string |
| 406 | var deviceID string |
| 407 | var proxyDeviceID string |
| 408 | |
| 409 | onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId) |
| 410 | |
| 411 | if onuInCache, ok := dh.onus.Load(onuKey); !ok { |
| 412 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 413 | 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] | 414 | ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT) |
| 415 | kwargs := make(map[string]interface{}) |
| 416 | kwargs["onu_id"] = omciInd.OnuId |
| 417 | kwargs["parent_port_no"] = ponPort |
| 418 | |
| 419 | onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs) |
| 420 | if err != nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 421 | 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] | 422 | return |
| 423 | } |
| 424 | deviceType = onuDevice.Type |
| 425 | deviceID = onuDevice.Id |
| 426 | proxyDeviceID = onuDevice.ProxyAddress.DeviceId |
| 427 | //if not exist in cache, then add to cache. |
| 428 | dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID)) |
| 429 | } else { |
| 430 | //found in cache |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 431 | 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] | 432 | deviceType = onuInCache.(*OnuDevice).deviceType |
| 433 | deviceID = onuInCache.(*OnuDevice).deviceID |
| 434 | proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID |
| 435 | } |
| 436 | */ |
| 437 | /* and compare onu_adapter py code: |
| 438 | omci_msg = InterAdapterOmciMessage( |
| 439 | message=bytes(frame), |
| 440 | proxy_address=self._proxy_address, |
| 441 | connect_status=self._device.connect_status) |
| 442 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 443 | 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] | 444 | |
| 445 | yield self._adapter_proxy.send_inter_adapter_message( |
| 446 | msg=omci_msg, |
| 447 | type=InterAdapterMessageType.OMCI_REQUEST, |
| 448 | from_adapter=self._device.type, |
| 449 | to_adapter=self._proxy_address.device_type, |
| 450 | to_device_id=self._device_id, |
| 451 | proxy_device_id=self._proxy_address.device_id |
| 452 | ) |
| 453 | */ |
| 454 | device, err := oo.coreProxy.GetDevice(ctx, |
| 455 | oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child |
| 456 | if err != nil || device == nil { |
| 457 | /*TODO: needs to handle error scenarios */ |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 458 | 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] | 459 | "ChildId": oo.deviceID}) |
| 460 | return errors.New("failed to fetch device") |
| 461 | } |
| 462 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 463 | logger.Debugw("omci-message-sending", log.Fields{"fromDeviceType": oo.pBaseDeviceHandler.DeviceType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 464 | "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType, |
| 465 | "onuDeviceID": oo.deviceID, "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID}) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 466 | logger.Debugw("omci-message-to-send:", |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 467 | log.Fields{"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame)}) |
| 468 | |
| 469 | omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame} |
| 470 | if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg, |
| 471 | ic.InterAdapterMessageType_OMCI_REQUEST, |
| 472 | //fromType,toType,toDevId, ProxyDevId |
| 473 | oo.pBaseDeviceHandler.DeviceType, oo.pBaseDeviceHandler.ProxyAddressType, |
| 474 | oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 475 | logger.Errorw("send omci request error", log.Fields{"error": sendErr}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 476 | return sendErr |
| 477 | } |
| 478 | oo.txQueue.Remove(queueElement) // Dequeue |
| 479 | } |
| 480 | oo.mutexTxQueue.Unlock() |
| 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, |
| 539 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "deviceId": 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{ |
| 543 | "deviceId": 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 | |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 564 | logger.Debugw("send MibReset-msg to:", log.Fields{"deviceId": 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{ |
| 574 | "Err": err, "deviceId": 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 | |
| 584 | func (oo *OmciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 585 | logger.Debugw("send MibUpload-msg to:", log.Fields{"deviceId": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 586 | request := &omci.MibUploadRequest{ |
| 587 | MeBasePacket: omci.MeBasePacket{ |
| 588 | EntityClass: me.OnuDataClassID, |
| 589 | }, |
| 590 | } |
| 591 | tid := oo.GetNextTid(highPrio) |
| 592 | pkt, err := serialize(omci.MibUploadRequestType, request, tid) |
| 593 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 594 | logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{ |
| 595 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 596 | return err |
| 597 | } |
| 598 | oo.uploadSequNo = 0 |
| 599 | oo.uploadNoOfCmds = 0 |
| 600 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 601 | omciRxCallbackPair := CallbackPair{ |
| 602 | cbKey: tid, |
| 603 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
| 604 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 605 | return oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 606 | } |
| 607 | |
| 608 | func (oo *OmciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 609 | logger.Debugw("send MibUploadNext-msg to:", log.Fields{"deviceId": oo.deviceID, "uploadSequNo": oo.uploadSequNo}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 610 | request := &omci.MibUploadNextRequest{ |
| 611 | MeBasePacket: omci.MeBasePacket{ |
| 612 | EntityClass: me.OnuDataClassID, |
| 613 | }, |
| 614 | CommandSequenceNumber: oo.uploadSequNo, |
| 615 | } |
| 616 | tid := oo.GetNextTid(highPrio) |
| 617 | pkt, err := serialize(omci.MibUploadNextRequestType, request, tid) |
| 618 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 619 | logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{ |
| 620 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 621 | return err |
| 622 | } |
| 623 | oo.uploadSequNo++ |
| 624 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 625 | omciRxCallbackPair := CallbackPair{ |
| 626 | cbKey: tid, |
| 627 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
| 628 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 629 | return oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 630 | } |
| 631 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 632 | func (oo *OmciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 633 | tid := oo.GetNextTid(highPrio) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 634 | logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 635 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 636 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 637 | meParams := me.ParamData{ |
| 638 | EntityID: galEthernetEID, |
| 639 | Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize}, |
| 640 | } |
| 641 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 642 | if omciErr.GetError() == nil { |
| 643 | //all setByCreate parameters already set, no default option required ... |
| 644 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 645 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 646 | logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{ |
| 647 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 648 | return nil |
| 649 | } |
| 650 | |
| 651 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 652 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 653 | logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{ |
| 654 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 655 | return nil |
| 656 | } |
| 657 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 658 | omciRxCallbackPair := CallbackPair{ |
| 659 | cbKey: tid, |
| 660 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
| 661 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 662 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 663 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 664 | logger.Errorw("Cannot send GalEnetProfile create", log.Fields{ |
| 665 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 666 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 667 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 668 | logger.Debug("send GalEnetProfile-Create-msg done") |
| 669 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 670 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 671 | logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{ |
| 672 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 673 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 676 | // 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] | 677 | func (oo *OmciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity { |
| 678 | tid := oo.GetNextTid(highPrio) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 679 | logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 680 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 681 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 682 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 683 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 684 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 685 | // read ONU-2G from DB ???? //TODO!!! |
| 686 | meParams := me.ParamData{ |
| 687 | EntityID: 0, |
| 688 | Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue}, |
| 689 | } |
| 690 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 691 | if omciErr.GetError() == nil { |
| 692 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 693 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 694 | logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{ |
| 695 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 696 | return nil |
| 697 | } |
| 698 | |
| 699 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 700 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 701 | logger.Errorw("Cannot serialize ONU2-G set", log.Fields{ |
| 702 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 703 | return nil |
| 704 | } |
| 705 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 706 | omciRxCallbackPair := CallbackPair{ |
| 707 | cbKey: tid, |
| 708 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
| 709 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 710 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 711 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 712 | logger.Errorw("Cannot send ONU2-G set", log.Fields{ |
| 713 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 714 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 715 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 716 | logger.Debug("send ONU2-G-Set-msg done") |
| 717 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 718 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 719 | logger.Errorw("Cannot generate ONU2-G", log.Fields{ |
| 720 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 721 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | func (oo *OmciCC) sendCreateMBServiceProfile(ctx context.Context, |
| 725 | a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 726 | tid := oo.GetNextTid(highPrio) |
| 727 | instID := macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 728 | logger.Debugw("send MBSP-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 729 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 730 | |
| 731 | meParams := me.ParamData{ |
| 732 | EntityID: instID, |
| 733 | Attributes: me.AttributeValueMap{ |
| 734 | "Priority": 0x8000, |
| 735 | "MaxAge": 20 * 256, //20s |
| 736 | "HelloTime": 2 * 256, //2s |
| 737 | "ForwardDelay": 15 * 256, //15s |
| 738 | //note: DynamicFilteringAgeingTime is taken from omci lib default as |
| 739 | // which is obviously different from default value used in python lib, |
| 740 | // where the value seems to be 0 (ONU defined) - to be considered in case of test artifacts ... |
| 741 | }, |
| 742 | } |
| 743 | |
| 744 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 745 | if omciErr.GetError() == nil { |
| 746 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 747 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 748 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 749 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 750 | logger.Errorw("Cannot encode MBSP for create", log.Fields{ |
| 751 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 752 | return nil |
| 753 | } |
| 754 | |
| 755 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 756 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 757 | logger.Errorw("Cannot serialize MBSP create", log.Fields{ |
| 758 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 759 | return nil |
| 760 | } |
| 761 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 762 | omciRxCallbackPair := CallbackPair{ |
| 763 | cbKey: tid, |
| 764 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
| 765 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 766 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 767 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 768 | logger.Errorw("Cannot send MBSP create", log.Fields{ |
| 769 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 770 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 771 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 772 | logger.Debug("send MBSP-Create-msg done") |
| 773 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 774 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 775 | logger.Errorw("Cannot generate MBSP Instance", log.Fields{ |
| 776 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 777 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | func (oo *OmciCC) sendCreateMBPConfigData(ctx context.Context, |
| 781 | a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 782 | tid := oo.GetNextTid(highPrio) |
| 783 | instID := macBridgePortAniEID + a_pUniPort.entityId |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 784 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 785 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 786 | |
| 787 | meParams := me.ParamData{ |
| 788 | EntityID: instID, |
| 789 | Attributes: me.AttributeValueMap{ |
| 790 | "BridgeIdPointer": macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo), |
| 791 | "PortNum": a_pUniPort.macBpNo, |
| 792 | "TpType": uint8(a_pUniPort.portType), |
| 793 | "TpPointer": a_pUniPort.entityId, |
| 794 | }, |
| 795 | } |
| 796 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 797 | if omciErr.GetError() == nil { |
| 798 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 799 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 800 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 801 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 802 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
| 803 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 804 | return nil |
| 805 | } |
| 806 | |
| 807 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 808 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 809 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
| 810 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 811 | return nil |
| 812 | } |
| 813 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 814 | omciRxCallbackPair := CallbackPair{ |
| 815 | cbKey: tid, |
| 816 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
| 817 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 818 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 819 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 820 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
| 821 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 822 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 823 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 824 | logger.Debug("send MBPCD-Create-msg done") |
| 825 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 826 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 827 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
| 828 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 829 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | func (oo *OmciCC) sendCreateEVTOConfigData(ctx context.Context, |
| 833 | a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity { |
| 834 | tid := oo.GetNextTid(highPrio) |
| 835 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
| 836 | instID := macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 837 | logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 838 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 839 | |
| 840 | // compare python adapter code WA VOL-1311: this is not done here! |
| 841 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 842 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 843 | assType := uint8(2) // default AssociationType is PPTPEthUni |
| 844 | if a_pUniPort.portType == UniVEIP { |
| 845 | assType = uint8(10) // for VEIP |
| 846 | } |
| 847 | meParams := me.ParamData{ |
| 848 | EntityID: instID, |
| 849 | Attributes: me.AttributeValueMap{ |
| 850 | "AssociationType": assType, |
| 851 | "AssociatedMePointer": a_pUniPort.entityId, |
| 852 | }, |
| 853 | } |
| 854 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 855 | if omciErr.GetError() == nil { |
| 856 | //all setByCreate parameters already set, no default option required ... |
| 857 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid)) |
| 858 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 859 | logger.Errorw("Cannot encode EVTOCD for create", log.Fields{ |
| 860 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 861 | return nil |
| 862 | } |
| 863 | |
| 864 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 865 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 866 | logger.Errorw("Cannot serialize EVTOCD create", log.Fields{ |
| 867 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 868 | return nil |
| 869 | } |
| 870 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 871 | omciRxCallbackPair := CallbackPair{ |
| 872 | cbKey: tid, |
| 873 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse}, |
| 874 | } |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 875 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 876 | if err != nil { |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 877 | logger.Errorw("Cannot send EVTOCD create", log.Fields{ |
| 878 | "Err": err, "deviceId": oo.deviceID}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 879 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 880 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 881 | logger.Debug("send EVTOCD-Create-msg done") |
| 882 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 883 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 884 | logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{ |
| 885 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 886 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | func (oo *OmciCC) sendSetOnuGLS(ctx context.Context, timeout int, |
| 890 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 891 | tid := oo.GetNextTid(highPrio) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 892 | logger.Debugw("send ONU-G-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 893 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 894 | |
| 895 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 896 | meParams := me.ParamData{ |
| 897 | EntityID: 0, |
| 898 | Attributes: requestedAttributes, |
| 899 | } |
| 900 | meInstance, omciErr := me.NewOnuG(meParams) |
| 901 | if omciErr.GetError() == nil { |
| 902 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 903 | if err != nil { |
| 904 | logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{ |
| 905 | "Err": err, "deviceId": oo.deviceID}) |
| 906 | return nil |
| 907 | } |
| 908 | |
| 909 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 910 | if err != nil { |
| 911 | logger.Errorw("Cannot serialize ONU-G set", log.Fields{ |
| 912 | "Err": err, "deviceId": oo.deviceID}) |
| 913 | return nil |
| 914 | } |
| 915 | |
| 916 | omciRxCallbackPair := CallbackPair{ |
| 917 | cbKey: tid, |
| 918 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 919 | } |
| 920 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 921 | if err != nil { |
| 922 | logger.Errorw("Cannot send ONU-G set", log.Fields{ |
| 923 | "Err": err, "deviceId": oo.deviceID}) |
| 924 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 925 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 926 | logger.Debug("send ONU-G-Set-msg done") |
| 927 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 928 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 929 | logger.Errorw("Cannot generate ONU-G", log.Fields{ |
| 930 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 931 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | func (oo *OmciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
| 935 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 936 | tid := oo.GetNextTid(highPrio) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 937 | logger.Debugw("send UNI-G-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 938 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 939 | |
| 940 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 941 | meParams := me.ParamData{ |
| 942 | EntityID: aInstNo, |
| 943 | Attributes: requestedAttributes, |
| 944 | } |
| 945 | meInstance, omciErr := me.NewUniG(meParams) |
| 946 | if omciErr.GetError() == nil { |
| 947 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 948 | if err != nil { |
| 949 | logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{ |
| 950 | "Err": err, "deviceId": oo.deviceID}) |
| 951 | return nil |
| 952 | } |
| 953 | |
| 954 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 955 | if err != nil { |
| 956 | logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{ |
| 957 | "Err": err, "deviceId": oo.deviceID}) |
| 958 | return nil |
| 959 | } |
| 960 | |
| 961 | omciRxCallbackPair := CallbackPair{ |
| 962 | cbKey: tid, |
| 963 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 964 | } |
| 965 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 966 | if err != nil { |
| 967 | logger.Errorw("Cannot send UNIG-G-Set", log.Fields{ |
| 968 | "Err": err, "deviceId": oo.deviceID}) |
| 969 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 970 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 971 | logger.Debug("send UNI-G-Set-msg done") |
| 972 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 973 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 974 | logger.Errorw("Cannot generate UNI-G", log.Fields{ |
| 975 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 976 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | func (oo *OmciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
| 980 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
| 981 | tid := oo.GetNextTid(highPrio) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 982 | logger.Debugw("send VEIP-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 983 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 984 | |
| 985 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 986 | meParams := me.ParamData{ |
| 987 | EntityID: aInstNo, |
| 988 | Attributes: requestedAttributes, |
| 989 | } |
| 990 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 991 | if omciErr.GetError() == nil { |
| 992 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 993 | if err != nil { |
| 994 | logger.Errorw("Cannot encode VEIP instance for set", log.Fields{ |
| 995 | "Err": err, "deviceId": oo.deviceID}) |
| 996 | return nil |
| 997 | } |
| 998 | |
| 999 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1000 | if err != nil { |
| 1001 | logger.Errorw("Cannot serialize VEIP-Set", log.Fields{ |
| 1002 | "Err": err, "deviceId": oo.deviceID}) |
| 1003 | return nil |
| 1004 | } |
| 1005 | |
| 1006 | omciRxCallbackPair := CallbackPair{ |
| 1007 | cbKey: tid, |
| 1008 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1009 | } |
| 1010 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1011 | if err != nil { |
| 1012 | logger.Errorw("Cannot send VEIP-Set", log.Fields{ |
| 1013 | "Err": err, "deviceId": oo.deviceID}) |
| 1014 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1015 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 1016 | logger.Debug("send VEIP-Set-msg done") |
| 1017 | return meInstance |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1018 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 1019 | logger.Errorw("Cannot generate VEIP", log.Fields{ |
| 1020 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1021 | return nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1022 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1023 | |
| 1024 | func (oo *OmciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
| 1025 | timeout int, highPrio bool) *me.ManagedEntity { |
| 1026 | |
| 1027 | tid := oo.GetNextTid(highPrio) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 1028 | logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "deviceId": oo.deviceID, |
| 1029 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1030 | |
| 1031 | meParams := me.ParamData{ |
| 1032 | EntityID: entityID, |
| 1033 | Attributes: requestedAttributes, |
| 1034 | } |
| 1035 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1036 | if omciErr.GetError() == nil { |
| 1037 | meClassIdName := meInstance.GetName() |
| 1038 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid)) |
| 1039 | if err != nil { |
| 1040 | logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIdName": meClassIdName, "Err": err, "deviceId": oo.deviceID}) |
| 1041 | return nil |
| 1042 | } |
| 1043 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1044 | if err != nil { |
| 1045 | logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIdName": meClassIdName, "Err": err, "deviceId": oo.deviceID}) |
| 1046 | return nil |
| 1047 | } |
| 1048 | omciRxCallbackPair := CallbackPair{ |
| 1049 | cbKey: tid, |
| 1050 | cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse}, |
| 1051 | } |
| 1052 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1053 | if err != nil { |
| 1054 | logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIdName": meClassIdName, "Err": err, "deviceId": oo.deviceID}) |
| 1055 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1056 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 1057 | logger.Debugw("send get-request-msg done", log.Fields{"meClassIdName": meClassIdName, "deviceId": oo.deviceID}) |
| 1058 | return meInstance |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1059 | } |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame^] | 1060 | logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1061 | return nil |
| 1062 | } |
| 1063 | |
| 1064 | func (oo *OmciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
| 1065 | aInstID uint16, rxChan chan Message) *me.ManagedEntity { |
| 1066 | tid := oo.GetNextTid(highPrio) |
| 1067 | logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1068 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1069 | |
| 1070 | meParams := me.ParamData{ |
| 1071 | EntityID: aInstID, |
| 1072 | Attributes: me.AttributeValueMap{}, |
| 1073 | } |
| 1074 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1075 | if omciErr.GetError() == nil { |
| 1076 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1077 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1078 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1079 | if err != nil { |
| 1080 | logger.Errorw("Cannot encode .1pMapper for create", log.Fields{ |
| 1081 | "Err": err, "deviceId": oo.deviceID}) |
| 1082 | return nil |
| 1083 | } |
| 1084 | |
| 1085 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1086 | if err != nil { |
| 1087 | logger.Errorw("Cannot serialize .1pMapper create", log.Fields{ |
| 1088 | "Err": err, "deviceId": oo.deviceID}) |
| 1089 | return nil |
| 1090 | } |
| 1091 | |
| 1092 | omciRxCallbackPair := CallbackPair{ |
| 1093 | cbKey: tid, |
| 1094 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1095 | } |
| 1096 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1097 | if err != nil { |
| 1098 | logger.Errorw("Cannot send .1pMapper create", log.Fields{ |
| 1099 | "Err": err, "deviceId": oo.deviceID}) |
| 1100 | return nil |
| 1101 | } |
| 1102 | logger.Debug("send .1pMapper-create-msg done") |
| 1103 | return meInstance |
| 1104 | } |
| 1105 | logger.Errorw("Cannot generate .1pMapper", log.Fields{ |
| 1106 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1107 | return nil |
| 1108 | } |
| 1109 | |
| 1110 | func (oo *OmciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
| 1111 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1112 | tid := oo.GetNextTid(highPrio) |
| 1113 | logger.Debugw("send MBPCD-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1114 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1115 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1116 | |
| 1117 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1118 | if omciErr.GetError() == nil { |
| 1119 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1120 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1121 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1122 | if err != nil { |
| 1123 | logger.Errorw("Cannot encode MBPCD for create", log.Fields{ |
| 1124 | "Err": err, "deviceId": oo.deviceID}) |
| 1125 | return nil |
| 1126 | } |
| 1127 | |
| 1128 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1129 | if err != nil { |
| 1130 | logger.Errorw("Cannot serialize MBPCD create", log.Fields{ |
| 1131 | "Err": err, "deviceId": oo.deviceID}) |
| 1132 | return nil |
| 1133 | } |
| 1134 | |
| 1135 | omciRxCallbackPair := CallbackPair{ |
| 1136 | cbKey: tid, |
| 1137 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1138 | } |
| 1139 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1140 | if err != nil { |
| 1141 | logger.Errorw("Cannot send MBPCD create", log.Fields{ |
| 1142 | "Err": err, "deviceId": oo.deviceID}) |
| 1143 | return nil |
| 1144 | } |
| 1145 | logger.Debug("send MBPCD-Create-msg done") |
| 1146 | return meInstance |
| 1147 | } |
| 1148 | logger.Errorw("Cannot generate MBPCD Instance", log.Fields{ |
| 1149 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1150 | return nil |
| 1151 | } |
| 1152 | |
| 1153 | func (oo *OmciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
| 1154 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1155 | tid := oo.GetNextTid(highPrio) |
| 1156 | logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1157 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1158 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1159 | |
| 1160 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1161 | if omciErr.GetError() == nil { |
| 1162 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
| 1163 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1164 | omci.TransactionID(tid), omci.AddDefaults(true)) |
| 1165 | if err != nil { |
| 1166 | logger.Errorw("Cannot encode GemNCTP for create", log.Fields{ |
| 1167 | "Err": err, "deviceId": oo.deviceID}) |
| 1168 | return nil |
| 1169 | } |
| 1170 | |
| 1171 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1172 | if err != nil { |
| 1173 | logger.Errorw("Cannot serialize GemNCTP create", log.Fields{ |
| 1174 | "Err": err, "deviceId": oo.deviceID}) |
| 1175 | return nil |
| 1176 | } |
| 1177 | |
| 1178 | omciRxCallbackPair := CallbackPair{ |
| 1179 | cbKey: tid, |
| 1180 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1181 | } |
| 1182 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1183 | if err != nil { |
| 1184 | logger.Errorw("Cannot send GemNCTP create", log.Fields{ |
| 1185 | "Err": err, "deviceId": oo.deviceID}) |
| 1186 | return nil |
| 1187 | } |
| 1188 | logger.Debug("send GemNCTP-Create-msg done") |
| 1189 | return meInstance |
| 1190 | } |
| 1191 | logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{ |
| 1192 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1193 | return nil |
| 1194 | } |
| 1195 | |
| 1196 | func (oo *OmciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
| 1197 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1198 | tid := oo.GetNextTid(highPrio) |
| 1199 | logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1200 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1201 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1202 | |
| 1203 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1204 | if omciErr.GetError() == nil { |
| 1205 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
| 1206 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1207 | omci.TransactionID(tid)) |
| 1208 | if err != nil { |
| 1209 | logger.Errorw("Cannot encode GemIwTp for create", log.Fields{ |
| 1210 | "Err": err, "deviceId": oo.deviceID}) |
| 1211 | return nil |
| 1212 | } |
| 1213 | |
| 1214 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1215 | if err != nil { |
| 1216 | logger.Errorw("Cannot serialize GemIwTp create", log.Fields{ |
| 1217 | "Err": err, "deviceId": oo.deviceID}) |
| 1218 | return nil |
| 1219 | } |
| 1220 | |
| 1221 | omciRxCallbackPair := CallbackPair{ |
| 1222 | cbKey: tid, |
| 1223 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1224 | } |
| 1225 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1226 | if err != nil { |
| 1227 | logger.Errorw("Cannot send GemIwTp create", log.Fields{ |
| 1228 | "Err": err, "deviceId": oo.deviceID}) |
| 1229 | return nil |
| 1230 | } |
| 1231 | logger.Debug("send GemIwTp-Create-msg done") |
| 1232 | return meInstance |
| 1233 | } |
| 1234 | logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{ |
| 1235 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1236 | return nil |
| 1237 | } |
| 1238 | |
| 1239 | func (oo *OmciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
| 1240 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1241 | tid := oo.GetNextTid(highPrio) |
| 1242 | logger.Debugw("send TCont-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1243 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1244 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1245 | |
| 1246 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1247 | if omciErr.GetError() == nil { |
| 1248 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1249 | if err != nil { |
| 1250 | logger.Errorw("Cannot encode TCont for set", log.Fields{ |
| 1251 | "Err": err, "deviceId": oo.deviceID}) |
| 1252 | return nil |
| 1253 | } |
| 1254 | |
| 1255 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1256 | if err != nil { |
| 1257 | logger.Errorw("Cannot serialize TCont set", log.Fields{ |
| 1258 | "Err": err, "deviceId": oo.deviceID}) |
| 1259 | return nil |
| 1260 | } |
| 1261 | |
| 1262 | omciRxCallbackPair := CallbackPair{ |
| 1263 | cbKey: tid, |
| 1264 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1265 | } |
| 1266 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1267 | if err != nil { |
| 1268 | logger.Errorw("Cannot send TCont set", log.Fields{ |
| 1269 | "Err": err, "deviceId": oo.deviceID}) |
| 1270 | return nil |
| 1271 | } |
| 1272 | logger.Debug("send TCont-set msg done") |
| 1273 | return meInstance |
| 1274 | } |
| 1275 | logger.Errorw("Cannot generate TCont Instance", log.Fields{ |
| 1276 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1277 | return nil |
| 1278 | } |
| 1279 | |
| 1280 | func (oo *OmciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
| 1281 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1282 | tid := oo.GetNextTid(highPrio) |
| 1283 | logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1284 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1285 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1286 | |
| 1287 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1288 | if omciErr.GetError() == nil { |
| 1289 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1290 | if err != nil { |
| 1291 | logger.Errorw("Cannot encode PrioQueue for set", log.Fields{ |
| 1292 | "Err": err, "deviceId": oo.deviceID}) |
| 1293 | return nil |
| 1294 | } |
| 1295 | |
| 1296 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1297 | if err != nil { |
| 1298 | logger.Errorw("Cannot serialize PrioQueue set", log.Fields{ |
| 1299 | "Err": err, "deviceId": oo.deviceID}) |
| 1300 | return nil |
| 1301 | } |
| 1302 | |
| 1303 | omciRxCallbackPair := CallbackPair{ |
| 1304 | cbKey: tid, |
| 1305 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1306 | } |
| 1307 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1308 | if err != nil { |
| 1309 | logger.Errorw("Cannot send PrioQueue set", log.Fields{ |
| 1310 | "Err": err, "deviceId": oo.deviceID}) |
| 1311 | return nil |
| 1312 | } |
| 1313 | logger.Debug("send PrioQueue-set msg done") |
| 1314 | return meInstance |
| 1315 | } |
| 1316 | logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{ |
| 1317 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1318 | return nil |
| 1319 | } |
| 1320 | |
| 1321 | func (oo *OmciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
| 1322 | rxChan chan Message, params ...me.ParamData) *me.ManagedEntity { |
| 1323 | tid := oo.GetNextTid(highPrio) |
| 1324 | logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"deviceId": oo.deviceID, |
| 1325 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1326 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1327 | |
| 1328 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1329 | if omciErr.GetError() == nil { |
| 1330 | omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid)) |
| 1331 | if err != nil { |
| 1332 | logger.Errorw("Cannot encode 1PMapper for set", log.Fields{ |
| 1333 | "Err": err, "deviceId": oo.deviceID}) |
| 1334 | return nil |
| 1335 | } |
| 1336 | |
| 1337 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1338 | if err != nil { |
| 1339 | logger.Errorw("Cannot serialize 1PMapper set", log.Fields{ |
| 1340 | "Err": err, "deviceId": oo.deviceID}) |
| 1341 | return nil |
| 1342 | } |
| 1343 | |
| 1344 | omciRxCallbackPair := CallbackPair{ |
| 1345 | cbKey: tid, |
| 1346 | cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse}, |
| 1347 | } |
| 1348 | err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair) |
| 1349 | if err != nil { |
| 1350 | logger.Errorw("Cannot send 1PMapper set", log.Fields{ |
| 1351 | "Err": err, "deviceId": oo.deviceID}) |
| 1352 | return nil |
| 1353 | } |
| 1354 | logger.Debug("send 1PMapper-set msg done") |
| 1355 | return meInstance |
| 1356 | } |
| 1357 | logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{ |
| 1358 | "Err": omciErr.GetError(), "deviceId": oo.deviceID}) |
| 1359 | return nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1360 | } |