blob: 5ee61f1f0741de8accb8c7c4c22ca935a1d29caf [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
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 Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
25 "errors"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000027 "sync"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000028 //"time"
29
30 "github.com/google/gopacket"
31 // TODO!!! Some references could be resolved auto, but some need specific context ....
32 gp "github.com/google/gopacket"
33
34 "github.com/opencord/omci-lib-go"
35 me "github.com/opencord/omci-lib-go/generated"
36 "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
37
38 //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
39 "github.com/opencord/voltha-lib-go/v3/pkg/log"
40 ic "github.com/opencord/voltha-protos/v3/go/inter_container"
41 //"github.com/opencord/voltha-protos/v3/go/openflow_13"
42 //"github.com/opencord/voltha-protos/v3/go/voltha"
43)
44
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000045// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Holger Hildebrandtfa074992020-03-27 15:42:06 +000046const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds
47
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000048const galEthernetEID = uint16(1)
49const maxGemPayloadSize = uint16(48)
50const connectivityModeValue = uint8(5)
51const defaultTPID = uint16(0x8100)
52const broadComDefaultVID = uint16(4091)
53const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
54const ieeeMapperServiceProfileEID = uint16(0x8001)
55const macBridgePortAniEID = uint16(0x2102)
56
57// ### OMCI related definitions - end
58
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000059//CallbackPairEntry to be used for OMCI send/receive correlation
60type CallbackPairEntry struct {
61 cbRespChannel chan Message
62 cbFunction func(*omci.OMCI, *gp.Packet, chan Message) error
63}
64
Holger Hildebrandtfa074992020-03-27 15:42:06 +000065//CallbackPair to be used for ReceiveCallback init
66type CallbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000067 cbKey uint16
68 cbEntry CallbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000069}
70
71type omciTransferStructure struct {
72 txFrame []byte
73 timeout int
74 retry int
75 highPrio bool
76}
77
78//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
79type OmciCC struct {
80 enabled bool
81 pOnuDeviceEntry *OnuDeviceEntry
82 deviceID string
83 pBaseDeviceHandler *DeviceHandler
84 coreProxy adapterif.CoreProxy
85 adapterProxy adapterif.AdapterProxy
86 supportExtMsg bool
87 //txRequest
88 //rxResponse
89 //pendingRequest
90 txFrames, txOnuFrames uint32
91 rxFrames, rxOnuFrames, rxOnuDiscards uint32
92
93 // OMCI params
94 mutexTid sync.Mutex
95 tid uint16
96 mutexHpTid sync.Mutex
97 hpTid uint16
98 uploadSequNo uint16
99 uploadNoOfCmds uint16
100
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000101 mutexTxQueue sync.Mutex
102 txQueue *list.List
103 mutexRxSchedMap sync.Mutex
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000104 rxSchedulerMap map[uint16]CallbackPairEntry
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000105 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000106}
107
108//NewOmciCC constructor returns a new instance of a OmciCC
109//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
110func NewOmciCC(ctx context.Context, onu_device_entry *OnuDeviceEntry,
111 device_id string, device_handler *DeviceHandler,
112 core_proxy adapterif.CoreProxy, adapter_proxy adapterif.AdapterProxy) *OmciCC {
divyadesai4d299552020-08-18 07:13:49 +0000113 logger.Infow("init-omciCC", log.Fields{"device-id": device_id})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000114 var omciCC OmciCC
115 omciCC.enabled = false
116 omciCC.pOnuDeviceEntry = onu_device_entry
117 omciCC.deviceID = device_id
118 omciCC.pBaseDeviceHandler = device_handler
119 omciCC.coreProxy = core_proxy
120 omciCC.adapterProxy = adapter_proxy
121 omciCC.supportExtMsg = false
122 omciCC.txFrames = 0
123 omciCC.txOnuFrames = 0
124 omciCC.rxFrames = 0
125 omciCC.rxOnuFrames = 0
126 omciCC.rxOnuDiscards = 0
127 omciCC.tid = 0x1
128 omciCC.hpTid = 0x8000
129 omciCC.uploadSequNo = 0
130 omciCC.uploadNoOfCmds = 0
131
132 omciCC.txQueue = list.New()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000133 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000134
135 return &omciCC
136}
137
138// Rx handler for omci messages
139func (oo *OmciCC) ReceiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000140 logger.Debugw("rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000141 "payload": hex.EncodeToString(omciMsg.Payload)})
142 /*
143 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
144 rxOnuFrames++
145
146 switch msgType {
147 case AlarmNotification:
148 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000149 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000150 // python code was:
151 //if msg_type == EntityOperations.AlarmNotification.value:
152 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
153 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
154 //
155 return errors.New("RxAlarmNotification unimplemented")
156 }
157 case AttributeValueChange:
158 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000159 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000160 // python code was:
161 //elif msg_type == EntityOperations.AttributeValueChange.value:
162 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
163 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
164 //
165 return errors.New("RxAttributeValueChange unimplemented")
166 }
167 case TestResult:
168 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000169 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000170 // python code was:
171 //elif msg_type == EntityOperations.TestResult.value:
172 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
173 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
174 //
175 return errors.New("RxTestResult unimplemented")
176 }
177 default:
178 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000179 logger.Errorw("rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000180 rxOnuDiscards++
181 return errors.New("RxOnuMsgType unimplemented")
182 }
183 }
184 */
185 return errors.New("ReceiveOnuMessage unimplemented")
186}
187
188// Rx handler for onu messages
189// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
190func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000191 //logger.Debugw("cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000192 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
193 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
194 // (am extendedFormat message could be destroyed this way!)
195 trailerLenData := rxMsg[42:44]
196 trailerLen := binary.BigEndian.Uint16(trailerLenData)
mpagenko1cc3cb42020-07-27 15:24:38 +0000197 //logger.Debugw("omci-received-trailer-len", log.Fields{"Length": trailerLen})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000198 if trailerLen != 40 { // invalid base Format entry -> autocorrect
199 binary.BigEndian.PutUint16(rxMsg[42:44], 40)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000200 logger.Debug("cc-corrected-omci-message: trailer len inserted")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000201 }
202 } else {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000203 logger.Errorw("received omci-message to small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000204 return errors.New("RxOmciMessage to small for BaseFormat")
205 }
206
207 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
208 if packet == nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000209 logger.Error("omci-message could not be decoded")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000210 return errors.New("could not decode rxMsg as OMCI")
211 }
212 omciLayer := packet.Layer(omci.LayerTypeOMCI)
213 if omciLayer == nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000214 logger.Error("omci-message could not decode omci layer")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000215 return errors.New("could not decode omci layer")
216 }
217 omciMsg, ok := omciLayer.(*omci.OMCI)
218 if !ok {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000219 logger.Error("omci-message could not assign omci layer")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000220 return errors.New("could not assign omci layer")
221 }
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000222 logger.Debugw("omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000223 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000224 if byte(omciMsg.MessageType) & ^me.AK == 0 {
225 // Not a response
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000226 logger.Debug("RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000227 if omciMsg.TransactionID == 0 {
228 return oo.ReceiveOnuMessage(ctx, omciMsg)
229 } else {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000230 logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages",
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000231 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload)})
232 return errors.New("Autonomous Omci Message with TranSCorrId != 0 not acccepted")
233 }
234 } else {
mpagenko1cc3cb42020-07-27 15:24:38 +0000235 //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000236 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000237 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
238 if ok && rxCallbackEntry.cbFunction != nil {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000239 //disadvantage of decoupling: error verification made difficult, but anyway the question is
240 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000241 go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000242 // having posted the response the request is regarded as 'done'
243 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
244 oo.mutexRxSchedMap.Unlock()
245 } else {
246 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000247 logger.Error("omci-message-response for not registered transCorrId")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000248 return errors.New("could not find registered response handler tor transCorrId")
249 }
250 }
251
252 return nil
253 /* py code was:
254 Receive and OMCI message from the proxy channel to the OLT.
255
256 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
257 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
258 """
259 if not self.enabled:
260 return
261
262 try:
263 now = arrow.utcnow()
264 d = None
265
266 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
267 # save the current value of the entity_id_to_class_map, then
268 # replace it with our custom one before decode, and then finally
269 # restore it later. Tried other ways but really made the code messy.
270 saved_me_map = omci_entities.entity_id_to_class_map
271 omci_entities.entity_id_to_class_map = self._me_map
272
273 try:
274 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000275 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000276 except KeyError as e:
277 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000278 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000279 rx_frame = self._decode_unknown_me(msg)
280 self._rx_unknown_me += 1
281
282 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000283 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000284 return
285
286 finally:
287 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
288
289 rx_tid = rx_frame.fields['transaction_id']
290 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000291 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000292 # Filter the Test Result frame and route through receive onu
293 # message method.
294 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000295 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000296 return self._receive_onu_message(rx_frame)
297
298 # Previously unreachable if this is the very first round-trip Rx or we
299 # have been running consecutive errors
300 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000301 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000302 self.reactor.callLater(0, self._publish_connectivity_event, True)
303
304 self._rx_frames += 1
305 self._consecutive_errors = 0
306
307 try:
308 high_priority = self._tid_is_high_priority(rx_tid)
309 index = self._get_priority_index(high_priority)
310
311 # (timestamp, defer, frame, timeout, retry, delayedCall)
312 last_tx_tuple = self._tx_request[index]
313
314 if last_tx_tuple is None or \
315 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
316 # Possible late Rx on a message that timed-out
317 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000318 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000319 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
320 self._rx_unknown_tid += 1
321 self._rx_late += 1
322 return
323
324 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
325 if dc is not None and not dc.cancelled and not dc.called:
326 dc.cancel()
327
328 _secs = self._update_rx_tx_stats(now, ts)
329
330 # Late arrival already serviced by a timeout?
331 if d.called:
332 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000333 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000334 return
335
336 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000337 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000338 if d is not None:
339 return d.errback(failure.Failure(e))
340 return
341
342 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000343 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000344 tx_tid = tx_frame.fields['transaction_id'])
345 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
346
347 # begin success callback chain (will cancel timeout and queue next Tx message)
348 self._rx_response[index] = rx_frame
349 d.callback(rx_frame)
350
351 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000352 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000353 */
354}
355
356func (oo *OmciCC) PublishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
357 return errors.New("PublishRxResponseFrame unimplemented")
358 /*
359 def _publish_rx_frame(self, tx_frame, rx_frame):
360 */
361}
362
363//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
364func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
365 receiveCallbackPair CallbackPair) error {
366
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000367 logger.Debugw("register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000368 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
369 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000370 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000371 oo.mutexRxSchedMap.Unlock()
372
373 //just use a simple list for starting - might need some more effort, especially for multi source write access
374 omciTxRequest := omciTransferStructure{
375 txFrame,
376 timeout,
377 retry,
378 highPrio,
379 }
380 oo.mutexTxQueue.Lock()
381 oo.txQueue.PushBack(omciTxRequest) // enqueue
382 oo.mutexTxQueue.Unlock()
383
384 // for first test just bypass and send directly:
385 go oo.sendNextRequest(ctx)
386 return nil
387}
388
389//Pull next tx request and send it
390func (oo *OmciCC) sendNextRequest(ctx context.Context) error {
391 // return errors.New("sendNextRequest unimplemented")
392
393 // just try to get something transferred !!
394 // avoid accessing the txQueue from parallel send requests
395 // block parallel omci send requests at least until SendIAP is 'committed'
396 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
397 oo.mutexTxQueue.Lock()
398 for oo.txQueue.Len() > 0 {
399 queueElement := oo.txQueue.Front() // First element
400 omciTxRequest := queueElement.Value.(omciTransferStructure)
401 /* compare olt device handler code:
402 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000403 logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000404 var deviceType string
405 var deviceID string
406 var proxyDeviceID string
407
408 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
409
410 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
411
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000412 logger.Debugw("omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000413 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
414 kwargs := make(map[string]interface{})
415 kwargs["onu_id"] = omciInd.OnuId
416 kwargs["parent_port_no"] = ponPort
417
418 onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
419 if err != nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000420 logger.Errorw("onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000421 return
422 }
423 deviceType = onuDevice.Type
424 deviceID = onuDevice.Id
425 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
426 //if not exist in cache, then add to cache.
427 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
428 } else {
429 //found in cache
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000430 logger.Debugw("omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000431 deviceType = onuInCache.(*OnuDevice).deviceType
432 deviceID = onuInCache.(*OnuDevice).deviceID
433 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
434 }
435 */
436 /* and compare onu_adapter py code:
437 omci_msg = InterAdapterOmciMessage(
438 message=bytes(frame),
439 proxy_address=self._proxy_address,
440 connect_status=self._device.connect_status)
441
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000442 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000443
444 yield self._adapter_proxy.send_inter_adapter_message(
445 msg=omci_msg,
446 type=InterAdapterMessageType.OMCI_REQUEST,
447 from_adapter=self._device.type,
448 to_adapter=self._proxy_address.device_type,
449 to_device_id=self._device_id,
450 proxy_device_id=self._proxy_address.device_id
451 )
452 */
453 device, err := oo.coreProxy.GetDevice(ctx,
454 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
455 if err != nil || device == nil {
456 /*TODO: needs to handle error scenarios */
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000457 logger.Errorw("Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000458 "ChildId": oo.deviceID})
459 return errors.New("failed to fetch device")
460 }
461
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000462 logger.Debugw("omci-message-sending", log.Fields{"fromDeviceType": oo.pBaseDeviceHandler.DeviceType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000463 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
464 "onuDeviceID": oo.deviceID, "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000465 logger.Debugw("omci-message-to-send:",
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000466 log.Fields{"TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame)})
467
468 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
469 if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg,
470 ic.InterAdapterMessageType_OMCI_REQUEST,
471 //fromType,toType,toDevId, ProxyDevId
472 oo.pBaseDeviceHandler.DeviceType, oo.pBaseDeviceHandler.ProxyAddressType,
473 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000474 logger.Errorw("send omci request error", log.Fields{"error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000475 return sendErr
476 }
477 oo.txQueue.Remove(queueElement) // Dequeue
478 }
479 oo.mutexTxQueue.Unlock()
480 return nil
481}
482
483func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
484 var next uint16
485 if highPriority {
486 oo.mutexTid.Lock()
487 next = oo.hpTid
488 oo.hpTid += 1
489 if oo.hpTid < 0x8000 {
490 oo.hpTid = 0x8000
491 }
492 oo.mutexTid.Unlock()
493 } else {
494 oo.mutexHpTid.Lock()
495 next = oo.tid
496 oo.tid += 1
497 if oo.tid >= 0x8000 {
498 oo.tid = 1
499 }
500 oo.mutexHpTid.Unlock()
501 }
502 return next
503}
504
505// ###################################################################################
506// # utility methods provided to work on OMCI messages
507func serialize(msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
508 omciLayer := &omci.OMCI{
509 TransactionID: tid,
510 MessageType: msgType,
511 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000512 return serializeOmciLayer(omciLayer, request)
513}
514
515func serializeOmciLayer(a_omciLayer *omci.OMCI, a_request gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000516 var options gopacket.SerializeOptions
517 options.FixLengths = true
518
519 buffer := gopacket.NewSerializeBuffer()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000520 err := gopacket.SerializeLayers(buffer, options, a_omciLayer, a_request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000521 if err != nil {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000522 logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000523 return nil, err
524 }
525 return buffer.Bytes(), nil
526}
527
528func hexEncode(omciPkt []byte) ([]byte, error) {
529 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
530 hex.Encode(dst, omciPkt)
531 return dst, nil
532}
533
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000534//supply a response handler for omci response messages to be transferred to the requested FSM
535func (oo *OmciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000536
mpagenko3dbcdd22020-07-22 07:38:45 +0000537 logger.Debugw("omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000538 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000539
540 if oo.pOnuDeviceEntry == nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000541 logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000542 "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000543 return errors.New("DeviceEntryPointer is nil")
544 }
545
546 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
547 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000548 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000549 Type: OMCI,
550 Data: OmciMessage{
551 OmciMsg: omciMsg,
552 OmciPacket: packet,
553 },
554 }
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000555 //logger.Debugw("Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000556 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000557
558 return nil
559}
560
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000561func (oo *OmciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
562
divyadesai4d299552020-08-18 07:13:49 +0000563 logger.Debugw("send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000564 request := &omci.MibResetRequest{
565 MeBasePacket: omci.MeBasePacket{
566 EntityClass: me.OnuDataClassID,
567 },
568 }
569 tid := oo.GetNextTid(highPrio)
570 pkt, err := serialize(omci.MibResetRequestType, request, tid)
571 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000572 logger.Errorw("Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000573 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000574 return err
575 }
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000576 omciRxCallbackPair := CallbackPair{
577 cbKey: tid,
578 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
579 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000580 return oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
581}
582
ozgecanetsiae11479f2020-07-06 09:44:47 +0300583func (oo *OmciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
divyadesai4d299552020-08-18 07:13:49 +0000584 logger.Debugw("send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300585 request := &omci.RebootRequest{
586 MeBasePacket: omci.MeBasePacket{
587 EntityClass: me.OnuGClassID,
588 },
589 }
590 tid := oo.GetNextTid(highPrio)
591 pkt, err := serialize(omci.RebootRequestType, request, tid)
592 if err != nil {
593 logger.Errorw("Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000594 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300595 return err
596 }
597 omciRxCallbackPair := CallbackPair{
598 cbKey: tid,
599 cbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse},
600 }
601
602 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
603 if err != nil {
604 logger.Errorw("Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000605 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300606 return err
607 }
608 err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel)
609 if err != nil {
610 logger.Error("aborting ONU Reboot!")
611 oo.pOnuDeviceEntry.pMibDownloadFsm.pFsm.Event("reset")
612 return err
613 }
614 return nil
615}
616
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000617func (oo *OmciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
divyadesai4d299552020-08-18 07:13:49 +0000618 logger.Debugw("send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 request := &omci.MibUploadRequest{
620 MeBasePacket: omci.MeBasePacket{
621 EntityClass: me.OnuDataClassID,
622 },
623 }
624 tid := oo.GetNextTid(highPrio)
625 pkt, err := serialize(omci.MibUploadRequestType, request, tid)
626 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000627 logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000628 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000629 return err
630 }
631 oo.uploadSequNo = 0
632 oo.uploadNoOfCmds = 0
633
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000634 omciRxCallbackPair := CallbackPair{
635 cbKey: tid,
636 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
637 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000638 return oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
639}
640
641func (oo *OmciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
divyadesai4d299552020-08-18 07:13:49 +0000642 logger.Debugw("send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000643 request := &omci.MibUploadNextRequest{
644 MeBasePacket: omci.MeBasePacket{
645 EntityClass: me.OnuDataClassID,
646 },
647 CommandSequenceNumber: oo.uploadSequNo,
648 }
649 tid := oo.GetNextTid(highPrio)
650 pkt, err := serialize(omci.MibUploadNextRequestType, request, tid)
651 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000652 logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000653 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000654 return err
655 }
656 oo.uploadSequNo++
657
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000658 omciRxCallbackPair := CallbackPair{
659 cbKey: tid,
660 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
661 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662 return oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
663}
664
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000665func (oo *OmciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
666 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000667 logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000668 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000669
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000670 meParams := me.ParamData{
671 EntityID: galEthernetEID,
672 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
673 }
674 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
675 if omciErr.GetError() == nil {
676 //all setByCreate parameters already set, no default option required ...
677 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
678 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000679 logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000680 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000681 return nil
682 }
683
684 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
685 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000686 logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000687 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000688 return nil
689 }
690
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000691 omciRxCallbackPair := CallbackPair{
692 cbKey: tid,
693 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
694 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000695 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
696 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000697 logger.Errorw("Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000698 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000699 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000700 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000701 logger.Debug("send GalEnetProfile-Create-msg done")
702 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000703 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000704 logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000705 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000706 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000707}
708
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000709// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000710func (oo *OmciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
711 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000712 logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000713 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000714
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000715 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
716 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000717 // By now we just use fix values to fire - this is anyway what the python adapter does
718 // read ONU-2G from DB ???? //TODO!!!
719 meParams := me.ParamData{
720 EntityID: 0,
721 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
722 }
723 meInstance, omciErr := me.NewOnu2G(meParams)
724 if omciErr.GetError() == nil {
725 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
726 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000727 logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000728 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000729 return nil
730 }
731
732 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
733 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000734 logger.Errorw("Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000735 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000736 return nil
737 }
738
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000739 omciRxCallbackPair := CallbackPair{
740 cbKey: tid,
741 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
742 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000743 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
744 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000745 logger.Errorw("Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000746 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000747 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000748 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000749 logger.Debug("send ONU2-G-Set-msg done")
750 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000751 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000752 logger.Errorw("Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000753 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000754 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000755}
756
757func (oo *OmciCC) sendCreateMBServiceProfile(ctx context.Context,
758 a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
759 tid := oo.GetNextTid(highPrio)
760 instID := macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo)
divyadesai4d299552020-08-18 07:13:49 +0000761 logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000762 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000763
764 meParams := me.ParamData{
765 EntityID: instID,
766 Attributes: me.AttributeValueMap{
767 "Priority": 0x8000,
768 "MaxAge": 20 * 256, //20s
769 "HelloTime": 2 * 256, //2s
770 "ForwardDelay": 15 * 256, //15s
771 //note: DynamicFilteringAgeingTime is taken from omci lib default as
772 // which is obviously different from default value used in python lib,
773 // where the value seems to be 0 (ONU defined) - to be considered in case of test artifacts ...
774 },
775 }
776
777 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
778 if omciErr.GetError() == nil {
779 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
780 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
781 omci.TransactionID(tid), omci.AddDefaults(true))
782 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000783 logger.Errorw("Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000784 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000785 return nil
786 }
787
788 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
789 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000790 logger.Errorw("Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000791 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000792 return nil
793 }
794
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000795 omciRxCallbackPair := CallbackPair{
796 cbKey: tid,
797 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
798 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000799 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
800 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000801 logger.Errorw("Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000802 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000803 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000804 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000805 logger.Debug("send MBSP-Create-msg done")
806 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000807 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000808 logger.Errorw("Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000809 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000810 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000811}
812
813func (oo *OmciCC) sendCreateMBPConfigData(ctx context.Context,
814 a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
815 tid := oo.GetNextTid(highPrio)
816 instID := macBridgePortAniEID + a_pUniPort.entityId
divyadesai4d299552020-08-18 07:13:49 +0000817 logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000818 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000819
820 meParams := me.ParamData{
821 EntityID: instID,
822 Attributes: me.AttributeValueMap{
823 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo),
824 "PortNum": a_pUniPort.macBpNo,
825 "TpType": uint8(a_pUniPort.portType),
826 "TpPointer": a_pUniPort.entityId,
827 },
828 }
829 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
830 if omciErr.GetError() == nil {
831 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
832 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
833 omci.TransactionID(tid), omci.AddDefaults(true))
834 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000835 logger.Errorw("Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000836 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000837 return nil
838 }
839
840 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
841 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000842 logger.Errorw("Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000843 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000844 return nil
845 }
846
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000847 omciRxCallbackPair := CallbackPair{
848 cbKey: tid,
849 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
850 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000851 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
852 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000853 logger.Errorw("Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000854 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000855 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000856 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000857 logger.Debug("send MBPCD-Create-msg done")
858 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000859 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000860 logger.Errorw("Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000861 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000862 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000863}
864
865func (oo *OmciCC) sendCreateEVTOConfigData(ctx context.Context,
866 a_pUniPort *OnuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
867 tid := oo.GetNextTid(highPrio)
868 //same entityId is used as for MBSP (see there), but just arbitrary ...
869 instID := macBridgeServiceProfileEID + uint16(a_pUniPort.macBpNo)
divyadesai4d299552020-08-18 07:13:49 +0000870 logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000871 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000872
873 // compare python adapter code WA VOL-1311: this is not done here!
874 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
875 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
876 assType := uint8(2) // default AssociationType is PPTPEthUni
877 if a_pUniPort.portType == UniVEIP {
878 assType = uint8(10) // for VEIP
879 }
880 meParams := me.ParamData{
881 EntityID: instID,
882 Attributes: me.AttributeValueMap{
883 "AssociationType": assType,
884 "AssociatedMePointer": a_pUniPort.entityId,
885 },
886 }
887 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
888 if omciErr.GetError() == nil {
889 //all setByCreate parameters already set, no default option required ...
890 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
891 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000892 logger.Errorw("Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000893 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000894 return nil
895 }
896
897 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
898 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000899 logger.Errorw("Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000900 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000901 return nil
902 }
903
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000904 omciRxCallbackPair := CallbackPair{
905 cbKey: tid,
906 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
907 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000908 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
909 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000910 logger.Errorw("Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000911 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000912 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000913 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000914 logger.Debug("send EVTOCD-Create-msg done")
915 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000916 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000917 logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000918 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000919 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000920}
921
922func (oo *OmciCC) sendSetOnuGLS(ctx context.Context, timeout int,
923 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
924 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000925 logger.Debugw("send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000926 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000927
928 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
929 meParams := me.ParamData{
930 EntityID: 0,
931 Attributes: requestedAttributes,
932 }
933 meInstance, omciErr := me.NewOnuG(meParams)
934 if omciErr.GetError() == nil {
935 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
936 if err != nil {
937 logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000938 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000939 return nil
940 }
941
942 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
943 if err != nil {
944 logger.Errorw("Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000945 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000946 return nil
947 }
948
949 omciRxCallbackPair := CallbackPair{
950 cbKey: tid,
951 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
952 }
953 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
954 if err != nil {
955 logger.Errorw("Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000956 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000957 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000958 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000959 logger.Debug("send ONU-G-Set-msg done")
960 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000961 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000962 logger.Errorw("Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000963 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000964 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000965}
966
967func (oo *OmciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
968 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
969 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000970 logger.Debugw("send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000971 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000972
973 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
974 meParams := me.ParamData{
975 EntityID: aInstNo,
976 Attributes: requestedAttributes,
977 }
978 meInstance, omciErr := me.NewUniG(meParams)
979 if omciErr.GetError() == nil {
980 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
981 if err != nil {
982 logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000983 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000984 return nil
985 }
986
987 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
988 if err != nil {
989 logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000990 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000991 return nil
992 }
993
994 omciRxCallbackPair := CallbackPair{
995 cbKey: tid,
996 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
997 }
998 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
999 if err != nil {
1000 logger.Errorw("Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001001 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001002 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001003 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001004 logger.Debug("send UNI-G-Set-msg done")
1005 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001006 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001007 logger.Errorw("Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001008 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001009 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001010}
1011
1012func (oo *OmciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
1013 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1014 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001015 logger.Debugw("send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001016 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001017
1018 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1019 meParams := me.ParamData{
1020 EntityID: aInstNo,
1021 Attributes: requestedAttributes,
1022 }
1023 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1024 if omciErr.GetError() == nil {
1025 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1026 if err != nil {
1027 logger.Errorw("Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001028 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001029 return nil
1030 }
1031
1032 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1033 if err != nil {
1034 logger.Errorw("Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001035 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001036 return nil
1037 }
1038
1039 omciRxCallbackPair := CallbackPair{
1040 cbKey: tid,
1041 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1042 }
1043 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1044 if err != nil {
1045 logger.Errorw("Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001046 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001047 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001048 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001049 logger.Debug("send VEIP-Set-msg done")
1050 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001051 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001052 logger.Errorw("Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001053 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001054 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001055}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001056
1057func (oo *OmciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
1058 timeout int, highPrio bool) *me.ManagedEntity {
1059
1060 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001061 logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001062 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001063
1064 meParams := me.ParamData{
1065 EntityID: entityID,
1066 Attributes: requestedAttributes,
1067 }
1068 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1069 if omciErr.GetError() == nil {
1070 meClassIdName := meInstance.GetName()
1071 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1072 if err != nil {
divyadesai4d299552020-08-18 07:13:49 +00001073 logger.Errorf("Cannot encode instance for get-request", log.Fields{"meClassIdName": meClassIdName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001074 return nil
1075 }
1076 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1077 if err != nil {
divyadesai4d299552020-08-18 07:13:49 +00001078 logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIdName": meClassIdName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001079 return nil
1080 }
1081 omciRxCallbackPair := CallbackPair{
1082 cbKey: tid,
1083 cbEntry: CallbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
1084 }
1085 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1086 if err != nil {
divyadesai4d299552020-08-18 07:13:49 +00001087 logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIdName": meClassIdName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001088 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001089 }
divyadesai4d299552020-08-18 07:13:49 +00001090 logger.Debugw("send get-request-msg done", log.Fields{"meClassIdName": meClassIdName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001091 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001092 }
divyadesai4d299552020-08-18 07:13:49 +00001093 logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001094 return nil
1095}
1096
1097func (oo *OmciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
1098 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
1099 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001100 logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001101 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1102
1103 meParams := me.ParamData{
1104 EntityID: aInstID,
1105 Attributes: me.AttributeValueMap{},
1106 }
1107 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1108 if omciErr.GetError() == nil {
1109 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1110 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1111 omci.TransactionID(tid), omci.AddDefaults(true))
1112 if err != nil {
1113 logger.Errorw("Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001114 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001115 return nil
1116 }
1117
1118 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1119 if err != nil {
1120 logger.Errorw("Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001121 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001122 return nil
1123 }
1124
1125 omciRxCallbackPair := CallbackPair{
1126 cbKey: tid,
1127 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1128 }
1129 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1130 if err != nil {
1131 logger.Errorw("Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001132 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001133 return nil
1134 }
1135 logger.Debug("send .1pMapper-create-msg done")
1136 return meInstance
1137 }
1138 logger.Errorw("Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001139 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001140 return nil
1141}
1142
1143func (oo *OmciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
1144 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1145 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001146 logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001147 "SequNo": strconv.FormatInt(int64(tid), 16),
1148 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1149
1150 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1151 if omciErr.GetError() == nil {
1152 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1153 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1154 omci.TransactionID(tid), omci.AddDefaults(true))
1155 if err != nil {
1156 logger.Errorw("Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001157 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001158 return nil
1159 }
1160
1161 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1162 if err != nil {
1163 logger.Errorw("Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001164 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001165 return nil
1166 }
1167
1168 omciRxCallbackPair := CallbackPair{
1169 cbKey: tid,
1170 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1171 }
1172 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1173 if err != nil {
1174 logger.Errorw("Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001175 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001176 return nil
1177 }
1178 logger.Debug("send MBPCD-Create-msg done")
1179 return meInstance
1180 }
1181 logger.Errorw("Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001182 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001183 return nil
1184}
1185
1186func (oo *OmciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
1187 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1188 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001189 logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001190 "SequNo": strconv.FormatInt(int64(tid), 16),
1191 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1192
1193 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1194 if omciErr.GetError() == nil {
1195 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1196 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1197 omci.TransactionID(tid), omci.AddDefaults(true))
1198 if err != nil {
1199 logger.Errorw("Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001200 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001201 return nil
1202 }
1203
1204 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1205 if err != nil {
1206 logger.Errorw("Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001207 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001208 return nil
1209 }
1210
1211 omciRxCallbackPair := CallbackPair{
1212 cbKey: tid,
1213 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1214 }
1215 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1216 if err != nil {
1217 logger.Errorw("Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001218 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001219 return nil
1220 }
1221 logger.Debug("send GemNCTP-Create-msg done")
1222 return meInstance
1223 }
1224 logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001225 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001226 return nil
1227}
1228
1229func (oo *OmciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
1230 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1231 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001232 logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001233 "SequNo": strconv.FormatInt(int64(tid), 16),
1234 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1235
1236 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1237 if omciErr.GetError() == nil {
1238 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1239 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1240 omci.TransactionID(tid))
1241 if err != nil {
1242 logger.Errorw("Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001243 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001244 return nil
1245 }
1246
1247 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1248 if err != nil {
1249 logger.Errorw("Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001250 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001251 return nil
1252 }
1253
1254 omciRxCallbackPair := CallbackPair{
1255 cbKey: tid,
1256 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1257 }
1258 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1259 if err != nil {
1260 logger.Errorw("Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001261 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001262 return nil
1263 }
1264 logger.Debug("send GemIwTp-Create-msg done")
1265 return meInstance
1266 }
1267 logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001268 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001269 return nil
1270}
1271
1272func (oo *OmciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
1273 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1274 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001275 logger.Debugw("send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001276 "SequNo": strconv.FormatInt(int64(tid), 16),
1277 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1278
1279 meInstance, omciErr := me.NewTCont(params[0])
1280 if omciErr.GetError() == nil {
1281 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1282 if err != nil {
1283 logger.Errorw("Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001284 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001285 return nil
1286 }
1287
1288 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1289 if err != nil {
1290 logger.Errorw("Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001291 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001292 return nil
1293 }
1294
1295 omciRxCallbackPair := CallbackPair{
1296 cbKey: tid,
1297 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1298 }
1299 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1300 if err != nil {
1301 logger.Errorw("Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001302 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001303 return nil
1304 }
1305 logger.Debug("send TCont-set msg done")
1306 return meInstance
1307 }
1308 logger.Errorw("Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001309 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001310 return nil
1311}
1312
1313func (oo *OmciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
1314 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1315 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001316 logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001317 "SequNo": strconv.FormatInt(int64(tid), 16),
1318 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1319
1320 meInstance, omciErr := me.NewPriorityQueue(params[0])
1321 if omciErr.GetError() == nil {
1322 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1323 if err != nil {
1324 logger.Errorw("Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001325 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001326 return nil
1327 }
1328
1329 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1330 if err != nil {
1331 logger.Errorw("Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001332 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001333 return nil
1334 }
1335
1336 omciRxCallbackPair := CallbackPair{
1337 cbKey: tid,
1338 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1339 }
1340 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1341 if err != nil {
1342 logger.Errorw("Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001343 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001344 return nil
1345 }
1346 logger.Debug("send PrioQueue-set msg done")
1347 return meInstance
1348 }
1349 logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001350 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001351 return nil
1352}
1353
1354func (oo *OmciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
1355 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1356 tid := oo.GetNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001357 logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001358 "SequNo": strconv.FormatInt(int64(tid), 16),
1359 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1360
1361 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1362 if omciErr.GetError() == nil {
1363 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1364 if err != nil {
1365 logger.Errorw("Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001366 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001367 return nil
1368 }
1369
1370 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1371 if err != nil {
1372 logger.Errorw("Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001373 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001374 return nil
1375 }
1376
1377 omciRxCallbackPair := CallbackPair{
1378 cbKey: tid,
1379 cbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse},
1380 }
1381 err = oo.Send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1382 if err != nil {
1383 logger.Errorw("Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001384 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001385 return nil
1386 }
1387 logger.Debug("send 1PMapper-set msg done")
1388 return meInstance
1389 }
1390 logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001391 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001392 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001393}