blob: 8d6d4ef04cdddb81151cd167a187f99d7505a905 [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"
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000039
dbainbri4d3a0dc2020-12-02 00:33:42 +000040 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
41 "github.com/opencord/voltha-lib-go/v4/pkg/log"
42 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
43 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
44 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000045)
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
dbainbri4d3a0dc2020-12-02 00:33:42 +000069 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000070}
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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000120 logger.Debugw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000147 logger.Debugw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000178 logger.Debugw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000217 logger.Errorw(ctx,"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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000229 //logger.Debugw(ctx,"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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000235 //logger.Debugw(ctx,"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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000238 logger.Debug(ctx, "cc-corrected-omci-message: trailer len inserted")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000239 }
240 } else {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000241 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000247 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000252 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000257 logger.Errorw(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000260 logger.Debugw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000264 logger.Debug(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000268 logger.Errorw(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000274 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530275 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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000280 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Himani Chawla4d908332020-08-31 12:30:20 +0530281 // 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()
dbainbri4d3a0dc2020-12-02 00:33:42 +0000286 logger.Errorw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000405 logger.Debugw(ctx, "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) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000442 logger.Debugw(ctx,"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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000451 logger.Debugw(ctx,"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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000457 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000458 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000459 logger.Errorw(ctx,"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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000469 logger.Debugw(ctx,"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 */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000496 logger.Errorw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000501 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +0000502 "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}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000508 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000509 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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000513 logger.Errorw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000545func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000546 omciLayer := &omci.OMCI{
547 TransactionID: tid,
548 MessageType: msgType,
549 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000550 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000551}
552
dbainbri4d3a0dc2020-12-02 00:33:42 +0000553func serializeOmciLayer(ctx context.Context, 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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000560 logger.Errorw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000575func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000576
dbainbri4d3a0dc2020-12-02 00:33:42 +0000577 logger.Debugw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000581 logger.Errorw(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000595 //logger.Debugw(ctx,"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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000603 logger.Debugw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000610 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000611 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000612 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000624 logger.Debugw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000631 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300632 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000633 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000644 logger.Errorw(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000648 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300649 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000650 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200651 "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000658 logger.Debugw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000665 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000666 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000667 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000682 logger.Debugw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000690 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000691 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000692 logger.Errorw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000707 logger.Debugw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000719 logger.Errorw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000724 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000725 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000726 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000737 logger.Errorw(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000741 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000742 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000743 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000744 logger.Errorw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000752 logger.Debugw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000767 logger.Errorw(ctx, "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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000772 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000773 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000774 logger.Errorw(ctx, "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 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000785 logger.Errorw(ctx, "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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000789 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000790 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000791 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000792 logger.Errorw(ctx, "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)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000801 logger.Debugw(ctx, "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{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300807 "Priority": 0x8000,
808 "MaxAge": 20 * 256, //20s
809 "HelloTime": 2 * 256, //2s
810 "ForwardDelay": 15 * 256, //15s
811 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000812 },
813 }
814
815 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
816 if omciErr.GetError() == nil {
817 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
818 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
819 omci.TransactionID(tid), omci.AddDefaults(true))
820 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000821 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000822 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000823 return nil
824 }
825
dbainbri4d3a0dc2020-12-02 00:33:42 +0000826 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000827 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000828 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000829 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000830 return nil
831 }
832
Himani Chawla6d2ae152020-09-02 13:11:20 +0530833 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000834 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530835 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000836 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530837 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000838 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000839 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000840 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000841 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000842 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000843 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000844 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000845 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000846 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000847 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000848 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000849}
850
Himani Chawla6d2ae152020-09-02 13:11:20 +0530851func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
852 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
853 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530854 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000855 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000856 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000857
858 meParams := me.ParamData{
859 EntityID: instID,
860 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530861 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
862 "PortNum": aPUniPort.macBpNo,
863 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530864 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000865 },
866 }
867 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
868 if omciErr.GetError() == nil {
869 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
870 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
871 omci.TransactionID(tid), omci.AddDefaults(true))
872 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000873 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000874 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000875 return nil
876 }
877
dbainbri4d3a0dc2020-12-02 00:33:42 +0000878 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000879 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000880 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000881 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000882 return nil
883 }
884
Himani Chawla6d2ae152020-09-02 13:11:20 +0530885 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000886 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530887 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000888 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530889 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000890 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000891 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000892 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000893 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000894 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000895 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000896 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000897 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000898 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000899 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000900 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000901}
902
Himani Chawla6d2ae152020-09-02 13:11:20 +0530903func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
904 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
905 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000906 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +0530907 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000908 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000909 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000910
911 // compare python adapter code WA VOL-1311: this is not done here!
912 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
913 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
914 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +0530915 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000916 assType = uint8(10) // for VEIP
917 }
918 meParams := me.ParamData{
919 EntityID: instID,
920 Attributes: me.AttributeValueMap{
921 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +0530922 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000923 },
924 }
925 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
926 if omciErr.GetError() == nil {
927 //all setByCreate parameters already set, no default option required ...
928 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
929 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000930 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000931 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000932 return nil
933 }
934
dbainbri4d3a0dc2020-12-02 00:33:42 +0000935 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000936 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000937 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000938 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000939 return nil
940 }
941
Himani Chawla6d2ae152020-09-02 13:11:20 +0530942 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000943 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530944 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000945 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530946 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000947 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000948 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000949 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000950 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000951 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000952 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000953 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000954 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000955 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000956 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000957 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000958}
959
Himani Chawla6d2ae152020-09-02 13:11:20 +0530960func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000961 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530962 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000963 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000964 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000965
966 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
967 meParams := me.ParamData{
968 EntityID: 0,
969 Attributes: requestedAttributes,
970 }
971 meInstance, omciErr := me.NewOnuG(meParams)
972 if omciErr.GetError() == nil {
973 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
974 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000975 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000976 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000977 return nil
978 }
979
dbainbri4d3a0dc2020-12-02 00:33:42 +0000980 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000981 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000982 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000983 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000984 return nil
985 }
986
Himani Chawla6d2ae152020-09-02 13:11:20 +0530987 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000988 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530989 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000990 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530991 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000992 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000993 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000994 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000995 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000996 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000997 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000998 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000999 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001000 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001001 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001002 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001003}
1004
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001005func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1006 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1007 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001008 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001009 "SequNo": strconv.FormatInt(int64(tid), 16)})
1010
1011 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1012 meParams := me.ParamData{
1013 EntityID: aInstNo,
1014 Attributes: requestedAttributes,
1015 }
1016 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1017 if omciErr.GetError() == nil {
1018 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1019 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001020 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001021 "Err": err, "device-id": oo.deviceID})
1022 return nil
1023 }
1024
dbainbri4d3a0dc2020-12-02 00:33:42 +00001025 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001026 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001027 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001028 "Err": err, "device-id": oo.deviceID})
1029 return nil
1030 }
1031
1032 omciRxCallbackPair := callbackPair{
1033 cbKey: tid,
1034 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1035 }
1036 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1037 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001038 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001039 "Err": err, "device-id": oo.deviceID})
1040 return nil
1041 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001042 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001043 return meInstance
1044 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001045 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001046 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1047 return nil
1048}
1049
1050/* UniG obsolete by now, left here in case it should be needed once again
1051 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301052func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001053 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301054 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001055 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001056 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001057
1058 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1059 meParams := me.ParamData{
1060 EntityID: aInstNo,
1061 Attributes: requestedAttributes,
1062 }
1063 meInstance, omciErr := me.NewUniG(meParams)
1064 if omciErr.GetError() == nil {
1065 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1066 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001067 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001068 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001069 return nil
1070 }
1071
1072 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1073 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001074 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001075 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001076 return nil
1077 }
1078
Himani Chawla6d2ae152020-09-02 13:11:20 +05301079 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001080 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301081 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001082 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301083 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001084 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001085 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001086 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001087 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001088 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001089 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001090 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001091 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001092 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001093 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001094 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001095}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001096*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001097
Himani Chawla6d2ae152020-09-02 13:11:20 +05301098func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001099 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301100 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001101 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001102 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001103
1104 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1105 meParams := me.ParamData{
1106 EntityID: aInstNo,
1107 Attributes: requestedAttributes,
1108 }
1109 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1110 if omciErr.GetError() == nil {
1111 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1112 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001113 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001114 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001115 return nil
1116 }
1117
dbainbri4d3a0dc2020-12-02 00:33:42 +00001118 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001119 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001120 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001121 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001122 return nil
1123 }
1124
Himani Chawla6d2ae152020-09-02 13:11:20 +05301125 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001126 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301127 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001128 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301129 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001130 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001131 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001132 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001133 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001134 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001135 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001136 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001137 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001138 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001139 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001140 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001141}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001142
Himani Chawla6d2ae152020-09-02 13:11:20 +05301143func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001144 timeout int, highPrio bool) *me.ManagedEntity {
1145
Himani Chawla6d2ae152020-09-02 13:11:20 +05301146 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001147 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001148 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001149
1150 meParams := me.ParamData{
1151 EntityID: entityID,
1152 Attributes: requestedAttributes,
1153 }
1154 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1155 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301156 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001157 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1158 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001159 logger.Errorf(ctx, "Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001160 return nil
1161 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001162 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001163 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001164 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001165 return nil
1166 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301167 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001168 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301169 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001170 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301171 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001172 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001173 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001174 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001175 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001176 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001177 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001178 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001179 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001180 return nil
1181}
1182
Himani Chawla6d2ae152020-09-02 13:11:20 +05301183func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001184 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301185 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001186 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001187 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1188
1189 meParams := me.ParamData{
1190 EntityID: aInstID,
1191 Attributes: me.AttributeValueMap{},
1192 }
1193 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1194 if omciErr.GetError() == nil {
1195 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1196 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1197 omci.TransactionID(tid), omci.AddDefaults(true))
1198 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001199 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001200 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001201 return nil
1202 }
1203
dbainbri4d3a0dc2020-12-02 00:33:42 +00001204 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001205 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001206 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001207 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001208 return nil
1209 }
1210
Himani Chawla6d2ae152020-09-02 13:11:20 +05301211 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001212 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301213 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001214 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301215 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001216 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001217 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001218 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001219 return nil
1220 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001221 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001222 return meInstance
1223 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001224 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001225 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001226 return nil
1227}
1228
Himani Chawla6d2ae152020-09-02 13:11:20 +05301229func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001230 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301231 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001232 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001233 "SequNo": strconv.FormatInt(int64(tid), 16),
1234 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1235
1236 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1237 if omciErr.GetError() == nil {
1238 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1239 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1240 omci.TransactionID(tid), omci.AddDefaults(true))
1241 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001242 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001243 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001244 return nil
1245 }
1246
dbainbri4d3a0dc2020-12-02 00:33:42 +00001247 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001248 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001249 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001250 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001251 return nil
1252 }
1253
Himani Chawla6d2ae152020-09-02 13:11:20 +05301254 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001255 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301256 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001257 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301258 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001259 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001260 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001261 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001262 return nil
1263 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001264 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001265 return meInstance
1266 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001267 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001268 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001269 return nil
1270}
1271
Himani Chawla6d2ae152020-09-02 13:11:20 +05301272func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001273 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301274 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001276 "SequNo": strconv.FormatInt(int64(tid), 16),
1277 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1278
1279 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1280 if omciErr.GetError() == nil {
1281 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1282 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1283 omci.TransactionID(tid), omci.AddDefaults(true))
1284 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001285 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001286 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001287 return nil
1288 }
1289
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001291 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001292 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001293 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001294 return nil
1295 }
1296
Himani Chawla6d2ae152020-09-02 13:11:20 +05301297 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001298 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301299 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001300 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301301 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001302 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001303 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001304 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001305 return nil
1306 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001307 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001308 return meInstance
1309 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001310 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001311 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001312 return nil
1313}
1314
Himani Chawla6d2ae152020-09-02 13:11:20 +05301315func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001316 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301317 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001318 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001319 "SequNo": strconv.FormatInt(int64(tid), 16),
1320 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1321
1322 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1323 if omciErr.GetError() == nil {
1324 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1325 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1326 omci.TransactionID(tid))
1327 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001328 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001329 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001330 return nil
1331 }
1332
dbainbri4d3a0dc2020-12-02 00:33:42 +00001333 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001334 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001335 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001336 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001337 return nil
1338 }
1339
Himani Chawla6d2ae152020-09-02 13:11:20 +05301340 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001341 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301342 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001343 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301344 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001345 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001346 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001347 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001348 return nil
1349 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001350 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001351 return meInstance
1352 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001353 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001354 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001355 return nil
1356}
1357
Himani Chawla6d2ae152020-09-02 13:11:20 +05301358func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001359 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301360 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001361 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001362 "SequNo": strconv.FormatInt(int64(tid), 16),
1363 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1364
1365 meInstance, omciErr := me.NewTCont(params[0])
1366 if omciErr.GetError() == nil {
1367 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1368 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001369 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001370 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001371 return nil
1372 }
1373
dbainbri4d3a0dc2020-12-02 00:33:42 +00001374 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001375 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001376 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001377 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 return nil
1379 }
1380
Himani Chawla6d2ae152020-09-02 13:11:20 +05301381 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001382 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301383 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001384 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301385 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001386 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001387 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001388 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001389 return nil
1390 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001391 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001392 return meInstance
1393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001394 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001395 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001396 return nil
1397}
1398
Himani Chawla6d2ae152020-09-02 13:11:20 +05301399func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001400 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301401 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001402 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001403 "SequNo": strconv.FormatInt(int64(tid), 16),
1404 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1405
1406 meInstance, omciErr := me.NewPriorityQueue(params[0])
1407 if omciErr.GetError() == nil {
1408 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1409 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001410 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001411 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001412 return nil
1413 }
1414
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001416 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001417 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001418 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001419 return nil
1420 }
1421
Himani Chawla6d2ae152020-09-02 13:11:20 +05301422 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001423 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301424 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301426 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001427 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001428 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001429 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001430 return nil
1431 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001432 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001433 return meInstance
1434 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001435 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001436 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001437 return nil
1438}
1439
Himani Chawla6d2ae152020-09-02 13:11:20 +05301440func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001441 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301442 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001443 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001444 "SequNo": strconv.FormatInt(int64(tid), 16),
1445 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1446
1447 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1448 if omciErr.GetError() == nil {
1449 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1450 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001451 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001452 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001453 return nil
1454 }
1455
dbainbri4d3a0dc2020-12-02 00:33:42 +00001456 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001457 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001458 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001459 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001460 return nil
1461 }
1462
Himani Chawla6d2ae152020-09-02 13:11:20 +05301463 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001464 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301465 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301467 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001468 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001469 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001470 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001471 return nil
1472 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001473 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001474 return meInstance
1475 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001476 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001477 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001478 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001479}
mpagenkodff5dda2020-08-28 11:52:01 +00001480
Himani Chawla6d2ae152020-09-02 13:11:20 +05301481func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001482 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301483 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001484 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001485 "SequNo": strconv.FormatInt(int64(tid), 16),
1486 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1487
1488 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1489 if omciErr.GetError() == nil {
1490 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1491 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1492 omci.TransactionID(tid))
1493 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001494 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001495 "Err": err, "device-id": oo.deviceID})
1496 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1497 // return (dual format) error code that can be used at caller for immediate error treatment
1498 // (relevant to all used sendXX() methods and their error conditions)
1499 return nil
1500 }
1501
dbainbri4d3a0dc2020-12-02 00:33:42 +00001502 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001503 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001504 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001505 "Err": err, "device-id": oo.deviceID})
1506 return nil
1507 }
1508
Himani Chawla6d2ae152020-09-02 13:11:20 +05301509 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001510 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301511 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001512 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301513 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001514 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001515 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001516 "Err": err, "device-id": oo.deviceID})
1517 return nil
1518 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001519 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001520 return meInstance
1521 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001522 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001523 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1524 return nil
1525}
1526
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001527// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001528func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1529 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1530 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001531 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001532 "SequNo": strconv.FormatInt(int64(tid), 16),
1533 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1534
1535 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1536 if omciErr.GetError() == nil {
1537 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1538 omci.TransactionID(tid))
1539 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001540 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001541 "Err": err, "device-id": oo.deviceID})
1542 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1543 // return (dual format) error code that can be used at caller for immediate error treatment
1544 // (relevant to all used sendXX() methods and their error conditions)
1545 return nil
1546 }
1547
dbainbri4d3a0dc2020-12-02 00:33:42 +00001548 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001549 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001550 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001551 "Err": err, "device-id": oo.deviceID})
1552 return nil
1553 }
1554
1555 omciRxCallbackPair := callbackPair{
1556 cbKey: tid,
1557 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1558 }
1559 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1560 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001561 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001562 "Err": err, "device-id": oo.deviceID})
1563 return nil
1564 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001565 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001566 return meInstance
1567 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001568 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001569 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1570 return nil
1571}
1572
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001573func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1574 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1575 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001576 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001577 "SequNo": strconv.FormatInt(int64(tid), 16),
1578 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1579
1580 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1581 if omciErr.GetError() == nil {
1582 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1583 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001584 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001585 "Err": err, "device-id": oo.deviceID})
1586 return nil
1587 }
1588
dbainbri4d3a0dc2020-12-02 00:33:42 +00001589 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001590 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001591 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001592 "Err": err, "device-id": oo.deviceID})
1593 return nil
1594 }
1595
1596 omciRxCallbackPair := callbackPair{
1597 cbKey: tid,
1598 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1599 }
1600 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1601 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001602 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001603 "Err": err, "device-id": oo.deviceID})
1604 return nil
1605 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001606 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001607 return meInstance
1608 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001609 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001610 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1611 return nil
1612}
1613
Himani Chawla6d2ae152020-09-02 13:11:20 +05301614func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001615 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301616 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001617 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001618 "SequNo": strconv.FormatInt(int64(tid), 16),
1619 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1620
1621 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1622 if omciErr.GetError() == nil {
1623 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1624 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001625 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001626 "Err": err, "device-id": oo.deviceID})
1627 return nil
1628 }
1629
dbainbri4d3a0dc2020-12-02 00:33:42 +00001630 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001631 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001632 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001633 "Err": err, "device-id": oo.deviceID})
1634 return nil
1635 }
1636
Himani Chawla6d2ae152020-09-02 13:11:20 +05301637 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001638 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301639 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001640 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301641 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001642 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001643 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001644 "Err": err, "device-id": oo.deviceID})
1645 return nil
1646 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001647 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001648 return meInstance
1649 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001650 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001651 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1652 return nil
1653}
mpagenko01e726e2020-10-23 09:45:29 +00001654
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001655func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1656 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1657 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001658 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001659 "SequNo": strconv.FormatInt(int64(tid), 16),
1660 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1661
1662 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1663 if omciErr.GetError() == nil {
1664 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1665 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001666 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001667 "Err": err, "device-id": oo.deviceID})
1668 return nil
1669 }
1670
dbainbri4d3a0dc2020-12-02 00:33:42 +00001671 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001672 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001673 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001674 "Err": err, "device-id": oo.deviceID})
1675 return nil
1676 }
1677
1678 omciRxCallbackPair := callbackPair{
1679 cbKey: tid,
1680 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1681 }
1682 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1683 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001684 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001685 "Err": err, "device-id": oo.deviceID})
1686 return nil
1687 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001688 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001689 return meInstance
1690 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001691 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001692 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1693 return nil
1694}
1695
mpagenko01e726e2020-10-23 09:45:29 +00001696func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1697 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1698 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001699 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001700 "SequNo": strconv.FormatInt(int64(tid), 16),
1701 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1702
1703 meParams := me.ParamData{EntityID: aInstID}
1704 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1705 if omciErr.GetError() == nil {
1706 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1707 omci.TransactionID(tid))
1708 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001709 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001710 "Err": err, "device-id": oo.deviceID})
1711 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1712 // return (dual format) error code that can be used at caller for immediate error treatment
1713 // (relevant to all used sendXX() methods and their error conditions)
1714 return nil
1715 }
1716
dbainbri4d3a0dc2020-12-02 00:33:42 +00001717 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001718 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001719 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001720 "Err": err, "device-id": oo.deviceID})
1721 return nil
1722 }
1723
1724 omciRxCallbackPair := callbackPair{
1725 cbKey: tid,
1726 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1727 }
1728 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1729 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001730 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001731 "Err": err, "device-id": oo.deviceID})
1732 return nil
1733 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001734 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001735 return meInstance
1736 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001737 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001738 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1739 return nil
1740}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001741
mpagenko8b07c1b2020-11-26 10:36:31 +00001742func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1743 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1744 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001745 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001746 "SequNo": strconv.FormatInt(int64(tid), 16),
1747 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1748
1749 meParams := me.ParamData{EntityID: aInstID}
1750 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
1751 if omciErr.GetError() == nil {
1752 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1753 omci.TransactionID(tid))
1754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001756 "Err": err, "device-id": oo.deviceID})
1757 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1758 // return (dual format) error code that can be used at caller for immediate error treatment
1759 // (relevant to all used sendXX() methods and their error conditions)
1760 return nil
1761 }
1762
dbainbri4d3a0dc2020-12-02 00:33:42 +00001763 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001764 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001765 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001766 "Err": err, "device-id": oo.deviceID})
1767 return nil
1768 }
1769
1770 omciRxCallbackPair := callbackPair{
1771 cbKey: tid,
1772 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1773 }
1774 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1775 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001776 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001777 "Err": err, "device-id": oo.deviceID})
1778 return nil
1779 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001780 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001781 return meInstance
1782 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001783 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001784 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1785 return nil
1786}
1787
1788func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
1789 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1790 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001791 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001792 "SequNo": strconv.FormatInt(int64(tid), 16),
1793 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1794
1795 meParams := me.ParamData{EntityID: aInstID}
1796 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
1797 if omciErr.GetError() == nil {
1798 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1799 omci.TransactionID(tid))
1800 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001801 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001802 "Err": err, "device-id": oo.deviceID})
1803 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1804 // return (dual format) error code that can be used at caller for immediate error treatment
1805 // (relevant to all used sendXX() methods and their error conditions)
1806 return nil
1807 }
1808
dbainbri4d3a0dc2020-12-02 00:33:42 +00001809 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001810 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001811 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001812 "Err": err, "device-id": oo.deviceID})
1813 return nil
1814 }
1815
1816 omciRxCallbackPair := callbackPair{
1817 cbKey: tid,
1818 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1819 }
1820 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1821 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001822 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001823 "Err": err, "device-id": oo.deviceID})
1824 return nil
1825 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001826 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001827 return meInstance
1828 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001829 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001830 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1831 return nil
1832}
1833
1834func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
1835 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1836 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001837 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001838 "SequNo": strconv.FormatInt(int64(tid), 16),
1839 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1840
1841 meParams := me.ParamData{EntityID: aInstID}
1842 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1843 if omciErr.GetError() == nil {
1844 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1845 omci.TransactionID(tid))
1846 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001847 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001848 "Err": err, "device-id": oo.deviceID})
1849 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1850 // return (dual format) error code that can be used at caller for immediate error treatment
1851 // (relevant to all used sendXX() methods and their error conditions)
1852 return nil
1853 }
1854
dbainbri4d3a0dc2020-12-02 00:33:42 +00001855 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001856 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001857 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001858 "Err": err, "device-id": oo.deviceID})
1859 return nil
1860 }
1861
1862 omciRxCallbackPair := callbackPair{
1863 cbKey: tid,
1864 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1865 }
1866 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1867 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001868 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001869 "Err": err, "device-id": oo.deviceID})
1870 return nil
1871 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001872 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001873 return meInstance
1874 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001875 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001876 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1877 return nil
1878}
1879
1880func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
1881 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1882 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001884 "SequNo": strconv.FormatInt(int64(tid), 16),
1885 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1886
1887 meParams := me.ParamData{EntityID: aInstID}
1888 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1889 if omciErr.GetError() == nil {
1890 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1891 omci.TransactionID(tid))
1892 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001893 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001894 "Err": err, "device-id": oo.deviceID})
1895 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1896 // return (dual format) error code that can be used at caller for immediate error treatment
1897 // (relevant to all used sendXX() methods and their error conditions)
1898 return nil
1899 }
1900
dbainbri4d3a0dc2020-12-02 00:33:42 +00001901 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001902 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001903 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001904 "Err": err, "device-id": oo.deviceID})
1905 return nil
1906 }
1907
1908 omciRxCallbackPair := callbackPair{
1909 cbKey: tid,
1910 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1911 }
1912 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1913 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001914 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001915 "Err": err, "device-id": oo.deviceID})
1916 return nil
1917 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001918 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001919 return meInstance
1920 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001921 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001922 "Err": omciErr.GetError(), "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) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
1928 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1929 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001930 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03001931 "SequNo": strconv.FormatInt(int64(tid), 16),
1932 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1933
1934 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
1935 if omciErr.GetError() == nil {
1936 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
1937 omci.AddDefaults(true))
1938 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001939 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03001940 return nil
1941 }
1942
dbainbri4d3a0dc2020-12-02 00:33:42 +00001943 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03001944 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001945 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03001946 return nil
1947 }
1948
1949 omciRxCallbackPair := callbackPair{cbKey: tid,
1950 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1951 }
1952 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1953 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001954 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03001955 return nil
1956 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001957 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03001958 return meInstance
1959 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001960 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03001961 "device-id": oo.deviceID})
1962 return nil
1963}
1964
mpagenkofc4f56e2020-11-04 17:17:49 +00001965// nolint: unused
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001966func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
1967 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1968 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001969 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001970 "SequNo": strconv.FormatInt(int64(tid), 16),
1971 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1972
1973 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
1974 if omciErr.GetError() == nil {
1975 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
1976 omci.AddDefaults(true))
1977 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001978 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001979 return nil
1980 }
1981
dbainbri4d3a0dc2020-12-02 00:33:42 +00001982 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001983 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001984 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001985 return nil
1986 }
1987
1988 omciRxCallbackPair := callbackPair{cbKey: tid,
1989 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1990 }
1991 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1992 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001993 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001994 return nil
1995 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001996 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001997 return meInstance
1998 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001999 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002000 "device-id": oo.deviceID})
2001 return nil
2002}
2003
2004// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002005func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2006 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2007 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002008 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002009 "SequNo": strconv.FormatInt(int64(tid), 16),
2010 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2011
2012 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2013 if omciErr.GetError() == nil {
2014 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2015 omci.AddDefaults(true))
2016 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002017 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002018 "device-id": oo.deviceID})
2019 return nil
2020 }
2021
dbainbri4d3a0dc2020-12-02 00:33:42 +00002022 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002023 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002024 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002025 "device-id": oo.deviceID})
2026 return nil
2027 }
2028
2029 omciRxCallbackPair := callbackPair{cbKey: tid,
2030 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2031 }
2032 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2033 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002034 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002035 "device-id": oo.deviceID})
2036 return nil
2037 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002038 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002039 return meInstance
2040 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002041 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002042 "device-id": oo.deviceID})
2043 return nil
2044}
2045
mpagenkofc4f56e2020-11-04 17:17:49 +00002046// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002047func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2048 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2049 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002050 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002051 "SequNo": strconv.FormatInt(int64(tid), 16),
2052 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2053
2054 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2055 if omciErr.GetError() == nil {
2056 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2057 omci.AddDefaults(true))
2058 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002059 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002060 "device-id": oo.deviceID})
2061 return nil
2062 }
2063
dbainbri4d3a0dc2020-12-02 00:33:42 +00002064 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002065 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002066 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002067 "device-id": oo.deviceID})
2068 return nil
2069 }
2070
2071 omciRxCallbackPair := callbackPair{cbKey: tid,
2072 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2073 }
2074 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2075 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002076 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002077 "device-id": oo.deviceID})
2078 return nil
2079 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002080 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002081 return meInstance
2082 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002083 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002084 "device-id": oo.deviceID})
2085 return nil
2086}
2087
mpagenkofc4f56e2020-11-04 17:17:49 +00002088// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002089func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2090 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2091 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002092 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002093 "SequNo": strconv.FormatInt(int64(tid), 16),
2094 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2095
2096 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2097 if omciErr.GetError() == nil {
2098 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2099 omci.AddDefaults(true))
2100 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002101 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002102 "device-id": oo.deviceID})
2103 return nil
2104 }
2105
dbainbri4d3a0dc2020-12-02 00:33:42 +00002106 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002107 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002108 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002109 "device-id": oo.deviceID})
2110 return nil
2111 }
2112
2113 omciRxCallbackPair := callbackPair{cbKey: tid,
2114 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2115 }
2116 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2117 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002118 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002119 "device-id": oo.deviceID})
2120 return nil
2121 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002122 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002123 return meInstance
2124 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002125 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002126 "device-id": oo.deviceID})
2127 return nil
2128}