blob: f916180e9b0f6888a83cd2b83175fc1b3c17cf57 [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
mpagenkoc8bba412021-01-15 15:38:44 +000064const cOmciBaseMessageTrailerLen = 40
65
66// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
67type tOmciReceiveError uint8
68
69const (
70 // cOmciMessageReceiveNoError - default start state
71 cOmciMessageReceiveNoError tOmciReceiveError = iota
72 // Error indication wrong trailer length within the message
73 cOmciMessageReceiveErrorTrailerLen
74 // Error indication missing trailer within the message
75 cOmciMessageReceiveErrorMissTrailer
76)
77
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000078// ### OMCI related definitions - end
79
Himani Chawla6d2ae152020-09-02 13:11:20 +053080//callbackPairEntry to be used for OMCI send/receive correlation
81type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000082 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000083 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000084}
85
Himani Chawla6d2ae152020-09-02 13:11:20 +053086//callbackPair to be used for ReceiveCallback init
87type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000088 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053089 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000090}
91
92type omciTransferStructure struct {
93 txFrame []byte
94 timeout int
95 retry int
96 highPrio bool
97}
98
Himani Chawla6d2ae152020-09-02 13:11:20 +053099//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
100type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000101 enabled bool
102 pOnuDeviceEntry *OnuDeviceEntry
103 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +0530104 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000105 coreProxy adapterif.CoreProxy
106 adapterProxy adapterif.AdapterProxy
107 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000108 rxOmciFrameError tOmciReceiveError
109
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000110 txFrames, txOnuFrames uint32
111 rxFrames, rxOnuFrames, rxOnuDiscards uint32
112
113 // OMCI params
114 mutexTid sync.Mutex
115 tid uint16
116 mutexHpTid sync.Mutex
117 hpTid uint16
118 uploadSequNo uint16
119 uploadNoOfCmds uint16
120
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000121 mutexTxQueue sync.Mutex
122 txQueue *list.List
123 mutexRxSchedMap sync.Mutex
Himani Chawla6d2ae152020-09-02 13:11:20 +0530124 rxSchedulerMap map[uint16]callbackPairEntry
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000125 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000126}
127
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000128var responsesWithMibDataSync = []omci.MessageType{
129 omci.CreateResponseType,
130 omci.DeleteResponseType,
131 omci.SetResponseType,
132 omci.StartSoftwareDownloadResponseType,
133 omci.EndSoftwareDownloadResponseType,
134 omci.ActivateSoftwareResponseType,
135 omci.CommitSoftwareResponseType,
136}
137
Himani Chawla6d2ae152020-09-02 13:11:20 +0530138//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000139//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530140func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
141 deviceID string, deviceHandler *deviceHandler,
142 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000143 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530144 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000145 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530146 omciCC.pOnuDeviceEntry = onuDeviceEntry
147 omciCC.deviceID = deviceID
148 omciCC.pBaseDeviceHandler = deviceHandler
149 omciCC.coreProxy = coreProxy
150 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000151 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000152 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000153 omciCC.txFrames = 0
154 omciCC.txOnuFrames = 0
155 omciCC.rxFrames = 0
156 omciCC.rxOnuFrames = 0
157 omciCC.rxOnuDiscards = 0
158 omciCC.tid = 0x1
159 omciCC.hpTid = 0x8000
160 omciCC.uploadSequNo = 0
161 omciCC.uploadNoOfCmds = 0
162
163 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530164 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000165
166 return &omciCC
167}
168
mpagenko900ee4b2020-10-12 11:56:34 +0000169//stop stops/resets the omciCC
170func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000171 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000172 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
173 oo.mutexTxQueue.Lock()
174 oo.txQueue.Init() // clear the tx queue
175 oo.mutexTxQueue.Unlock()
176 oo.mutexRxSchedMap.Lock()
177 for k := range oo.rxSchedulerMap {
178 delete(oo.rxSchedulerMap, k) //clear the scheduler map
179 }
180 oo.mutexRxSchedMap.Unlock()
181 oo.mutexHpTid.Lock()
182 oo.hpTid = 0x8000 //reset the high prio transactionId
183 oo.mutexHpTid.Unlock()
184 oo.mutexTid.Lock()
185 oo.tid = 1 //reset the low prio transactionId
186 oo.mutexTid.Unlock()
187 //reset control values
188 oo.uploadSequNo = 0
189 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000190 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000191 //reset the stats counter - which might be topic of discussion ...
192 oo.txFrames = 0
193 oo.txOnuFrames = 0
194 oo.rxFrames = 0
195 oo.rxOnuFrames = 0
196 oo.rxOnuDiscards = 0
197
198 return nil
199}
200
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000201// Rx handler for omci messages
Himani Chawla6d2ae152020-09-02 13:11:20 +0530202func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000203 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000204 "payload": hex.EncodeToString(omciMsg.Payload)})
205 /*
206 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
207 rxOnuFrames++
208
209 switch msgType {
210 case AlarmNotification:
211 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000212 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000213 // python code was:
214 //if msg_type == EntityOperations.AlarmNotification.value:
215 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
216 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
217 //
218 return errors.New("RxAlarmNotification unimplemented")
219 }
220 case AttributeValueChange:
221 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000222 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000223 // python code was:
224 //elif msg_type == EntityOperations.AttributeValueChange.value:
225 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
226 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
227 //
228 return errors.New("RxAttributeValueChange unimplemented")
229 }
230 case TestResult:
231 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000232 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000233 // python code was:
234 //elif msg_type == EntityOperations.TestResult.value:
235 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
236 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
237 //
238 return errors.New("RxTestResult unimplemented")
239 }
240 default:
241 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000242 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000243 rxOnuDiscards++
244 return errors.New("RxOnuMsgType unimplemented")
245 }
246 }
247 */
Himani Chawla4d908332020-08-31 12:30:20 +0530248 return errors.New("receiveOnuMessage unimplemented")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000249}
250
251// Rx handler for onu messages
252// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530253func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000254 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000255 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
256 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000257 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000258 trailerLenData := rxMsg[42:44]
259 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000260 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000261 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
262 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
263 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
264 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
265 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
266 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
267 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
268 }
269 }
270 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
271 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
272 // (an extendedFormat message could be destroyed this way!)
273 // extend/overwrite with trailer
274 trailer := make([]byte, 8)
275 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
276 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
277 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
278 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
279 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
280 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
281 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000282 }
283 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000284 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
285 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200286 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000287 }
288
289 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
290 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000291 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200292 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000293 }
294 omciLayer := packet.Layer(omci.LayerTypeOMCI)
295 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000296 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200297 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000298 }
299 omciMsg, ok := omciLayer.(*omci.OMCI)
300 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000301 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200302 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000303 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000304 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000305 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000306 if byte(omciMsg.MessageType)&me.AK == 0 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000307 // Not a response
dbainbri4d3a0dc2020-12-02 00:33:42 +0000308 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000309 if omciMsg.TransactionID == 0 {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530310 return oo.receiveOnuMessage(ctx, omciMsg)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000311 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000312 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200313 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000314 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200315 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530316
317 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000318 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530319 oo.mutexRxSchedMap.Lock()
320 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
321 if ok && rxCallbackEntry.cbFunction != nil {
322 //disadvantage of decoupling: error verification made difficult, but anyway the question is
323 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000324 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000325 if isResponseWithMibDataSync(omciMsg.MessageType) {
326 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
327 }
mpagenkoc8bba412021-01-15 15:38:44 +0000328
Himani Chawla4d908332020-08-31 12:30:20 +0530329 // having posted the response the request is regarded as 'done'
330 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
331 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000332 } else {
Himani Chawla4d908332020-08-31 12:30:20 +0530333 oo.mutexRxSchedMap.Unlock()
Matteo Scandolo20ca10c2021-01-21 14:35:45 -0800334 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID, "omciMsg": omciMsg, "transCorrId": omciMsg.TransactionID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200335 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000336 }
337
338 return nil
339 /* py code was:
340 Receive and OMCI message from the proxy channel to the OLT.
341
342 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
343 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
344 """
345 if not self.enabled:
346 return
347
348 try:
349 now = arrow.utcnow()
350 d = None
351
352 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
353 # save the current value of the entity_id_to_class_map, then
354 # replace it with our custom one before decode, and then finally
355 # restore it later. Tried other ways but really made the code messy.
356 saved_me_map = omci_entities.entity_id_to_class_map
357 omci_entities.entity_id_to_class_map = self._me_map
358
359 try:
360 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000361 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000362 except KeyError as e:
363 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000364 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000365 rx_frame = self._decode_unknown_me(msg)
366 self._rx_unknown_me += 1
367
368 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000369 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000370 return
371
372 finally:
373 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
374
375 rx_tid = rx_frame.fields['transaction_id']
376 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000377 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000378 # Filter the Test Result frame and route through receive onu
379 # message method.
380 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000381 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000382 return self._receive_onu_message(rx_frame)
383
384 # Previously unreachable if this is the very first round-trip Rx or we
385 # have been running consecutive errors
386 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000387 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000388 self.reactor.callLater(0, self._publish_connectivity_event, True)
389
390 self._rx_frames += 1
391 self._consecutive_errors = 0
392
393 try:
394 high_priority = self._tid_is_high_priority(rx_tid)
395 index = self._get_priority_index(high_priority)
396
397 # (timestamp, defer, frame, timeout, retry, delayedCall)
398 last_tx_tuple = self._tx_request[index]
399
400 if last_tx_tuple is None or \
401 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
402 # Possible late Rx on a message that timed-out
403 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000404 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000405 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
406 self._rx_unknown_tid += 1
407 self._rx_late += 1
408 return
409
410 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
411 if dc is not None and not dc.cancelled and not dc.called:
412 dc.cancel()
413
414 _secs = self._update_rx_tx_stats(now, ts)
415
416 # Late arrival already serviced by a timeout?
417 if d.called:
418 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000419 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000420 return
421
422 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000423 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000424 if d is not None:
425 return d.errback(failure.Failure(e))
426 return
427
428 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000429 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000430 tx_tid = tx_frame.fields['transaction_id'])
431 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
432
433 # begin success callback chain (will cancel timeout and queue next Tx message)
434 self._rx_response[index] = rx_frame
435 d.callback(rx_frame)
436
437 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000438 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000439 */
440}
441
Himani Chawla6d2ae152020-09-02 13:11:20 +0530442/*
443func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530444 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530445 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000446}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530447*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000448
449//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530450func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
451 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000452
dbainbri4d3a0dc2020-12-02 00:33:42 +0000453 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000454 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
455 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000456 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000457 oo.mutexRxSchedMap.Unlock()
458
459 //just use a simple list for starting - might need some more effort, especially for multi source write access
460 omciTxRequest := omciTransferStructure{
461 txFrame,
462 timeout,
463 retry,
464 highPrio,
465 }
466 oo.mutexTxQueue.Lock()
467 oo.txQueue.PushBack(omciTxRequest) // enqueue
468 oo.mutexTxQueue.Unlock()
469
470 // for first test just bypass and send directly:
471 go oo.sendNextRequest(ctx)
472 return nil
473}
474
475//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530476func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000477 // return errors.New("sendNextRequest unimplemented")
478
479 // just try to get something transferred !!
480 // avoid accessing the txQueue from parallel send requests
481 // block parallel omci send requests at least until SendIAP is 'committed'
482 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
483 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000484 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000485 for oo.txQueue.Len() > 0 {
486 queueElement := oo.txQueue.Front() // First element
487 omciTxRequest := queueElement.Value.(omciTransferStructure)
488 /* compare olt device handler code:
489 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000490 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000491 var deviceType string
492 var deviceID string
493 var proxyDeviceID string
494
495 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
496
497 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
498
dbainbri4d3a0dc2020-12-02 00:33:42 +0000499 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 +0000500 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
501 kwargs := make(map[string]interface{})
502 kwargs["onu_id"] = omciInd.OnuId
503 kwargs["parent_port_no"] = ponPort
504
dbainbri4d3a0dc2020-12-02 00:33:42 +0000505 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000506 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000507 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000508 return
509 }
510 deviceType = onuDevice.Type
511 deviceID = onuDevice.Id
512 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
513 //if not exist in cache, then add to cache.
514 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
515 } else {
516 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000517 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 +0000518 deviceType = onuInCache.(*OnuDevice).deviceType
519 deviceID = onuInCache.(*OnuDevice).deviceID
520 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
521 }
522 */
523 /* and compare onu_adapter py code:
524 omci_msg = InterAdapterOmciMessage(
525 message=bytes(frame),
526 proxy_address=self._proxy_address,
527 connect_status=self._device.connect_status)
528
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000529 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000530
531 yield self._adapter_proxy.send_inter_adapter_message(
532 msg=omci_msg,
533 type=InterAdapterMessageType.OMCI_REQUEST,
534 from_adapter=self._device.type,
535 to_adapter=self._proxy_address.device_type,
536 to_device_id=self._device_id,
537 proxy_device_id=self._proxy_address.device_id
538 )
539 */
540 device, err := oo.coreProxy.GetDevice(ctx,
541 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
542 if err != nil || device == nil {
543 /*TODO: needs to handle error scenarios */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000544 logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000545 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200546 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000547 }
548
dbainbri4d3a0dc2020-12-02 00:33:42 +0000549 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +0000550 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
551 "device-id": oo.deviceID,
552 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
553 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554
555 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000556 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000557 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800558 //fromTopic,toType,toDevId, ProxyDevId
559 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000560 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000561 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000562 return sendErr
563 }
564 oo.txQueue.Remove(queueElement) // Dequeue
565 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566 return nil
567}
568
Himani Chawla6d2ae152020-09-02 13:11:20 +0530569func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000570 var next uint16
571 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000572 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000573 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530574 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000575 if oo.hpTid < 0x8000 {
576 oo.hpTid = 0x8000
577 }
mpagenko900ee4b2020-10-12 11:56:34 +0000578 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000579 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000580 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000581 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530582 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000583 if oo.tid >= 0x8000 {
584 oo.tid = 1
585 }
mpagenko900ee4b2020-10-12 11:56:34 +0000586 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000587 }
588 return next
589}
590
591// ###################################################################################
592// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000593func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000594 omciLayer := &omci.OMCI{
595 TransactionID: tid,
596 MessageType: msgType,
597 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000598 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000599}
600
dbainbri4d3a0dc2020-12-02 00:33:42 +0000601func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000602 var options gopacket.SerializeOptions
603 options.FixLengths = true
604
605 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530606 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000607 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000608 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000609 return nil, err
610 }
611 return buffer.Bytes(), nil
612}
613
Himani Chawla4d908332020-08-31 12:30:20 +0530614/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000615func hexEncode(omciPkt []byte) ([]byte, error) {
616 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
617 hex.Encode(dst, omciPkt)
618 return dst, nil
619}
Himani Chawla4d908332020-08-31 12:30:20 +0530620*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000621
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000622//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000623func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000624
dbainbri4d3a0dc2020-12-02 00:33:42 +0000625 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000626 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000627
628 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000629 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000630 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200631 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000632 }
633
634 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
635 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000636 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000637 Type: OMCI,
638 Data: OmciMessage{
639 OmciMsg: omciMsg,
640 OmciPacket: packet,
641 },
642 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000643 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000644 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000645
646 return nil
647}
648
Himani Chawla6d2ae152020-09-02 13:11:20 +0530649func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000650
dbainbri4d3a0dc2020-12-02 00:33:42 +0000651 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000652 request := &omci.MibResetRequest{
653 MeBasePacket: omci.MeBasePacket{
654 EntityClass: me.OnuDataClassID,
655 },
656 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530657 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000658 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000659 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000660 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000661 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662 return err
663 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530664 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000665 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530666 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000667 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530668 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000669}
670
Himani Chawla6d2ae152020-09-02 13:11:20 +0530671func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000672 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300673 request := &omci.RebootRequest{
674 MeBasePacket: omci.MeBasePacket{
675 EntityClass: me.OnuGClassID,
676 },
677 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530678 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000679 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300680 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000681 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000682 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300683 return err
684 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530685 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300686 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530687 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300688 }
689
Himani Chawla6d2ae152020-09-02 13:11:20 +0530690 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300691 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000692 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000693 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300694 return err
695 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000696 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300697 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000698 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200699 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300700 return err
701 }
702 return nil
703}
704
Himani Chawla6d2ae152020-09-02 13:11:20 +0530705func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000707 request := &omci.MibUploadRequest{
708 MeBasePacket: omci.MeBasePacket{
709 EntityClass: me.OnuDataClassID,
710 },
711 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530712 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000713 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000714 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000715 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000716 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717 return err
718 }
719 oo.uploadSequNo = 0
720 oo.uploadNoOfCmds = 0
721
Himani Chawla6d2ae152020-09-02 13:11:20 +0530722 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000723 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530724 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000725 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530726 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000727}
728
Himani Chawla6d2ae152020-09-02 13:11:20 +0530729func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000730 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000731 request := &omci.MibUploadNextRequest{
732 MeBasePacket: omci.MeBasePacket{
733 EntityClass: me.OnuDataClassID,
734 },
735 CommandSequenceNumber: oo.uploadSequNo,
736 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530737 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000738 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000739 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000740 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000741 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000742 return err
743 }
744 oo.uploadSequNo++
745
Himani Chawla6d2ae152020-09-02 13:11:20 +0530746 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000747 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530748 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000749 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530750 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000751}
752
Himani Chawla6d2ae152020-09-02 13:11:20 +0530753func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
754 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000755 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000756 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000757
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000758 meParams := me.ParamData{
759 EntityID: galEthernetEID,
760 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
761 }
762 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
763 if omciErr.GetError() == nil {
764 //all setByCreate parameters already set, no default option required ...
765 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
766 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000767 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", 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 GalEnetProfile create", 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 GalEnetProfile create", 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 GalEnetProfile-Create-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 GalEnetProfileInstance", 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
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000797// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530798func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
799 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000800 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000801 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000802
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000803 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
804 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000805 // By now we just use fix values to fire - this is anyway what the python adapter does
806 // read ONU-2G from DB ???? //TODO!!!
807 meParams := me.ParamData{
808 EntityID: 0,
809 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
810 }
811 meInstance, omciErr := me.NewOnu2G(meParams)
812 if omciErr.GetError() == nil {
813 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
814 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000815 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000816 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000817 return nil
818 }
819
dbainbri4d3a0dc2020-12-02 00:33:42 +0000820 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000821 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000822 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000823 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000824 return nil
825 }
826
Himani Chawla6d2ae152020-09-02 13:11:20 +0530827 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000828 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530829 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000830 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530831 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000832 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000833 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000834 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000835 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000836 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000837 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000838 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000839 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000840 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000841 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000842 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000843}
844
Himani Chawla6d2ae152020-09-02 13:11:20 +0530845func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
846 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
847 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530848 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000849 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000850 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000851
852 meParams := me.ParamData{
853 EntityID: instID,
854 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300855 "Priority": 0x8000,
856 "MaxAge": 20 * 256, //20s
857 "HelloTime": 2 * 256, //2s
858 "ForwardDelay": 15 * 256, //15s
859 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000860 },
861 }
862
863 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
864 if omciErr.GetError() == nil {
865 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
866 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
867 omci.TransactionID(tid), omci.AddDefaults(true))
868 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000869 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000870 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000871 return nil
872 }
873
dbainbri4d3a0dc2020-12-02 00:33:42 +0000874 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000875 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000876 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000877 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000878 return nil
879 }
880
Himani Chawla6d2ae152020-09-02 13:11:20 +0530881 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000882 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530883 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000884 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530885 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000886 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000887 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000888 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000889 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000890 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000891 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000892 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000893 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000894 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000895 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000896 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000897}
898
Himani Chawla6d2ae152020-09-02 13:11:20 +0530899func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
900 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
901 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530902 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000903 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000904 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000905
906 meParams := me.ParamData{
907 EntityID: instID,
908 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530909 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
910 "PortNum": aPUniPort.macBpNo,
911 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530912 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000913 },
914 }
915 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
916 if omciErr.GetError() == nil {
917 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
918 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
919 omci.TransactionID(tid), omci.AddDefaults(true))
920 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000921 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000922 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000923 return nil
924 }
925
dbainbri4d3a0dc2020-12-02 00:33:42 +0000926 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000927 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000928 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000929 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000930 return nil
931 }
932
Himani Chawla6d2ae152020-09-02 13:11:20 +0530933 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000934 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530935 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000936 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530937 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000938 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000939 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000940 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000941 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000942 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000943 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000944 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000945 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000946 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000947 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000948 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949}
950
Himani Chawla6d2ae152020-09-02 13:11:20 +0530951func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
952 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
953 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000954 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +0530955 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000956 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000957 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000958
959 // compare python adapter code WA VOL-1311: this is not done here!
960 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
961 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
962 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +0530963 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000964 assType = uint8(10) // for VEIP
965 }
966 meParams := me.ParamData{
967 EntityID: instID,
968 Attributes: me.AttributeValueMap{
969 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +0530970 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000971 },
972 }
973 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
974 if omciErr.GetError() == nil {
975 //all setByCreate parameters already set, no default option required ...
976 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
977 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000978 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000979 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000980 return nil
981 }
982
dbainbri4d3a0dc2020-12-02 00:33:42 +0000983 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000984 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000985 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000986 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000987 return nil
988 }
989
Himani Chawla6d2ae152020-09-02 13:11:20 +0530990 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000991 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530992 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000993 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530994 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000995 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000996 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000997 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000998 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000999 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001000 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001001 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001002 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001003 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001004 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001005 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001006}
1007
Himani Chawla6d2ae152020-09-02 13:11:20 +05301008func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001009 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301010 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001011 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001012 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001013
1014 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1015 meParams := me.ParamData{
1016 EntityID: 0,
1017 Attributes: requestedAttributes,
1018 }
1019 meInstance, omciErr := me.NewOnuG(meParams)
1020 if omciErr.GetError() == nil {
1021 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1022 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001023 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001024 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001025 return nil
1026 }
1027
dbainbri4d3a0dc2020-12-02 00:33:42 +00001028 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001029 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001030 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001031 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001032 return nil
1033 }
1034
Himani Chawla6d2ae152020-09-02 13:11:20 +05301035 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001036 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301037 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001038 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301039 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001040 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001041 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001042 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001043 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001044 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001045 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001046 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001047 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001048 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001049 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001050 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001051}
1052
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001053func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1054 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1055 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001056 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001057 "SequNo": strconv.FormatInt(int64(tid), 16)})
1058
1059 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1060 meParams := me.ParamData{
1061 EntityID: aInstNo,
1062 Attributes: requestedAttributes,
1063 }
1064 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1065 if omciErr.GetError() == nil {
1066 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1067 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001068 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001069 "Err": err, "device-id": oo.deviceID})
1070 return nil
1071 }
1072
dbainbri4d3a0dc2020-12-02 00:33:42 +00001073 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001074 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001075 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001076 "Err": err, "device-id": oo.deviceID})
1077 return nil
1078 }
1079
1080 omciRxCallbackPair := callbackPair{
1081 cbKey: tid,
1082 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1083 }
1084 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1085 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001086 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001087 "Err": err, "device-id": oo.deviceID})
1088 return nil
1089 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001090 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001091 return meInstance
1092 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001093 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001094 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1095 return nil
1096}
1097
1098/* UniG obsolete by now, left here in case it should be needed once again
1099 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301100func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001101 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301102 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001103 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001104 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001105
1106 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1107 meParams := me.ParamData{
1108 EntityID: aInstNo,
1109 Attributes: requestedAttributes,
1110 }
1111 meInstance, omciErr := me.NewUniG(meParams)
1112 if omciErr.GetError() == nil {
1113 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1114 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001115 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001116 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001117 return nil
1118 }
1119
1120 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1121 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001122 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001123 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001124 return nil
1125 }
1126
Himani Chawla6d2ae152020-09-02 13:11:20 +05301127 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001128 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301129 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001130 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301131 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001132 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001133 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001134 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001135 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001136 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001137 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001138 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001139 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001140 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001141 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001142 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001143}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001144*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001145
Himani Chawla6d2ae152020-09-02 13:11:20 +05301146func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001147 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301148 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001149 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001150 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001151
1152 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1153 meParams := me.ParamData{
1154 EntityID: aInstNo,
1155 Attributes: requestedAttributes,
1156 }
1157 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1158 if omciErr.GetError() == nil {
1159 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1160 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001161 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001162 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001163 return nil
1164 }
1165
dbainbri4d3a0dc2020-12-02 00:33:42 +00001166 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001167 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001168 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001169 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001170 return nil
1171 }
1172
Himani Chawla6d2ae152020-09-02 13:11:20 +05301173 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001174 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301175 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001176 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301177 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001178 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001179 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001180 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001181 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001182 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001183 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001184 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001185 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001186 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001187 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001188 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001189}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001190
Himani Chawla6d2ae152020-09-02 13:11:20 +05301191func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001192 timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001193
Himani Chawla6d2ae152020-09-02 13:11:20 +05301194 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001195 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001196 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001197
1198 meParams := me.ParamData{
1199 EntityID: entityID,
1200 Attributes: requestedAttributes,
1201 }
1202 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1203 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301204 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001205 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1206 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001207 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 +00001208 return nil
1209 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001210 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001211 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001212 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001213 return nil
1214 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301215 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001216 cbKey: tid,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001217 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001218 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301219 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001220 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001221 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 +00001222 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001223 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001224 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001225 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001226 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001227 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001228 return nil
1229}
1230
Himani Chawla6d2ae152020-09-02 13:11:20 +05301231func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001232 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301233 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001234 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001235 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1236
1237 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001238 EntityID: aInstID,
1239 Attributes: me.AttributeValueMap{
1240 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1241 "TpPointer": 0xFFFF,
1242 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1243 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1244 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1245 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1246 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1247 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1248 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1249 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1250 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001251 }
1252 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1253 if omciErr.GetError() == nil {
1254 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1255 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1256 omci.TransactionID(tid), omci.AddDefaults(true))
1257 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001258 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001259 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001260 return nil
1261 }
1262
dbainbri4d3a0dc2020-12-02 00:33:42 +00001263 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001264 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001265 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001266 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001267 return nil
1268 }
1269
Himani Chawla6d2ae152020-09-02 13:11:20 +05301270 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001271 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301272 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001273 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301274 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001275 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001276 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001277 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001278 return nil
1279 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001280 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001281 return meInstance
1282 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001283 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001284 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001285 return nil
1286}
1287
Himani Chawla6d2ae152020-09-02 13:11:20 +05301288func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001289 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301290 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001291 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001292 "SequNo": strconv.FormatInt(int64(tid), 16),
1293 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1294
1295 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1296 if omciErr.GetError() == nil {
1297 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1298 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1299 omci.TransactionID(tid), omci.AddDefaults(true))
1300 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001301 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001302 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001303 return nil
1304 }
1305
dbainbri4d3a0dc2020-12-02 00:33:42 +00001306 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001307 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001308 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001309 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001310 return nil
1311 }
1312
Himani Chawla6d2ae152020-09-02 13:11:20 +05301313 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001314 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301315 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001316 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301317 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001318 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001319 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001320 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001321 return nil
1322 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001323 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001324 return meInstance
1325 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001326 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001327 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001328 return nil
1329}
1330
Himani Chawla6d2ae152020-09-02 13:11:20 +05301331func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001332 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301333 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001334 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001335 "SequNo": strconv.FormatInt(int64(tid), 16),
1336 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1337
1338 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1339 if omciErr.GetError() == nil {
1340 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1341 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1342 omci.TransactionID(tid), omci.AddDefaults(true))
1343 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001344 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001345 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001346 return nil
1347 }
1348
dbainbri4d3a0dc2020-12-02 00:33:42 +00001349 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001350 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001351 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001352 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001353 return nil
1354 }
1355
Himani Chawla6d2ae152020-09-02 13:11:20 +05301356 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001357 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301358 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001359 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301360 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001361 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001362 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001363 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001364 return nil
1365 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001366 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001367 return meInstance
1368 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001369 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001370 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001371 return nil
1372}
1373
Himani Chawla6d2ae152020-09-02 13:11:20 +05301374func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001375 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301376 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001377 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 "SequNo": strconv.FormatInt(int64(tid), 16),
1379 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1380
1381 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1382 if omciErr.GetError() == nil {
1383 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1384 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1385 omci.TransactionID(tid))
1386 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001387 logger.Errorw(ctx, "Cannot encode GemIwTp for create", 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 }
1391
dbainbri4d3a0dc2020-12-02 00:33:42 +00001392 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001393 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001394 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001395 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001396 return nil
1397 }
1398
Himani Chawla6d2ae152020-09-02 13:11:20 +05301399 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001400 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301401 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001402 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301403 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001404 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001405 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001406 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001407 return nil
1408 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001409 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001410 return meInstance
1411 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001412 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001413 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001414 return nil
1415}
1416
Himani Chawla6d2ae152020-09-02 13:11:20 +05301417func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001418 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301419 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001420 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 "SequNo": strconv.FormatInt(int64(tid), 16),
1422 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1423
1424 meInstance, omciErr := me.NewTCont(params[0])
1425 if omciErr.GetError() == nil {
1426 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1427 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001428 logger.Errorw(ctx, "Cannot encode TCont for 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 }
1432
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001434 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001435 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001436 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001437 return nil
1438 }
1439
Himani Chawla6d2ae152020-09-02 13:11:20 +05301440 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001441 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301442 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001443 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301444 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001445 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001446 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001447 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001448 return nil
1449 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001450 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001451 return meInstance
1452 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001453 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001454 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001455 return nil
1456}
1457
Himani Chawla6d2ae152020-09-02 13:11:20 +05301458func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001459 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301460 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001461 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001462 "SequNo": strconv.FormatInt(int64(tid), 16),
1463 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1464
1465 meInstance, omciErr := me.NewPriorityQueue(params[0])
1466 if omciErr.GetError() == nil {
1467 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1468 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001469 logger.Errorw(ctx, "Cannot encode PrioQueue for 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 }
1473
dbainbri4d3a0dc2020-12-02 00:33:42 +00001474 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001475 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001476 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001477 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001478 return nil
1479 }
1480
Himani Chawla6d2ae152020-09-02 13:11:20 +05301481 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001482 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301483 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001484 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301485 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001486 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001487 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001488 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001489 return nil
1490 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001491 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001492 return meInstance
1493 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001494 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001495 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001496 return nil
1497}
1498
Himani Chawla6d2ae152020-09-02 13:11:20 +05301499func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001500 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301501 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001502 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001503 "SequNo": strconv.FormatInt(int64(tid), 16),
1504 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1505
1506 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1507 if omciErr.GetError() == nil {
1508 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1509 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001510 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001511 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001512 return nil
1513 }
1514
dbainbri4d3a0dc2020-12-02 00:33:42 +00001515 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001519 return nil
1520 }
1521
Himani Chawla6d2ae152020-09-02 13:11:20 +05301522 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001523 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301524 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001525 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301526 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001527 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001528 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001529 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001530 return nil
1531 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001532 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001533 return meInstance
1534 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001535 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001536 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001537 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001538}
mpagenkodff5dda2020-08-28 11:52:01 +00001539
Himani Chawla6d2ae152020-09-02 13:11:20 +05301540func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001541 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301542 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001543 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001544 "SequNo": strconv.FormatInt(int64(tid), 16),
1545 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1546
1547 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1548 if omciErr.GetError() == nil {
1549 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1550 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1551 omci.TransactionID(tid))
1552 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001553 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001554 "Err": err, "device-id": oo.deviceID})
1555 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1556 // return (dual format) error code that can be used at caller for immediate error treatment
1557 // (relevant to all used sendXX() methods and their error conditions)
1558 return nil
1559 }
1560
dbainbri4d3a0dc2020-12-02 00:33:42 +00001561 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001562 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001563 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001564 "Err": err, "device-id": oo.deviceID})
1565 return nil
1566 }
1567
Himani Chawla6d2ae152020-09-02 13:11:20 +05301568 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001569 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301570 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001571 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301572 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001573 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001574 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001575 "Err": err, "device-id": oo.deviceID})
1576 return nil
1577 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001578 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001579 return meInstance
1580 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001581 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001582 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1583 return nil
1584}
1585
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001586// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001587func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1588 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1589 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001590 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001591 "SequNo": strconv.FormatInt(int64(tid), 16),
1592 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1593
1594 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1595 if omciErr.GetError() == nil {
1596 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1597 omci.TransactionID(tid))
1598 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001599 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001600 "Err": err, "device-id": oo.deviceID})
1601 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1602 // return (dual format) error code that can be used at caller for immediate error treatment
1603 // (relevant to all used sendXX() methods and their error conditions)
1604 return nil
1605 }
1606
dbainbri4d3a0dc2020-12-02 00:33:42 +00001607 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001608 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001609 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001610 "Err": err, "device-id": oo.deviceID})
1611 return nil
1612 }
1613
1614 omciRxCallbackPair := callbackPair{
1615 cbKey: tid,
1616 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1617 }
1618 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1619 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001620 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001621 "Err": err, "device-id": oo.deviceID})
1622 return nil
1623 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001624 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001625 return meInstance
1626 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001627 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001628 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1629 return nil
1630}
1631
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001632func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1633 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1634 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001635 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001636 "SequNo": strconv.FormatInt(int64(tid), 16),
1637 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1638
1639 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1640 if omciErr.GetError() == nil {
1641 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1642 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001643 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001644 "Err": err, "device-id": oo.deviceID})
1645 return nil
1646 }
1647
dbainbri4d3a0dc2020-12-02 00:33:42 +00001648 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001649 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001650 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001651 "Err": err, "device-id": oo.deviceID})
1652 return nil
1653 }
1654
1655 omciRxCallbackPair := callbackPair{
1656 cbKey: tid,
1657 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1658 }
1659 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1660 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001662 "Err": err, "device-id": oo.deviceID})
1663 return nil
1664 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001665 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001666 return meInstance
1667 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001669 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1670 return nil
1671}
1672
Himani Chawla6d2ae152020-09-02 13:11:20 +05301673func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001674 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301675 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001676 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001677 "SequNo": strconv.FormatInt(int64(tid), 16),
1678 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1679
1680 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1681 if omciErr.GetError() == nil {
1682 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1683 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001684 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001685 "Err": err, "device-id": oo.deviceID})
1686 return nil
1687 }
1688
dbainbri4d3a0dc2020-12-02 00:33:42 +00001689 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001690 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001691 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001692 "Err": err, "device-id": oo.deviceID})
1693 return nil
1694 }
1695
Himani Chawla6d2ae152020-09-02 13:11:20 +05301696 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001697 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301698 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001699 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301700 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001701 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001702 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001703 "Err": err, "device-id": oo.deviceID})
1704 return nil
1705 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001706 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001707 return meInstance
1708 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001709 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001710 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1711 return nil
1712}
mpagenko01e726e2020-10-23 09:45:29 +00001713
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001714func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1715 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1716 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001717 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001718 "SequNo": strconv.FormatInt(int64(tid), 16),
1719 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1720
1721 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1722 if omciErr.GetError() == nil {
1723 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1724 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001725 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001726 "Err": err, "device-id": oo.deviceID})
1727 return nil
1728 }
1729
dbainbri4d3a0dc2020-12-02 00:33:42 +00001730 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001731 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001732 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001733 "Err": err, "device-id": oo.deviceID})
1734 return nil
1735 }
1736
1737 omciRxCallbackPair := callbackPair{
1738 cbKey: tid,
1739 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1740 }
1741 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1742 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001743 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001744 "Err": err, "device-id": oo.deviceID})
1745 return nil
1746 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001747 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001748 return meInstance
1749 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001750 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001751 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1752 return nil
1753}
1754
mpagenko01e726e2020-10-23 09:45:29 +00001755func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1756 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1757 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001758 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001759 "SequNo": strconv.FormatInt(int64(tid), 16),
1760 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1761
1762 meParams := me.ParamData{EntityID: aInstID}
1763 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1764 if omciErr.GetError() == nil {
1765 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1766 omci.TransactionID(tid))
1767 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001768 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001769 "Err": err, "device-id": oo.deviceID})
1770 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1771 // return (dual format) error code that can be used at caller for immediate error treatment
1772 // (relevant to all used sendXX() methods and their error conditions)
1773 return nil
1774 }
1775
dbainbri4d3a0dc2020-12-02 00:33:42 +00001776 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001777 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001778 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001779 "Err": err, "device-id": oo.deviceID})
1780 return nil
1781 }
1782
1783 omciRxCallbackPair := callbackPair{
1784 cbKey: tid,
1785 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1786 }
1787 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1788 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001789 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001790 "Err": err, "device-id": oo.deviceID})
1791 return nil
1792 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001793 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001794 return meInstance
1795 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001796 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001797 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1798 return nil
1799}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001800
mpagenko8b07c1b2020-11-26 10:36:31 +00001801func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1802 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1803 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001804 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001805 "SequNo": strconv.FormatInt(int64(tid), 16),
1806 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1807
1808 meParams := me.ParamData{EntityID: aInstID}
1809 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
1810 if omciErr.GetError() == nil {
1811 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1812 omci.TransactionID(tid))
1813 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001815 "Err": err, "device-id": oo.deviceID})
1816 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1817 // return (dual format) error code that can be used at caller for immediate error treatment
1818 // (relevant to all used sendXX() methods and their error conditions)
1819 return nil
1820 }
1821
dbainbri4d3a0dc2020-12-02 00:33:42 +00001822 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001823 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001824 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001825 "Err": err, "device-id": oo.deviceID})
1826 return nil
1827 }
1828
1829 omciRxCallbackPair := callbackPair{
1830 cbKey: tid,
1831 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1832 }
1833 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1834 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001835 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001836 "Err": err, "device-id": oo.deviceID})
1837 return nil
1838 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001839 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001840 return meInstance
1841 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001842 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001843 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1844 return nil
1845}
1846
1847func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
1848 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1849 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001850 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001851 "SequNo": strconv.FormatInt(int64(tid), 16),
1852 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1853
1854 meParams := me.ParamData{EntityID: aInstID}
1855 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
1856 if omciErr.GetError() == nil {
1857 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1858 omci.TransactionID(tid))
1859 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001860 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001861 "Err": err, "device-id": oo.deviceID})
1862 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1863 // return (dual format) error code that can be used at caller for immediate error treatment
1864 // (relevant to all used sendXX() methods and their error conditions)
1865 return nil
1866 }
1867
dbainbri4d3a0dc2020-12-02 00:33:42 +00001868 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001869 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001870 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001871 "Err": err, "device-id": oo.deviceID})
1872 return nil
1873 }
1874
1875 omciRxCallbackPair := callbackPair{
1876 cbKey: tid,
1877 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1878 }
1879 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1880 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001881 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001882 "Err": err, "device-id": oo.deviceID})
1883 return nil
1884 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001885 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001886 return meInstance
1887 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001888 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001889 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1890 return nil
1891}
1892
1893func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
1894 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1895 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001896 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001897 "SequNo": strconv.FormatInt(int64(tid), 16),
1898 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1899
1900 meParams := me.ParamData{EntityID: aInstID}
1901 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1902 if omciErr.GetError() == nil {
1903 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1904 omci.TransactionID(tid))
1905 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001906 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001907 "Err": err, "device-id": oo.deviceID})
1908 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1909 // return (dual format) error code that can be used at caller for immediate error treatment
1910 // (relevant to all used sendXX() methods and their error conditions)
1911 return nil
1912 }
1913
dbainbri4d3a0dc2020-12-02 00:33:42 +00001914 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001915 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001916 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001917 "Err": err, "device-id": oo.deviceID})
1918 return nil
1919 }
1920
1921 omciRxCallbackPair := callbackPair{
1922 cbKey: tid,
1923 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1924 }
1925 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1926 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001927 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001928 "Err": err, "device-id": oo.deviceID})
1929 return nil
1930 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001931 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001932 return meInstance
1933 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001934 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001935 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1936 return nil
1937}
1938
1939func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
1940 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1941 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001942 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001943 "SequNo": strconv.FormatInt(int64(tid), 16),
1944 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1945
1946 meParams := me.ParamData{EntityID: aInstID}
1947 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1948 if omciErr.GetError() == nil {
1949 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1950 omci.TransactionID(tid))
1951 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001952 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001953 "Err": err, "device-id": oo.deviceID})
1954 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1955 // return (dual format) error code that can be used at caller for immediate error treatment
1956 // (relevant to all used sendXX() methods and their error conditions)
1957 return nil
1958 }
1959
dbainbri4d3a0dc2020-12-02 00:33:42 +00001960 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001961 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001962 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001963 "Err": err, "device-id": oo.deviceID})
1964 return nil
1965 }
1966
1967 omciRxCallbackPair := callbackPair{
1968 cbKey: tid,
1969 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1970 }
1971 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1972 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001973 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001974 "Err": err, "device-id": oo.deviceID})
1975 return nil
1976 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001977 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001978 return meInstance
1979 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001980 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001981 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1982 return nil
1983}
1984
mpagenkofc4f56e2020-11-04 17:17:49 +00001985// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03001986func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
1987 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1988 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001989 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03001990 "SequNo": strconv.FormatInt(int64(tid), 16),
1991 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1992
1993 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
1994 if omciErr.GetError() == nil {
1995 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
1996 omci.AddDefaults(true))
1997 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001998 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03001999 return nil
2000 }
2001
dbainbri4d3a0dc2020-12-02 00:33:42 +00002002 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002003 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002004 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002005 return nil
2006 }
2007
2008 omciRxCallbackPair := callbackPair{cbKey: tid,
2009 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2010 }
2011 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2012 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002013 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002014 return nil
2015 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002016 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002017 return meInstance
2018 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002019 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002020 "device-id": oo.deviceID})
2021 return nil
2022}
2023
mpagenkofc4f56e2020-11-04 17:17:49 +00002024// nolint: unused
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002025func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2026 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2027 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002028 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002029 "SequNo": strconv.FormatInt(int64(tid), 16),
2030 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2031
2032 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2033 if omciErr.GetError() == nil {
2034 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2035 omci.AddDefaults(true))
2036 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002037 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002038 return nil
2039 }
2040
dbainbri4d3a0dc2020-12-02 00:33:42 +00002041 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002042 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002043 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002044 return nil
2045 }
2046
2047 omciRxCallbackPair := callbackPair{cbKey: tid,
2048 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2049 }
2050 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2051 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002052 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002053 return nil
2054 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002055 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002056 return meInstance
2057 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002058 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002059 "device-id": oo.deviceID})
2060 return nil
2061}
2062
2063// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002064func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2065 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2066 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002067 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002068 "SequNo": strconv.FormatInt(int64(tid), 16),
2069 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2070
2071 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2072 if omciErr.GetError() == nil {
2073 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2074 omci.AddDefaults(true))
2075 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002076 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002077 "device-id": oo.deviceID})
2078 return nil
2079 }
2080
dbainbri4d3a0dc2020-12-02 00:33:42 +00002081 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002082 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002083 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002084 "device-id": oo.deviceID})
2085 return nil
2086 }
2087
2088 omciRxCallbackPair := callbackPair{cbKey: tid,
2089 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2090 }
2091 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2092 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002093 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002094 "device-id": oo.deviceID})
2095 return nil
2096 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002097 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002098 return meInstance
2099 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002100 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002101 "device-id": oo.deviceID})
2102 return nil
2103}
2104
mpagenkofc4f56e2020-11-04 17:17:49 +00002105// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002106func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2107 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2108 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002109 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002110 "SequNo": strconv.FormatInt(int64(tid), 16),
2111 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2112
2113 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2114 if omciErr.GetError() == nil {
2115 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2116 omci.AddDefaults(true))
2117 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002118 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002119 "device-id": oo.deviceID})
2120 return nil
2121 }
2122
dbainbri4d3a0dc2020-12-02 00:33:42 +00002123 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002124 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002125 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002126 "device-id": oo.deviceID})
2127 return nil
2128 }
2129
2130 omciRxCallbackPair := callbackPair{cbKey: tid,
2131 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2132 }
2133 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2134 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002136 "device-id": oo.deviceID})
2137 return nil
2138 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002139 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002140 return meInstance
2141 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002142 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002143 "device-id": oo.deviceID})
2144 return nil
2145}
2146
mpagenkofc4f56e2020-11-04 17:17:49 +00002147// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002148func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2149 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2150 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002151 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002152 "SequNo": strconv.FormatInt(int64(tid), 16),
2153 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2154
2155 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2156 if omciErr.GetError() == nil {
2157 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2158 omci.AddDefaults(true))
2159 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002160 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002161 "device-id": oo.deviceID})
2162 return nil
2163 }
2164
dbainbri4d3a0dc2020-12-02 00:33:42 +00002165 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002166 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002167 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002168 "device-id": oo.deviceID})
2169 return nil
2170 }
2171
2172 omciRxCallbackPair := callbackPair{cbKey: tid,
2173 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2174 }
2175 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2176 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002177 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002178 "device-id": oo.deviceID})
2179 return nil
2180 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002181 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002182 return meInstance
2183 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002184 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002185 "device-id": oo.deviceID})
2186 return nil
2187}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002188
2189func isResponseWithMibDataSync(msgType omci.MessageType) bool {
2190 for _, v := range responsesWithMibDataSync {
2191 if v == msgType {
2192 return true
2193 }
2194 }
2195 return false
2196}