blob: ffe44eae4b239fb38501155f474ec1ab6b475611 [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 Hildebrandt4b5e73f2021-08-19 06:51:21 +000017//Package common provides global definitions
18package common
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
Andrea Campanella6515c582020-10-05 11:25:00 +020025 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandt93d183f2022-04-22 15:50:26 +000027 "strings"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000028 "sync"
mpagenko80622a52021-02-09 16:53:23 +000029 "time" //by now for testing
Holger Hildebrandtfa074992020-03-27 15:42:06 +000030
31 "github.com/google/gopacket"
32 // TODO!!! Some references could be resolved auto, but some need specific context ....
33 gp "github.com/google/gopacket"
34
mpagenko836a1fd2021-11-01 16:12:42 +000035 "github.com/opencord/omci-lib-go/v2"
36 me "github.com/opencord/omci-lib-go/v2/generated"
37 oframe "github.com/opencord/omci-lib-go/v2/meframe"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000038
khenaidoo7d3c5582021-08-11 18:09:44 -040039 vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
40
khenaidoo7d3c5582021-08-11 18:09:44 -040041 "github.com/opencord/voltha-lib-go/v7/pkg/log"
khenaidoo42dcdfd2021-10-19 17:34:12 -040042 "github.com/opencord/voltha-protos/v5/go/common"
43 ia "github.com/opencord/voltha-protos/v5/go/inter_adapter"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000044)
45
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000046// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053047
Holger Hildebrandt9b64e0b2022-04-21 08:02:00 +000048const maxGemPayloadSize = uint16(2048)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000049const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053050
51//const defaultTPID = uint16(0x8100)
52//const broadComDefaultVID = uint16(4091)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000053
54// UnusedTcontAllocID - TODO: add comment
55const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
mpagenko8b07c1b2020-11-26 10:36:31 +000056
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +000057const cOmciDeviceIdentifierPos = 3
mpagenkoc8bba412021-01-15 15:38:44 +000058const cOmciBaseMessageTrailerLen = 40
59
60// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
61type tOmciReceiveError uint8
62
63const (
64 // cOmciMessageReceiveNoError - default start state
65 cOmciMessageReceiveNoError tOmciReceiveError = iota
66 // Error indication wrong trailer length within the message
67 cOmciMessageReceiveErrorTrailerLen
68 // Error indication missing trailer within the message
69 cOmciMessageReceiveErrorMissTrailer
70)
71
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000072// CDefaultRetries - TODO: add comment
73const CDefaultRetries = 2
Holger Hildebrandt366ef192021-05-05 11:07:44 +000074
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000075// ### OMCI related definitions - end
76
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000077//CallbackPairEntry to be used for OMCI send/receive correlation
78type CallbackPairEntry struct {
79 CbRespChannel chan Message
80 CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
81 FramePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000082}
83
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000084//CallbackPair to be used for ReceiveCallback init
85type CallbackPair struct {
86 CbKey uint16
87 CbEntry CallbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000088}
89
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000090// OmciTransferStructure - TODO: add comment
91type OmciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000092 txFrame []byte
93 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000094 retries int
mpagenko80622a52021-02-09 16:53:23 +000095 highPrio bool
96 withFramePrint bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000097 cbPair CallbackPair
Holger Hildebrandt366ef192021-05-05 11:07:44 +000098 chSuccess chan bool
kesavand011d5162021-11-25 19:21:06 +053099 OnuSwWindow *ia.OmciMessages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000100}
101
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000102//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
103type OmciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000104 enabled bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000105 pBaseDeviceHandler IdeviceHandler
106 pOnuDeviceEntry IonuDeviceEntry
107 pOnuAlarmManager IonuAlarmManager
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000108 deviceID string
khenaidoo7d3c5582021-08-11 18:09:44 -0400109 coreClient *vgrpc.Client
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000110 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000111 rxOmciFrameError tOmciReceiveError
112
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000113 txFrames, txOnuFrames uint32
114 rxFrames, rxOnuFrames, rxOnuDiscards uint32
115
116 // OMCI params
117 mutexTid sync.Mutex
118 tid uint16
119 mutexHpTid sync.Mutex
120 hpTid uint16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000121 UploadSequNo uint16
122 UploadNoOfCmds uint16
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000123
Holger Hildebrandt34555512021-10-01 16:26:59 +0000124 mutexSendQueuedRequests sync.Mutex
125 mutexLowPrioTxQueue sync.Mutex
126 lowPrioTxQueue *list.List
127 mutexHighPrioTxQueue sync.Mutex
128 highPrioTxQueue *list.List
129 mutexRxSchedMap sync.Mutex
130 rxSchedulerMap map[uint16]CallbackPairEntry
131 mutexMonReq sync.RWMutex
132 monitoredRequests map[uint16]OmciTransferStructure
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000133}
134
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000135var responsesWithMibDataSync = []omci.MessageType{
136 omci.CreateResponseType,
137 omci.DeleteResponseType,
138 omci.SetResponseType,
139 omci.StartSoftwareDownloadResponseType,
140 omci.EndSoftwareDownloadResponseType,
141 omci.ActivateSoftwareResponseType,
142 omci.CommitSoftwareResponseType,
143}
144
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000145//NewOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000146//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000147func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
148 onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
149 coreClient *vgrpc.Client) *OmciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000150 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000151 var omciCC OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000152 omciCC.enabled = false
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000153 omciCC.pBaseDeviceHandler = deviceHandler
154 omciCC.pOnuAlarmManager = onuAlarmManager
Himani Chawla4d908332020-08-31 12:30:20 +0530155 omciCC.pOnuDeviceEntry = onuDeviceEntry
156 omciCC.deviceID = deviceID
khenaidoo7d3c5582021-08-11 18:09:44 -0400157 omciCC.coreClient = coreClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000158 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000159 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000160 omciCC.txFrames = 0
161 omciCC.txOnuFrames = 0
162 omciCC.rxFrames = 0
163 omciCC.rxOnuFrames = 0
164 omciCC.rxOnuDiscards = 0
165 omciCC.tid = 0x1
166 omciCC.hpTid = 0x8000
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000167 omciCC.UploadSequNo = 0
168 omciCC.UploadNoOfCmds = 0
Holger Hildebrandt34555512021-10-01 16:26:59 +0000169 omciCC.lowPrioTxQueue = list.New()
170 omciCC.highPrioTxQueue = list.New()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000171 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
172 omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000173
174 return &omciCC
175}
176
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000177//Stop stops/resets the omciCC
178func (oo *OmciCC) Stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000179 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000180 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
mpagenko8cd1bf72021-06-22 10:11:19 +0000181 oo.CancelRequestMonitoring(ctx)
Holger Hildebrandt34555512021-10-01 16:26:59 +0000182 // clear the tx queues
183 oo.mutexHighPrioTxQueue.Lock()
184 oo.highPrioTxQueue.Init()
185 oo.mutexHighPrioTxQueue.Unlock()
186 oo.mutexLowPrioTxQueue.Lock()
187 oo.lowPrioTxQueue.Init()
188 oo.mutexLowPrioTxQueue.Unlock()
189 //clear the scheduler map
mpagenko900ee4b2020-10-12 11:56:34 +0000190 oo.mutexRxSchedMap.Lock()
191 for k := range oo.rxSchedulerMap {
Holger Hildebrandt34555512021-10-01 16:26:59 +0000192 delete(oo.rxSchedulerMap, k)
mpagenko900ee4b2020-10-12 11:56:34 +0000193 }
194 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000195 //reset the high prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000196 oo.mutexHpTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000197 oo.hpTid = 0x8000
mpagenko900ee4b2020-10-12 11:56:34 +0000198 oo.mutexHpTid.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000199 //reset the low prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000200 oo.mutexTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000201 oo.tid = 1
mpagenko900ee4b2020-10-12 11:56:34 +0000202 oo.mutexTid.Unlock()
203 //reset control values
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000204 oo.UploadSequNo = 0
205 oo.UploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000206 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000207 //reset the stats counter - which might be topic of discussion ...
208 oo.txFrames = 0
209 oo.txOnuFrames = 0
210 oo.rxFrames = 0
211 oo.rxOnuFrames = 0
212 oo.rxOnuDiscards = 0
213
214 return nil
215}
216
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000217// Rx handler for omci messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000218func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000219 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000220 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530221 switch omciMsg.MessageType {
222 case omci.AlarmNotificationType:
223 data := OmciMessage{
224 OmciMsg: omciMsg,
225 OmciPacket: packet,
226 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000227 go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530228 return nil
229 default:
230 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
231 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000232 /*
233 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
234 rxOnuFrames++
235
236 switch msgType {
237 case AlarmNotification:
238 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000239 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000240 // python code was:
241 //if msg_type == EntityOperations.AlarmNotification.value:
242 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
243 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
244 //
245 return errors.New("RxAlarmNotification unimplemented")
246 }
247 case AttributeValueChange:
248 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000249 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000250 // python code was:
251 //elif msg_type == EntityOperations.AttributeValueChange.value:
252 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
253 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
254 //
255 return errors.New("RxAttributeValueChange unimplemented")
256 }
257 case TestResult:
258 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000259 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000260 // python code was:
261 //elif msg_type == EntityOperations.TestResult.value:
262 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
263 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
264 //
265 return errors.New("RxTestResult unimplemented")
266 }
267 default:
268 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000269 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000270 rxOnuDiscards++
271 return errors.New("RxOnuMsgType unimplemented")
272 }
273 }
274 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000275}
276
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000277func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
mpagenko80622a52021-02-09 16:53:23 +0000278 //assuming omci message content is hex coded!
279 // with restricted output of 16bytes would be ...rxMsg[:16]
280 logger.Debugw(ctx, "omci-message-received:", log.Fields{
281 "RxOmciMessage": hex.EncodeToString(rxMsg),
282 "device-id": oo.deviceID})
283}
284
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000285// ReceiveMessage - Rx handler for onu messages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000286// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000287// nolint: gocyclo
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000288func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000289 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000290
291 if len(rxMsg) < 10 {
292 logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort",
293 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
294 if len(rxMsg) > 0 {
295 oo.printRxMessage(ctx, rxMsg)
mpagenkoc8bba412021-01-15 15:38:44 +0000296 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000297 return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID)
298 }
299 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
300 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
301 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
302 // (an extendedFormat message could be destroyed this way!)
303 trailerLenData := rxMsg[42:44]
304 trailerLen := binary.BigEndian.Uint16(trailerLenData)
305 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
306 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
307 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
308 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
309 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
310 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
311 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
312 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
313 }
314 }
315 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
316 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
317 // (an extendedFormat message could be destroyed this way!)
318 // extend/overwrite with trailer
319 trailer := make([]byte, 8)
320 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
321 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
322 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
323 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
324 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
325 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
326 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
327 }
328 } else {
329 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
330 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
331 oo.printRxMessage(ctx, rxMsg)
332 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
333 }
334 } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) {
335 if len(rxMsg) > 1980 {
336 logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort",
337 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
338 oo.printRxMessage(ctx, rxMsg)
339 return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000340 }
341 } else {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000342 logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort",
mpagenkoc8bba412021-01-15 15:38:44 +0000343 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000344 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000345 return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000346 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000347 decodeOptions := gopacket.DecodeOptions{
348 Lazy: true,
349 NoCopy: true,
350 }
351 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000352 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000353 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000354 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200355 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000356 }
357 omciLayer := packet.Layer(omci.LayerTypeOMCI)
358 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000359 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000360 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200361 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000362 }
mpagenko836a1fd2021-11-01 16:12:42 +0000363 // insert some check on detected OMCI decoding issues and log them
364 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
365 // even though allowed from omci-lib due to set relaxed decoding
366 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
367 // (compare mib_sync.go unknownAttrLayer)
368 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
369 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
370 errMsg := failure.Error()
371 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
372 "device-id": oo.deviceID, "issue": errMsg})
373 }
374 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000375 omciMsg, ok := omciLayer.(*omci.OMCI)
376 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000377 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000378 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200379 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000380 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000381 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000382 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
383 "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID})
mpagenko836a1fd2021-11-01 16:12:42 +0000384
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700385 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
386 // We expect to find the TID in the oo.rxSchedulerMap
387 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000388 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000389 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000390 logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000391 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530392 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000394 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200395 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000396 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200397 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530398 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000399 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530400 oo.mutexRxSchedMap.Lock()
401 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000402 if ok && rxCallbackEntry.CbFunction != nil {
403 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000404 oo.printRxMessage(ctx, rxMsg)
405 }
Himani Chawla4d908332020-08-31 12:30:20 +0530406 //disadvantage of decoupling: error verification made difficult, but anyway the question is
407 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000408 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000409 isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet)
410 if err != nil {
411 // qualified error logging already done in function above
412 if !rxCallbackEntry.FramePrint {
413 oo.printRxMessage(ctx, rxMsg)
414 }
415 return fmt.Errorf("could not decode further layers %s", oo.deviceID)
416 }
417 if isSuccessfulResponse {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000418 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000419 } else {
420 logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type",
421 log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID})
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000422 }
mpagenkoc8bba412021-01-15 15:38:44 +0000423
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700424 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
425 // so do not clean up the TransactionID in that case.
426 if omciMsg.MessageType != omci.TestResponseType {
427 // having posted the response the request is regarded as 'done'
428 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
429 }
Himani Chawla4d908332020-08-31 12:30:20 +0530430 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000431 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000432 }
mpagenko80622a52021-02-09 16:53:23 +0000433 oo.mutexRxSchedMap.Unlock()
434 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
435 oo.printRxMessage(ctx, rxMsg)
436 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000437
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000438 /* py code was:
439 Receive and OMCI message from the proxy channel to the OLT.
440
441 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
442 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
443 """
444 if not self.enabled:
445 return
446
447 try:
448 now = arrow.utcnow()
449 d = None
450
451 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
452 # save the current value of the entity_id_to_class_map, then
453 # replace it with our custom one before decode, and then finally
454 # restore it later. Tried other ways but really made the code messy.
455 saved_me_map = omci_entities.entity_id_to_class_map
456 omci_entities.entity_id_to_class_map = self._me_map
457
458 try:
459 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000460 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000461 except KeyError as e:
462 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000463 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000464 rx_frame = self._decode_unknown_me(msg)
465 self._rx_unknown_me += 1
466
467 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000468 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000469 return
470
471 finally:
472 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
473
474 rx_tid = rx_frame.fields['transaction_id']
475 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000476 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000477 # Filter the Test Result frame and route through receive onu
478 # message method.
479 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000480 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000481 return self._receive_onu_message(rx_frame)
482
483 # Previously unreachable if this is the very first round-trip Rx or we
484 # have been running consecutive errors
485 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000486 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000487 self.reactor.callLater(0, self._publish_connectivity_event, True)
488
489 self._rx_frames += 1
490 self._consecutive_errors = 0
491
492 try:
493 high_priority = self._tid_is_high_priority(rx_tid)
494 index = self._get_priority_index(high_priority)
495
496 # (timestamp, defer, frame, timeout, retry, delayedCall)
497 last_tx_tuple = self._tx_request[index]
498
499 if last_tx_tuple is None or \
500 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
501 # Possible late Rx on a message that timed-out
502 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000503 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000504 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
505 self._rx_unknown_tid += 1
506 self._rx_late += 1
507 return
508
509 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
510 if dc is not None and not dc.cancelled and not dc.called:
511 dc.cancel()
512
513 _secs = self._update_rx_tx_stats(now, ts)
514
515 # Late arrival already serviced by a timeout?
516 if d.called:
517 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000518 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000519 return
520
521 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000522 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000523 if d is not None:
524 return d.errback(failure.Failure(e))
525 return
526
527 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000528 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000529 tx_tid = tx_frame.fields['transaction_id'])
530 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
531
532 # begin success callback chain (will cancel timeout and queue next Tx message)
533 self._rx_response[index] = rx_frame
534 d.callback(rx_frame)
535
536 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000537 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000538 */
539}
540
Himani Chawla6d2ae152020-09-02 13:11:20 +0530541/*
542func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530543 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530544 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000545}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530546*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000547
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700548// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000549func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700550 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
551 delete(oo.rxSchedulerMap, tid)
552}
553
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000554// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
555func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
556 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000557
mpagenkoc26d4c02021-05-06 14:27:57 +0000558 if timeout != 0 {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000559 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000560 oo.mutexRxSchedMap.Lock()
561 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000562 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000563 oo.mutexRxSchedMap.Unlock()
564 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000565
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000566 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000567 //just use a simple list for starting - might need some more effort, especially for multi source write access
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000568 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000569 txFrame,
570 timeout,
571 retry,
572 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000573 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000574 receiveCallbackPair,
575 nil,
kesavand011d5162021-11-25 19:21:06 +0530576 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000577 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000578 oo.mutexMonReq.Lock()
579 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000580 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000581 // do not call processRequestMonitoring in background here to ensure correct sequencing
582 // of requested messages into txQueue (especially for non-response-supervised messages)
583 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000584 return nil
585 }
586 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000587 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000588 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000589}
590
Holger Hildebrandt34555512021-10-01 16:26:59 +0000591func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
592 // Avoid accessing the txQueues from parallel send routines to block
593 // parallel omci send requests at least until SendIAP is 'committed'.
594 // To guarantee window size 1 for one ONU it would be necessary to wait
595 // for the corresponding response too (t.b.d.).
596 oo.mutexSendQueuedRequests.Lock()
597 defer oo.mutexSendQueuedRequests.Unlock()
598 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
599 logger.Errorw(ctx, "Error during sending high prio requests!",
600 log.Fields{"err": err, "device-id": oo.deviceID})
601 return
602 }
603 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
604 logger.Errorw(ctx, "Error during sending low prio requests!",
605 log.Fields{"err": err, "device-id": oo.deviceID})
606 return
607 }
608}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000609
Holger Hildebrandt34555512021-10-01 16:26:59 +0000610func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
611 oo.mutexHighPrioTxQueue.Lock()
612 defer oo.mutexHighPrioTxQueue.Unlock()
613 for oo.highPrioTxQueue.Len() > 0 {
614 queueElement := oo.highPrioTxQueue.Front() // First element
615 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000616 // Element will be removed from the queue regardless of the send success, to prevent
617 // an accumulation of send requests for the same message in the event of an error.
618 // In this case, resend attempts for the message are ensured by our retry
619 // mechanism after omci-timeout.
620 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
Holger Hildebrandt34555512021-10-01 16:26:59 +0000621 return err
mpagenko80622a52021-02-09 16:53:23 +0000622 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000623 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
624 }
625 return nil
626}
627
628func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
629 oo.mutexLowPrioTxQueue.Lock()
630 for oo.lowPrioTxQueue.Len() > 0 {
631 queueElement := oo.lowPrioTxQueue.Front() // First element
kesavand011d5162021-11-25 19:21:06 +0530632 // check if the element is for onu sw section
633 aOmciTxReq := queueElement.Value.(OmciTransferStructure)
634 if aOmciTxReq.OnuSwWindow != nil {
635 if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000636 // Element will be removed from the queue regardless of the send success, to prevent
637 // an accumulation of send requests for the same message in the event of an error.
638 // In this case, resend attempts for the message are ensured by our retry
639 // mechanism after omci-timeout.
640 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530641 oo.mutexLowPrioTxQueue.Unlock()
642 return err
643 }
644 } else {
645 err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure))
646 if err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000647 // Element will be removed from the queue regardless of the send success, to prevent
648 // an accumulation of send requests for the same message in the event of an error.
649 // In this case, resend attempts for the message are ensured by our retry
650 // mechanism after omci-timeout.
651 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530652 oo.mutexLowPrioTxQueue.Unlock()
653 return err
654 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200655 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000656 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
657 // Interrupt the sending of low priority requests to process any high priority requests
658 // that may have arrived in the meantime
659 oo.mutexLowPrioTxQueue.Unlock()
660 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
661 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000663 oo.mutexLowPrioTxQueue.Lock()
664 }
665
666 oo.mutexLowPrioTxQueue.Unlock()
667 return nil
668}
669
670func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
671 if omciTxRequest.withFramePrint {
672 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
673 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
674 "device-id": oo.deviceID,
675 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
676 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
677 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
678 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400679 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000680 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
681 ChildDeviceId: oo.deviceID,
682 Message: omciTxRequest.txFrame,
683 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
684 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
685 }
686 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
687 if sendErr != nil {
Holger Hildebrandtabfef032022-02-25 12:40:20 +0000688 logger.Errorw(ctx, "send omci request error", log.Fields{"device-id": oo.deviceID, "ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandt34555512021-10-01 16:26:59 +0000689 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000690 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000691 return nil
692}
693
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000694// GetNextTid - TODO: add comment
695func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000696 var next uint16
697 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000698 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000699 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530700 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000701 if oo.hpTid < 0x8000 {
702 oo.hpTid = 0x8000
703 }
mpagenko900ee4b2020-10-12 11:56:34 +0000704 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000705 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000706 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000707 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530708 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000709 if oo.tid >= 0x8000 {
710 oo.tid = 1
711 }
mpagenko900ee4b2020-10-12 11:56:34 +0000712 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000713 }
714 return next
715}
716
kesavand011d5162021-11-25 19:21:06 +0530717//GetOnuSwSecNextTid get the next low prio tid for the onu sw sections
718//onu sw sections uses only low priority tids
719//The mutexTid lock should be taken prior to using this function
720func (oo *OmciCC) GetOnuSwSecNextTid() uint16 {
721 next := oo.tid
722 oo.tid++
723 if oo.tid >= 0x8000 {
724 oo.tid = 1
725 }
726 return next
727}
728
729//GetOnuSwSecLastTid gets the last allocated tid
730//The mutexTid lock should be taken prior to using this function
731func (oo *OmciCC) GetOnuSwSecLastTid() uint16 {
732 next := oo.tid
733 lastAllocatedTid := next - 1
734 return lastAllocatedTid
735}
736
737//LockMutexTID locks mutexTid
738func (oo *OmciCC) LockMutexTID() {
739 oo.mutexTid.Lock()
740}
741
742//UnLockMutexTID unlocks mutexTid
743func (oo *OmciCC) UnLockMutexTID() {
744 oo.mutexTid.Unlock()
745}
746
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000747// ###################################################################################
748// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000749
750// Serialize - TODO: add comment
751func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000752 omciLayer := &omci.OMCI{
753 TransactionID: tid,
754 MessageType: msgType,
755 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000756 return SerializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000757}
758
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000759// SerializeOmciLayer - TODO: add comment
760func SerializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000761 var options gopacket.SerializeOptions
762 options.FixLengths = true
763
764 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530765 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000766 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000767 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000768 return nil, err
769 }
770 return buffer.Bytes(), nil
771}
772
Himani Chawla4d908332020-08-31 12:30:20 +0530773/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000774func hexEncode(omciPkt []byte) ([]byte, error) {
775 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
776 hex.Encode(dst, omciPkt)
777 return dst, nil
778}
Himani Chawla4d908332020-08-31 12:30:20 +0530779*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000780
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000781//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000782func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000783
dbainbri4d3a0dc2020-12-02 00:33:42 +0000784 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000785 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000786
787 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000788 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000789 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200790 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000791 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000792 oo.mutexMonReq.RLock()
793 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000794 //implement non-blocking channel send to avoid blocking on mutexMonReq later
795 select {
796 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
797 default:
798 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
799 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
800 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000801 } else {
802 logger.Infow(ctx, "reqMon: map entry does not exist!",
803 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
804 }
805 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000806
807 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
808 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000809 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000810 Type: OMCI,
811 Data: OmciMessage{
812 OmciMsg: omciMsg,
813 OmciPacket: packet,
814 },
815 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000816 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000817 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000818
819 return nil
820}
821
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000822// SendMibReset sends MibResetRequest
823func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000824
dbainbri4d3a0dc2020-12-02 00:33:42 +0000825 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000826 request := &omci.MibResetRequest{
827 MeBasePacket: omci.MeBasePacket{
828 EntityClass: me.OnuDataClassID,
829 },
830 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000831 tid := oo.GetNextTid(highPrio)
832 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000833 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000834 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000835 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000836 return err
837 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000838 omciRxCallbackPair := CallbackPair{
839 CbKey: tid,
840 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000841 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000842 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000843}
844
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000845// SendReboot sends RebootRequest
846func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
847 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300848 request := &omci.RebootRequest{
849 MeBasePacket: omci.MeBasePacket{
850 EntityClass: me.OnuGClassID,
851 },
852 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000853 tid := oo.GetNextTid(highPrio)
854 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300855 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000856 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000857 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300858 return err
859 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000860 omciRxCallbackPair := CallbackPair{
861 CbKey: tid,
862 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300863 }
864
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000865 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300866 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000867 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000868 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300869 return err
870 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000871 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300872 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000873 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200874 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300875 return err
876 }
877 return nil
878}
879
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000880// SendMibUpload sends MibUploadRequest
881func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000882 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000883 request := &omci.MibUploadRequest{
884 MeBasePacket: omci.MeBasePacket{
885 EntityClass: me.OnuDataClassID,
886 },
887 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000888 tid := oo.GetNextTid(highPrio)
889 pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000890 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000891 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000892 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000893 return err
894 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000895 oo.UploadSequNo = 0
896 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000897
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000898 omciRxCallbackPair := CallbackPair{
899 CbKey: tid,
900 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000901 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000902 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000903}
904
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000905// SendMibUploadNext sends MibUploadNextRequest
906func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
907 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000908 request := &omci.MibUploadNextRequest{
909 MeBasePacket: omci.MeBasePacket{
910 EntityClass: me.OnuDataClassID,
911 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000912 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000913 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000914 tid := oo.GetNextTid(highPrio)
915 pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000916 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000917 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000918 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000919 return err
920 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000921 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000922
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000923 omciRxCallbackPair := CallbackPair{
924 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000925 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
926 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
927 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000928 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000929 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000930 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000931}
932
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000933// SendGetAllAlarm gets all alarm ME instances
934func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530935 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
936 request := &omci.GetAllAlarmsRequest{
937 MeBasePacket: omci.MeBasePacket{
938 EntityClass: me.OnuDataClassID,
939 },
940 AlarmRetrievalMode: byte(alarmRetreivalMode),
941 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000942 tid := oo.GetNextTid(highPrio)
943 pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530944 if err != nil {
945 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
946 "Err": err, "device-id": oo.deviceID})
947 return err
948 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000949 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530950
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000951 omciRxCallbackPair := CallbackPair{
952 CbKey: tid,
953 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530954 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000955 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530956}
957
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000958// SendGetAllAlarmNext gets next alarm ME instance
959func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
960 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
961 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +0530962 "alarmUploadSeqNo": alarmUploadSeqNo})
963 request := &omci.GetAllAlarmsNextRequest{
964 MeBasePacket: omci.MeBasePacket{
965 EntityClass: me.OnuDataClassID,
966 },
967 CommandSequenceNumber: alarmUploadSeqNo,
968 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000969 tid := oo.GetNextTid(highPrio)
970 pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530971 if err != nil {
972 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
973 "Err": err, "device-id": oo.deviceID})
974 return err
975 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000976 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530977
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000978 omciRxCallbackPair := CallbackPair{
979 CbKey: tid,
980 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530981 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000982 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530983}
984
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000985// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
986func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
987 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000988 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000989 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000990
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000991 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000992 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +0000993 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000994 }
995 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
996 if omciErr.GetError() == nil {
997 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +0000998 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000999 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001000 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001001 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001002 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001003 }
1004
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001005 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001006 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001007 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001008 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001009 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001010 }
1011
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001012 omciRxCallbackPair := CallbackPair{
1013 CbKey: tid,
1014 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001015 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001016 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001017 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001018 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001019 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001020 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001021 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001022 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001023 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001024 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001025 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001026 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001027 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001028}
1029
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001030// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001031// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001032func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1033 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001034 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001035 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001036
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001037 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
1038 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001039 // By now we just use fix values to fire - this is anyway what the python adapter does
1040 // read ONU-2G from DB ???? //TODO!!!
1041 meParams := me.ParamData{
1042 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001043 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001044 }
1045 meInstance, omciErr := me.NewOnu2G(meParams)
1046 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001047 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001048 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001049 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001050 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001051 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001052 }
1053
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001054 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001055 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001056 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001057 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001058 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001059 }
1060
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001061 omciRxCallbackPair := CallbackPair{
1062 CbKey: tid,
1063 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001064 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001065 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001066 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001067 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001068 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001069 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001070 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001071 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001072 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001073 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001074 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001075 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001076 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001077}
1078
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001079// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1080func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1081 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1082 tid := oo.GetNextTid(highPrio)
1083 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001084 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001085 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001086
1087 meParams := me.ParamData{
1088 EntityID: instID,
1089 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001090 me.MacBridgeServiceProfile_Priority: 0x8000,
1091 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1092 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1093 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1094 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001095 },
1096 }
1097
1098 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1099 if omciErr.GetError() == nil {
1100 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001101 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1102 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001103 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001104 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001105 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001106 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001107 }
1108
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001109 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001110 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001111 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001112 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001113 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001114 }
1115
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001116 omciRxCallbackPair := CallbackPair{
1117 CbKey: tid,
1118 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001119 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001120 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001121 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001122 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001123 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001124 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001125 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001126 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001127 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001128 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001129 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001130 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001131 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001132}
1133
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001134// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1135func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1136 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1137 tid := oo.GetNextTid(highPrio)
1138 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001139 if idErr != nil {
1140 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1141 "Err": idErr, "device-id": oo.deviceID})
1142 return nil, idErr
1143 }
1144 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001145 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001146
1147 meParams := me.ParamData{
1148 EntityID: instID,
1149 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001150 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1151 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1152 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1153 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001154 },
1155 }
1156 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1157 if omciErr.GetError() == nil {
1158 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001159 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1160 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001161 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001162 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001163 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001164 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001165 }
1166
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001167 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001168 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001169 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001170 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001171 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001172 }
1173
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001174 omciRxCallbackPair := CallbackPair{
1175 CbKey: tid,
1176 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001177 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001178 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001179 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001180 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001181 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001182 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001183 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001184 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001185 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001186 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001187 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001188 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001189 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001190}
1191
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001192// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1193func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1194 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1195 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001196 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001197 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001199 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001200
1201 // compare python adapter code WA VOL-1311: this is not done here!
1202 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1203 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1204 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001205 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001206 assType = uint8(10) // for VEIP
1207 }
1208 meParams := me.ParamData{
1209 EntityID: instID,
1210 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001211 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1212 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001213 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001214 },
1215 }
1216 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1217 if omciErr.GetError() == nil {
1218 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001219 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1220 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001221 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001222 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001223 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001224 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001225 }
1226
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001227 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001228 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001229 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001230 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001231 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001232 }
1233
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001234 omciRxCallbackPair := CallbackPair{
1235 CbKey: tid,
1236 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001237 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001238 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001239 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001240 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001241 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001242 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001243 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001245 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001246 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001247 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001248 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001249 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250}
1251
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001252// SendSetOnuGLS sets OnuG ME instance
1253func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001254 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001255 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001256 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001257 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001258
1259 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1260 meParams := me.ParamData{
1261 EntityID: 0,
1262 Attributes: requestedAttributes,
1263 }
1264 meInstance, omciErr := me.NewOnuG(meParams)
1265 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001266 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001267 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001268 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001269 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001270 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001271 }
1272
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001273 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001274 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001276 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001277 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001278 }
1279
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001280 omciRxCallbackPair := CallbackPair{
1281 CbKey: tid,
1282 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001283 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001284 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001285 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001286 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001287 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001288 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001289 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001291 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001292 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001293 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001294 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001295 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001296}
1297
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001298// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1299func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001300 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001301 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001302 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001303 "SequNo": strconv.FormatInt(int64(tid), 16)})
1304
1305 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1306 meParams := me.ParamData{
1307 EntityID: aInstNo,
1308 Attributes: requestedAttributes,
1309 }
1310 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1311 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001312 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001313 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001314 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001315 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001316 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001317 }
1318
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001319 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001320 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001321 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001322 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001323 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001324 }
1325
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001326 omciRxCallbackPair := CallbackPair{
1327 CbKey: tid,
1328 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001329 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001330 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001331 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001332 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001333 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001334 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001335 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001336 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001337 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001338 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001339 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001340 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001341 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001342}
1343
1344/* UniG obsolete by now, left here in case it should be needed once again
1345 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301346func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001347 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001348 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001349 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001350 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001351
1352 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1353 meParams := me.ParamData{
1354 EntityID: aInstNo,
1355 Attributes: requestedAttributes,
1356 }
1357 meInstance, omciErr := me.NewUniG(meParams)
1358 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001359 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001360 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001361 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001362 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001363 return nil
1364 }
1365
1366 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1367 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001368 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001369 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001370 return nil
1371 }
1372
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001373 omciRxCallbackPair := CallbackPair{
1374 CbKey: tid,
1375 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001376 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001377 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001378 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001379 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001380 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001381 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001382 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001383 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001384 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001385 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001386 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001387 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001388 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001389}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001390*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001391
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001392// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1393func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001394 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001395 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001396 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001397 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001398
1399 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1400 meParams := me.ParamData{
1401 EntityID: aInstNo,
1402 Attributes: requestedAttributes,
1403 }
1404 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1405 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001406 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001407 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001408 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001409 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001410 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001411 }
1412
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001413 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001414 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001416 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001417 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001418 }
1419
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001420 omciRxCallbackPair := CallbackPair{
1421 CbKey: tid,
1422 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001423 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001424 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001425 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001426 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001427 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001428 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001429 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001431 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001432 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001434 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001435 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001436}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001437
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001438// SendGetMe gets ME instance
1439func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001440 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001441
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001442 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001443 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001444 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001445
1446 meParams := me.ParamData{
1447 EntityID: entityID,
1448 Attributes: requestedAttributes,
1449 }
1450 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1451 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301452 meClassIDName := meInstance.GetName()
mpagenko836a1fd2021-11-01 16:12:42 +00001453 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001454 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001455 logger.Errorf(ctx, "Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001456 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001457 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001458 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001459 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001461 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001462 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001463 omciRxCallbackPair := CallbackPair{
1464 CbKey: tid,
1465 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001466 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001467 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001468 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001469 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001470 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001471 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001472 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001473 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001474 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001475 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001476 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001477}
1478
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001479// SendGetMeWithAttributeMask gets ME instance with attribute mask
1480func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301481 timeout int, highPrio bool, rxChan chan Message) error {
1482
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001483 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301484 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1485 "SequNo": strconv.FormatInt(int64(tid), 16)})
1486
1487 request := &omci.GetRequest{
1488 MeBasePacket: omci.MeBasePacket{
1489 EntityInstance: entityID,
1490 EntityClass: classID,
1491 },
1492 AttributeMask: requestedAttributesMask,
1493 }
1494
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001495 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301496 if err != nil {
1497 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1498 return err
1499 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001500 omciRxCallbackPair := CallbackPair{
1501 CbKey: tid,
1502 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301503 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001504 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301505 if err != nil {
1506 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1507 return err
1508 }
1509 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1510 return nil
1511}
1512
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001513// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1514func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001515 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001516 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001518 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1519
1520 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001521 EntityID: aInstID,
1522 Attributes: me.AttributeValueMap{
1523 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001524 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1525 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1526 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1527 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1528 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1529 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1530 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1531 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1532 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001533 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001534 }
1535 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1536 if omciErr.GetError() == nil {
1537 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001538 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1539 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001540 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001541 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001542 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001543 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001544 }
1545
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001546 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001547 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001548 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001549 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001550 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001551 }
1552
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001553 omciRxCallbackPair := CallbackPair{
1554 CbKey: tid,
1555 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001556 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001557 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001558 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001559 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001560 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001561 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001562 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001563 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001564 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001565 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001566 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001567 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001568 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001569}
1570
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001571// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1572func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001573 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001574 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001575 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001576 "SequNo": strconv.FormatInt(int64(tid), 16),
1577 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1578
1579 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1580 if omciErr.GetError() == nil {
1581 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001582 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1583 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001584 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001585 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001586 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001587 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001588 }
1589
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001590 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001591 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001592 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001593 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001594 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001595 }
1596
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001597 omciRxCallbackPair := CallbackPair{
1598 CbKey: tid,
1599 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001600 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001601 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001602 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001603 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001604 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001605 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001606 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001607 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001608 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001609 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001610 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001611 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001612 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001613}
1614
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001615// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1616func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001617 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001618 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001619 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001620 "SequNo": strconv.FormatInt(int64(tid), 16),
1621 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1622
1623 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1624 if omciErr.GetError() == nil {
1625 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001626 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1627 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001628 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001629 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001630 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001631 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001632 }
1633
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001634 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001635 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001636 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001637 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001638 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001639 }
1640
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001641 omciRxCallbackPair := CallbackPair{
1642 CbKey: tid,
1643 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001644 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001645 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001646 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001647 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001648 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001649 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001650 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001651 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001652 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001653 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001654 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001655 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001656 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001657}
1658
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001659// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1660func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1661 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001662 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1663 "SequNo": strconv.FormatInt(int64(tid), 16),
1664 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1665
1666 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1667 if omciErr.GetError() == nil {
1668 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001669 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1670 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001671 if err != nil {
1672 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1673 "Err": err, "device-id": oo.deviceID})
1674 return nil, err
1675 }
1676
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001677 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001678 if err != nil {
1679 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1680 "Err": err, "device-id": oo.deviceID})
1681 return nil, err
1682 }
1683
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001684 omciRxCallbackPair := CallbackPair{
1685 CbKey: tid,
1686 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001687 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001688 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001689 if err != nil {
1690 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1691 "Err": err, "device-id": oo.deviceID})
1692 return nil, err
1693 }
1694 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1695 return meInstance, nil
1696 }
1697 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1698 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1699 return nil, omciErr.GetError()
1700}
1701
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001702// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1703func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001704 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001705 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001706 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001707 "SequNo": strconv.FormatInt(int64(tid), 16),
1708 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1709
1710 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1711 if omciErr.GetError() == nil {
1712 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001713 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1714 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001715 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001716 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001717 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001718 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001719 }
1720
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001721 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001722 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001723 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001724 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001725 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001726 }
1727
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001728 omciRxCallbackPair := CallbackPair{
1729 CbKey: tid,
1730 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001731 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001732 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001733 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001734 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001735 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001736 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001737 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001738 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001739 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001740 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001741 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001742 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001743 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001744}
1745
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001746// SendSetTcontVar sets TCont ME instance
1747func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001748 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001749 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001750 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001751 "SequNo": strconv.FormatInt(int64(tid), 16),
1752 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1753
1754 meInstance, omciErr := me.NewTCont(params[0])
1755 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001756 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001757 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001758 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001759 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001760 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001761 }
1762
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001763 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001764 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001765 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001766 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001767 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001768 }
1769
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001770 omciRxCallbackPair := CallbackPair{
1771 CbKey: tid,
1772 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001773 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001774 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001775 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001776 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001777 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001778 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001779 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001780 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001781 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001782 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001783 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001784 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001785 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001786}
1787
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001788// SendSetPrioQueueVar sets PriorityQueue ME instance
1789func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001790 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001791 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001792 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001793 "SequNo": strconv.FormatInt(int64(tid), 16),
1794 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1795
1796 meInstance, omciErr := me.NewPriorityQueue(params[0])
1797 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001798 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001799 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001800 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001801 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001802 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001803 }
1804
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001805 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001806 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001807 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001808 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001809 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001810 }
1811
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001812 omciRxCallbackPair := CallbackPair{
1813 CbKey: tid,
1814 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001815 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001816 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001817 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001818 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001819 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001820 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001821 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001822 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001823 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001824 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001825 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001826 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001827 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001828}
1829
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001830// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1831func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001832 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001833 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001834 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001835 "SequNo": strconv.FormatInt(int64(tid), 16),
1836 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1837
1838 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1839 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001840 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001841 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001842 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001843 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001844 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001845 }
1846
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001847 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001848 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001849 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001850 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001851 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001852 }
1853
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001854 omciRxCallbackPair := CallbackPair{
1855 CbKey: tid,
1856 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001857 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001858 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001859 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001860 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001861 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001862 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001863 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001864 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001865 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001866 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001867 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001868 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001869 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001870}
mpagenkodff5dda2020-08-28 11:52:01 +00001871
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001872// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1873func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001874 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001875 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001876 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001877 "SequNo": strconv.FormatInt(int64(tid), 16),
1878 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1879
1880 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1881 if omciErr.GetError() == nil {
1882 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001883 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1884 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001885 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001886 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001887 "Err": err, "device-id": oo.deviceID})
1888 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1889 // return (dual format) error code that can be used at caller for immediate error treatment
1890 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001891 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001892 }
1893
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001894 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001895 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001896 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001897 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001898 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001899 }
1900
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001901 omciRxCallbackPair := CallbackPair{
1902 CbKey: tid,
1903 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001904 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001905 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001906 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001907 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001908 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001909 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001910 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001911 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001912 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001913 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001914 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001915 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001916 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001917}
1918
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001919// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001920func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001921 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001922 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001923 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001924 "SequNo": strconv.FormatInt(int64(tid), 16),
1925 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1926
1927 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1928 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001929 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1930 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001931 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001932 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001933 "Err": err, "device-id": oo.deviceID})
1934 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1935 // return (dual format) error code that can be used at caller for immediate error treatment
1936 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001937 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001938 }
1939
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001940 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001941 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001942 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001943 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001944 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001945 }
1946
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001947 omciRxCallbackPair := CallbackPair{
1948 CbKey: tid,
1949 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001950 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001951 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001952 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001953 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001954 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001955 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001956 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001957 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001958 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001959 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001960 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001961 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001962 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001963}
1964
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001965// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
1966func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001967 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001968 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001969 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001970 "SequNo": strconv.FormatInt(int64(tid), 16),
1971 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1972
1973 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1974 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001975 //EnhancedMode not yet supported, used with default options
1976 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1977 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001978 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001979 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001980 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001981 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001982 }
1983
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001984 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001985 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001986 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001987 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001988 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001989 }
1990
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001991 omciRxCallbackPair := CallbackPair{
1992 CbKey: tid,
1993 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001994 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001995 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001996 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001997 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001998 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001999 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002000 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002001 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002002 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002003 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002004 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002005 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002006 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002007}
2008
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002009// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
2010func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002011 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002012 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002013 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00002014 "SequNo": strconv.FormatInt(int64(tid), 16),
2015 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2016
2017 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2018 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002019 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00002020 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002021 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002022 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002023 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002024 }
2025
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002026 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002027 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002028 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002029 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002030 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002031 }
2032
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002033 omciRxCallbackPair := CallbackPair{
2034 CbKey: tid,
2035 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002036 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002037 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002038 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002039 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002040 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002041 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002042 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002043 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002044 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002045 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002046 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002047 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002048 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002049}
mpagenko01e726e2020-10-23 09:45:29 +00002050
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002051// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2052func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002053 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002054 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002055 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002056 "SequNo": strconv.FormatInt(int64(tid), 16),
2057 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2058
2059 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2060 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002061 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002062 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002063 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002064 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002065 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002066 }
2067
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002068 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002069 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002070 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002071 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002072 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002073 }
2074
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002075 omciRxCallbackPair := CallbackPair{
2076 CbKey: tid,
2077 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002078 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002079 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002080 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002081 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002082 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002083 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002084 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002085 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002086 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002087 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002088 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002089 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002090 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002091}
2092
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002093// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2094func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002095 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002096 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002097 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002098 "SequNo": strconv.FormatInt(int64(tid), 16),
2099 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2100
2101 meParams := me.ParamData{EntityID: aInstID}
2102 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2103 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002104 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2105 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002106 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002107 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002108 "Err": err, "device-id": oo.deviceID})
2109 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2110 // return (dual format) error code that can be used at caller for immediate error treatment
2111 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002112 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002113 }
2114
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002115 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002116 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002117 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002118 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002119 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002120 }
2121
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002122 omciRxCallbackPair := CallbackPair{
2123 CbKey: tid,
2124 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002125 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002126 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002127 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002128 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002129 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002130 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002131 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002132 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002133 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002134 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002136 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002137 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002138}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002139
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002140// SendCreateTDVar creates TrafficDescriptor ME instance
2141func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2142 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002143 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2144 "SequNo": strconv.FormatInt(int64(tid), 16),
2145 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2146 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2147 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002148 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002149 if err != nil {
2150 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002151 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002152 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002153 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002154 if err != nil {
2155 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002156 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002157 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002158 omciRxCallbackPair := CallbackPair{
2159 CbKey: tid,
2160 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002161 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002162 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002163 if err != nil {
2164 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002165 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002166 }
2167 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002168 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002169 }
2170 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002171 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002172}
2173
2174// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002175func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002176 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002177 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002178 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2179 "SequNo": strconv.FormatInt(int64(tid), 16),
2180 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2181
2182 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2183 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002184 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002185 if err != nil {
2186 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002187 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002188 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002189 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002190 if err != nil {
2191 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002192 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002193 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002194 omciRxCallbackPair := CallbackPair{
2195 CbKey: tid,
2196 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002197 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002198 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002199 if err != nil {
2200 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002201 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002202 }
2203 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002204 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002205 }
2206 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002207 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002208
2209}
2210
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002211// SendDeleteTD - TODO: add comment
2212func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002213 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002214 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002215 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2216 "SequNo": strconv.FormatInt(int64(tid), 16),
2217 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2218
2219 meParams := me.ParamData{EntityID: aInstID}
2220 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2221 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002222 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002223 if err != nil {
2224 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002225 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002226 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002227 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002228 if err != nil {
2229 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002230 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002231 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002232 omciRxCallbackPair := CallbackPair{
2233 CbKey: tid,
2234 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002235 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002236 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002237 if err != nil {
2238 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002239 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002240 }
2241 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002242 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002243 }
2244 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002245 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002246
2247}
2248
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002249// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2250func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002251 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002252 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002253 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002254 "SequNo": strconv.FormatInt(int64(tid), 16),
2255 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2256
2257 meParams := me.ParamData{EntityID: aInstID}
2258 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2259 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002260 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2261 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002262 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002263 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002264 "Err": err, "device-id": oo.deviceID})
2265 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2266 // return (dual format) error code that can be used at caller for immediate error treatment
2267 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002268 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002269 }
2270
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002271 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002272 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002273 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002274 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002275 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002276 }
2277
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002278 omciRxCallbackPair := CallbackPair{
2279 CbKey: tid,
2280 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002281 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002282 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002283 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002284 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002285 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002286 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002287 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002288 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002289 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002290 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002291 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002292 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002293 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002294}
2295
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002296// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2297func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002298 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002299 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002300 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002301 "SequNo": strconv.FormatInt(int64(tid), 16),
2302 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2303
2304 meParams := me.ParamData{EntityID: aInstID}
2305 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2306 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002307 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2308 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002309 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002310 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002311 "Err": err, "device-id": oo.deviceID})
2312 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2313 // return (dual format) error code that can be used at caller for immediate error treatment
2314 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002315 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002316 }
2317
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002318 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002319 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002320 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002321 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002322 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002323 }
2324
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002325 omciRxCallbackPair := CallbackPair{
2326 CbKey: tid,
2327 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002328 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002329 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002330 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002331 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002332 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002333 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002334 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002335 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002336 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002337 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002338 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002339 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002340 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002341}
2342
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002343// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2344func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002345 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002346 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002347 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002348 "SequNo": strconv.FormatInt(int64(tid), 16),
2349 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2350
2351 meParams := me.ParamData{EntityID: aInstID}
2352 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2353 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002354 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2355 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002356 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002357 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002358 "Err": err, "device-id": oo.deviceID})
2359 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2360 // return (dual format) error code that can be used at caller for immediate error treatment
2361 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002362 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002363 }
2364
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002365 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002366 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002367 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002368 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002369 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002370 }
2371
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002372 omciRxCallbackPair := CallbackPair{
2373 CbKey: tid,
2374 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002375 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002376 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002377 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002378 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002379 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002380 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002381 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002382 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002383 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002384 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002385 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002386 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002387 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002388}
2389
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002390// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2391func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002392 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002393 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002394 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002395 "SequNo": strconv.FormatInt(int64(tid), 16),
2396 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2397
2398 meParams := me.ParamData{EntityID: aInstID}
2399 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2400 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002401 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2402 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002403 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002404 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002405 "Err": err, "device-id": oo.deviceID})
2406 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2407 // return (dual format) error code that can be used at caller for immediate error treatment
2408 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002409 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002410 }
2411
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002412 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002413 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002414 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002415 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002416 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002417 }
2418
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002419 omciRxCallbackPair := CallbackPair{
2420 CbKey: tid,
2421 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002422 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002423 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002424 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002425 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002426 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002427 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002428 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002429 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002430 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002431 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002432 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002433 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002434 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002435}
2436
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002437// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2438func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002439 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002440 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002441 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002442 "SequNo": strconv.FormatInt(int64(tid), 16),
2443 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2444
2445 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2446 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002447 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2448 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002449 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002450 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002451 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002452 }
2453
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002454 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002455 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002456 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002457 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002458 }
2459
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002460 omciRxCallbackPair := CallbackPair{CbKey: tid,
2461 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002462 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002463 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002464 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002465 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002466 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002467 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002468 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002469 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002470 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002471 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002472 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002473 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002474}
2475
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002476// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2477func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002478 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002479 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002480 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002481 "SequNo": strconv.FormatInt(int64(tid), 16),
2482 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2483
2484 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2485 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002486 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2487 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002488 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002489 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002490 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002491 }
2492
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002493 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002494 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002495 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002496 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002497 }
2498
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002499 omciRxCallbackPair := CallbackPair{CbKey: tid,
2500 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002501 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002502 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002503 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002504 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002505 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002506 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002507 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002508 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002509 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002510 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002511 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002512 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002513}
2514
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002515// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2516func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002517 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002518 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002519 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002520 "SequNo": strconv.FormatInt(int64(tid), 16),
2521 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2522
2523 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2524 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002525 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2526 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002527 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002528 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002529 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002530 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002531 }
2532
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002533 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002534 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002535 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002536 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002537 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002538 }
2539
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002540 omciRxCallbackPair := CallbackPair{CbKey: tid,
2541 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002542 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002543 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002544 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002545 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002546 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002547 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002548 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002549 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002550 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002551 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002552 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002553 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002554 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002555}
2556
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002557// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2558func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002559 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002560 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002561 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002562 "SequNo": strconv.FormatInt(int64(tid), 16),
2563 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2564
2565 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2566 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002567 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2568 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002569 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002570 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002571 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002572 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002573 }
2574
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002575 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002576 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002577 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002578 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002579 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002580 }
2581
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002582 omciRxCallbackPair := CallbackPair{CbKey: tid,
2583 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002584 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002585 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002586 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002587 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002588 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002589 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002590 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002591 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002592 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002593 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002594 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002595 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002596 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002597}
2598
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002599// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2600func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002601 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002602 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002603 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002604 "SequNo": strconv.FormatInt(int64(tid), 16),
2605 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2606
2607 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2608 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002609 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2610 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002611 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002612 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002613 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002614 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002615 }
2616
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002617 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002618 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002619 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002620 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002621 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002622 }
2623
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002624 omciRxCallbackPair := CallbackPair{CbKey: tid,
2625 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002626 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002627 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002628 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002629 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002630 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002631 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002632 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002633 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002634 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002635 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002636 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002637 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002638 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002639}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002640
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002641// SendCreateVoipVoiceCTP nolint: unused
2642func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2643 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2644 tid := oo.GetNextTid(highPrio)
2645 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2646 "SequNo": strconv.FormatInt(int64(tid), 16),
2647 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2648
2649 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2650 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002651 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2652 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002653 if err != nil {
2654 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2655 "device-id": oo.deviceID})
2656 return nil, err
2657 }
2658
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002659 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002660 if err != nil {
2661 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2662 "device-id": oo.deviceID})
2663 return nil, err
2664 }
2665
2666 omciRxCallbackPair := CallbackPair{CbKey: tid,
2667 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2668 }
2669 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2670 if err != nil {
2671 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2672 "device-id": oo.deviceID})
2673 return nil, err
2674 }
2675 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2676 return meInstance, nil
2677 }
2678 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2679 "device-id": oo.deviceID})
2680 return nil, omciErr.GetError()
2681}
2682
2683// SendSetVoipVoiceCTP nolint: unused
2684func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2685 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2686 tid := oo.GetNextTid(highPrio)
2687 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2688 "SequNo": strconv.FormatInt(int64(tid), 16),
2689 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2690
2691 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2692 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002693 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2694 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002695 if err != nil {
2696 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2697 "device-id": oo.deviceID})
2698 return nil, err
2699 }
2700
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002701 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002702 if err != nil {
2703 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2704 "device-id": oo.deviceID})
2705 return nil, err
2706 }
2707
2708 omciRxCallbackPair := CallbackPair{CbKey: tid,
2709 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2710 }
2711 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2712 if err != nil {
2713 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2714 "device-id": oo.deviceID})
2715 return nil, err
2716 }
2717 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2718 return meInstance, nil
2719 }
2720 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2721 "device-id": oo.deviceID})
2722 return nil, omciErr.GetError()
2723}
2724
2725// SendDeleteVoipVoiceCTP nolint: unused
2726func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2727 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2728 tid := oo.GetNextTid(highPrio)
2729 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2730 "SequNo": strconv.FormatInt(int64(tid), 16),
2731 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2732
2733 meParams := me.ParamData{EntityID: aInstID}
2734 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2735 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002736 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2737 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002738 if err != nil {
2739 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2740 "Err": err, "device-id": oo.deviceID})
2741 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2742 // return (dual format) error code that can be used at caller for immediate error treatment
2743 // (relevant to all used sendXX() methods and their error conditions)
2744 return nil, err
2745 }
2746
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002747 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002748 if err != nil {
2749 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2750 "Err": err, "device-id": oo.deviceID})
2751 return nil, err
2752 }
2753
2754 omciRxCallbackPair := CallbackPair{
2755 CbKey: tid,
2756 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2757 }
2758 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2759 if err != nil {
2760 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2761 "Err": err, "device-id": oo.deviceID})
2762 return nil, err
2763 }
2764 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2765 return meInstance, nil
2766 }
2767 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2768 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2769 return nil, omciErr.GetError()
2770}
2771
2772// SendCreateVoipMediaProfile nolint: unused
2773func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2774 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2775 tid := oo.GetNextTid(highPrio)
2776 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2777 "SequNo": strconv.FormatInt(int64(tid), 16),
2778 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2779
2780 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2781 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002782 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2783 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002784 if err != nil {
2785 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2786 "device-id": oo.deviceID})
2787 return nil, err
2788 }
2789
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002790 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002791 if err != nil {
2792 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2793 "device-id": oo.deviceID})
2794 return nil, err
2795 }
2796
2797 omciRxCallbackPair := CallbackPair{CbKey: tid,
2798 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2799 }
2800 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2801 if err != nil {
2802 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2803 "device-id": oo.deviceID})
2804 return nil, err
2805 }
2806 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2807 return meInstance, nil
2808 }
2809 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2810 "device-id": oo.deviceID})
2811 return nil, omciErr.GetError()
2812}
2813
2814// SendSetVoipMediaProfile nolint: unused
2815func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2816 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2817 tid := oo.GetNextTid(highPrio)
2818 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2819 "SequNo": strconv.FormatInt(int64(tid), 16),
2820 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2821
2822 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2823 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002824 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2825 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002826 if err != nil {
2827 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2828 "device-id": oo.deviceID})
2829 return nil, err
2830 }
2831
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002832 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002833 if err != nil {
2834 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2835 "device-id": oo.deviceID})
2836 return nil, err
2837 }
2838
2839 omciRxCallbackPair := CallbackPair{CbKey: tid,
2840 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2841 }
2842 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2843 if err != nil {
2844 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2845 "device-id": oo.deviceID})
2846 return nil, err
2847 }
2848 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2849 return meInstance, nil
2850 }
2851 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2852 "device-id": oo.deviceID})
2853 return nil, omciErr.GetError()
2854}
2855
2856// SendDeleteVoipMediaProfile nolint: unused
2857func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2858 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2859 tid := oo.GetNextTid(highPrio)
2860 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2861 "SequNo": strconv.FormatInt(int64(tid), 16),
2862 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2863
2864 meParams := me.ParamData{EntityID: aInstID}
2865 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2866 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002867 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2868 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002869 if err != nil {
2870 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2871 "Err": err, "device-id": oo.deviceID})
2872 return nil, err
2873 }
2874
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002875 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002876 if err != nil {
2877 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2878 "Err": err, "device-id": oo.deviceID})
2879 return nil, err
2880 }
2881
2882 omciRxCallbackPair := CallbackPair{
2883 CbKey: tid,
2884 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2885 }
2886 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2887 if err != nil {
2888 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2889 "Err": err, "device-id": oo.deviceID})
2890 return nil, err
2891 }
2892 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2893 return meInstance, nil
2894 }
2895 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2896 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2897 return nil, omciErr.GetError()
2898}
2899
2900// SendCreateVoiceServiceProfile nolint: unused
2901func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2902 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2903 tid := oo.GetNextTid(highPrio)
2904 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2905 "SequNo": strconv.FormatInt(int64(tid), 16),
2906 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2907
2908 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2909 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002910 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2911 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002912 if err != nil {
2913 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2914 "device-id": oo.deviceID})
2915 return nil, err
2916 }
2917
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002918 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002919 if err != nil {
2920 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2921 "device-id": oo.deviceID})
2922 return nil, err
2923 }
2924
2925 omciRxCallbackPair := CallbackPair{CbKey: tid,
2926 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2927 }
2928 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2929 if err != nil {
2930 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
2931 "device-id": oo.deviceID})
2932 return nil, err
2933 }
2934 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
2935 return meInstance, nil
2936 }
2937 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2938 "device-id": oo.deviceID})
2939 return nil, omciErr.GetError()
2940}
2941
2942// SendSetVoiceServiceProfile nolint: unused
2943func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2944 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2945 tid := oo.GetNextTid(highPrio)
2946 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2947 "SequNo": strconv.FormatInt(int64(tid), 16),
2948 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2949
2950 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2951 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002952 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2953 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002954 if err != nil {
2955 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
2956 "device-id": oo.deviceID})
2957 return nil, err
2958 }
2959
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002960 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002961 if err != nil {
2962 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
2963 "device-id": oo.deviceID})
2964 return nil, err
2965 }
2966
2967 omciRxCallbackPair := CallbackPair{CbKey: tid,
2968 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2969 }
2970 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2971 if err != nil {
2972 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
2973 "device-id": oo.deviceID})
2974 return nil, err
2975 }
2976 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
2977 return meInstance, nil
2978 }
2979 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2980 "device-id": oo.deviceID})
2981 return nil, omciErr.GetError()
2982}
2983
2984// SendDeleteVoiceServiceProfile nolint: unused
2985func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2986 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2987 tid := oo.GetNextTid(highPrio)
2988 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2989 "SequNo": strconv.FormatInt(int64(tid), 16),
2990 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2991
2992 meParams := me.ParamData{EntityID: aInstID}
2993 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
2994 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002995 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2996 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002997 if err != nil {
2998 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
2999 "Err": err, "device-id": oo.deviceID})
3000 return nil, err
3001 }
3002
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003003 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003004 if err != nil {
3005 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
3006 "Err": err, "device-id": oo.deviceID})
3007 return nil, err
3008 }
3009
3010 omciRxCallbackPair := CallbackPair{
3011 CbKey: tid,
3012 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3013 }
3014 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3015 if err != nil {
3016 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
3017 "Err": err, "device-id": oo.deviceID})
3018 return nil, err
3019 }
3020 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
3021 return meInstance, nil
3022 }
3023 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
3024 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3025 return nil, omciErr.GetError()
3026}
3027
3028// SendCreateSIPUserData nolint: unused
3029func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
3030 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3031 tid := oo.GetNextTid(highPrio)
3032 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
3033 "SequNo": strconv.FormatInt(int64(tid), 16),
3034 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3035
3036 meInstance, omciErr := me.NewSipUserData(params[0])
3037 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003038 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3039 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003040 if err != nil {
3041 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3042 "device-id": oo.deviceID})
3043 return nil, err
3044 }
3045
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003046 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003047 if err != nil {
3048 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3049 "device-id": oo.deviceID})
3050 return nil, err
3051 }
3052
3053 omciRxCallbackPair := CallbackPair{CbKey: tid,
3054 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3055 }
3056 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3057 if err != nil {
3058 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3059 "device-id": oo.deviceID})
3060 return nil, err
3061 }
3062 logger.Debug(ctx, "send SIPUserData-create-msg done")
3063 return meInstance, nil
3064 }
3065 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3066 "device-id": oo.deviceID})
3067 return nil, omciErr.GetError()
3068}
3069
3070// SendSetSIPUserData nolint: unused
3071func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3072 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3073 tid := oo.GetNextTid(highPrio)
3074 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3075 "SequNo": strconv.FormatInt(int64(tid), 16),
3076 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3077
3078 meInstance, omciErr := me.NewSipUserData(params[0])
3079 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003080 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3081 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003082 if err != nil {
3083 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3084 "device-id": oo.deviceID})
3085 return nil, err
3086 }
3087
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003088 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003089 if err != nil {
3090 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3091 "device-id": oo.deviceID})
3092 return nil, err
3093 }
3094
3095 omciRxCallbackPair := CallbackPair{CbKey: tid,
3096 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3097 }
3098 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3099 if err != nil {
3100 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3101 "device-id": oo.deviceID})
3102 return nil, err
3103 }
3104 logger.Debug(ctx, "send SIPUserData-set-msg done")
3105 return meInstance, nil
3106 }
3107 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3108 "device-id": oo.deviceID})
3109 return nil, omciErr.GetError()
3110}
3111
3112// SendDeleteSIPUserData nolint: unused
3113func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3114 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3115 tid := oo.GetNextTid(highPrio)
3116 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3117 "SequNo": strconv.FormatInt(int64(tid), 16),
3118 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3119
3120 meParams := me.ParamData{EntityID: aInstID}
3121 meInstance, omciErr := me.NewSipUserData(meParams)
3122 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003123 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3124 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003125 if err != nil {
3126 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3127 "Err": err, "device-id": oo.deviceID})
3128 return nil, err
3129 }
3130
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003131 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003132 if err != nil {
3133 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3134 "Err": err, "device-id": oo.deviceID})
3135 return nil, err
3136 }
3137
3138 omciRxCallbackPair := CallbackPair{
3139 CbKey: tid,
3140 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3141 }
3142 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3143 if err != nil {
3144 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3145 "Err": err, "device-id": oo.deviceID})
3146 return nil, err
3147 }
3148 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3149 return meInstance, nil
3150 }
3151 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3152 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3153 return nil, omciErr.GetError()
3154}
3155
3156// SendCreateVoipApplicationServiceProfile nolint: unused
3157func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3158 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3159 tid := oo.GetNextTid(highPrio)
3160 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3161 "SequNo": strconv.FormatInt(int64(tid), 16),
3162 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3163
3164 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3165 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003166 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3167 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003168 if err != nil {
3169 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3170 "device-id": oo.deviceID})
3171 return nil, err
3172 }
3173
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003174 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003175 if err != nil {
3176 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3177 "device-id": oo.deviceID})
3178 return nil, err
3179 }
3180
3181 omciRxCallbackPair := CallbackPair{CbKey: tid,
3182 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3183 }
3184 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3185 if err != nil {
3186 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3187 "device-id": oo.deviceID})
3188 return nil, err
3189 }
3190 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3191 return meInstance, nil
3192 }
3193 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3194 "device-id": oo.deviceID})
3195 return nil, omciErr.GetError()
3196}
3197
3198// SendSetVoipApplicationServiceProfile nolint: unused
3199func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3200 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3201 tid := oo.GetNextTid(highPrio)
3202 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3203 "SequNo": strconv.FormatInt(int64(tid), 16),
3204 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3205
3206 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3207 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003208 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3209 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003210 if err != nil {
3211 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3212 "device-id": oo.deviceID})
3213 return nil, err
3214 }
3215
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003216 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003217 if err != nil {
3218 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3219 "device-id": oo.deviceID})
3220 return nil, err
3221 }
3222
3223 omciRxCallbackPair := CallbackPair{CbKey: tid,
3224 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3225 }
3226 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3227 if err != nil {
3228 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3229 "device-id": oo.deviceID})
3230 return nil, err
3231 }
3232 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3233 return meInstance, nil
3234 }
3235 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3236 "device-id": oo.deviceID})
3237 return nil, omciErr.GetError()
3238}
3239
3240// SendDeleteVoipApplicationServiceProfile nolint: unused
3241func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3242 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3243 tid := oo.GetNextTid(highPrio)
3244 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3245 "SequNo": strconv.FormatInt(int64(tid), 16),
3246 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3247
3248 meParams := me.ParamData{EntityID: aInstID}
3249 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3250 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003251 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3252 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003253 if err != nil {
3254 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3255 "Err": err, "device-id": oo.deviceID})
3256 return nil, err
3257 }
3258
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003259 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003260 if err != nil {
3261 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3262 "Err": err, "device-id": oo.deviceID})
3263 return nil, err
3264 }
3265
3266 omciRxCallbackPair := CallbackPair{
3267 CbKey: tid,
3268 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3269 }
3270 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3271 if err != nil {
3272 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3273 "Err": err, "device-id": oo.deviceID})
3274 return nil, err
3275 }
3276 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3277 return meInstance, nil
3278 }
3279 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3280 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3281 return nil, omciErr.GetError()
3282}
3283
3284// SendCreateSIPAgentConfigData nolint: unused
3285func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3286 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3287 tid := oo.GetNextTid(highPrio)
3288 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3289 "SequNo": strconv.FormatInt(int64(tid), 16),
3290 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3291
3292 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3293 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003294 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3295 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003296 if err != nil {
3297 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3298 "device-id": oo.deviceID})
3299 return nil, err
3300 }
3301
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003302 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003303 if err != nil {
3304 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3305 "device-id": oo.deviceID})
3306 return nil, err
3307 }
3308
3309 omciRxCallbackPair := CallbackPair{CbKey: tid,
3310 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3311 }
3312 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3313 if err != nil {
3314 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3315 "device-id": oo.deviceID})
3316 return nil, err
3317 }
3318 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3319 return meInstance, nil
3320 }
3321 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3322 "device-id": oo.deviceID})
3323 return nil, omciErr.GetError()
3324}
3325
3326// SendSetSIPAgentConfigData nolint: unused
3327func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3328 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3329 tid := oo.GetNextTid(highPrio)
3330 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3331 "SequNo": strconv.FormatInt(int64(tid), 16),
3332 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3333
3334 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3335 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003336 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3337 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003338 if err != nil {
3339 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3340 "device-id": oo.deviceID})
3341 return nil, err
3342 }
3343
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003344 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003345 if err != nil {
3346 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3347 "device-id": oo.deviceID})
3348 return nil, err
3349 }
3350
3351 omciRxCallbackPair := CallbackPair{CbKey: tid,
3352 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3353 }
3354 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3355 if err != nil {
3356 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3357 "device-id": oo.deviceID})
3358 return nil, err
3359 }
3360 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3361 return meInstance, nil
3362 }
3363 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3364 "device-id": oo.deviceID})
3365 return nil, omciErr.GetError()
3366}
3367
3368// SendDeleteSIPAgentConfigData nolint: unused
3369func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3370 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3371 tid := oo.GetNextTid(highPrio)
3372 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3373 "SequNo": strconv.FormatInt(int64(tid), 16),
3374 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3375
3376 meParams := me.ParamData{EntityID: aInstID}
3377 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3378 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003379 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3380 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003381 if err != nil {
3382 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3383 "Err": err, "device-id": oo.deviceID})
3384 return nil, err
3385 }
3386
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003387 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003388 if err != nil {
3389 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3390 "Err": err, "device-id": oo.deviceID})
3391 return nil, err
3392 }
3393
3394 omciRxCallbackPair := CallbackPair{
3395 CbKey: tid,
3396 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3397 }
3398 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3399 if err != nil {
3400 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3401 "Err": err, "device-id": oo.deviceID})
3402 return nil, err
3403 }
3404 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3405 return meInstance, nil
3406 }
3407 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3408 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3409 return nil, omciErr.GetError()
3410}
3411
3412// SendCreateTCPUDPConfigData nolint: unused
3413func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3414 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3415 tid := oo.GetNextTid(highPrio)
3416 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3417 "SequNo": strconv.FormatInt(int64(tid), 16),
3418 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3419
3420 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3421 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003422 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3423 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003424 if err != nil {
3425 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3426 "device-id": oo.deviceID})
3427 return nil, err
3428 }
3429
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003430 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003431 if err != nil {
3432 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3433 "device-id": oo.deviceID})
3434 return nil, err
3435 }
3436
3437 omciRxCallbackPair := CallbackPair{CbKey: tid,
3438 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3439 }
3440 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3441 if err != nil {
3442 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3443 "device-id": oo.deviceID})
3444 return nil, err
3445 }
3446 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3447 return meInstance, nil
3448 }
3449 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3450 "device-id": oo.deviceID})
3451 return nil, omciErr.GetError()
3452}
3453
3454// SendSetTCPUDPConfigData nolint: unused
3455func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3456 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3457 tid := oo.GetNextTid(highPrio)
3458 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3459 "SequNo": strconv.FormatInt(int64(tid), 16),
3460 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3461
3462 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3463 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003464 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3465 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003466 if err != nil {
3467 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3468 "device-id": oo.deviceID})
3469 return nil, err
3470 }
3471
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003472 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003473 if err != nil {
3474 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3475 "device-id": oo.deviceID})
3476 return nil, err
3477 }
3478
3479 omciRxCallbackPair := CallbackPair{CbKey: tid,
3480 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3481 }
3482 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3483 if err != nil {
3484 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3485 "device-id": oo.deviceID})
3486 return nil, err
3487 }
3488 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3489 return meInstance, nil
3490 }
3491 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3492 "device-id": oo.deviceID})
3493 return nil, omciErr.GetError()
3494}
3495
3496// SendDeleteTCPUDPConfigData nolint: unused
3497func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3498 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3499 tid := oo.GetNextTid(highPrio)
3500 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3501 "SequNo": strconv.FormatInt(int64(tid), 16),
3502 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3503
3504 meParams := me.ParamData{EntityID: aInstID}
3505 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3506 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003507 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3508 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003509 if err != nil {
3510 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3511 "Err": err, "device-id": oo.deviceID})
3512 return nil, err
3513 }
3514
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003515 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003516 if err != nil {
3517 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3518 "Err": err, "device-id": oo.deviceID})
3519 return nil, err
3520 }
3521
3522 omciRxCallbackPair := CallbackPair{
3523 CbKey: tid,
3524 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3525 }
3526 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3527 if err != nil {
3528 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3529 "Err": err, "device-id": oo.deviceID})
3530 return nil, err
3531 }
3532 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3533 return meInstance, nil
3534 }
3535 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3536 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3537 return nil, omciErr.GetError()
3538}
3539
3540// SendCreateIPHostConfigData nolint: unused
3541func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3542 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3543 tid := oo.GetNextTid(highPrio)
3544 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3545 "SequNo": strconv.FormatInt(int64(tid), 16),
3546 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3547
3548 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3549 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003550 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3551 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003552 if err != nil {
3553 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3554 "device-id": oo.deviceID})
3555 return nil, err
3556 }
3557
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003558 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003559 if err != nil {
3560 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3561 "device-id": oo.deviceID})
3562 return nil, err
3563 }
3564
3565 omciRxCallbackPair := CallbackPair{CbKey: tid,
3566 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3567 }
3568 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3569 if err != nil {
3570 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3571 "device-id": oo.deviceID})
3572 return nil, err
3573 }
3574 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3575 return meInstance, nil
3576 }
3577 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3578 "device-id": oo.deviceID})
3579 return nil, omciErr.GetError()
3580}
3581
3582// SendSetIPHostConfigData nolint: unused
3583func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3584 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3585 tid := oo.GetNextTid(highPrio)
3586 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3587 "SequNo": strconv.FormatInt(int64(tid), 16),
3588 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3589
3590 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3591 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003592 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3593 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003594 if err != nil {
3595 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3596 "device-id": oo.deviceID})
3597 return nil, err
3598 }
3599
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003600 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003601 if err != nil {
3602 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3603 "device-id": oo.deviceID})
3604 return nil, err
3605 }
3606
3607 omciRxCallbackPair := CallbackPair{CbKey: tid,
3608 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3609 }
3610 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3611 if err != nil {
3612 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3613 "device-id": oo.deviceID})
3614 return nil, err
3615 }
3616 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3617 return meInstance, nil
3618 }
3619 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3620 "device-id": oo.deviceID})
3621 return nil, omciErr.GetError()
3622}
3623
3624// SendDeleteIPHostConfigData nolint: unused
3625func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3626 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3627 tid := oo.GetNextTid(highPrio)
3628 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3629 "SequNo": strconv.FormatInt(int64(tid), 16),
3630 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3631
3632 meParams := me.ParamData{EntityID: aInstID}
3633 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3634 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003635 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3636 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003637 if err != nil {
3638 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3639 "Err": err, "device-id": oo.deviceID})
3640 return nil, err
3641 }
3642
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003643 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003644 if err != nil {
3645 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3646 "Err": err, "device-id": oo.deviceID})
3647 return nil, err
3648 }
3649
3650 omciRxCallbackPair := CallbackPair{
3651 CbKey: tid,
3652 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3653 }
3654 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3655 if err != nil {
3656 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3657 "Err": err, "device-id": oo.deviceID})
3658 return nil, err
3659 }
3660 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3661 return meInstance, nil
3662 }
3663 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3664 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3665 return nil, omciErr.GetError()
3666}
3667
3668// SendCreateRTPProfileData nolint: unused
3669func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3670 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3671 tid := oo.GetNextTid(highPrio)
3672 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3673 "SequNo": strconv.FormatInt(int64(tid), 16),
3674 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3675
3676 meInstance, omciErr := me.NewRtpProfileData(params[0])
3677 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003678 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3679 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003680 if err != nil {
3681 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3682 "device-id": oo.deviceID})
3683 return nil, err
3684 }
3685
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003686 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003687 if err != nil {
3688 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3689 "device-id": oo.deviceID})
3690 return nil, err
3691 }
3692
3693 omciRxCallbackPair := CallbackPair{CbKey: tid,
3694 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3695 }
3696 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3697 if err != nil {
3698 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3699 "device-id": oo.deviceID})
3700 return nil, err
3701 }
3702 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3703 return meInstance, nil
3704 }
3705 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3706 "device-id": oo.deviceID})
3707 return nil, omciErr.GetError()
3708}
3709
3710// SendSetRTPProfileData nolint: unused
3711func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3712 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3713 tid := oo.GetNextTid(highPrio)
3714 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3715 "SequNo": strconv.FormatInt(int64(tid), 16),
3716 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3717
3718 meInstance, omciErr := me.NewRtpProfileData(params[0])
3719 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003720 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3721 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003722 if err != nil {
3723 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3724 "device-id": oo.deviceID})
3725 return nil, err
3726 }
3727
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003728 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003729 if err != nil {
3730 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3731 "device-id": oo.deviceID})
3732 return nil, err
3733 }
3734
3735 omciRxCallbackPair := CallbackPair{CbKey: tid,
3736 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3737 }
3738 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3739 if err != nil {
3740 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3741 "device-id": oo.deviceID})
3742 return nil, err
3743 }
3744 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3745 return meInstance, nil
3746 }
3747 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3748 "device-id": oo.deviceID})
3749 return nil, omciErr.GetError()
3750}
3751
3752// SendDeleteRTPProfileData nolint: unused
3753func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3754 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3755 tid := oo.GetNextTid(highPrio)
3756 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3757 "SequNo": strconv.FormatInt(int64(tid), 16),
3758 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3759
3760 meParams := me.ParamData{EntityID: aInstID}
3761 meInstance, omciErr := me.NewRtpProfileData(meParams)
3762 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003763 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3764 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003765 if err != nil {
3766 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3767 "Err": err, "device-id": oo.deviceID})
3768 return nil, err
3769 }
3770
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003771 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003772 if err != nil {
3773 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3774 "Err": err, "device-id": oo.deviceID})
3775 return nil, err
3776 }
3777
3778 omciRxCallbackPair := CallbackPair{
3779 CbKey: tid,
3780 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3781 }
3782 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3783 if err != nil {
3784 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3785 "Err": err, "device-id": oo.deviceID})
3786 return nil, err
3787 }
3788 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3789 return meInstance, nil
3790 }
3791 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3792 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3793 return nil, omciErr.GetError()
3794}
3795
3796// SendCreateNetworkDialPlanTable nolint: unused
3797func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3798 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3799 tid := oo.GetNextTid(highPrio)
3800 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3801 "SequNo": strconv.FormatInt(int64(tid), 16),
3802 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3803
3804 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3805 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003806 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3807 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003808 if err != nil {
3809 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3810 "device-id": oo.deviceID})
3811 return nil, err
3812 }
3813
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003814 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003815 if err != nil {
3816 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3817 "device-id": oo.deviceID})
3818 return nil, err
3819 }
3820
3821 omciRxCallbackPair := CallbackPair{CbKey: tid,
3822 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3823 }
3824 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3825 if err != nil {
3826 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3827 "device-id": oo.deviceID})
3828 return nil, err
3829 }
3830 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3831 return meInstance, nil
3832 }
3833 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3834 "device-id": oo.deviceID})
3835 return nil, omciErr.GetError()
3836}
3837
3838// SendSetNetworkDialPlanTable nolint: unused
3839func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3840 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3841 tid := oo.GetNextTid(highPrio)
3842 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3843 "SequNo": strconv.FormatInt(int64(tid), 16),
3844 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3845
3846 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3847 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003848 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3849 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003850 if err != nil {
3851 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3852 "device-id": oo.deviceID})
3853 return nil, err
3854 }
3855
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003856 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003857 if err != nil {
3858 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3859 "device-id": oo.deviceID})
3860 return nil, err
3861 }
3862
3863 omciRxCallbackPair := CallbackPair{CbKey: tid,
3864 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3865 }
3866 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3867 if err != nil {
3868 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3869 "device-id": oo.deviceID})
3870 return nil, err
3871 }
3872 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3873 return meInstance, nil
3874 }
3875 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3876 "device-id": oo.deviceID})
3877 return nil, omciErr.GetError()
3878}
3879
3880// SendDeleteNetworkDialPlanTable nolint: unused
3881func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3882 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3883 tid := oo.GetNextTid(highPrio)
3884 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3885 "SequNo": strconv.FormatInt(int64(tid), 16),
3886 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3887
3888 meParams := me.ParamData{EntityID: aInstID}
3889 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3890 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003891 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3892 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003893 if err != nil {
3894 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3895 "Err": err, "device-id": oo.deviceID})
3896 return nil, err
3897 }
3898
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003899 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003900 if err != nil {
3901 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3902 "Err": err, "device-id": oo.deviceID})
3903 return nil, err
3904 }
3905
3906 omciRxCallbackPair := CallbackPair{
3907 CbKey: tid,
3908 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3909 }
3910 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3911 if err != nil {
3912 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3913 "Err": err, "device-id": oo.deviceID})
3914 return nil, err
3915 }
3916 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3917 return meInstance, nil
3918 }
3919 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3920 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3921 return nil, omciErr.GetError()
3922}
3923
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003924// SendSyncTime sends SynchronizeTimeRequest
3925func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
3926 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003927 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
3928 "SequNo": strconv.FormatInt(int64(tid), 16)})
3929
3930 omciLayer := &omci.OMCI{
3931 TransactionID: tid,
3932 MessageType: omci.SynchronizeTimeRequestType,
3933 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3934 // Length: 0x28, // Optional, defaults to 40 octets
3935 }
3936 utcTime := time.Now().UTC()
3937 request := &omci.SynchronizeTimeRequest{
3938 MeBasePacket: omci.MeBasePacket{
3939 EntityClass: me.OnuGClassID,
3940 // Default Instance ID is 0
3941 },
3942 Year: uint16(utcTime.Year()),
3943 Month: uint8(utcTime.Month()),
3944 Day: uint8(utcTime.Day()),
3945 Hour: uint8(utcTime.Hour()),
3946 Minute: uint8(utcTime.Minute()),
3947 Second: uint8(utcTime.Second()),
3948 }
3949
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003950 pkt, err := SerializeOmciLayer(ctx, omciLayer, request)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003951 if err != nil {
3952 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
3953 "device-id": oo.deviceID})
3954 return err
3955 }
3956
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003957 omciRxCallbackPair := CallbackPair{CbKey: tid,
3958 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003959 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003960 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003961 if err != nil {
3962 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
3963 "device-id": oo.deviceID})
3964 return err
3965 }
3966 logger.Debug(ctx, "send synchronize time request done")
3967 return nil
3968}
3969
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003970// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
3971func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003972 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003973 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003974 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3975 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3976 meParam := me.ParamData{EntityID: entityID}
3977 var meInstance *me.ManagedEntity
3978 var omciErr me.OmciErrors
3979 if upstream {
3980 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
3981 } else {
3982 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
3983 }
3984 if omciErr.GetError() == nil {
3985 var omciLayer *omci.OMCI
3986 var msgLayer gopacket.SerializableLayer
3987 var err error
3988 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003989 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3990 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003991 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003992 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
3993 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003994 }
3995 if err != nil {
3996 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
3997 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003998 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003999 }
4000
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004001 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004002 if err != nil {
4003 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
4004 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004005 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004006 }
4007
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004008 omciRxCallbackPair := CallbackPair{CbKey: tid,
4009 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004010 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004011 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004012 if err != nil {
4013 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
4014 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004015 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004016 }
4017 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
4018 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004019 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004020 }
4021 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
4022 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004023 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004024}
4025
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004026// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
4027func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004028 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004029 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004030 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4031 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4032 meParam := me.ParamData{EntityID: entityID}
4033 var meInstance *me.ManagedEntity
4034 var omciErr me.OmciErrors
4035 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
4036
4037 if omciErr.GetError() == nil {
4038 var omciLayer *omci.OMCI
4039 var msgLayer gopacket.SerializableLayer
4040 var err error
4041 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004042 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4043 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004044 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004045 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4046 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004047 }
4048 if err != nil {
4049 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4050 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004051 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004052 }
4053
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004054 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004055 if err != nil {
4056 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4057 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004058 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004059 }
4060
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004061 omciRxCallbackPair := CallbackPair{CbKey: tid,
4062 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004063 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004064 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004065 if err != nil {
4066 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4067 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004068 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004069 }
4070 logger.Debugw(ctx, "send ethernet uni history data ME done",
4071 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004072 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004073 }
4074 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4075 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004076 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004077}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004078
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004079// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4080func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004081 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004082 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004083 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4084 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4085 meParam := me.ParamData{EntityID: entityID}
4086 var meInstance *me.ManagedEntity
4087 var omciErr me.OmciErrors
4088 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4089
4090 if omciErr.GetError() == nil {
4091 var omciLayer *omci.OMCI
4092 var msgLayer gopacket.SerializableLayer
4093 var err error
4094 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004095 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4096 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004097 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004098 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4099 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004100 }
4101 if err != nil {
4102 logger.Errorw(ctx, "Cannot encode fec history data ME",
4103 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004104 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004105 }
4106
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004107 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004108 if err != nil {
4109 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4110 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004111 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004112 }
4113
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004114 omciRxCallbackPair := CallbackPair{CbKey: tid,
4115 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004116 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004117 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004118 if err != nil {
4119 logger.Errorw(ctx, "Cannot send fec history data ME",
4120 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004121 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004122 }
4123 logger.Debugw(ctx, "send fec history data ME done",
4124 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004125 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004126 }
4127 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4128 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004129 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004130}
4131
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004132// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4133func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004134 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004135 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004136 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4137 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4138 meParam := me.ParamData{EntityID: entityID}
4139 var meInstance *me.ManagedEntity
4140 var omciErr me.OmciErrors
4141 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4142
4143 if omciErr.GetError() == nil {
4144 var omciLayer *omci.OMCI
4145 var msgLayer gopacket.SerializableLayer
4146 var err error
4147 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004148 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4149 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004150 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004151 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4152 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004153 }
4154 if err != nil {
4155 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4156 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004157 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004158 }
4159
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004160 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004161 if err != nil {
4162 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4163 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004164 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004165 }
4166
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004167 omciRxCallbackPair := CallbackPair{CbKey: tid,
4168 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004169 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004170 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004171 if err != nil {
4172 logger.Errorw(ctx, "Cannot send gemport history data ME",
4173 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004174 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004175 }
4176 logger.Debugw(ctx, "send gemport history data ME done",
4177 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004178 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004179 }
4180 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4181 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004182 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004183}
4184
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004185// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4186func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004187 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004188 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004189 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4190 "SequNo": strconv.FormatInt(int64(tid), 16),
4191 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4192
4193 omciLayer := &omci.OMCI{
4194 TransactionID: tid,
4195 MessageType: omci.StartSoftwareDownloadRequestType,
4196 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4197 // Length: 0x28, // Optional, defaults to 40 octets
4198 }
4199 request := &omci.StartSoftwareDownloadRequest{
4200 MeBasePacket: omci.MeBasePacket{
4201 EntityClass: me.SoftwareImageClassID,
4202 EntityInstance: aImageMeID, //inactive image
4203 },
4204 WindowSize: aDownloadWindowSize,
4205 ImageSize: aFileLen,
4206 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4207 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4208 }
4209
4210 var options gopacket.SerializeOptions
4211 options.FixLengths = true
4212 buffer := gopacket.NewSerializeBuffer()
4213 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4214 if err != nil {
4215 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4216 "device-id": oo.deviceID})
4217 return err
4218 }
4219 outgoingPacket := buffer.Bytes()
4220
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004221 omciRxCallbackPair := CallbackPair{CbKey: tid,
4222 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004223 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004224 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004225 if err != nil {
4226 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4227 "device-id": oo.deviceID})
4228 return err
4229 }
4230 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004231 return nil
4232}
4233
kesavand011d5162021-11-25 19:21:06 +05304234// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4235//Before invoking this function the oo.mutexTid needs to be be locked so that
4236//GetOnuSwSecNextTid can be invoked without further locking
4237func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4238 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
4239 omciMsgsPerWindow *ia.OmciMessages) (OmciTransferStructure, error) {
4240 //onuswsections uses only low prioirity tids
4241 tid := oo.GetOnuSwSecNextTid()
4242 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4243 "SequNo": strconv.FormatInt(int64(tid), 16),
4244 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4245
4246 var omciTxReq OmciTransferStructure
4247 msgType := omci.DownloadSectionRequestType
4248
4249 if aAckRequest > 0 {
4250 msgType = omci.DownloadSectionRequestWithResponseType
4251
4252 }
4253 omciLayer := &omci.OMCI{
4254 TransactionID: tid,
4255 MessageType: msgType,
4256 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4257 // Length: 0x28, // Optional, defaults to 40 octets
4258 }
4259 localSectionData := make([]byte, len(aSection))
4260
4261 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4262 request := &omci.DownloadSectionRequest{
4263 MeBasePacket: omci.MeBasePacket{
4264 EntityClass: me.SoftwareImageClassID,
4265 EntityInstance: aImageMeID, //inactive image
4266 },
4267 SectionNumber: aDownloadSectionNo,
4268 SectionData: localSectionData,
4269 }
4270
4271 var options gopacket.SerializeOptions
4272 options.FixLengths = true
4273 buffer := gopacket.NewSerializeBuffer()
4274 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4275 if err != nil {
4276 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4277 "device-id": oo.deviceID})
4278 return omciTxReq, err
4279 }
4280 outgoingPacket := buffer.Bytes()
4281
4282 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4283
4284 if aAckRequest > 0 {
4285 // only the last section should have a timeout as an ack is required only for the last section of the window
4286 omciTxReq = OmciTransferStructure{
4287 withFramePrint: true,
4288 OnuSwWindow: omciMsgsPerWindow,
4289 }
4290 return omciTxReq, nil
4291 }
4292
4293 return omciTxReq, nil
4294}
4295
4296//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4297func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4298 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4299 if aOmciTxRequest.OnuSwWindow == nil {
4300 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4301 log.Fields{"device-id": oo.deviceID})
4302 return
4303
4304 }
4305
4306 tid := oo.GetOnuSwSecLastTid()
4307 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4308 omciRxCallbackPair := CallbackPair{CbKey: tid,
4309 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4310 }
4311
4312 aOmciTxRequest.cbPair = omciRxCallbackPair
4313 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4314 oo.mutexRxSchedMap.Lock()
4315 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4316 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4317 oo.mutexRxSchedMap.Unlock()
4318
4319 chSuccess := make(chan bool)
4320 aOmciTxRequest.chSuccess = chSuccess
4321 aOmciTxRequest.timeout = aTimeout
4322 aOmciTxRequest.retries = CDefaultRetries
4323
4324 //tid := aOmciTxRequest.cbPair.CbKey
4325 oo.mutexMonReq.Lock()
4326 oo.monitoredRequests[tid] = aOmciTxRequest
4327 oo.mutexMonReq.Unlock()
4328
4329 retries := aOmciTxRequest.retries
4330 retryCounter := 0
4331 if aTimeout == 0 {
4332 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4333 return
4334 }
4335loop:
4336 for retryCounter <= retries {
4337 // the onu sw sections are enqueued only to the low priority queue
4338 oo.mutexLowPrioTxQueue.Lock()
4339 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4340 oo.mutexLowPrioTxQueue.Unlock()
4341
4342 go oo.sendQueuedRequests(ctx)
4343
4344 select {
4345 case success := <-chSuccess:
4346 if success {
4347 logger.Debugw(ctx, "reqMon: response received in time",
4348 log.Fields{"tid": tid, "device-id": oo.deviceID})
4349 } else {
4350 logger.Debugw(ctx, "reqMon: wait for response aborted",
4351 log.Fields{"tid": tid, "device-id": oo.deviceID})
4352 }
4353 break loop
4354 case <-time.After(time.Duration(aTimeout) * time.Second):
4355 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004356 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
kesavand011d5162021-11-25 19:21:06 +05304357 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004358 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
kesavand011d5162021-11-25 19:21:06 +05304359 break loop
4360 } else {
4361 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4362 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4363 }
4364 }
4365 retryCounter++
4366 }
4367 oo.mutexMonReq.Lock()
4368 delete(oo.monitoredRequests, tid)
4369 oo.mutexMonReq.Unlock()
4370}
4371
4372func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
4373 if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil {
4374 lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4375 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
4376 "TxOmciMessage": hex.EncodeToString(lastSection),
4377 "device-id": oo.deviceID,
4378 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4379 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4380 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4381 }
4382 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4383 if sendErr != nil {
4384 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
4385 return sendErr
4386 }
4387 return nil
4388}
4389
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004390// SendDownloadSection sends DownloadSectionRequestWithResponse
4391func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004392 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004393 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004394 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4395 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004396 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004397
4398 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4399 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004400 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004401 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004402 if aAckRequest > 0 {
4403 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004404 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004405 }
mpagenko80622a52021-02-09 16:53:23 +00004406 omciLayer := &omci.OMCI{
4407 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004408 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004409 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4410 // Length: 0x28, // Optional, defaults to 40 octets
4411 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304412 localSectionData := make([]byte, len(aSection))
4413
mpagenko15ff4a52021-03-02 10:09:20 +00004414 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004415 request := &omci.DownloadSectionRequest{
4416 MeBasePacket: omci.MeBasePacket{
4417 EntityClass: me.SoftwareImageClassID,
4418 EntityInstance: aImageMeID, //inactive image
4419 },
4420 SectionNumber: aDownloadSectionNo,
4421 SectionData: localSectionData,
4422 }
4423
4424 var options gopacket.SerializeOptions
4425 options.FixLengths = true
4426 buffer := gopacket.NewSerializeBuffer()
4427 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4428 if err != nil {
4429 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4430 "device-id": oo.deviceID})
4431 return err
4432 }
4433 outgoingPacket := buffer.Bytes()
4434
mpagenko15ff4a52021-03-02 10:09:20 +00004435 //for initial debug purpose overrule the requested print state for some frames
4436 printFrame := aPrint
4437 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4438 printFrame = true
4439 }
4440
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004441 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004442 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4443 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004444 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004445 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004446 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004447 if err != nil {
4448 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4449 "device-id": oo.deviceID})
4450 return err
4451 }
4452 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004453 return nil
4454}
4455
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004456//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4457func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004458 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004459 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004460 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4461 "SequNo": strconv.FormatInt(int64(tid), 16),
4462 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4463
mpagenko15ff4a52021-03-02 10:09:20 +00004464 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004465 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004466 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004467 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4468 // Length: 0x28, // Optional, defaults to 40 octets
4469 }
mpagenko15ff4a52021-03-02 10:09:20 +00004470 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004471 MeBasePacket: omci.MeBasePacket{
4472 EntityClass: me.SoftwareImageClassID,
4473 EntityInstance: aImageMeID, //inactive image
4474 },
mpagenko15ff4a52021-03-02 10:09:20 +00004475 CRC32: aImageCrc,
4476 ImageSize: aFileLen,
4477 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4478 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004479 }
mpagenko15ff4a52021-03-02 10:09:20 +00004480
4481 var options gopacket.SerializeOptions
4482 options.FixLengths = true
4483 buffer := gopacket.NewSerializeBuffer()
4484 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4485 if err != nil {
4486 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004487 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004488 return err
mpagenko80622a52021-02-09 16:53:23 +00004489 }
mpagenko15ff4a52021-03-02 10:09:20 +00004490 outgoingPacket := buffer.Bytes()
4491
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004492 omciRxCallbackPair := CallbackPair{CbKey: tid,
4493 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004494 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004495 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004496 if err != nil {
4497 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4498 "device-id": oo.deviceID})
4499 return err
4500 }
4501 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004502 return nil
4503}
4504
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004505// SendActivateSoftware sends ActivateSoftwareRequest
4506func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004507 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004508 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004509 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4510 "SequNo": strconv.FormatInt(int64(tid), 16),
4511 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4512
4513 omciLayer := &omci.OMCI{
4514 TransactionID: tid,
4515 MessageType: omci.ActivateSoftwareRequestType,
4516 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4517 // Length: 0x28, // Optional, defaults to 40 octets
4518 }
4519 request := &omci.ActivateSoftwareRequest{
4520 MeBasePacket: omci.MeBasePacket{
4521 EntityClass: me.SoftwareImageClassID,
4522 EntityInstance: aImageMeID, //inactive image
4523 },
4524 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4525 }
4526
4527 var options gopacket.SerializeOptions
4528 options.FixLengths = true
4529 buffer := gopacket.NewSerializeBuffer()
4530 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4531 if err != nil {
4532 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4533 "device-id": oo.deviceID})
4534 return err
4535 }
4536 outgoingPacket := buffer.Bytes()
4537
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004538 omciRxCallbackPair := CallbackPair{CbKey: tid,
4539 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004540 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004541 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004542 if err != nil {
4543 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4544 "device-id": oo.deviceID})
4545 return err
4546 }
4547 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004548 return nil
4549}
mpagenko80622a52021-02-09 16:53:23 +00004550
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004551// SendCommitSoftware sends CommitSoftwareRequest
4552func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko15ff4a52021-03-02 10:09:20 +00004553 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004554 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004555 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4556 "SequNo": strconv.FormatInt(int64(tid), 16),
4557 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4558
4559 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004560 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004561 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004562 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4563 // Length: 0x28, // Optional, defaults to 40 octets
4564 }
mpagenko15ff4a52021-03-02 10:09:20 +00004565 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004566 MeBasePacket: omci.MeBasePacket{
4567 EntityClass: me.SoftwareImageClassID,
4568 EntityInstance: aImageMeID, //inactive image
4569 },
mpagenko80622a52021-02-09 16:53:23 +00004570 }
mpagenko15ff4a52021-03-02 10:09:20 +00004571
4572 var options gopacket.SerializeOptions
4573 options.FixLengths = true
4574 buffer := gopacket.NewSerializeBuffer()
4575 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4576 if err != nil {
4577 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004578 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004579 return err
mpagenko80622a52021-02-09 16:53:23 +00004580 }
mpagenko15ff4a52021-03-02 10:09:20 +00004581 outgoingPacket := buffer.Bytes()
4582
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004583 omciRxCallbackPair := CallbackPair{CbKey: tid,
4584 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004585 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004586 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004587 if err != nil {
4588 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4589 "device-id": oo.deviceID})
4590 return err
4591 }
4592 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004593 return nil
4594}
4595
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004596//SendSelfTestReq sends TestRequest
4597func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4598 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004599 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4600 "SequNo": strconv.FormatInt(int64(tid), 16),
4601 "InstId": strconv.FormatInt(int64(instdID), 16)})
4602 omciLayer := &omci.OMCI{
4603 TransactionID: tid,
4604 MessageType: omci.TestRequestType,
4605 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4606 // Length: 0x28, // Optional, defaults to 40 octets
4607 }
4608
4609 var request *omci.OpticalLineSupervisionTestRequest
4610 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004611 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004612 request = &omci.OpticalLineSupervisionTestRequest{
4613 MeBasePacket: omci.MeBasePacket{
4614 EntityClass: classID,
4615 EntityInstance: instdID,
4616 },
4617 SelectTest: uint8(7), // self test
4618 GeneralPurposeBuffer: uint16(0),
4619 VendorSpecificParameters: uint16(0),
4620 }
4621 default:
4622 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4623 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4624 }
4625 // Test serialization back to former string
4626 var options gopacket.SerializeOptions
4627 options.FixLengths = true
4628
4629 buffer := gopacket.NewSerializeBuffer()
4630 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4631 if err != nil {
4632 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4633 "device-id": oo.deviceID})
4634 return err
4635 }
4636 outgoingPacket := buffer.Bytes()
4637
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004638 omciRxCallbackPair := CallbackPair{CbKey: tid,
4639 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004640 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004641 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004642 if err != nil {
4643 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4644 "device-id": oo.deviceID})
4645 return err
4646 }
4647 logger.Debug(ctx, "send self test request done")
4648 return nil
4649}
4650
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004651//nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004652func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4653
4654 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4655 if err != nil {
4656 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4657 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4658 }
4659 msgLayer := (*packet).Layer(nextLayer)
4660 if msgLayer != nil {
4661 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4662 if failure := (*packet).ErrorLayer(); failure != nil {
4663 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4664 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4665 // can examine for UnkonwnMEs and UnknownAttributes
4666 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
4667 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4668 return false, nil
4669 } else if nextLayer == omci.LayerTypeGetResponse {
4670 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4671 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4672 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4673 if unknownAttrLayer != nil {
4674 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4675 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4676 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4677 }
4678 }
4679 }
4680 }
4681 // Try to decode any further error information
4682 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4683 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4684 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4685 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4686 }
4687 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4688 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4689 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4690 }
4691 } else if failure := (*packet).ErrorLayer(); failure != nil {
4692 // message layer could not be decoded, but at least check if additional failure information is available
4693 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004694 errMsg := decodeFailure.String()
4695 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4696 if strings.Contains(strings.ToLower(errMsg), "table decode") {
4697 // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass
4698 // so that later processing can deal with it
4699 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass",
4700 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4701 return false, nil
4702 }
4703 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004704 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004705 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg})
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004706 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4707 }
4708 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4709 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4710 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4711 } else {
4712 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4713 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4714 }
4715
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004716 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004717 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004718 switch nextLayer {
4719 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004720 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4721 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004722 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004723 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004724 }
4725 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004726 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4727 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004728 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004729 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004730 }
4731 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004732 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4733 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004734 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004735 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004736 }
4737 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004738 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4739 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004740 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004741 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004742 }
4743 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004744 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4745 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004746 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004747 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004748 }
4749 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004750 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4751 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004752 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004753 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004754 }
4755 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004756 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4757 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004758 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004759 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004760 }
4761 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004762 }
4763 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004764 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004765}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004766
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004767func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004768 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004769 if timeout == 0 {
4770 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004771 // enqueue
4772 if aOmciTxRequest.highPrio {
4773 oo.mutexHighPrioTxQueue.Lock()
4774 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4775 oo.mutexHighPrioTxQueue.Unlock()
4776 } else {
4777 oo.mutexLowPrioTxQueue.Lock()
4778 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4779 oo.mutexLowPrioTxQueue.Unlock()
4780 }
4781 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004782 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004783 //the supervised sending with waiting on the response (based on TID) is called in background
4784 // to avoid blocking of the sender for the complete OMCI handshake procedure
4785 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4786 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4787 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004788 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004789}
4790
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004791func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004792 chSuccess := make(chan bool)
4793 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004794 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004795 oo.mutexMonReq.Lock()
4796 oo.monitoredRequests[tid] = aOmciTxRequest
4797 oo.mutexMonReq.Unlock()
4798
4799 retries := aOmciTxRequest.retries
4800 retryCounter := 0
4801loop:
4802 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004803 // enqueue
4804 if aOmciTxRequest.highPrio {
4805 oo.mutexHighPrioTxQueue.Lock()
4806 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4807 oo.mutexHighPrioTxQueue.Unlock()
4808 } else {
4809 oo.mutexLowPrioTxQueue.Lock()
4810 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4811 oo.mutexLowPrioTxQueue.Unlock()
4812 }
4813 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004814
4815 select {
4816 case success := <-chSuccess:
4817 if success {
4818 logger.Debugw(ctx, "reqMon: response received in time",
4819 log.Fields{"tid": tid, "device-id": oo.deviceID})
4820 } else {
4821 logger.Debugw(ctx, "reqMon: wait for response aborted",
4822 log.Fields{"tid": tid, "device-id": oo.deviceID})
4823 }
4824 break loop
4825 case <-time.After(time.Duration(aTimeout) * time.Second):
4826 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004827 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
mpagenko7455fd42021-06-10 16:25:55 +00004828 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004829 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
mpagenko7455fd42021-06-10 16:25:55 +00004830 break loop
4831 } else {
4832 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4833 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4834 }
4835 }
4836 retryCounter++
4837 }
4838 oo.mutexMonReq.Lock()
4839 delete(oo.monitoredRequests, tid)
4840 oo.mutexMonReq.Unlock()
4841}
4842
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004843//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004844func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004845 logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004846 oo.mutexMonReq.RLock()
4847 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004848 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4849 select {
4850 case oo.monitoredRequests[k].chSuccess <- false:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004851 logger.Debugw(ctx, "send cancellation on omciRespChannel",
4852 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004853 default:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004854 logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
4855 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004856 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004857 }
4858 oo.mutexMonReq.RUnlock()
4859}
4860
4861//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4862//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004863func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4864 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004865}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304866
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004867// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4868func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304869 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004870 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304871 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4872 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4873
4874 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004875 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304876 }
4877 var meInstance *me.ManagedEntity
4878 var omciErr me.OmciErrors
4879 if classID == me.EthernetFrameExtendedPmClassID {
4880 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4881 } else {
4882 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4883 }
4884
4885 if omciErr.GetError() == nil {
4886 var omciLayer *omci.OMCI
4887 var msgLayer gopacket.SerializableLayer
4888 var err error
4889 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004890 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4891 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304892 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004893 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4894 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304895 }
4896 if err != nil {
4897 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4898 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4899 return nil, err
4900 }
4901
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004902 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304903 if err != nil {
4904 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
4905 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4906 return nil, err
4907 }
4908
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004909 omciRxCallbackPair := CallbackPair{CbKey: tid,
4910 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304911 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004912 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304913 if err != nil {
4914 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4915 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4916 return nil, err
4917 }
4918 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
4919 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4920 return meInstance, nil
4921 }
4922 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4923 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4924 return nil, omciErr.GetError()
4925}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004926
4927// RLockMutexMonReq lock read access to monitoredRequests
4928func (oo *OmciCC) RLockMutexMonReq() {
4929 oo.mutexMonReq.RLock()
4930}
4931
4932// RUnlockMutexMonReq unlock read access to monitoredRequests
4933func (oo *OmciCC) RUnlockMutexMonReq() {
4934 oo.mutexMonReq.RUnlock()
4935}
4936
4937// GetMonitoredRequest get OmciTransferStructure for an omciTransID
4938func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
4939 value, exist = oo.monitoredRequests[omciTransID]
4940 return value, exist
4941}
4942
4943// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
4944func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
4945 oo.monitoredRequests[omciTransID].chSuccess <- chVal
4946}
Himani Chawlaee10b542021-09-20 16:46:40 +05304947
4948// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
4949func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
4950 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
4951 tid := oo.GetNextTid(highPrio)
4952 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
4953 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
4954
4955 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004956 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05304957 }
4958 var meInstance *me.ManagedEntity
4959 var omciErr me.OmciErrors
4960 if classID == me.EthernetFrameExtendedPmClassID {
4961 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
4962 } else {
4963 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
4964 }
4965
4966 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00004967 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05304968 if err != nil {
4969 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4970 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4971 return nil, err
4972 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004973 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawlaee10b542021-09-20 16:46:40 +05304974 if err != nil {
4975 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
4976 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4977 return nil, err
4978 }
4979 omciRxCallbackPair := CallbackPair{
4980 CbKey: tid,
4981 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4982 }
4983 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4984 if err != nil {
4985 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4986 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4987 return nil, err
4988 }
4989 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
4990 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4991 return meInstance, nil
4992 }
4993 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4994 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4995 return nil, omciErr.GetError()
4996}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00004997
4998// PrepareForGarbageCollection - remove references to prepare for garbage collection
4999func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
5000 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
5001 oo.pBaseDeviceHandler = nil
5002 oo.pOnuDeviceEntry = nil
5003 oo.pOnuAlarmManager = nil
5004}