blob: 17e674df701408541918d8e74a860ad05848f631 [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"
Andrea Campanella6515c582020-10-05 11:25:00 +020026 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000027 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000028 "sync"
mpagenkodff5dda2020-08-28 11:52:01 +000029
Holger Hildebrandtfa074992020-03-27 15:42:06 +000030 //"time"
31
32 "github.com/google/gopacket"
33 // TODO!!! Some references could be resolved auto, but some need specific context ....
34 gp "github.com/google/gopacket"
35
36 "github.com/opencord/omci-lib-go"
37 me "github.com/opencord/omci-lib-go/generated"
38 "github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif"
39
40 //"github.com/opencord/voltha-lib-go/v3/pkg/kafka"
41 "github.com/opencord/voltha-lib-go/v3/pkg/log"
42 ic "github.com/opencord/voltha-protos/v3/go/inter_container"
43 //"github.com/opencord/voltha-protos/v3/go/openflow_13"
44 //"github.com/opencord/voltha-protos/v3/go/voltha"
45)
46
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053048
49//ConstDefaultOmciTimeout - Default OMCI Timeout
Holger Hildebrandtfa074992020-03-27 15:42:06 +000050const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds
51
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000052const galEthernetEID = uint16(1)
53const maxGemPayloadSize = uint16(48)
54const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053055
56//const defaultTPID = uint16(0x8100)
57//const broadComDefaultVID = uint16(4091)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000058const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
59const ieeeMapperServiceProfileEID = uint16(0x8001)
60const macBridgePortAniEID = uint16(0x2102)
61
mpagenko8b07c1b2020-11-26 10:36:31 +000062const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
63
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000064// ### OMCI related definitions - end
65
Himani Chawla6d2ae152020-09-02 13:11:20 +053066//callbackPairEntry to be used for OMCI send/receive correlation
67type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000068 cbRespChannel chan Message
69 cbFunction func(*omci.OMCI, *gp.Packet, chan Message) error
70}
71
Himani Chawla6d2ae152020-09-02 13:11:20 +053072//callbackPair to be used for ReceiveCallback init
73type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000074 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053075 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000076}
77
78type omciTransferStructure struct {
79 txFrame []byte
80 timeout int
81 retry int
82 highPrio bool
83}
84
Himani Chawla6d2ae152020-09-02 13:11:20 +053085//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
86type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +000087 enabled bool
88 pOnuDeviceEntry *OnuDeviceEntry
89 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +053090 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +000091 coreProxy adapterif.CoreProxy
92 adapterProxy adapterif.AdapterProxy
93 supportExtMsg bool
94 //txRequest
95 //rxResponse
96 //pendingRequest
97 txFrames, txOnuFrames uint32
98 rxFrames, rxOnuFrames, rxOnuDiscards uint32
99
100 // OMCI params
101 mutexTid sync.Mutex
102 tid uint16
103 mutexHpTid sync.Mutex
104 hpTid uint16
105 uploadSequNo uint16
106 uploadNoOfCmds uint16
107
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000108 mutexTxQueue sync.Mutex
109 txQueue *list.List
110 mutexRxSchedMap sync.Mutex
Himani Chawla6d2ae152020-09-02 13:11:20 +0530111 rxSchedulerMap map[uint16]callbackPairEntry
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000112 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000113}
114
Himani Chawla6d2ae152020-09-02 13:11:20 +0530115//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000116//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530117func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
118 deviceID string, deviceHandler *deviceHandler,
119 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
Holger Hildebrandt80129db2020-11-23 10:49:32 +0000120 logger.Debugw("init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530121 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000122 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530123 omciCC.pOnuDeviceEntry = onuDeviceEntry
124 omciCC.deviceID = deviceID
125 omciCC.pBaseDeviceHandler = deviceHandler
126 omciCC.coreProxy = coreProxy
127 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000128 omciCC.supportExtMsg = false
129 omciCC.txFrames = 0
130 omciCC.txOnuFrames = 0
131 omciCC.rxFrames = 0
132 omciCC.rxOnuFrames = 0
133 omciCC.rxOnuDiscards = 0
134 omciCC.tid = 0x1
135 omciCC.hpTid = 0x8000
136 omciCC.uploadSequNo = 0
137 omciCC.uploadNoOfCmds = 0
138
139 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530140 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000141
142 return &omciCC
143}
144
mpagenko900ee4b2020-10-12 11:56:34 +0000145//stop stops/resets the omciCC
146func (oo *omciCC) stop(ctx context.Context) error {
mpagenko8b07c1b2020-11-26 10:36:31 +0000147 logger.Debugw("omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000148 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
149 oo.mutexTxQueue.Lock()
150 oo.txQueue.Init() // clear the tx queue
151 oo.mutexTxQueue.Unlock()
152 oo.mutexRxSchedMap.Lock()
153 for k := range oo.rxSchedulerMap {
154 delete(oo.rxSchedulerMap, k) //clear the scheduler map
155 }
156 oo.mutexRxSchedMap.Unlock()
157 oo.mutexHpTid.Lock()
158 oo.hpTid = 0x8000 //reset the high prio transactionId
159 oo.mutexHpTid.Unlock()
160 oo.mutexTid.Lock()
161 oo.tid = 1 //reset the low prio transactionId
162 oo.mutexTid.Unlock()
163 //reset control values
164 oo.uploadSequNo = 0
165 oo.uploadNoOfCmds = 0
166 //reset the stats counter - which might be topic of discussion ...
167 oo.txFrames = 0
168 oo.txOnuFrames = 0
169 oo.rxFrames = 0
170 oo.rxOnuFrames = 0
171 oo.rxOnuDiscards = 0
172
173 return nil
174}
175
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000176// Rx handler for omci messages
Himani Chawla6d2ae152020-09-02 13:11:20 +0530177func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000178 logger.Debugw("rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000179 "payload": hex.EncodeToString(omciMsg.Payload)})
180 /*
181 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
182 rxOnuFrames++
183
184 switch msgType {
185 case AlarmNotification:
186 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000187 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000188 // python code was:
189 //if msg_type == EntityOperations.AlarmNotification.value:
190 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
191 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
192 //
193 return errors.New("RxAlarmNotification unimplemented")
194 }
195 case AttributeValueChange:
196 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000197 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000198 // python code was:
199 //elif msg_type == EntityOperations.AttributeValueChange.value:
200 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
201 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
202 //
203 return errors.New("RxAttributeValueChange unimplemented")
204 }
205 case TestResult:
206 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000207 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000208 // python code was:
209 //elif msg_type == EntityOperations.TestResult.value:
210 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
211 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
212 //
213 return errors.New("RxTestResult unimplemented")
214 }
215 default:
216 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000217 logger.Errorw("rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000218 rxOnuDiscards++
219 return errors.New("RxOnuMsgType unimplemented")
220 }
221 }
222 */
Himani Chawla4d908332020-08-31 12:30:20 +0530223 return errors.New("receiveOnuMessage unimplemented")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000224}
225
226// Rx handler for onu messages
227// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530228func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000229 //logger.Debugw("cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000230 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
231 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
232 // (am extendedFormat message could be destroyed this way!)
233 trailerLenData := rxMsg[42:44]
234 trailerLen := binary.BigEndian.Uint16(trailerLenData)
mpagenko1cc3cb42020-07-27 15:24:38 +0000235 //logger.Debugw("omci-received-trailer-len", log.Fields{"Length": trailerLen})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000236 if trailerLen != 40 { // invalid base Format entry -> autocorrect
237 binary.BigEndian.PutUint16(rxMsg[42:44], 40)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000238 logger.Debug("cc-corrected-omci-message: trailer len inserted")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000239 }
240 } else {
Himani Chawla4d908332020-08-31 12:30:20 +0530241 logger.Errorw("received omci-message too small for OmciBaseFormat - abort", log.Fields{"Length": len(rxMsg)})
Andrea Campanella6515c582020-10-05 11:25:00 +0200242 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000243 }
244
245 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
246 if packet == nil {
mpagenko8b07c1b2020-11-26 10:36:31 +0000247 logger.Errorw("omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200248 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000249 }
250 omciLayer := packet.Layer(omci.LayerTypeOMCI)
251 if omciLayer == nil {
mpagenko8b07c1b2020-11-26 10:36:31 +0000252 logger.Errorw("omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200253 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000254 }
255 omciMsg, ok := omciLayer.(*omci.OMCI)
256 if !ok {
mpagenko8b07c1b2020-11-26 10:36:31 +0000257 logger.Errorw("omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200258 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000259 }
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000260 logger.Debugw("omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000261 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000262 if byte(omciMsg.MessageType)&me.AK == 0 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000263 // Not a response
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000264 logger.Debug("RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000265 if omciMsg.TransactionID == 0 {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530266 return oo.receiveOnuMessage(ctx, omciMsg)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000267 }
Himani Chawla4d908332020-08-31 12:30:20 +0530268 logger.Errorw("Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200269 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000270 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200271 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530272
273 }
274 //logger.Debug("RxMsg is a Omci Response Message: try to schedule it to the requester")
275 oo.mutexRxSchedMap.Lock()
276 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
277 if ok && rxCallbackEntry.cbFunction != nil {
278 //disadvantage of decoupling: error verification made difficult, but anyway the question is
279 // how to react on erroneous frame reception, maybe can simply be ignored
280 go rxCallbackEntry.cbFunction(omciMsg, &packet, rxCallbackEntry.cbRespChannel)
281 // having posted the response the request is regarded as 'done'
282 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
283 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000284 } else {
Himani Chawla4d908332020-08-31 12:30:20 +0530285 oo.mutexRxSchedMap.Unlock()
mpagenko8b07c1b2020-11-26 10:36:31 +0000286 logger.Errorw("omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200287 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000288 }
289
290 return nil
291 /* py code was:
292 Receive and OMCI message from the proxy channel to the OLT.
293
294 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
295 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
296 """
297 if not self.enabled:
298 return
299
300 try:
301 now = arrow.utcnow()
302 d = None
303
304 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
305 # save the current value of the entity_id_to_class_map, then
306 # replace it with our custom one before decode, and then finally
307 # restore it later. Tried other ways but really made the code messy.
308 saved_me_map = omci_entities.entity_id_to_class_map
309 omci_entities.entity_id_to_class_map = self._me_map
310
311 try:
312 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000313 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000314 except KeyError as e:
315 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000316 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000317 rx_frame = self._decode_unknown_me(msg)
318 self._rx_unknown_me += 1
319
320 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000321 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000322 return
323
324 finally:
325 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
326
327 rx_tid = rx_frame.fields['transaction_id']
328 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000329 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000330 # Filter the Test Result frame and route through receive onu
331 # message method.
332 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000333 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000334 return self._receive_onu_message(rx_frame)
335
336 # Previously unreachable if this is the very first round-trip Rx or we
337 # have been running consecutive errors
338 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000339 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000340 self.reactor.callLater(0, self._publish_connectivity_event, True)
341
342 self._rx_frames += 1
343 self._consecutive_errors = 0
344
345 try:
346 high_priority = self._tid_is_high_priority(rx_tid)
347 index = self._get_priority_index(high_priority)
348
349 # (timestamp, defer, frame, timeout, retry, delayedCall)
350 last_tx_tuple = self._tx_request[index]
351
352 if last_tx_tuple is None or \
353 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
354 # Possible late Rx on a message that timed-out
355 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000356 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000357 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
358 self._rx_unknown_tid += 1
359 self._rx_late += 1
360 return
361
362 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
363 if dc is not None and not dc.cancelled and not dc.called:
364 dc.cancel()
365
366 _secs = self._update_rx_tx_stats(now, ts)
367
368 # Late arrival already serviced by a timeout?
369 if d.called:
370 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000371 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000372 return
373
374 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000375 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000376 if d is not None:
377 return d.errback(failure.Failure(e))
378 return
379
380 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000381 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000382 tx_tid = tx_frame.fields['transaction_id'])
383 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
384
385 # begin success callback chain (will cancel timeout and queue next Tx message)
386 self._rx_response[index] = rx_frame
387 d.callback(rx_frame)
388
389 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000390 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000391 */
392}
393
Himani Chawla6d2ae152020-09-02 13:11:20 +0530394/*
395func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530396 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530397 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000398}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530399*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000400
401//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530402func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
403 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000404
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000405 logger.Debugw("register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000406 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
407 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000408 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000409 oo.mutexRxSchedMap.Unlock()
410
411 //just use a simple list for starting - might need some more effort, especially for multi source write access
412 omciTxRequest := omciTransferStructure{
413 txFrame,
414 timeout,
415 retry,
416 highPrio,
417 }
418 oo.mutexTxQueue.Lock()
419 oo.txQueue.PushBack(omciTxRequest) // enqueue
420 oo.mutexTxQueue.Unlock()
421
422 // for first test just bypass and send directly:
423 go oo.sendNextRequest(ctx)
424 return nil
425}
426
427//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530428func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000429 // return errors.New("sendNextRequest unimplemented")
430
431 // just try to get something transferred !!
432 // avoid accessing the txQueue from parallel send requests
433 // block parallel omci send requests at least until SendIAP is 'committed'
434 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
435 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000436 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000437 for oo.txQueue.Len() > 0 {
438 queueElement := oo.txQueue.Front() // First element
439 omciTxRequest := queueElement.Value.(omciTransferStructure)
440 /* compare olt device handler code:
441 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000442 logger.Debugw("omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000443 var deviceType string
444 var deviceID string
445 var proxyDeviceID string
446
447 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
448
449 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
450
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000451 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 +0000452 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
453 kwargs := make(map[string]interface{})
454 kwargs["onu_id"] = omciInd.OnuId
455 kwargs["parent_port_no"] = ponPort
456
457 onuDevice, err := dh.coreProxy.GetChildDevice(context.TODO(), dh.device.Id, kwargs)
458 if err != nil {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000459 logger.Errorw("onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000460 return
461 }
462 deviceType = onuDevice.Type
463 deviceID = onuDevice.Id
464 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
465 //if not exist in cache, then add to cache.
466 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
467 } else {
468 //found in cache
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000469 logger.Debugw("omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000470 deviceType = onuInCache.(*OnuDevice).deviceType
471 deviceID = onuInCache.(*OnuDevice).deviceID
472 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
473 }
474 */
475 /* and compare onu_adapter py code:
476 omci_msg = InterAdapterOmciMessage(
477 message=bytes(frame),
478 proxy_address=self._proxy_address,
479 connect_status=self._device.connect_status)
480
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000481 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000482
483 yield self._adapter_proxy.send_inter_adapter_message(
484 msg=omci_msg,
485 type=InterAdapterMessageType.OMCI_REQUEST,
486 from_adapter=self._device.type,
487 to_adapter=self._proxy_address.device_type,
488 to_device_id=self._device_id,
489 proxy_device_id=self._proxy_address.device_id
490 )
491 */
492 device, err := oo.coreProxy.GetDevice(ctx,
493 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
494 if err != nil || device == nil {
495 /*TODO: needs to handle error scenarios */
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000496 logger.Errorw("Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000497 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200498 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000499 }
500
mpagenko8b07c1b2020-11-26 10:36:31 +0000501 logger.Debugw("omci-message-to-send:", log.Fields{
502 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
503 "device-id": oo.deviceID,
504 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
505 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000506
507 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
508 if sendErr := oo.adapterProxy.SendInterAdapterMessage(context.Background(), omciMsg,
509 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800510 //fromTopic,toType,toDevId, ProxyDevId
511 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000512 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
Andrea Campanella6515c582020-10-05 11:25:00 +0200513 logger.Errorw("send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000514 return sendErr
515 }
516 oo.txQueue.Remove(queueElement) // Dequeue
517 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000518 return nil
519}
520
Himani Chawla6d2ae152020-09-02 13:11:20 +0530521func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000522 var next uint16
523 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000524 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000525 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530526 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000527 if oo.hpTid < 0x8000 {
528 oo.hpTid = 0x8000
529 }
mpagenko900ee4b2020-10-12 11:56:34 +0000530 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000531 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000532 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000533 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530534 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000535 if oo.tid >= 0x8000 {
536 oo.tid = 1
537 }
mpagenko900ee4b2020-10-12 11:56:34 +0000538 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000539 }
540 return next
541}
542
543// ###################################################################################
544// # utility methods provided to work on OMCI messages
545func serialize(msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
546 omciLayer := &omci.OMCI{
547 TransactionID: tid,
548 MessageType: msgType,
549 }
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000550 return serializeOmciLayer(omciLayer, request)
551}
552
Himani Chawla4d908332020-08-31 12:30:20 +0530553func serializeOmciLayer(aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554 var options gopacket.SerializeOptions
555 options.FixLengths = true
556
557 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530558 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000559 if err != nil {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000560 logger.Errorw("Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000561 return nil, err
562 }
563 return buffer.Bytes(), nil
564}
565
Himani Chawla4d908332020-08-31 12:30:20 +0530566/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000567func hexEncode(omciPkt []byte) ([]byte, error) {
568 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
569 hex.Encode(dst, omciPkt)
570 return dst, nil
571}
Himani Chawla4d908332020-08-31 12:30:20 +0530572*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000573
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000574//supply a response handler for omci response messages to be transferred to the requested FSM
Himani Chawla6d2ae152020-09-02 13:11:20 +0530575func (oo *omciCC) receiveOmciResponse(omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000576
mpagenko3dbcdd22020-07-22 07:38:45 +0000577 logger.Debugw("omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000578 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000579
580 if oo.pOnuDeviceEntry == nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000581 logger.Errorw("Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000582 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200583 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000584 }
585
586 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
587 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000588 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000589 Type: OMCI,
590 Data: OmciMessage{
591 OmciMsg: omciMsg,
592 OmciPacket: packet,
593 },
594 }
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000595 //logger.Debugw("Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000596 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000597
598 return nil
599}
600
Himani Chawla6d2ae152020-09-02 13:11:20 +0530601func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000602
divyadesai4d299552020-08-18 07:13:49 +0000603 logger.Debugw("send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 request := &omci.MibResetRequest{
605 MeBasePacket: omci.MeBasePacket{
606 EntityClass: me.OnuDataClassID,
607 },
608 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530609 tid := oo.getNextTid(highPrio)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000610 pkt, err := serialize(omci.MibResetRequestType, request, tid)
611 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000612 logger.Errorw("Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000613 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000614 return err
615 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530616 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000617 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530618 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000619 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530620 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000621}
622
Himani Chawla6d2ae152020-09-02 13:11:20 +0530623func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
divyadesai4d299552020-08-18 07:13:49 +0000624 logger.Debugw("send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300625 request := &omci.RebootRequest{
626 MeBasePacket: omci.MeBasePacket{
627 EntityClass: me.OnuGClassID,
628 },
629 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530630 tid := oo.getNextTid(highPrio)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300631 pkt, err := serialize(omci.RebootRequestType, request, tid)
632 if err != nil {
633 logger.Errorw("Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000634 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300635 return err
636 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530637 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300638 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530639 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300640 }
641
Himani Chawla6d2ae152020-09-02 13:11:20 +0530642 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300643 if err != nil {
644 logger.Errorw("Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000645 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300646 return err
647 }
648 err = oo.pOnuDeviceEntry.waitForRebootResponse(responseChannel)
649 if err != nil {
Andrea Campanella6515c582020-10-05 11:25:00 +0200650 logger.Errorw("aborting ONU Reboot!", log.Fields{
651 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300652 return err
653 }
654 return nil
655}
656
Himani Chawla6d2ae152020-09-02 13:11:20 +0530657func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
divyadesai4d299552020-08-18 07:13:49 +0000658 logger.Debugw("send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000659 request := &omci.MibUploadRequest{
660 MeBasePacket: omci.MeBasePacket{
661 EntityClass: me.OnuDataClassID,
662 },
663 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530664 tid := oo.getNextTid(highPrio)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000665 pkt, err := serialize(omci.MibUploadRequestType, request, tid)
666 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000667 logger.Errorw("Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000668 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000669 return err
670 }
671 oo.uploadSequNo = 0
672 oo.uploadNoOfCmds = 0
673
Himani Chawla6d2ae152020-09-02 13:11:20 +0530674 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000675 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530676 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000677 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530678 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000679}
680
Himani Chawla6d2ae152020-09-02 13:11:20 +0530681func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
divyadesai4d299552020-08-18 07:13:49 +0000682 logger.Debugw("send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000683 request := &omci.MibUploadNextRequest{
684 MeBasePacket: omci.MeBasePacket{
685 EntityClass: me.OnuDataClassID,
686 },
687 CommandSequenceNumber: oo.uploadSequNo,
688 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530689 tid := oo.getNextTid(highPrio)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000690 pkt, err := serialize(omci.MibUploadNextRequestType, request, tid)
691 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000692 logger.Errorw("Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000693 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000694 return err
695 }
696 oo.uploadSequNo++
697
Himani Chawla6d2ae152020-09-02 13:11:20 +0530698 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000699 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530700 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000701 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530702 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000703}
704
Himani Chawla6d2ae152020-09-02 13:11:20 +0530705func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
706 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000707 logger.Debugw("send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000708 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000709
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000710 meParams := me.ParamData{
711 EntityID: galEthernetEID,
712 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
713 }
714 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
715 if omciErr.GetError() == nil {
716 //all setByCreate parameters already set, no default option required ...
717 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
718 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000719 logger.Errorw("Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000720 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000721 return nil
722 }
723
724 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
725 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000726 logger.Errorw("Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000727 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000728 return nil
729 }
730
Himani Chawla6d2ae152020-09-02 13:11:20 +0530731 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000732 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530733 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000734 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530735 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000736 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000737 logger.Errorw("Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000738 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000739 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000740 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000741 logger.Debug("send GalEnetProfile-Create-msg done")
742 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000743 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000744 logger.Errorw("Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000745 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000746 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000747}
748
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000749// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530750func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
751 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000752 logger.Debugw("send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000753 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000754
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000755 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
756 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000757 // By now we just use fix values to fire - this is anyway what the python adapter does
758 // read ONU-2G from DB ???? //TODO!!!
759 meParams := me.ParamData{
760 EntityID: 0,
761 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
762 }
763 meInstance, omciErr := me.NewOnu2G(meParams)
764 if omciErr.GetError() == nil {
765 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
766 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000767 logger.Errorw("Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000768 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000769 return nil
770 }
771
772 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
773 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000774 logger.Errorw("Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000775 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000776 return nil
777 }
778
Himani Chawla6d2ae152020-09-02 13:11:20 +0530779 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000780 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530781 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000782 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530783 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000784 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000785 logger.Errorw("Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000786 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000787 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000788 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000789 logger.Debug("send ONU2-G-Set-msg done")
790 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000791 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000792 logger.Errorw("Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000793 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000794 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000795}
796
Himani Chawla6d2ae152020-09-02 13:11:20 +0530797func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
798 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
799 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530800 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
divyadesai4d299552020-08-18 07:13:49 +0000801 logger.Debugw("send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000802 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000803
804 meParams := me.ParamData{
805 EntityID: instID,
806 Attributes: me.AttributeValueMap{
807 "Priority": 0x8000,
808 "MaxAge": 20 * 256, //20s
809 "HelloTime": 2 * 256, //2s
810 "ForwardDelay": 15 * 256, //15s
811 //note: DynamicFilteringAgeingTime is taken from omci lib default as
812 // which is obviously different from default value used in python lib,
813 // where the value seems to be 0 (ONU defined) - to be considered in case of test artifacts ...
814 },
815 }
816
817 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
818 if omciErr.GetError() == nil {
819 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
820 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
821 omci.TransactionID(tid), omci.AddDefaults(true))
822 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000823 logger.Errorw("Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000824 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000825 return nil
826 }
827
828 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
829 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000830 logger.Errorw("Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000831 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000832 return nil
833 }
834
Himani Chawla6d2ae152020-09-02 13:11:20 +0530835 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000836 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530837 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000838 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530839 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000840 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000841 logger.Errorw("Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000842 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000843 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000844 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000845 logger.Debug("send MBSP-Create-msg done")
846 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000847 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000848 logger.Errorw("Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000849 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000850 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000851}
852
Himani Chawla6d2ae152020-09-02 13:11:20 +0530853func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
854 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
855 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530856 instID := macBridgePortAniEID + aPUniPort.entityID
divyadesai4d299552020-08-18 07:13:49 +0000857 logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000858 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000859
860 meParams := me.ParamData{
861 EntityID: instID,
862 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530863 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
864 "PortNum": aPUniPort.macBpNo,
865 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530866 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000867 },
868 }
869 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
870 if omciErr.GetError() == nil {
871 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
872 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
873 omci.TransactionID(tid), omci.AddDefaults(true))
874 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000875 logger.Errorw("Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000876 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000877 return nil
878 }
879
880 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
881 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000882 logger.Errorw("Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000883 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000884 return nil
885 }
886
Himani Chawla6d2ae152020-09-02 13:11:20 +0530887 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000888 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530889 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000890 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530891 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000892 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000893 logger.Errorw("Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000894 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000895 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000896 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000897 logger.Debug("send MBPCD-Create-msg done")
898 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000899 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000900 logger.Errorw("Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000901 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000902 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000903}
904
Himani Chawla6d2ae152020-09-02 13:11:20 +0530905func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
906 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
907 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000908 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +0530909 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
divyadesai4d299552020-08-18 07:13:49 +0000910 logger.Debugw("send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000911 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000912
913 // compare python adapter code WA VOL-1311: this is not done here!
914 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
915 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
916 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +0530917 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000918 assType = uint8(10) // for VEIP
919 }
920 meParams := me.ParamData{
921 EntityID: instID,
922 Attributes: me.AttributeValueMap{
923 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +0530924 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000925 },
926 }
927 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
928 if omciErr.GetError() == nil {
929 //all setByCreate parameters already set, no default option required ...
930 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
931 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000932 logger.Errorw("Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000933 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000934 return nil
935 }
936
937 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
938 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000939 logger.Errorw("Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000940 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000941 return nil
942 }
943
Himani Chawla6d2ae152020-09-02 13:11:20 +0530944 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000945 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530946 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000947 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530948 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949 if err != nil {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000950 logger.Errorw("Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000951 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000952 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000953 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000954 logger.Debug("send EVTOCD-Create-msg done")
955 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000956 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000957 logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000958 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000959 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000960}
961
Himani Chawla6d2ae152020-09-02 13:11:20 +0530962func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000963 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530964 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +0000965 logger.Debugw("send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000966 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000967
968 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
969 meParams := me.ParamData{
970 EntityID: 0,
971 Attributes: requestedAttributes,
972 }
973 meInstance, omciErr := me.NewOnuG(meParams)
974 if omciErr.GetError() == nil {
975 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
976 if err != nil {
977 logger.Errorw("Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000978 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000979 return nil
980 }
981
982 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
983 if err != nil {
984 logger.Errorw("Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000985 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000986 return nil
987 }
988
Himani Chawla6d2ae152020-09-02 13:11:20 +0530989 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000990 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530991 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000992 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530993 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000994 if err != nil {
995 logger.Errorw("Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000996 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000997 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000998 }
mpagenko3dbcdd22020-07-22 07:38:45 +0000999 logger.Debug("send ONU-G-Set-msg done")
1000 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001001 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001002 logger.Errorw("Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001003 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001004 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001005}
1006
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001007func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1008 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1009 tid := oo.getNextTid(highPrio)
1010 logger.Debugw("send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
1011 "SequNo": strconv.FormatInt(int64(tid), 16)})
1012
1013 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1014 meParams := me.ParamData{
1015 EntityID: aInstNo,
1016 Attributes: requestedAttributes,
1017 }
1018 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1019 if omciErr.GetError() == nil {
1020 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1021 if err != nil {
1022 logger.Errorw("Cannot encode PPTPEthUni instance for set", log.Fields{
1023 "Err": err, "device-id": oo.deviceID})
1024 return nil
1025 }
1026
1027 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1028 if err != nil {
1029 logger.Errorw("Cannot serialize PPTPEthUni-Set", log.Fields{
1030 "Err": err, "device-id": oo.deviceID})
1031 return nil
1032 }
1033
1034 omciRxCallbackPair := callbackPair{
1035 cbKey: tid,
1036 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1037 }
1038 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1039 if err != nil {
1040 logger.Errorw("Cannot send PPTPEthUni-Set", log.Fields{
1041 "Err": err, "device-id": oo.deviceID})
1042 return nil
1043 }
1044 logger.Debug("send PPTPEthUni-Set-msg done")
1045 return meInstance
1046 }
1047 logger.Errorw("Cannot generate PPTPEthUni", log.Fields{
1048 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1049 return nil
1050}
1051
1052/* UniG obsolete by now, left here in case it should be needed once again
1053 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301054func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001055 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301056 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001057 logger.Debugw("send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001058 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001059
1060 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1061 meParams := me.ParamData{
1062 EntityID: aInstNo,
1063 Attributes: requestedAttributes,
1064 }
1065 meInstance, omciErr := me.NewUniG(meParams)
1066 if omciErr.GetError() == nil {
1067 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1068 if err != nil {
1069 logger.Errorw("Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001070 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001071 return nil
1072 }
1073
1074 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1075 if err != nil {
1076 logger.Errorw("Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001077 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001078 return nil
1079 }
1080
Himani Chawla6d2ae152020-09-02 13:11:20 +05301081 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001082 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301083 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001084 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301085 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001086 if err != nil {
1087 logger.Errorw("Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001088 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001089 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001090 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001091 logger.Debug("send UNI-G-Set-msg done")
1092 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001093 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001094 logger.Errorw("Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001095 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001096 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001097}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001098*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001099
Himani Chawla6d2ae152020-09-02 13:11:20 +05301100func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001101 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301102 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001103 logger.Debugw("send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001104 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001105
1106 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1107 meParams := me.ParamData{
1108 EntityID: aInstNo,
1109 Attributes: requestedAttributes,
1110 }
1111 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1112 if omciErr.GetError() == nil {
1113 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1114 if err != nil {
1115 logger.Errorw("Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001116 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001117 return nil
1118 }
1119
1120 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1121 if err != nil {
1122 logger.Errorw("Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001123 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001124 return nil
1125 }
1126
Himani Chawla6d2ae152020-09-02 13:11:20 +05301127 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001128 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301129 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001130 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301131 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001132 if err != nil {
1133 logger.Errorw("Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001134 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001135 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001136 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001137 logger.Debug("send VEIP-Set-msg done")
1138 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001139 }
mpagenko3dbcdd22020-07-22 07:38:45 +00001140 logger.Errorw("Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001141 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001142 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001143}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001144
Himani Chawla6d2ae152020-09-02 13:11:20 +05301145func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001146 timeout int, highPrio bool) *me.ManagedEntity {
1147
Himani Chawla6d2ae152020-09-02 13:11:20 +05301148 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001149 logger.Debugw("send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001150 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001151
1152 meParams := me.ParamData{
1153 EntityID: entityID,
1154 Attributes: requestedAttributes,
1155 }
1156 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1157 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301158 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001159 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1160 if err != nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301161 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 +00001162 return nil
1163 }
1164 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1165 if err != nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301166 logger.Errorw("Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001167 return nil
1168 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301169 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001170 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301171 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001172 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301173 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001174 if err != nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301175 logger.Errorw("Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001176 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001177 }
Himani Chawla4d908332020-08-31 12:30:20 +05301178 logger.Debugw("send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001179 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001180 }
divyadesai4d299552020-08-18 07:13:49 +00001181 logger.Errorw("Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001182 return nil
1183}
1184
Himani Chawla6d2ae152020-09-02 13:11:20 +05301185func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001186 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301187 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001188 logger.Debugw("send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001189 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1190
1191 meParams := me.ParamData{
1192 EntityID: aInstID,
1193 Attributes: me.AttributeValueMap{},
1194 }
1195 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1196 if omciErr.GetError() == nil {
1197 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1198 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1199 omci.TransactionID(tid), omci.AddDefaults(true))
1200 if err != nil {
1201 logger.Errorw("Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001202 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001203 return nil
1204 }
1205
1206 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1207 if err != nil {
1208 logger.Errorw("Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001209 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001210 return nil
1211 }
1212
Himani Chawla6d2ae152020-09-02 13:11:20 +05301213 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001214 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301215 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001216 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301217 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001218 if err != nil {
1219 logger.Errorw("Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001220 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001221 return nil
1222 }
1223 logger.Debug("send .1pMapper-create-msg done")
1224 return meInstance
1225 }
1226 logger.Errorw("Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001227 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001228 return nil
1229}
1230
Himani Chawla6d2ae152020-09-02 13:11:20 +05301231func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001232 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301233 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001234 logger.Debugw("send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001235 "SequNo": strconv.FormatInt(int64(tid), 16),
1236 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1237
1238 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1239 if omciErr.GetError() == nil {
1240 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1241 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1242 omci.TransactionID(tid), omci.AddDefaults(true))
1243 if err != nil {
1244 logger.Errorw("Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001245 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001246 return nil
1247 }
1248
1249 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1250 if err != nil {
1251 logger.Errorw("Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001252 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001253 return nil
1254 }
1255
Himani Chawla6d2ae152020-09-02 13:11:20 +05301256 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001257 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301258 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001259 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301260 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001261 if err != nil {
1262 logger.Errorw("Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001263 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001264 return nil
1265 }
1266 logger.Debug("send MBPCD-Create-msg done")
1267 return meInstance
1268 }
1269 logger.Errorw("Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001270 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001271 return nil
1272}
1273
Himani Chawla6d2ae152020-09-02 13:11:20 +05301274func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001275 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301276 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001277 logger.Debugw("send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001278 "SequNo": strconv.FormatInt(int64(tid), 16),
1279 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1280
1281 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1282 if omciErr.GetError() == nil {
1283 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1284 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1285 omci.TransactionID(tid), omci.AddDefaults(true))
1286 if err != nil {
1287 logger.Errorw("Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001288 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001289 return nil
1290 }
1291
1292 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1293 if err != nil {
1294 logger.Errorw("Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001295 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001296 return nil
1297 }
1298
Himani Chawla6d2ae152020-09-02 13:11:20 +05301299 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001300 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301301 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001302 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301303 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001304 if err != nil {
1305 logger.Errorw("Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001306 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001307 return nil
1308 }
1309 logger.Debug("send GemNCTP-Create-msg done")
1310 return meInstance
1311 }
1312 logger.Errorw("Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001313 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001314 return nil
1315}
1316
Himani Chawla6d2ae152020-09-02 13:11:20 +05301317func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001318 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301319 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001320 logger.Debugw("send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001321 "SequNo": strconv.FormatInt(int64(tid), 16),
1322 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1323
1324 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1325 if omciErr.GetError() == nil {
1326 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1327 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1328 omci.TransactionID(tid))
1329 if err != nil {
1330 logger.Errorw("Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001331 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001332 return nil
1333 }
1334
1335 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1336 if err != nil {
1337 logger.Errorw("Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001338 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001339 return nil
1340 }
1341
Himani Chawla6d2ae152020-09-02 13:11:20 +05301342 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001343 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301344 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001345 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301346 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001347 if err != nil {
1348 logger.Errorw("Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001349 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001350 return nil
1351 }
1352 logger.Debug("send GemIwTp-Create-msg done")
1353 return meInstance
1354 }
1355 logger.Errorw("Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001356 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001357 return nil
1358}
1359
Himani Chawla6d2ae152020-09-02 13:11:20 +05301360func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001361 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301362 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001363 logger.Debugw("send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001364 "SequNo": strconv.FormatInt(int64(tid), 16),
1365 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1366
1367 meInstance, omciErr := me.NewTCont(params[0])
1368 if omciErr.GetError() == nil {
1369 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1370 if err != nil {
1371 logger.Errorw("Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001372 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001373 return nil
1374 }
1375
1376 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1377 if err != nil {
1378 logger.Errorw("Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001379 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001380 return nil
1381 }
1382
Himani Chawla6d2ae152020-09-02 13:11:20 +05301383 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001384 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301385 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001386 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301387 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001388 if err != nil {
1389 logger.Errorw("Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001390 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001391 return nil
1392 }
1393 logger.Debug("send TCont-set msg done")
1394 return meInstance
1395 }
1396 logger.Errorw("Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001397 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001398 return nil
1399}
1400
Himani Chawla6d2ae152020-09-02 13:11:20 +05301401func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001402 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301403 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001404 logger.Debugw("send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001405 "SequNo": strconv.FormatInt(int64(tid), 16),
1406 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1407
1408 meInstance, omciErr := me.NewPriorityQueue(params[0])
1409 if omciErr.GetError() == nil {
1410 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1411 if err != nil {
1412 logger.Errorw("Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001413 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001414 return nil
1415 }
1416
1417 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1418 if err != nil {
1419 logger.Errorw("Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001420 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 return nil
1422 }
1423
Himani Chawla6d2ae152020-09-02 13:11:20 +05301424 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301426 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001427 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301428 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001429 if err != nil {
1430 logger.Errorw("Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001431 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001432 return nil
1433 }
1434 logger.Debug("send PrioQueue-set msg done")
1435 return meInstance
1436 }
1437 logger.Errorw("Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001438 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001439 return nil
1440}
1441
Himani Chawla6d2ae152020-09-02 13:11:20 +05301442func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001443 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301444 tid := oo.getNextTid(highPrio)
divyadesai4d299552020-08-18 07:13:49 +00001445 logger.Debugw("send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001446 "SequNo": strconv.FormatInt(int64(tid), 16),
1447 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1448
1449 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1450 if omciErr.GetError() == nil {
1451 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1452 if err != nil {
1453 logger.Errorw("Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001454 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001455 return nil
1456 }
1457
1458 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1459 if err != nil {
1460 logger.Errorw("Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001461 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001462 return nil
1463 }
1464
Himani Chawla6d2ae152020-09-02 13:11:20 +05301465 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301467 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001468 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301469 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001470 if err != nil {
1471 logger.Errorw("Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001472 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001473 return nil
1474 }
1475 logger.Debug("send 1PMapper-set msg done")
1476 return meInstance
1477 }
1478 logger.Errorw("Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001479 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001480 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001481}
mpagenkodff5dda2020-08-28 11:52:01 +00001482
Himani Chawla6d2ae152020-09-02 13:11:20 +05301483func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001484 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301485 tid := oo.getNextTid(highPrio)
mpagenkodff5dda2020-08-28 11:52:01 +00001486 logger.Debugw("send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1487 "SequNo": strconv.FormatInt(int64(tid), 16),
1488 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1489
1490 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1491 if omciErr.GetError() == nil {
1492 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1493 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1494 omci.TransactionID(tid))
1495 if err != nil {
1496 logger.Errorw("Cannot encode VTFD for create", log.Fields{
1497 "Err": err, "device-id": oo.deviceID})
1498 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1499 // return (dual format) error code that can be used at caller for immediate error treatment
1500 // (relevant to all used sendXX() methods and their error conditions)
1501 return nil
1502 }
1503
1504 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1505 if err != nil {
1506 logger.Errorw("Cannot serialize VTFD create", log.Fields{
1507 "Err": err, "device-id": oo.deviceID})
1508 return nil
1509 }
1510
Himani Chawla6d2ae152020-09-02 13:11:20 +05301511 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001512 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301513 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001514 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301515 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001516 if err != nil {
1517 logger.Errorw("Cannot send VTFD create", log.Fields{
1518 "Err": err, "device-id": oo.deviceID})
1519 return nil
1520 }
1521 logger.Debug("send VTFD-Create-msg done")
1522 return meInstance
1523 }
1524 logger.Errorw("Cannot generate VTFD Instance", log.Fields{
1525 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1526 return nil
1527}
1528
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001529func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1530 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1531 tid := oo.getNextTid(highPrio)
1532 logger.Debugw("send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1533 "SequNo": strconv.FormatInt(int64(tid), 16),
1534 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1535
1536 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1537 if omciErr.GetError() == nil {
1538 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1539 omci.TransactionID(tid))
1540 if err != nil {
1541 logger.Errorw("Cannot encode VTFD for set", log.Fields{
1542 "Err": err, "device-id": oo.deviceID})
1543 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1544 // return (dual format) error code that can be used at caller for immediate error treatment
1545 // (relevant to all used sendXX() methods and their error conditions)
1546 return nil
1547 }
1548
1549 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1550 if err != nil {
1551 logger.Errorw("Cannot serialize VTFD set", log.Fields{
1552 "Err": err, "device-id": oo.deviceID})
1553 return nil
1554 }
1555
1556 omciRxCallbackPair := callbackPair{
1557 cbKey: tid,
1558 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1559 }
1560 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1561 if err != nil {
1562 logger.Errorw("Cannot send VTFD set", log.Fields{
1563 "Err": err, "device-id": oo.deviceID})
1564 return nil
1565 }
1566 logger.Debug("send VTFD-Set-msg done")
1567 return meInstance
1568 }
1569 logger.Errorw("Cannot generate VTFD Instance", log.Fields{
1570 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1571 return nil
1572}
1573
Himani Chawla6d2ae152020-09-02 13:11:20 +05301574func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001575 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301576 tid := oo.getNextTid(highPrio)
mpagenkodff5dda2020-08-28 11:52:01 +00001577 logger.Debugw("send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1578 "SequNo": strconv.FormatInt(int64(tid), 16),
1579 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1580
1581 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1582 if omciErr.GetError() == nil {
1583 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1584 if err != nil {
1585 logger.Errorw("Cannot encode EVTOCD for set", log.Fields{
1586 "Err": err, "device-id": oo.deviceID})
1587 return nil
1588 }
1589
1590 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1591 if err != nil {
1592 logger.Errorw("Cannot serialize EVTOCD set", log.Fields{
1593 "Err": err, "device-id": oo.deviceID})
1594 return nil
1595 }
1596
Himani Chawla6d2ae152020-09-02 13:11:20 +05301597 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001598 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301599 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001600 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301601 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001602 if err != nil {
1603 logger.Errorw("Cannot send EVTOCD set", log.Fields{
1604 "Err": err, "device-id": oo.deviceID})
1605 return nil
1606 }
1607 logger.Debug("send EVTOCD-set msg done")
1608 return meInstance
1609 }
1610 logger.Errorw("Cannot generate EVTOCD Instance", log.Fields{
1611 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1612 return nil
1613}
mpagenko01e726e2020-10-23 09:45:29 +00001614
1615func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1616 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1617 tid := oo.getNextTid(highPrio)
1618 logger.Debugw("send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1619 "SequNo": strconv.FormatInt(int64(tid), 16),
1620 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1621
1622 meParams := me.ParamData{EntityID: aInstID}
1623 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1624 if omciErr.GetError() == nil {
1625 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1626 omci.TransactionID(tid))
1627 if err != nil {
1628 logger.Errorw("Cannot encode VTFD for delete", log.Fields{
1629 "Err": err, "device-id": oo.deviceID})
1630 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1631 // return (dual format) error code that can be used at caller for immediate error treatment
1632 // (relevant to all used sendXX() methods and their error conditions)
1633 return nil
1634 }
1635
1636 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1637 if err != nil {
1638 logger.Errorw("Cannot serialize VTFD delete", log.Fields{
1639 "Err": err, "device-id": oo.deviceID})
1640 return nil
1641 }
1642
1643 omciRxCallbackPair := callbackPair{
1644 cbKey: tid,
1645 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1646 }
1647 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1648 if err != nil {
1649 logger.Errorw("Cannot send VTFD delete", log.Fields{
1650 "Err": err, "device-id": oo.deviceID})
1651 return nil
1652 }
1653 logger.Debug("send VTFD-Delete-msg done")
1654 return meInstance
1655 }
1656 logger.Errorw("Cannot generate VTFD Instance for delete", log.Fields{
1657 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1658 return nil
1659}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001660
mpagenko8b07c1b2020-11-26 10:36:31 +00001661func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1662 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1663 tid := oo.getNextTid(highPrio)
1664 logger.Debugw("send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1665 "SequNo": strconv.FormatInt(int64(tid), 16),
1666 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1667
1668 meParams := me.ParamData{EntityID: aInstID}
1669 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
1670 if omciErr.GetError() == nil {
1671 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1672 omci.TransactionID(tid))
1673 if err != nil {
1674 logger.Errorw("Cannot encode GemIwTp for delete", log.Fields{
1675 "Err": err, "device-id": oo.deviceID})
1676 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1677 // return (dual format) error code that can be used at caller for immediate error treatment
1678 // (relevant to all used sendXX() methods and their error conditions)
1679 return nil
1680 }
1681
1682 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1683 if err != nil {
1684 logger.Errorw("Cannot serialize GemIwTp delete", log.Fields{
1685 "Err": err, "device-id": oo.deviceID})
1686 return nil
1687 }
1688
1689 omciRxCallbackPair := callbackPair{
1690 cbKey: tid,
1691 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1692 }
1693 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1694 if err != nil {
1695 logger.Errorw("Cannot send GemIwTp delete", log.Fields{
1696 "Err": err, "device-id": oo.deviceID})
1697 return nil
1698 }
1699 logger.Debug("send GemIwTp-Delete-msg done")
1700 return meInstance
1701 }
1702 logger.Errorw("Cannot generate GemIwTp Instance for delete", log.Fields{
1703 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1704 return nil
1705}
1706
1707func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
1708 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1709 tid := oo.getNextTid(highPrio)
1710 logger.Debugw("send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1711 "SequNo": strconv.FormatInt(int64(tid), 16),
1712 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1713
1714 meParams := me.ParamData{EntityID: aInstID}
1715 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
1716 if omciErr.GetError() == nil {
1717 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1718 omci.TransactionID(tid))
1719 if err != nil {
1720 logger.Errorw("Cannot encode GemNCtp for delete", log.Fields{
1721 "Err": err, "device-id": oo.deviceID})
1722 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1723 // return (dual format) error code that can be used at caller for immediate error treatment
1724 // (relevant to all used sendXX() methods and their error conditions)
1725 return nil
1726 }
1727
1728 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1729 if err != nil {
1730 logger.Errorw("Cannot serialize GemNCtp delete", log.Fields{
1731 "Err": err, "device-id": oo.deviceID})
1732 return nil
1733 }
1734
1735 omciRxCallbackPair := callbackPair{
1736 cbKey: tid,
1737 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1738 }
1739 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1740 if err != nil {
1741 logger.Errorw("Cannot send GemNCtp delete", log.Fields{
1742 "Err": err, "device-id": oo.deviceID})
1743 return nil
1744 }
1745 logger.Debug("send GemNCtp-Delete-msg done")
1746 return meInstance
1747 }
1748 logger.Errorw("Cannot generate GemNCtp Instance for delete", log.Fields{
1749 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1750 return nil
1751}
1752
1753func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
1754 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1755 tid := oo.getNextTid(highPrio)
1756 logger.Debugw("send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1757 "SequNo": strconv.FormatInt(int64(tid), 16),
1758 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1759
1760 meParams := me.ParamData{EntityID: aInstID}
1761 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1762 if omciErr.GetError() == nil {
1763 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1764 omci.TransactionID(tid))
1765 if err != nil {
1766 logger.Errorw("Cannot encode .1pMapper for delete", log.Fields{
1767 "Err": err, "device-id": oo.deviceID})
1768 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1769 // return (dual format) error code that can be used at caller for immediate error treatment
1770 // (relevant to all used sendXX() methods and their error conditions)
1771 return nil
1772 }
1773
1774 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1775 if err != nil {
1776 logger.Errorw("Cannot serialize .1pMapper delete", log.Fields{
1777 "Err": err, "device-id": oo.deviceID})
1778 return nil
1779 }
1780
1781 omciRxCallbackPair := callbackPair{
1782 cbKey: tid,
1783 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1784 }
1785 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1786 if err != nil {
1787 logger.Errorw("Cannot send .1pMapper delete", log.Fields{
1788 "Err": err, "device-id": oo.deviceID})
1789 return nil
1790 }
1791 logger.Debug("send .1pMapper-Delete-msg done")
1792 return meInstance
1793 }
1794 logger.Errorw("Cannot generate .1pMapper Instance for delete", log.Fields{
1795 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1796 return nil
1797}
1798
1799func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
1800 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1801 tid := oo.getNextTid(highPrio)
1802 logger.Debugw("send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1803 "SequNo": strconv.FormatInt(int64(tid), 16),
1804 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1805
1806 meParams := me.ParamData{EntityID: aInstID}
1807 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1808 if omciErr.GetError() == nil {
1809 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1810 omci.TransactionID(tid))
1811 if err != nil {
1812 logger.Errorw("Cannot encode MBPCD for delete", log.Fields{
1813 "Err": err, "device-id": oo.deviceID})
1814 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1815 // return (dual format) error code that can be used at caller for immediate error treatment
1816 // (relevant to all used sendXX() methods and their error conditions)
1817 return nil
1818 }
1819
1820 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1821 if err != nil {
1822 logger.Errorw("Cannot serialize MBPCD delete", log.Fields{
1823 "Err": err, "device-id": oo.deviceID})
1824 return nil
1825 }
1826
1827 omciRxCallbackPair := callbackPair{
1828 cbKey: tid,
1829 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1830 }
1831 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1832 if err != nil {
1833 logger.Errorw("Cannot send MBPCD delete", log.Fields{
1834 "Err": err, "device-id": oo.deviceID})
1835 return nil
1836 }
1837 logger.Debug("send MBPCD-Delete-msg done")
1838 return meInstance
1839 }
1840 logger.Errorw("Cannot generate MBPCD Instance for delete", log.Fields{
1841 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1842 return nil
1843}
1844
mpagenkofc4f56e2020-11-04 17:17:49 +00001845// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03001846func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
1847 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1848 tid := oo.getNextTid(highPrio)
1849 logger.Debugw("send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
1850 "SequNo": strconv.FormatInt(int64(tid), 16),
1851 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1852
1853 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
1854 if omciErr.GetError() == nil {
1855 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
1856 omci.AddDefaults(true))
1857 if err != nil {
1858 logger.Errorw("Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
1859 return nil
1860 }
1861
1862 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1863 if err != nil {
1864 logger.Errorw("Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
1865 return nil
1866 }
1867
1868 omciRxCallbackPair := callbackPair{cbKey: tid,
1869 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1870 }
1871 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1872 if err != nil {
1873 logger.Errorw("Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
1874 return nil
1875 }
1876 logger.Debug("send MulticastGEMIWTP-create-msg done")
1877 return meInstance
1878 }
1879 logger.Errorw("Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
1880 "device-id": oo.deviceID})
1881 return nil
1882}
1883
mpagenkofc4f56e2020-11-04 17:17:49 +00001884// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03001885func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
1886 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1887 tid := oo.getNextTid(highPrio)
1888 logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
1889 "SequNo": strconv.FormatInt(int64(tid), 16),
1890 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1891
1892 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
1893 if omciErr.GetError() == nil {
1894 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
1895 omci.AddDefaults(true))
1896 if err != nil {
1897 logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
1898 "device-id": oo.deviceID})
1899 return nil
1900 }
1901
1902 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1903 if err != nil {
1904 logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
1905 "device-id": oo.deviceID})
1906 return nil
1907 }
1908
1909 omciRxCallbackPair := callbackPair{cbKey: tid,
1910 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1911 }
1912 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1913 if err != nil {
1914 logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
1915 "device-id": oo.deviceID})
1916 return nil
1917 }
1918 logger.Debug("send MulticastOperationProfile-create-msg done")
1919 return meInstance
1920 }
1921 logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
1922 "device-id": oo.deviceID})
1923 return nil
1924}
1925
mpagenkofc4f56e2020-11-04 17:17:49 +00001926// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03001927func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
1928 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1929 tid := oo.getNextTid(highPrio)
1930 logger.Debugw("send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
1931 "SequNo": strconv.FormatInt(int64(tid), 16),
1932 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1933
1934 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
1935 if omciErr.GetError() == nil {
1936 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
1937 omci.AddDefaults(true))
1938 if err != nil {
1939 logger.Errorw("Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
1940 "device-id": oo.deviceID})
1941 return nil
1942 }
1943
1944 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1945 if err != nil {
1946 logger.Errorw("Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
1947 "device-id": oo.deviceID})
1948 return nil
1949 }
1950
1951 omciRxCallbackPair := callbackPair{cbKey: tid,
1952 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1953 }
1954 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1955 if err != nil {
1956 logger.Errorw("Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
1957 "device-id": oo.deviceID})
1958 return nil
1959 }
1960 logger.Debug("send MulticastOperationProfile-create-msg done")
1961 return meInstance
1962 }
1963 logger.Errorw("Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
1964 "device-id": oo.deviceID})
1965 return nil
1966}
1967
mpagenkofc4f56e2020-11-04 17:17:49 +00001968// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03001969func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
1970 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1971 tid := oo.getNextTid(highPrio)
1972 logger.Debugw("send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
1973 "SequNo": strconv.FormatInt(int64(tid), 16),
1974 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1975
1976 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
1977 if omciErr.GetError() == nil {
1978 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
1979 omci.AddDefaults(true))
1980 if err != nil {
1981 logger.Errorw("Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
1982 "device-id": oo.deviceID})
1983 return nil
1984 }
1985
1986 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1987 if err != nil {
1988 logger.Errorw("Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
1989 "device-id": oo.deviceID})
1990 return nil
1991 }
1992
1993 omciRxCallbackPair := callbackPair{cbKey: tid,
1994 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1995 }
1996 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1997 if err != nil {
1998 logger.Errorw("Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
1999 "device-id": oo.deviceID})
2000 return nil
2001 }
2002 logger.Debug("send MulticastSubConfigInfo-create-msg done")
2003 return meInstance
2004 }
2005 logger.Errorw("Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
2006 "device-id": oo.deviceID})
2007 return nil
2008}