blob: a47ca1a8d157d4332fe38d69b00ba432dee14106 [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
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000881func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000882 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000883
884 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000885
886 omciLayer := &omci.OMCI{
887 TransactionID: tid,
888 MessageType: omci.MibUploadRequestType,
889 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000890 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000891 omciLayer.DeviceIdentifier = omci.ExtendedIdent
892 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000893 request := &omci.MibUploadRequest{
894 MeBasePacket: omci.MeBasePacket{
895 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000896 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000897 },
898 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000899 var options gopacket.SerializeOptions
900 options.FixLengths = true
901
902 buffer := gopacket.NewSerializeBuffer()
903 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000904 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000905 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000906 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000907 return err
908 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000909 oo.UploadSequNo = 0
910 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000911
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000912 omciRxCallbackPair := CallbackPair{
913 CbKey: tid,
914 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000915 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000916 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000917}
918
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000919// SendMibUploadNext sends MibUploadNextRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000920func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000921 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000922
923 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000924
925 omciLayer := &omci.OMCI{
926 TransactionID: tid,
927 MessageType: omci.MibUploadNextRequestType,
928 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000929 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000930 omciLayer.DeviceIdentifier = omci.ExtendedIdent
931 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000932 request := &omci.MibUploadNextRequest{
933 MeBasePacket: omci.MeBasePacket{
934 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000935 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000936 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000937 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000938 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000939 var options gopacket.SerializeOptions
940 options.FixLengths = true
941
942 buffer := gopacket.NewSerializeBuffer()
943 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000944 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000945 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000946 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000947 return err
948 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000949 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000950
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000951 omciRxCallbackPair := CallbackPair{
952 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000953 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
954 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
955 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000956 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000957 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000958 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000959}
960
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000961// SendGetAllAlarm gets all alarm ME instances
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000962func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool, isExtendedOmci bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530963 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000964
965 tid := oo.GetNextTid(highPrio)
966 omciLayer := &omci.OMCI{
967 TransactionID: tid,
968 MessageType: omci.GetAllAlarmsRequestType,
969 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
970 }
971 if isExtendedOmci {
972 omciLayer.DeviceIdentifier = omci.ExtendedIdent
973 }
Himani Chawlad3dac422021-03-13 02:31:31 +0530974 request := &omci.GetAllAlarmsRequest{
975 MeBasePacket: omci.MeBasePacket{
976 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000977 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +0530978 },
979 AlarmRetrievalMode: byte(alarmRetreivalMode),
980 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000981 var options gopacket.SerializeOptions
982 options.FixLengths = true
983 buffer := gopacket.NewSerializeBuffer()
984 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +0530985 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000986 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err,
987 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +0530988 return err
989 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000990 outgoingPacket := buffer.Bytes()
991
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000992 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530993
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000994 omciRxCallbackPair := CallbackPair{
995 CbKey: tid,
996 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530997 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000998 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
999 if err != nil {
1000 logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err,
1001 "device-id": oo.deviceID})
1002 return err
1003 }
1004 logger.Debug(ctx, "send GetAllAlarmsRequest done")
1005 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301006}
1007
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001008// SendGetAllAlarmNext gets next alarm ME instance
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001009func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool, isExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001010 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
1011 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +05301012 "alarmUploadSeqNo": alarmUploadSeqNo})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001013
1014 tid := oo.GetNextTid(highPrio)
1015 omciLayer := &omci.OMCI{
1016 TransactionID: tid,
1017 MessageType: omci.GetAllAlarmsNextRequestType,
1018 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
1019 }
1020 if isExtendedOmci {
1021 omciLayer.DeviceIdentifier = omci.ExtendedIdent
1022 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301023 request := &omci.GetAllAlarmsNextRequest{
1024 MeBasePacket: omci.MeBasePacket{
1025 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001026 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301027 },
1028 CommandSequenceNumber: alarmUploadSeqNo,
1029 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001030 var options gopacket.SerializeOptions
1031 options.FixLengths = true
1032 buffer := gopacket.NewSerializeBuffer()
1033 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301034 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001035 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err,
1036 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301037 return err
1038 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001039 outgoingPacket := buffer.Bytes()
1040
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001041 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +05301042
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001043 omciRxCallbackPair := CallbackPair{
1044 CbKey: tid,
1045 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301046 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001047 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1048 if err != nil {
1049 logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err,
1050 "device-id": oo.deviceID})
1051 return err
1052 }
1053 logger.Debug(ctx, "send GetAllAlarmsNextRequest done")
1054 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301055}
1056
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001057// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
1058func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1059 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001060 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001061 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001062
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001063 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001064 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001065 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001066 }
1067 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
1068 if omciErr.GetError() == nil {
1069 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001070 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001071 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001072 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001073 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001074 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001075 }
1076
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001077 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001078 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001079 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001080 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001081 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001082 }
1083
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001084 omciRxCallbackPair := CallbackPair{
1085 CbKey: tid,
1086 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001087 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001088 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001089 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001090 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001091 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001092 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001093 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001094 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001095 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001096 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001097 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001098 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001099 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001100}
1101
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001102// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001103// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001104func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1105 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001106 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001107 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001108
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001109 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
1110 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001111 // By now we just use fix values to fire - this is anyway what the python adapter does
1112 // read ONU-2G from DB ???? //TODO!!!
1113 meParams := me.ParamData{
1114 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001115 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001116 }
1117 meInstance, omciErr := me.NewOnu2G(meParams)
1118 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001119 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001120 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001121 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001122 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001123 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001124 }
1125
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001126 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001127 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001129 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001130 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001131 }
1132
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001133 omciRxCallbackPair := CallbackPair{
1134 CbKey: tid,
1135 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001136 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001137 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001138 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001139 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001140 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001141 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001142 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001143 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001144 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001145 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001146 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001147 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001148 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001149}
1150
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001151// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1152func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1153 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1154 tid := oo.GetNextTid(highPrio)
1155 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001156 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001157 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001158
1159 meParams := me.ParamData{
1160 EntityID: instID,
1161 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001162 me.MacBridgeServiceProfile_Priority: 0x8000,
1163 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1164 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1165 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1166 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001167 },
1168 }
1169
1170 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1171 if omciErr.GetError() == nil {
1172 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001173 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1174 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001175 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001176 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001177 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001178 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001179 }
1180
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001181 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001182 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001183 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001184 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001185 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001186 }
1187
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001188 omciRxCallbackPair := CallbackPair{
1189 CbKey: tid,
1190 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001191 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001192 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001193 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001194 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001195 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001196 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001197 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001199 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001200 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001201 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001202 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001203 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001204}
1205
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001206// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1207func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1208 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1209 tid := oo.GetNextTid(highPrio)
1210 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001211 if idErr != nil {
1212 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1213 "Err": idErr, "device-id": oo.deviceID})
1214 return nil, idErr
1215 }
1216 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001217 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001218
1219 meParams := me.ParamData{
1220 EntityID: instID,
1221 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001222 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1223 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1224 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1225 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001226 },
1227 }
1228 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1229 if omciErr.GetError() == nil {
1230 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001231 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1232 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001233 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001234 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001235 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001236 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001237 }
1238
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001239 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001240 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001241 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001242 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001243 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001244 }
1245
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001246 omciRxCallbackPair := CallbackPair{
1247 CbKey: tid,
1248 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001249 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001250 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001251 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001252 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001253 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001254 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001255 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001256 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001257 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001258 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001259 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001260 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001261 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001262}
1263
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001264// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1265func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1266 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1267 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001268 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001269 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001270 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001271 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001272
1273 // compare python adapter code WA VOL-1311: this is not done here!
1274 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1275 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1276 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001277 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001278 assType = uint8(10) // for VEIP
1279 }
1280 meParams := me.ParamData{
1281 EntityID: instID,
1282 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001283 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1284 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001285 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001286 },
1287 }
1288 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1289 if omciErr.GetError() == nil {
1290 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001291 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1292 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001293 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001294 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001295 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001296 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001297 }
1298
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001299 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001300 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001301 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001302 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001303 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001304 }
1305
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001306 omciRxCallbackPair := CallbackPair{
1307 CbKey: tid,
1308 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001309 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001310 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001311 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001312 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001313 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001314 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001315 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001316 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001317 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001318 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001319 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001320 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001321 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001322}
1323
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001324// SendSetOnuGLS sets OnuG ME instance
1325func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001326 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001327 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001328 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001329 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001330
1331 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1332 meParams := me.ParamData{
1333 EntityID: 0,
1334 Attributes: requestedAttributes,
1335 }
1336 meInstance, omciErr := me.NewOnuG(meParams)
1337 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001338 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001339 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001340 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001341 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001342 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001343 }
1344
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001345 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001346 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001347 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001348 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001349 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001350 }
1351
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001352 omciRxCallbackPair := CallbackPair{
1353 CbKey: tid,
1354 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001355 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001356 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001357 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001358 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001359 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001360 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001361 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001362 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001363 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001364 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001365 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001366 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001367 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001368}
1369
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001370// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1371func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001372 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001373 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001374 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001375 "SequNo": strconv.FormatInt(int64(tid), 16)})
1376
1377 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1378 meParams := me.ParamData{
1379 EntityID: aInstNo,
1380 Attributes: requestedAttributes,
1381 }
1382 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1383 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001384 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001385 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001386 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001387 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001388 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001389 }
1390
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001391 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001392 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001393 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001394 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001395 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001396 }
1397
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001398 omciRxCallbackPair := CallbackPair{
1399 CbKey: tid,
1400 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001401 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001402 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001403 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001404 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001405 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001406 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001407 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001408 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001409 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001410 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001411 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001412 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001413 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001414}
1415
1416/* UniG obsolete by now, left here in case it should be needed once again
1417 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301418func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001419 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001420 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001421 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001422 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001423
1424 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1425 meParams := me.ParamData{
1426 EntityID: aInstNo,
1427 Attributes: requestedAttributes,
1428 }
1429 meInstance, omciErr := me.NewUniG(meParams)
1430 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001431 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001432 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001434 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001435 return nil
1436 }
1437
1438 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1439 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001440 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001441 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001442 return nil
1443 }
1444
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001445 omciRxCallbackPair := CallbackPair{
1446 CbKey: tid,
1447 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001448 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001449 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001450 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001451 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001452 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001453 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001454 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001455 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001456 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001457 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001458 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001459 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001460 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001461}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001462*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001463
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001464// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1465func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001466 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001467 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001468 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001469 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001470
1471 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1472 meParams := me.ParamData{
1473 EntityID: aInstNo,
1474 Attributes: requestedAttributes,
1475 }
1476 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1477 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001478 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001479 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001480 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001481 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001482 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001483 }
1484
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001485 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001486 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001487 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001488 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001489 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001490 }
1491
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001492 omciRxCallbackPair := CallbackPair{
1493 CbKey: tid,
1494 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001495 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001496 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001497 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001498 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001499 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001500 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001501 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001502 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001503 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001504 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001505 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001506 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001507 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001508}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001509
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001510// SendGetMe gets ME instance
1511func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001512 timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001513
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001514 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001515 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001517
1518 meParams := me.ParamData{
1519 EntityID: entityID,
1520 Attributes: requestedAttributes,
1521 }
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001522 var messageSet omci.DeviceIdent = omci.BaselineIdent
1523 if isExtendedOmci {
1524 messageSet = omci.ExtendedIdent
1525 }
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001526 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1527 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301528 meClassIDName := meInstance.GetName()
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001529 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid), oframe.FrameFormat(messageSet))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001530 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001531 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 +03001532 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001533 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001534 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001535 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001536 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001537 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001538 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001539 omciRxCallbackPair := CallbackPair{
1540 CbKey: tid,
1541 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001542 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001543 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001544 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001545 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001546 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001547 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001548 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001549 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001550 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001551 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001552 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001553}
1554
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001555// SendGetMeWithAttributeMask gets ME instance with attribute mask
1556func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301557 timeout int, highPrio bool, rxChan chan Message) error {
1558
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001559 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301560 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1561 "SequNo": strconv.FormatInt(int64(tid), 16)})
1562
1563 request := &omci.GetRequest{
1564 MeBasePacket: omci.MeBasePacket{
1565 EntityInstance: entityID,
1566 EntityClass: classID,
1567 },
1568 AttributeMask: requestedAttributesMask,
1569 }
1570
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001571 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301572 if err != nil {
1573 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1574 return err
1575 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001576 omciRxCallbackPair := CallbackPair{
1577 CbKey: tid,
1578 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301579 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001580 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301581 if err != nil {
1582 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1583 return err
1584 }
1585 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1586 return nil
1587}
1588
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001589// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1590func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001591 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001592 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001593 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001594 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1595
1596 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001597 EntityID: aInstID,
1598 Attributes: me.AttributeValueMap{
1599 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001600 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1601 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1602 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1603 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1604 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1605 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1606 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1607 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1608 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001609 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001610 }
1611 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1612 if omciErr.GetError() == nil {
1613 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001614 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1615 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001616 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001617 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001618 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001619 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001620 }
1621
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001622 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001623 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001624 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001625 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001626 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001627 }
1628
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001629 omciRxCallbackPair := CallbackPair{
1630 CbKey: tid,
1631 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001632 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001633 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001634 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001635 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001636 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001637 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001638 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001639 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001640 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001641 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001642 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001643 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001644 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001645}
1646
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001647// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1648func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001649 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001650 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001651 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001652 "SequNo": strconv.FormatInt(int64(tid), 16),
1653 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1654
1655 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1656 if omciErr.GetError() == nil {
1657 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001658 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1659 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001660 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001662 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001663 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001664 }
1665
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001666 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001667 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001669 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001670 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001671 }
1672
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001673 omciRxCallbackPair := CallbackPair{
1674 CbKey: tid,
1675 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001676 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001677 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001678 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001679 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001680 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001681 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001682 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001683 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001684 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001685 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001686 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001687 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001688 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001689}
1690
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001691// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1692func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001693 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001694 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001695 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001696 "SequNo": strconv.FormatInt(int64(tid), 16),
1697 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1698
1699 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1700 if omciErr.GetError() == nil {
1701 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001702 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1703 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001704 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001705 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001706 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001707 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001708 }
1709
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001710 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001711 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001712 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001713 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001714 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001715 }
1716
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001717 omciRxCallbackPair := CallbackPair{
1718 CbKey: tid,
1719 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001720 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001721 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001722 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001723 logger.Errorw(ctx, "Cannot send GemNCTP 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001727 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001728 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001729 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001730 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001731 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001732 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001733}
1734
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001735// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1736func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1737 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001738 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1739 "SequNo": strconv.FormatInt(int64(tid), 16),
1740 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1741
1742 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1743 if omciErr.GetError() == nil {
1744 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001745 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1746 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001747 if err != nil {
1748 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1749 "Err": err, "device-id": oo.deviceID})
1750 return nil, err
1751 }
1752
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001753 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001754 if err != nil {
1755 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1756 "Err": err, "device-id": oo.deviceID})
1757 return nil, err
1758 }
1759
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001760 omciRxCallbackPair := CallbackPair{
1761 CbKey: tid,
1762 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001763 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001764 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001765 if err != nil {
1766 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1767 "Err": err, "device-id": oo.deviceID})
1768 return nil, err
1769 }
1770 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1771 return meInstance, nil
1772 }
1773 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1774 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1775 return nil, omciErr.GetError()
1776}
1777
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001778// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1779func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001780 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001781 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001782 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001783 "SequNo": strconv.FormatInt(int64(tid), 16),
1784 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1785
1786 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1787 if omciErr.GetError() == nil {
1788 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001789 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1790 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001791 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001792 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001793 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001794 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001795 }
1796
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001797 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001798 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001799 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001800 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001801 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001802 }
1803
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001804 omciRxCallbackPair := CallbackPair{
1805 CbKey: tid,
1806 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001807 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001808 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001809 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001810 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001811 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001812 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001813 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001815 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001816 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001817 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001818 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001819 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001820}
1821
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001822// SendSetTcontVar sets TCont ME instance
1823func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001824 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001825 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001826 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001827 "SequNo": strconv.FormatInt(int64(tid), 16),
1828 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1829
1830 meInstance, omciErr := me.NewTCont(params[0])
1831 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001832 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001833 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001834 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001835 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001836 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001837 }
1838
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001839 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001840 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001841 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001842 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001843 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001844 }
1845
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001846 omciRxCallbackPair := CallbackPair{
1847 CbKey: tid,
1848 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001849 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001850 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001851 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001852 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001853 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001854 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001855 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001856 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001857 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001858 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001859 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001860 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001861 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001862}
1863
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001864// SendSetPrioQueueVar sets PriorityQueue ME instance
1865func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001866 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001867 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001868 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001869 "SequNo": strconv.FormatInt(int64(tid), 16),
1870 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1871
1872 meInstance, omciErr := me.NewPriorityQueue(params[0])
1873 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001874 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001875 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001876 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001877 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001878 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001879 }
1880
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001881 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001882 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001884 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001885 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001886 }
1887
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001888 omciRxCallbackPair := CallbackPair{
1889 CbKey: tid,
1890 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001891 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001892 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001893 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001894 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001895 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001896 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001897 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001899 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001900 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001901 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001902 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001903 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001904}
1905
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001906// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1907func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001908 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001909 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001910 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001911 "SequNo": strconv.FormatInt(int64(tid), 16),
1912 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1913
1914 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1915 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001916 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001917 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001918 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001919 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001920 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001921 }
1922
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001923 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001924 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001925 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001926 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001927 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001928 }
1929
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001930 omciRxCallbackPair := CallbackPair{
1931 CbKey: tid,
1932 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001933 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001934 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001935 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001936 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001937 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001938 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001939 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001940 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001941 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001942 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001943 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001944 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001945 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001946}
mpagenkodff5dda2020-08-28 11:52:01 +00001947
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001948// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1949func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001950 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001951 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001952 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001953 "SequNo": strconv.FormatInt(int64(tid), 16),
1954 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1955
1956 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1957 if omciErr.GetError() == nil {
1958 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001959 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1960 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001961 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001962 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001963 "Err": err, "device-id": oo.deviceID})
1964 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1965 // return (dual format) error code that can be used at caller for immediate error treatment
1966 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001967 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001968 }
1969
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001970 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001971 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001972 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001973 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001974 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001975 }
1976
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001977 omciRxCallbackPair := CallbackPair{
1978 CbKey: tid,
1979 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001980 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001981 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001982 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001983 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001984 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001985 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001986 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001987 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001988 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001989 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001990 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001991 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001992 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001993}
1994
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001995// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001996func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001997 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001998 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001999 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002000 "SequNo": strconv.FormatInt(int64(tid), 16),
2001 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2002
2003 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
2004 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002005 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
2006 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002007 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002008 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002009 "Err": err, "device-id": oo.deviceID})
2010 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2011 // return (dual format) error code that can be used at caller for immediate error treatment
2012 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002013 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002014 }
2015
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002016 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002017 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002018 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002019 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002020 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002021 }
2022
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002023 omciRxCallbackPair := CallbackPair{
2024 CbKey: tid,
2025 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002026 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002027 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002028 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002030 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002031 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002032 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002033 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002034 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002035 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002036 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002037 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002038 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002039}
2040
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002041// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
2042func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002043 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002044 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002045 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002046 "SequNo": strconv.FormatInt(int64(tid), 16),
2047 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2048
2049 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2050 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002051 //EnhancedMode not yet supported, used with default options
2052 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
2053 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002054 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002055 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002056 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002057 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002058 }
2059
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002060 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002061 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002062 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002063 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002064 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002065 }
2066
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002067 omciRxCallbackPair := CallbackPair{
2068 CbKey: tid,
2069 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002070 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002071 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002072 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002073 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002074 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002075 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002076 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002077 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002078 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002079 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002080 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002081 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002082 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002083}
2084
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002085// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
2086func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002087 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002088 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002089 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00002090 "SequNo": strconv.FormatInt(int64(tid), 16),
2091 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2092
2093 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2094 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002095 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00002096 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002097 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002098 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002099 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002100 }
2101
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002102 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002103 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002104 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002105 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002106 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002107 }
2108
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002109 omciRxCallbackPair := CallbackPair{
2110 CbKey: tid,
2111 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002112 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002113 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002114 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002115 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002116 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002117 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002118 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002119 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002120 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002121 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002122 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002123 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002124 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002125}
mpagenko01e726e2020-10-23 09:45:29 +00002126
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002127// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2128func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002129 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002130 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002131 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002132 "SequNo": strconv.FormatInt(int64(tid), 16),
2133 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2134
2135 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2136 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002137 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002138 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002139 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002140 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002141 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002142 }
2143
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002144 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002145 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002146 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002147 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002148 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002149 }
2150
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002151 omciRxCallbackPair := CallbackPair{
2152 CbKey: tid,
2153 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002154 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002155 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002156 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002157 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002158 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002159 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002160 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002161 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002162 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002163 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002164 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002165 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002166 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002167}
2168
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002169// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2170func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002171 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002172 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002173 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002174 "SequNo": strconv.FormatInt(int64(tid), 16),
2175 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2176
2177 meParams := me.ParamData{EntityID: aInstID}
2178 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2179 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002180 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2181 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002182 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002183 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002184 "Err": err, "device-id": oo.deviceID})
2185 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2186 // return (dual format) error code that can be used at caller for immediate error treatment
2187 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002188 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002189 }
2190
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002191 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002192 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002193 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002194 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002195 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002196 }
2197
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002198 omciRxCallbackPair := CallbackPair{
2199 CbKey: tid,
2200 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002201 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002202 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002203 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002204 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002205 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002206 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002207 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002208 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002209 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002210 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002211 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002212 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002213 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002214}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002215
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002216// SendCreateTDVar creates TrafficDescriptor ME instance
2217func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2218 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002219 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2220 "SequNo": strconv.FormatInt(int64(tid), 16),
2221 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2222 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2223 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002224 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002225 if err != nil {
2226 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002227 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002228 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002229 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002230 if err != nil {
2231 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002232 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002233 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002234 omciRxCallbackPair := CallbackPair{
2235 CbKey: tid,
2236 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002237 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002238 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002239 if err != nil {
2240 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002242 }
2243 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002244 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002245 }
2246 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002247 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002248}
2249
2250// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002251func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002252 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002253 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002254 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2255 "SequNo": strconv.FormatInt(int64(tid), 16),
2256 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2257
2258 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2259 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002260 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002261 if err != nil {
2262 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002263 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002264 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002265 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002266 if err != nil {
2267 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002268 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002269 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002270 omciRxCallbackPair := CallbackPair{
2271 CbKey: tid,
2272 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002273 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002274 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002275 if err != nil {
2276 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002277 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002278 }
2279 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002280 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002281 }
2282 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002283 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002284
2285}
2286
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002287// SendDeleteTD - TODO: add comment
2288func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002289 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002290 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002291 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2292 "SequNo": strconv.FormatInt(int64(tid), 16),
2293 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2294
2295 meParams := me.ParamData{EntityID: aInstID}
2296 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2297 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002298 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002299 if err != nil {
2300 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002301 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002302 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002303 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002304 if err != nil {
2305 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002306 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002307 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002308 omciRxCallbackPair := CallbackPair{
2309 CbKey: tid,
2310 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002311 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002312 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002313 if err != nil {
2314 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002315 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002316 }
2317 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002318 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002319 }
2320 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002321 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002322
2323}
2324
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002325// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2326func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002327 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002328 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002329 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002330 "SequNo": strconv.FormatInt(int64(tid), 16),
2331 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2332
2333 meParams := me.ParamData{EntityID: aInstID}
2334 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2335 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002336 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2337 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002338 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002339 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002340 "Err": err, "device-id": oo.deviceID})
2341 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2342 // return (dual format) error code that can be used at caller for immediate error treatment
2343 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002344 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002345 }
2346
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002347 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002348 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002349 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002350 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002351 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002352 }
2353
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002354 omciRxCallbackPair := CallbackPair{
2355 CbKey: tid,
2356 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002357 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002358 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002359 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002360 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002361 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002362 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002363 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002364 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002365 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002366 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002367 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002368 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002369 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002370}
2371
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002372// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2373func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002374 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002375 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002376 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002377 "SequNo": strconv.FormatInt(int64(tid), 16),
2378 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2379
2380 meParams := me.ParamData{EntityID: aInstID}
2381 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2382 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002383 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2384 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002385 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002386 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002387 "Err": err, "device-id": oo.deviceID})
2388 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2389 // return (dual format) error code that can be used at caller for immediate error treatment
2390 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002391 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002392 }
2393
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002394 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002395 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002396 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002397 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002398 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002399 }
2400
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002401 omciRxCallbackPair := CallbackPair{
2402 CbKey: tid,
2403 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002404 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002405 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002406 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002407 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002408 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002409 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002410 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002411 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002412 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002413 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002414 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002415 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002416 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002417}
2418
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002419// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2420func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002421 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002422 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002423 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002424 "SequNo": strconv.FormatInt(int64(tid), 16),
2425 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2426
2427 meParams := me.ParamData{EntityID: aInstID}
2428 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2429 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002430 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2431 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002432 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002433 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002434 "Err": err, "device-id": oo.deviceID})
2435 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2436 // return (dual format) error code that can be used at caller for immediate error treatment
2437 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002438 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002439 }
2440
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002441 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002442 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002443 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002444 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002445 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002446 }
2447
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002448 omciRxCallbackPair := CallbackPair{
2449 CbKey: tid,
2450 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002451 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002452 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002453 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002454 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002455 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002456 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002457 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002458 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002459 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002460 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002461 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002462 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002463 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002464}
2465
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002466// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2467func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002468 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002469 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002470 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002471 "SequNo": strconv.FormatInt(int64(tid), 16),
2472 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2473
2474 meParams := me.ParamData{EntityID: aInstID}
2475 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2476 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002477 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2478 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002479 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002480 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002481 "Err": err, "device-id": oo.deviceID})
2482 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2483 // return (dual format) error code that can be used at caller for immediate error treatment
2484 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002485 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002486 }
2487
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002488 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002489 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002490 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002491 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002492 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002493 }
2494
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002495 omciRxCallbackPair := CallbackPair{
2496 CbKey: tid,
2497 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002498 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002499 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002500 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002501 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002502 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002503 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002504 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002505 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002506 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002507 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002508 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002509 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002510 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002511}
2512
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002513// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2514func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002515 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002516 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002517 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002518 "SequNo": strconv.FormatInt(int64(tid), 16),
2519 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2520
2521 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2522 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002523 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2524 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002525 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002526 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002527 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002528 }
2529
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002530 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002531 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002532 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002533 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002534 }
2535
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002536 omciRxCallbackPair := CallbackPair{CbKey: tid,
2537 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002538 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002539 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002540 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002541 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002542 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002543 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002544 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002545 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002546 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002547 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002548 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002549 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002550}
2551
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002552// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2553func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002554 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002555 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002556 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002557 "SequNo": strconv.FormatInt(int64(tid), 16),
2558 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2559
2560 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2561 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002562 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2563 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002564 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002565 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002566 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002567 }
2568
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002569 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002570 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002571 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002572 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002573 }
2574
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002575 omciRxCallbackPair := CallbackPair{CbKey: tid,
2576 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002577 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002578 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002579 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002580 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002581 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002582 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002583 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002584 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002585 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002586 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002587 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002588 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002589}
2590
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002591// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2592func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002593 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002594 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002595 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002596 "SequNo": strconv.FormatInt(int64(tid), 16),
2597 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2598
2599 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2600 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002601 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2602 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002603 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002604 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002605 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002606 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002607 }
2608
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002609 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002610 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002611 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002612 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002613 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002614 }
2615
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002616 omciRxCallbackPair := CallbackPair{CbKey: tid,
2617 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002618 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002619 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002620 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002621 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002622 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002623 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002624 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002625 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002626 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002627 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002628 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002629 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002630 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002631}
2632
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002633// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2634func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002635 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002636 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002637 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002638 "SequNo": strconv.FormatInt(int64(tid), 16),
2639 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2640
2641 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2642 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002643 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2644 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002645 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002646 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002647 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002648 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002649 }
2650
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002651 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002652 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002653 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002654 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002655 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002656 }
2657
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002658 omciRxCallbackPair := CallbackPair{CbKey: tid,
2659 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002660 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002661 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002662 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002663 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002664 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002665 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002666 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002667 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002668 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002669 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002670 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002671 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002672 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002673}
2674
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002675// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2676func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002677 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002678 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002679 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002680 "SequNo": strconv.FormatInt(int64(tid), 16),
2681 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2682
2683 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2684 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002685 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2686 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002687 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002688 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002689 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002690 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002691 }
2692
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002693 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002694 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002695 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002696 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002697 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002698 }
2699
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002700 omciRxCallbackPair := CallbackPair{CbKey: tid,
2701 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002702 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002703 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002704 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002705 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002706 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002707 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002708 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002709 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002710 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002711 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002712 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002713 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002714 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002715}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002716
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002717// SendCreateVoipVoiceCTP nolint: unused
2718func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2719 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2720 tid := oo.GetNextTid(highPrio)
2721 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2722 "SequNo": strconv.FormatInt(int64(tid), 16),
2723 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2724
2725 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2726 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002727 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2728 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002729 if err != nil {
2730 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2731 "device-id": oo.deviceID})
2732 return nil, err
2733 }
2734
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002735 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002736 if err != nil {
2737 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2738 "device-id": oo.deviceID})
2739 return nil, err
2740 }
2741
2742 omciRxCallbackPair := CallbackPair{CbKey: tid,
2743 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2744 }
2745 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2746 if err != nil {
2747 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2748 "device-id": oo.deviceID})
2749 return nil, err
2750 }
2751 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2752 return meInstance, nil
2753 }
2754 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2755 "device-id": oo.deviceID})
2756 return nil, omciErr.GetError()
2757}
2758
2759// SendSetVoipVoiceCTP nolint: unused
2760func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2761 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2762 tid := oo.GetNextTid(highPrio)
2763 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2764 "SequNo": strconv.FormatInt(int64(tid), 16),
2765 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2766
2767 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2768 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002769 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2770 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002771 if err != nil {
2772 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2773 "device-id": oo.deviceID})
2774 return nil, err
2775 }
2776
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002777 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002778 if err != nil {
2779 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2780 "device-id": oo.deviceID})
2781 return nil, err
2782 }
2783
2784 omciRxCallbackPair := CallbackPair{CbKey: tid,
2785 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2786 }
2787 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2788 if err != nil {
2789 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2790 "device-id": oo.deviceID})
2791 return nil, err
2792 }
2793 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2794 return meInstance, nil
2795 }
2796 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2797 "device-id": oo.deviceID})
2798 return nil, omciErr.GetError()
2799}
2800
2801// SendDeleteVoipVoiceCTP nolint: unused
2802func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2803 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2804 tid := oo.GetNextTid(highPrio)
2805 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2806 "SequNo": strconv.FormatInt(int64(tid), 16),
2807 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2808
2809 meParams := me.ParamData{EntityID: aInstID}
2810 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2811 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002812 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2813 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002814 if err != nil {
2815 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2816 "Err": err, "device-id": oo.deviceID})
2817 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2818 // return (dual format) error code that can be used at caller for immediate error treatment
2819 // (relevant to all used sendXX() methods and their error conditions)
2820 return nil, err
2821 }
2822
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002823 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002824 if err != nil {
2825 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2826 "Err": err, "device-id": oo.deviceID})
2827 return nil, err
2828 }
2829
2830 omciRxCallbackPair := CallbackPair{
2831 CbKey: tid,
2832 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2833 }
2834 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2835 if err != nil {
2836 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2837 "Err": err, "device-id": oo.deviceID})
2838 return nil, err
2839 }
2840 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2841 return meInstance, nil
2842 }
2843 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2844 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2845 return nil, omciErr.GetError()
2846}
2847
2848// SendCreateVoipMediaProfile nolint: unused
2849func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2850 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2851 tid := oo.GetNextTid(highPrio)
2852 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2853 "SequNo": strconv.FormatInt(int64(tid), 16),
2854 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2855
2856 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2857 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002858 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2859 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002860 if err != nil {
2861 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2862 "device-id": oo.deviceID})
2863 return nil, err
2864 }
2865
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002866 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002867 if err != nil {
2868 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2869 "device-id": oo.deviceID})
2870 return nil, err
2871 }
2872
2873 omciRxCallbackPair := CallbackPair{CbKey: tid,
2874 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2875 }
2876 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2877 if err != nil {
2878 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2879 "device-id": oo.deviceID})
2880 return nil, err
2881 }
2882 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2883 return meInstance, nil
2884 }
2885 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2886 "device-id": oo.deviceID})
2887 return nil, omciErr.GetError()
2888}
2889
2890// SendSetVoipMediaProfile nolint: unused
2891func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2892 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2893 tid := oo.GetNextTid(highPrio)
2894 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2895 "SequNo": strconv.FormatInt(int64(tid), 16),
2896 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2897
2898 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2899 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002900 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2901 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002902 if err != nil {
2903 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2904 "device-id": oo.deviceID})
2905 return nil, err
2906 }
2907
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002908 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002909 if err != nil {
2910 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2911 "device-id": oo.deviceID})
2912 return nil, err
2913 }
2914
2915 omciRxCallbackPair := CallbackPair{CbKey: tid,
2916 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2917 }
2918 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2919 if err != nil {
2920 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2921 "device-id": oo.deviceID})
2922 return nil, err
2923 }
2924 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2925 return meInstance, nil
2926 }
2927 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2928 "device-id": oo.deviceID})
2929 return nil, omciErr.GetError()
2930}
2931
2932// SendDeleteVoipMediaProfile nolint: unused
2933func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2934 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2935 tid := oo.GetNextTid(highPrio)
2936 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2937 "SequNo": strconv.FormatInt(int64(tid), 16),
2938 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2939
2940 meParams := me.ParamData{EntityID: aInstID}
2941 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2942 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002943 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2944 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002945 if err != nil {
2946 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2947 "Err": err, "device-id": oo.deviceID})
2948 return nil, err
2949 }
2950
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002951 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002952 if err != nil {
2953 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2954 "Err": err, "device-id": oo.deviceID})
2955 return nil, err
2956 }
2957
2958 omciRxCallbackPair := CallbackPair{
2959 CbKey: tid,
2960 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2961 }
2962 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2963 if err != nil {
2964 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2965 "Err": err, "device-id": oo.deviceID})
2966 return nil, err
2967 }
2968 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2969 return meInstance, nil
2970 }
2971 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2972 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2973 return nil, omciErr.GetError()
2974}
2975
2976// SendCreateVoiceServiceProfile nolint: unused
2977func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2978 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2979 tid := oo.GetNextTid(highPrio)
2980 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2981 "SequNo": strconv.FormatInt(int64(tid), 16),
2982 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2983
2984 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2985 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002986 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2987 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002988 if err != nil {
2989 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2990 "device-id": oo.deviceID})
2991 return nil, err
2992 }
2993
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002994 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002995 if err != nil {
2996 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2997 "device-id": oo.deviceID})
2998 return nil, err
2999 }
3000
3001 omciRxCallbackPair := CallbackPair{CbKey: tid,
3002 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3003 }
3004 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3005 if err != nil {
3006 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
3007 "device-id": oo.deviceID})
3008 return nil, err
3009 }
3010 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
3011 return meInstance, nil
3012 }
3013 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3014 "device-id": oo.deviceID})
3015 return nil, omciErr.GetError()
3016}
3017
3018// SendSetVoiceServiceProfile nolint: unused
3019func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3020 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3021 tid := oo.GetNextTid(highPrio)
3022 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3023 "SequNo": strconv.FormatInt(int64(tid), 16),
3024 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3025
3026 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3027 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003028 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3029 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003030 if err != nil {
3031 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
3032 "device-id": oo.deviceID})
3033 return nil, err
3034 }
3035
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003036 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003037 if err != nil {
3038 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
3039 "device-id": oo.deviceID})
3040 return nil, err
3041 }
3042
3043 omciRxCallbackPair := CallbackPair{CbKey: tid,
3044 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3045 }
3046 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3047 if err != nil {
3048 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
3049 "device-id": oo.deviceID})
3050 return nil, err
3051 }
3052 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
3053 return meInstance, nil
3054 }
3055 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3056 "device-id": oo.deviceID})
3057 return nil, omciErr.GetError()
3058}
3059
3060// SendDeleteVoiceServiceProfile nolint: unused
3061func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3062 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3063 tid := oo.GetNextTid(highPrio)
3064 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3065 "SequNo": strconv.FormatInt(int64(tid), 16),
3066 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3067
3068 meParams := me.ParamData{EntityID: aInstID}
3069 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
3070 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003071 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3072 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003073 if err != nil {
3074 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
3075 "Err": err, "device-id": oo.deviceID})
3076 return nil, err
3077 }
3078
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003079 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003080 if err != nil {
3081 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
3082 "Err": err, "device-id": oo.deviceID})
3083 return nil, err
3084 }
3085
3086 omciRxCallbackPair := CallbackPair{
3087 CbKey: tid,
3088 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3089 }
3090 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3091 if err != nil {
3092 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
3093 "Err": err, "device-id": oo.deviceID})
3094 return nil, err
3095 }
3096 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
3097 return meInstance, nil
3098 }
3099 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
3100 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3101 return nil, omciErr.GetError()
3102}
3103
3104// SendCreateSIPUserData nolint: unused
3105func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
3106 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3107 tid := oo.GetNextTid(highPrio)
3108 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
3109 "SequNo": strconv.FormatInt(int64(tid), 16),
3110 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3111
3112 meInstance, omciErr := me.NewSipUserData(params[0])
3113 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003114 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3115 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003116 if err != nil {
3117 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3118 "device-id": oo.deviceID})
3119 return nil, err
3120 }
3121
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003122 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003123 if err != nil {
3124 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3125 "device-id": oo.deviceID})
3126 return nil, err
3127 }
3128
3129 omciRxCallbackPair := CallbackPair{CbKey: tid,
3130 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3131 }
3132 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3133 if err != nil {
3134 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3135 "device-id": oo.deviceID})
3136 return nil, err
3137 }
3138 logger.Debug(ctx, "send SIPUserData-create-msg done")
3139 return meInstance, nil
3140 }
3141 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3142 "device-id": oo.deviceID})
3143 return nil, omciErr.GetError()
3144}
3145
3146// SendSetSIPUserData nolint: unused
3147func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3148 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3149 tid := oo.GetNextTid(highPrio)
3150 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3151 "SequNo": strconv.FormatInt(int64(tid), 16),
3152 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3153
3154 meInstance, omciErr := me.NewSipUserData(params[0])
3155 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003156 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3157 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003158 if err != nil {
3159 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3160 "device-id": oo.deviceID})
3161 return nil, err
3162 }
3163
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003164 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003165 if err != nil {
3166 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3167 "device-id": oo.deviceID})
3168 return nil, err
3169 }
3170
3171 omciRxCallbackPair := CallbackPair{CbKey: tid,
3172 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3173 }
3174 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3175 if err != nil {
3176 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3177 "device-id": oo.deviceID})
3178 return nil, err
3179 }
3180 logger.Debug(ctx, "send SIPUserData-set-msg done")
3181 return meInstance, nil
3182 }
3183 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3184 "device-id": oo.deviceID})
3185 return nil, omciErr.GetError()
3186}
3187
3188// SendDeleteSIPUserData nolint: unused
3189func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3190 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3191 tid := oo.GetNextTid(highPrio)
3192 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3193 "SequNo": strconv.FormatInt(int64(tid), 16),
3194 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3195
3196 meParams := me.ParamData{EntityID: aInstID}
3197 meInstance, omciErr := me.NewSipUserData(meParams)
3198 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003199 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3200 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003201 if err != nil {
3202 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3203 "Err": err, "device-id": oo.deviceID})
3204 return nil, err
3205 }
3206
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003207 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003208 if err != nil {
3209 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3210 "Err": err, "device-id": oo.deviceID})
3211 return nil, err
3212 }
3213
3214 omciRxCallbackPair := CallbackPair{
3215 CbKey: tid,
3216 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3217 }
3218 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3219 if err != nil {
3220 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3221 "Err": err, "device-id": oo.deviceID})
3222 return nil, err
3223 }
3224 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3225 return meInstance, nil
3226 }
3227 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3228 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3229 return nil, omciErr.GetError()
3230}
3231
3232// SendCreateVoipApplicationServiceProfile nolint: unused
3233func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3234 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3235 tid := oo.GetNextTid(highPrio)
3236 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3237 "SequNo": strconv.FormatInt(int64(tid), 16),
3238 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3239
3240 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3241 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003242 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3243 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003244 if err != nil {
3245 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3246 "device-id": oo.deviceID})
3247 return nil, err
3248 }
3249
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003250 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003251 if err != nil {
3252 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3253 "device-id": oo.deviceID})
3254 return nil, err
3255 }
3256
3257 omciRxCallbackPair := CallbackPair{CbKey: tid,
3258 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3259 }
3260 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3261 if err != nil {
3262 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3263 "device-id": oo.deviceID})
3264 return nil, err
3265 }
3266 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3267 return meInstance, nil
3268 }
3269 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3270 "device-id": oo.deviceID})
3271 return nil, omciErr.GetError()
3272}
3273
3274// SendSetVoipApplicationServiceProfile nolint: unused
3275func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3276 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3277 tid := oo.GetNextTid(highPrio)
3278 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3279 "SequNo": strconv.FormatInt(int64(tid), 16),
3280 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3281
3282 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3283 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003284 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3285 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003286 if err != nil {
3287 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3288 "device-id": oo.deviceID})
3289 return nil, err
3290 }
3291
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003292 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003293 if err != nil {
3294 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3295 "device-id": oo.deviceID})
3296 return nil, err
3297 }
3298
3299 omciRxCallbackPair := CallbackPair{CbKey: tid,
3300 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3301 }
3302 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3303 if err != nil {
3304 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3305 "device-id": oo.deviceID})
3306 return nil, err
3307 }
3308 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3309 return meInstance, nil
3310 }
3311 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3312 "device-id": oo.deviceID})
3313 return nil, omciErr.GetError()
3314}
3315
3316// SendDeleteVoipApplicationServiceProfile nolint: unused
3317func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3318 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3319 tid := oo.GetNextTid(highPrio)
3320 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3321 "SequNo": strconv.FormatInt(int64(tid), 16),
3322 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3323
3324 meParams := me.ParamData{EntityID: aInstID}
3325 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3326 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003327 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3328 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003329 if err != nil {
3330 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3331 "Err": err, "device-id": oo.deviceID})
3332 return nil, err
3333 }
3334
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003335 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003336 if err != nil {
3337 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3338 "Err": err, "device-id": oo.deviceID})
3339 return nil, err
3340 }
3341
3342 omciRxCallbackPair := CallbackPair{
3343 CbKey: tid,
3344 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3345 }
3346 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3347 if err != nil {
3348 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3349 "Err": err, "device-id": oo.deviceID})
3350 return nil, err
3351 }
3352 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3353 return meInstance, nil
3354 }
3355 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3356 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3357 return nil, omciErr.GetError()
3358}
3359
3360// SendCreateSIPAgentConfigData nolint: unused
3361func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3362 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3363 tid := oo.GetNextTid(highPrio)
3364 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3365 "SequNo": strconv.FormatInt(int64(tid), 16),
3366 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3367
3368 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3369 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003370 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3371 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003372 if err != nil {
3373 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3374 "device-id": oo.deviceID})
3375 return nil, err
3376 }
3377
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003378 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003379 if err != nil {
3380 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3381 "device-id": oo.deviceID})
3382 return nil, err
3383 }
3384
3385 omciRxCallbackPair := CallbackPair{CbKey: tid,
3386 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3387 }
3388 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3389 if err != nil {
3390 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3391 "device-id": oo.deviceID})
3392 return nil, err
3393 }
3394 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3395 return meInstance, nil
3396 }
3397 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3398 "device-id": oo.deviceID})
3399 return nil, omciErr.GetError()
3400}
3401
3402// SendSetSIPAgentConfigData nolint: unused
3403func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3404 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3405 tid := oo.GetNextTid(highPrio)
3406 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3407 "SequNo": strconv.FormatInt(int64(tid), 16),
3408 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3409
3410 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3411 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003412 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3413 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003414 if err != nil {
3415 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3416 "device-id": oo.deviceID})
3417 return nil, err
3418 }
3419
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003420 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003421 if err != nil {
3422 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3423 "device-id": oo.deviceID})
3424 return nil, err
3425 }
3426
3427 omciRxCallbackPair := CallbackPair{CbKey: tid,
3428 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3429 }
3430 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3431 if err != nil {
3432 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3433 "device-id": oo.deviceID})
3434 return nil, err
3435 }
3436 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3437 return meInstance, nil
3438 }
3439 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3440 "device-id": oo.deviceID})
3441 return nil, omciErr.GetError()
3442}
3443
3444// SendDeleteSIPAgentConfigData nolint: unused
3445func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3446 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3447 tid := oo.GetNextTid(highPrio)
3448 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3449 "SequNo": strconv.FormatInt(int64(tid), 16),
3450 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3451
3452 meParams := me.ParamData{EntityID: aInstID}
3453 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3454 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003455 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3456 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003457 if err != nil {
3458 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3459 "Err": err, "device-id": oo.deviceID})
3460 return nil, err
3461 }
3462
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003463 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003464 if err != nil {
3465 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3466 "Err": err, "device-id": oo.deviceID})
3467 return nil, err
3468 }
3469
3470 omciRxCallbackPair := CallbackPair{
3471 CbKey: tid,
3472 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3473 }
3474 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3475 if err != nil {
3476 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3477 "Err": err, "device-id": oo.deviceID})
3478 return nil, err
3479 }
3480 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3481 return meInstance, nil
3482 }
3483 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3484 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3485 return nil, omciErr.GetError()
3486}
3487
3488// SendCreateTCPUDPConfigData nolint: unused
3489func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3490 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3491 tid := oo.GetNextTid(highPrio)
3492 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3493 "SequNo": strconv.FormatInt(int64(tid), 16),
3494 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3495
3496 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3497 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003498 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3499 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003500 if err != nil {
3501 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3502 "device-id": oo.deviceID})
3503 return nil, err
3504 }
3505
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003506 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003507 if err != nil {
3508 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3509 "device-id": oo.deviceID})
3510 return nil, err
3511 }
3512
3513 omciRxCallbackPair := CallbackPair{CbKey: tid,
3514 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3515 }
3516 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3517 if err != nil {
3518 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3519 "device-id": oo.deviceID})
3520 return nil, err
3521 }
3522 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3523 return meInstance, nil
3524 }
3525 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3526 "device-id": oo.deviceID})
3527 return nil, omciErr.GetError()
3528}
3529
3530// SendSetTCPUDPConfigData nolint: unused
3531func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3532 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3533 tid := oo.GetNextTid(highPrio)
3534 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3535 "SequNo": strconv.FormatInt(int64(tid), 16),
3536 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3537
3538 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3539 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003540 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3541 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003542 if err != nil {
3543 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3544 "device-id": oo.deviceID})
3545 return nil, err
3546 }
3547
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003548 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003549 if err != nil {
3550 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3551 "device-id": oo.deviceID})
3552 return nil, err
3553 }
3554
3555 omciRxCallbackPair := CallbackPair{CbKey: tid,
3556 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3557 }
3558 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3559 if err != nil {
3560 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3561 "device-id": oo.deviceID})
3562 return nil, err
3563 }
3564 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3565 return meInstance, nil
3566 }
3567 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3568 "device-id": oo.deviceID})
3569 return nil, omciErr.GetError()
3570}
3571
3572// SendDeleteTCPUDPConfigData nolint: unused
3573func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3574 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3575 tid := oo.GetNextTid(highPrio)
3576 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3577 "SequNo": strconv.FormatInt(int64(tid), 16),
3578 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3579
3580 meParams := me.ParamData{EntityID: aInstID}
3581 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3582 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003583 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3584 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003585 if err != nil {
3586 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3587 "Err": err, "device-id": oo.deviceID})
3588 return nil, err
3589 }
3590
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003591 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003592 if err != nil {
3593 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3594 "Err": err, "device-id": oo.deviceID})
3595 return nil, err
3596 }
3597
3598 omciRxCallbackPair := CallbackPair{
3599 CbKey: tid,
3600 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3601 }
3602 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3603 if err != nil {
3604 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3605 "Err": err, "device-id": oo.deviceID})
3606 return nil, err
3607 }
3608 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3609 return meInstance, nil
3610 }
3611 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3612 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3613 return nil, omciErr.GetError()
3614}
3615
3616// SendCreateIPHostConfigData nolint: unused
3617func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3618 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3619 tid := oo.GetNextTid(highPrio)
3620 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3621 "SequNo": strconv.FormatInt(int64(tid), 16),
3622 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3623
3624 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3625 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003626 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3627 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003628 if err != nil {
3629 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3630 "device-id": oo.deviceID})
3631 return nil, err
3632 }
3633
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003634 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003635 if err != nil {
3636 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3637 "device-id": oo.deviceID})
3638 return nil, err
3639 }
3640
3641 omciRxCallbackPair := CallbackPair{CbKey: tid,
3642 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3643 }
3644 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3645 if err != nil {
3646 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3647 "device-id": oo.deviceID})
3648 return nil, err
3649 }
3650 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3651 return meInstance, nil
3652 }
3653 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3654 "device-id": oo.deviceID})
3655 return nil, omciErr.GetError()
3656}
3657
3658// SendSetIPHostConfigData nolint: unused
3659func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3660 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3661 tid := oo.GetNextTid(highPrio)
3662 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3663 "SequNo": strconv.FormatInt(int64(tid), 16),
3664 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3665
3666 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3667 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003668 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3669 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003670 if err != nil {
3671 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3672 "device-id": oo.deviceID})
3673 return nil, err
3674 }
3675
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003676 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003677 if err != nil {
3678 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3679 "device-id": oo.deviceID})
3680 return nil, err
3681 }
3682
3683 omciRxCallbackPair := CallbackPair{CbKey: tid,
3684 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3685 }
3686 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3687 if err != nil {
3688 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3689 "device-id": oo.deviceID})
3690 return nil, err
3691 }
3692 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3693 return meInstance, nil
3694 }
3695 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3696 "device-id": oo.deviceID})
3697 return nil, omciErr.GetError()
3698}
3699
3700// SendDeleteIPHostConfigData nolint: unused
3701func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3702 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3703 tid := oo.GetNextTid(highPrio)
3704 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3705 "SequNo": strconv.FormatInt(int64(tid), 16),
3706 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3707
3708 meParams := me.ParamData{EntityID: aInstID}
3709 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3710 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003711 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3712 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003713 if err != nil {
3714 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3715 "Err": err, "device-id": oo.deviceID})
3716 return nil, err
3717 }
3718
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003719 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003720 if err != nil {
3721 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3722 "Err": err, "device-id": oo.deviceID})
3723 return nil, err
3724 }
3725
3726 omciRxCallbackPair := CallbackPair{
3727 CbKey: tid,
3728 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3729 }
3730 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3731 if err != nil {
3732 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3733 "Err": err, "device-id": oo.deviceID})
3734 return nil, err
3735 }
3736 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3737 return meInstance, nil
3738 }
3739 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3740 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3741 return nil, omciErr.GetError()
3742}
3743
3744// SendCreateRTPProfileData nolint: unused
3745func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3746 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3747 tid := oo.GetNextTid(highPrio)
3748 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3749 "SequNo": strconv.FormatInt(int64(tid), 16),
3750 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3751
3752 meInstance, omciErr := me.NewRtpProfileData(params[0])
3753 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003754 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3755 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003756 if err != nil {
3757 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3758 "device-id": oo.deviceID})
3759 return nil, err
3760 }
3761
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003762 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003763 if err != nil {
3764 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3765 "device-id": oo.deviceID})
3766 return nil, err
3767 }
3768
3769 omciRxCallbackPair := CallbackPair{CbKey: tid,
3770 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3771 }
3772 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3773 if err != nil {
3774 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3775 "device-id": oo.deviceID})
3776 return nil, err
3777 }
3778 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3779 return meInstance, nil
3780 }
3781 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3782 "device-id": oo.deviceID})
3783 return nil, omciErr.GetError()
3784}
3785
3786// SendSetRTPProfileData nolint: unused
3787func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3788 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3789 tid := oo.GetNextTid(highPrio)
3790 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3791 "SequNo": strconv.FormatInt(int64(tid), 16),
3792 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3793
3794 meInstance, omciErr := me.NewRtpProfileData(params[0])
3795 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003796 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3797 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003798 if err != nil {
3799 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3800 "device-id": oo.deviceID})
3801 return nil, err
3802 }
3803
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003804 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003805 if err != nil {
3806 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3807 "device-id": oo.deviceID})
3808 return nil, err
3809 }
3810
3811 omciRxCallbackPair := CallbackPair{CbKey: tid,
3812 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3813 }
3814 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3815 if err != nil {
3816 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3817 "device-id": oo.deviceID})
3818 return nil, err
3819 }
3820 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3821 return meInstance, nil
3822 }
3823 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3824 "device-id": oo.deviceID})
3825 return nil, omciErr.GetError()
3826}
3827
3828// SendDeleteRTPProfileData nolint: unused
3829func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3830 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3831 tid := oo.GetNextTid(highPrio)
3832 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3833 "SequNo": strconv.FormatInt(int64(tid), 16),
3834 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3835
3836 meParams := me.ParamData{EntityID: aInstID}
3837 meInstance, omciErr := me.NewRtpProfileData(meParams)
3838 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003839 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3840 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003841 if err != nil {
3842 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3843 "Err": err, "device-id": oo.deviceID})
3844 return nil, err
3845 }
3846
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003847 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003848 if err != nil {
3849 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3850 "Err": err, "device-id": oo.deviceID})
3851 return nil, err
3852 }
3853
3854 omciRxCallbackPair := CallbackPair{
3855 CbKey: tid,
3856 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3857 }
3858 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3859 if err != nil {
3860 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3861 "Err": err, "device-id": oo.deviceID})
3862 return nil, err
3863 }
3864 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3865 return meInstance, nil
3866 }
3867 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3868 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3869 return nil, omciErr.GetError()
3870}
3871
3872// SendCreateNetworkDialPlanTable nolint: unused
3873func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3874 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3875 tid := oo.GetNextTid(highPrio)
3876 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3877 "SequNo": strconv.FormatInt(int64(tid), 16),
3878 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3879
3880 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3881 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003882 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3883 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003884 if err != nil {
3885 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3886 "device-id": oo.deviceID})
3887 return nil, err
3888 }
3889
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003890 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003891 if err != nil {
3892 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3893 "device-id": oo.deviceID})
3894 return nil, err
3895 }
3896
3897 omciRxCallbackPair := CallbackPair{CbKey: tid,
3898 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3899 }
3900 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3901 if err != nil {
3902 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3903 "device-id": oo.deviceID})
3904 return nil, err
3905 }
3906 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3907 return meInstance, nil
3908 }
3909 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3910 "device-id": oo.deviceID})
3911 return nil, omciErr.GetError()
3912}
3913
3914// SendSetNetworkDialPlanTable nolint: unused
3915func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3916 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3917 tid := oo.GetNextTid(highPrio)
3918 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3919 "SequNo": strconv.FormatInt(int64(tid), 16),
3920 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3921
3922 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3923 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003924 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3925 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003926 if err != nil {
3927 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3928 "device-id": oo.deviceID})
3929 return nil, err
3930 }
3931
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003932 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003933 if err != nil {
3934 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3935 "device-id": oo.deviceID})
3936 return nil, err
3937 }
3938
3939 omciRxCallbackPair := CallbackPair{CbKey: tid,
3940 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3941 }
3942 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3943 if err != nil {
3944 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3945 "device-id": oo.deviceID})
3946 return nil, err
3947 }
3948 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3949 return meInstance, nil
3950 }
3951 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3952 "device-id": oo.deviceID})
3953 return nil, omciErr.GetError()
3954}
3955
3956// SendDeleteNetworkDialPlanTable nolint: unused
3957func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3958 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3959 tid := oo.GetNextTid(highPrio)
3960 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3961 "SequNo": strconv.FormatInt(int64(tid), 16),
3962 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3963
3964 meParams := me.ParamData{EntityID: aInstID}
3965 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3966 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003967 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3968 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003969 if err != nil {
3970 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3971 "Err": err, "device-id": oo.deviceID})
3972 return nil, err
3973 }
3974
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003975 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003976 if err != nil {
3977 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3978 "Err": err, "device-id": oo.deviceID})
3979 return nil, err
3980 }
3981
3982 omciRxCallbackPair := CallbackPair{
3983 CbKey: tid,
3984 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3985 }
3986 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3987 if err != nil {
3988 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3989 "Err": err, "device-id": oo.deviceID})
3990 return nil, err
3991 }
3992 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3993 return meInstance, nil
3994 }
3995 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3996 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3997 return nil, omciErr.GetError()
3998}
3999
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004000// SendSyncTime sends SynchronizeTimeRequest
4001func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
4002 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004003 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
4004 "SequNo": strconv.FormatInt(int64(tid), 16)})
4005
4006 omciLayer := &omci.OMCI{
4007 TransactionID: tid,
4008 MessageType: omci.SynchronizeTimeRequestType,
4009 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4010 // Length: 0x28, // Optional, defaults to 40 octets
4011 }
4012 utcTime := time.Now().UTC()
4013 request := &omci.SynchronizeTimeRequest{
4014 MeBasePacket: omci.MeBasePacket{
4015 EntityClass: me.OnuGClassID,
4016 // Default Instance ID is 0
4017 },
4018 Year: uint16(utcTime.Year()),
4019 Month: uint8(utcTime.Month()),
4020 Day: uint8(utcTime.Day()),
4021 Hour: uint8(utcTime.Hour()),
4022 Minute: uint8(utcTime.Minute()),
4023 Second: uint8(utcTime.Second()),
4024 }
4025
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004026 pkt, err := SerializeOmciLayer(ctx, omciLayer, request)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004027 if err != nil {
4028 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
4029 "device-id": oo.deviceID})
4030 return err
4031 }
4032
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004033 omciRxCallbackPair := CallbackPair{CbKey: tid,
4034 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004035 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004036 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004037 if err != nil {
4038 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
4039 "device-id": oo.deviceID})
4040 return err
4041 }
4042 logger.Debug(ctx, "send synchronize time request done")
4043 return nil
4044}
4045
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004046// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
4047func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004048 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004049 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004050 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4051 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4052 meParam := me.ParamData{EntityID: entityID}
4053 var meInstance *me.ManagedEntity
4054 var omciErr me.OmciErrors
4055 if upstream {
4056 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
4057 } else {
4058 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
4059 }
4060 if omciErr.GetError() == nil {
4061 var omciLayer *omci.OMCI
4062 var msgLayer gopacket.SerializableLayer
4063 var err error
4064 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004065 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4066 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004067 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004068 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4069 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004070 }
4071 if err != nil {
4072 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
4073 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004074 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004075 }
4076
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004077 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004078 if err != nil {
4079 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
4080 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004081 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004082 }
4083
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004084 omciRxCallbackPair := CallbackPair{CbKey: tid,
4085 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004086 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004087 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004088 if err != nil {
4089 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
4090 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004091 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004092 }
4093 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
4094 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004095 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004096 }
4097 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
4098 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 +03004099 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004100}
4101
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004102// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
4103func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004104 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004105 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004106 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4107 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4108 meParam := me.ParamData{EntityID: entityID}
4109 var meInstance *me.ManagedEntity
4110 var omciErr me.OmciErrors
4111 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
4112
4113 if omciErr.GetError() == nil {
4114 var omciLayer *omci.OMCI
4115 var msgLayer gopacket.SerializableLayer
4116 var err error
4117 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004118 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4119 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004120 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004121 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4122 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004123 }
4124 if err != nil {
4125 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4126 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004127 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004128 }
4129
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004130 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004131 if err != nil {
4132 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4133 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004134 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004135 }
4136
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004137 omciRxCallbackPair := CallbackPair{CbKey: tid,
4138 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004139 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004140 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004141 if err != nil {
4142 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4143 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004144 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004145 }
4146 logger.Debugw(ctx, "send ethernet uni history data ME done",
4147 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004148 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004149 }
4150 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4151 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004152 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004153}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004154
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004155// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4156func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004157 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004158 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004159 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4160 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4161 meParam := me.ParamData{EntityID: entityID}
4162 var meInstance *me.ManagedEntity
4163 var omciErr me.OmciErrors
4164 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4165
4166 if omciErr.GetError() == nil {
4167 var omciLayer *omci.OMCI
4168 var msgLayer gopacket.SerializableLayer
4169 var err error
4170 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004171 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4172 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004173 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004174 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4175 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004176 }
4177 if err != nil {
4178 logger.Errorw(ctx, "Cannot encode fec history data ME",
4179 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004180 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004181 }
4182
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004183 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004184 if err != nil {
4185 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4186 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004187 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004188 }
4189
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004190 omciRxCallbackPair := CallbackPair{CbKey: tid,
4191 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004192 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004193 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004194 if err != nil {
4195 logger.Errorw(ctx, "Cannot send fec history data ME",
4196 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004197 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004198 }
4199 logger.Debugw(ctx, "send fec history data ME done",
4200 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004201 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004202 }
4203 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4204 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004205 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004206}
4207
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004208// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4209func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004210 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004211 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004212 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4213 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4214 meParam := me.ParamData{EntityID: entityID}
4215 var meInstance *me.ManagedEntity
4216 var omciErr me.OmciErrors
4217 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4218
4219 if omciErr.GetError() == nil {
4220 var omciLayer *omci.OMCI
4221 var msgLayer gopacket.SerializableLayer
4222 var err error
4223 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004224 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4225 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004226 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004227 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4228 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004229 }
4230 if err != nil {
4231 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4232 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004233 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004234 }
4235
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004236 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004237 if err != nil {
4238 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4239 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004240 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004241 }
4242
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004243 omciRxCallbackPair := CallbackPair{CbKey: tid,
4244 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004245 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004246 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004247 if err != nil {
4248 logger.Errorw(ctx, "Cannot send gemport history data ME",
4249 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004250 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004251 }
4252 logger.Debugw(ctx, "send gemport history data ME done",
4253 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004254 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004255 }
4256 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4257 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004258 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004259}
4260
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004261// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4262func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004263 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004264 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004265 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4266 "SequNo": strconv.FormatInt(int64(tid), 16),
4267 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4268
4269 omciLayer := &omci.OMCI{
4270 TransactionID: tid,
4271 MessageType: omci.StartSoftwareDownloadRequestType,
4272 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4273 // Length: 0x28, // Optional, defaults to 40 octets
4274 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004275 if aIsExtendedOmci {
4276 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4277 }
mpagenko80622a52021-02-09 16:53:23 +00004278 request := &omci.StartSoftwareDownloadRequest{
4279 MeBasePacket: omci.MeBasePacket{
4280 EntityClass: me.SoftwareImageClassID,
4281 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004282 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004283 },
4284 WindowSize: aDownloadWindowSize,
4285 ImageSize: aFileLen,
4286 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4287 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4288 }
4289
4290 var options gopacket.SerializeOptions
4291 options.FixLengths = true
4292 buffer := gopacket.NewSerializeBuffer()
4293 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4294 if err != nil {
4295 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4296 "device-id": oo.deviceID})
4297 return err
4298 }
4299 outgoingPacket := buffer.Bytes()
4300
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004301 omciRxCallbackPair := CallbackPair{CbKey: tid,
4302 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004303 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004304 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004305 if err != nil {
4306 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4307 "device-id": oo.deviceID})
4308 return err
4309 }
4310 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004311 return nil
4312}
4313
kesavand011d5162021-11-25 19:21:06 +05304314// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4315//Before invoking this function the oo.mutexTid needs to be be locked so that
4316//GetOnuSwSecNextTid can be invoked without further locking
4317func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4318 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004319 omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) {
kesavand011d5162021-11-25 19:21:06 +05304320 //onuswsections uses only low prioirity tids
4321 tid := oo.GetOnuSwSecNextTid()
4322 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4323 "SequNo": strconv.FormatInt(int64(tid), 16),
4324 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4325
4326 var omciTxReq OmciTransferStructure
4327 msgType := omci.DownloadSectionRequestType
4328
4329 if aAckRequest > 0 {
4330 msgType = omci.DownloadSectionRequestWithResponseType
4331
4332 }
4333 omciLayer := &omci.OMCI{
4334 TransactionID: tid,
4335 MessageType: msgType,
4336 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4337 // Length: 0x28, // Optional, defaults to 40 octets
4338 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004339 if aIsExtendedOmci {
4340 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4341 }
kesavand011d5162021-11-25 19:21:06 +05304342 localSectionData := make([]byte, len(aSection))
4343
4344 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4345 request := &omci.DownloadSectionRequest{
4346 MeBasePacket: omci.MeBasePacket{
4347 EntityClass: me.SoftwareImageClassID,
4348 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004349 Extended: aIsExtendedOmci,
kesavand011d5162021-11-25 19:21:06 +05304350 },
4351 SectionNumber: aDownloadSectionNo,
4352 SectionData: localSectionData,
4353 }
4354
4355 var options gopacket.SerializeOptions
4356 options.FixLengths = true
4357 buffer := gopacket.NewSerializeBuffer()
4358 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4359 if err != nil {
4360 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4361 "device-id": oo.deviceID})
4362 return omciTxReq, err
4363 }
4364 outgoingPacket := buffer.Bytes()
4365
4366 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4367
4368 if aAckRequest > 0 {
4369 // only the last section should have a timeout as an ack is required only for the last section of the window
4370 omciTxReq = OmciTransferStructure{
4371 withFramePrint: true,
4372 OnuSwWindow: omciMsgsPerWindow,
4373 }
4374 return omciTxReq, nil
4375 }
4376
4377 return omciTxReq, nil
4378}
4379
4380//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4381func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4382 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4383 if aOmciTxRequest.OnuSwWindow == nil {
4384 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4385 log.Fields{"device-id": oo.deviceID})
4386 return
4387
4388 }
4389
4390 tid := oo.GetOnuSwSecLastTid()
4391 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4392 omciRxCallbackPair := CallbackPair{CbKey: tid,
4393 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4394 }
4395
4396 aOmciTxRequest.cbPair = omciRxCallbackPair
4397 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4398 oo.mutexRxSchedMap.Lock()
4399 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4400 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4401 oo.mutexRxSchedMap.Unlock()
4402
4403 chSuccess := make(chan bool)
4404 aOmciTxRequest.chSuccess = chSuccess
4405 aOmciTxRequest.timeout = aTimeout
4406 aOmciTxRequest.retries = CDefaultRetries
4407
4408 //tid := aOmciTxRequest.cbPair.CbKey
4409 oo.mutexMonReq.Lock()
4410 oo.monitoredRequests[tid] = aOmciTxRequest
4411 oo.mutexMonReq.Unlock()
4412
4413 retries := aOmciTxRequest.retries
4414 retryCounter := 0
4415 if aTimeout == 0 {
4416 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4417 return
4418 }
4419loop:
4420 for retryCounter <= retries {
4421 // the onu sw sections are enqueued only to the low priority queue
4422 oo.mutexLowPrioTxQueue.Lock()
4423 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4424 oo.mutexLowPrioTxQueue.Unlock()
4425
4426 go oo.sendQueuedRequests(ctx)
4427
4428 select {
4429 case success := <-chSuccess:
4430 if success {
4431 logger.Debugw(ctx, "reqMon: response received in time",
4432 log.Fields{"tid": tid, "device-id": oo.deviceID})
4433 } else {
4434 logger.Debugw(ctx, "reqMon: wait for response aborted",
4435 log.Fields{"tid": tid, "device-id": oo.deviceID})
4436 }
4437 break loop
4438 case <-time.After(time.Duration(aTimeout) * time.Second):
4439 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004440 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
kesavand011d5162021-11-25 19:21:06 +05304441 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004442 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
kesavand011d5162021-11-25 19:21:06 +05304443 break loop
4444 } else {
4445 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4446 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4447 }
4448 }
4449 retryCounter++
4450 }
4451 oo.mutexMonReq.Lock()
4452 delete(oo.monitoredRequests, tid)
4453 oo.mutexMonReq.Unlock()
4454}
4455
4456func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
4457 if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil {
4458 lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4459 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
4460 "TxOmciMessage": hex.EncodeToString(lastSection),
4461 "device-id": oo.deviceID,
4462 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4463 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4464 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4465 }
4466 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4467 if sendErr != nil {
4468 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
4469 return sendErr
4470 }
4471 return nil
4472}
4473
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004474// SendDownloadSection sends DownloadSectionRequestWithResponse
4475func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004476 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004477 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004478 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4479 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004480 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004481
4482 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4483 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004484 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004485 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004486 if aAckRequest > 0 {
4487 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004488 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004489 }
mpagenko80622a52021-02-09 16:53:23 +00004490 omciLayer := &omci.OMCI{
4491 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004492 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004493 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4494 // Length: 0x28, // Optional, defaults to 40 octets
4495 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004496 if aIsExtendedOmci {
4497 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4498 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304499 localSectionData := make([]byte, len(aSection))
4500
mpagenko15ff4a52021-03-02 10:09:20 +00004501 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004502 request := &omci.DownloadSectionRequest{
4503 MeBasePacket: omci.MeBasePacket{
4504 EntityClass: me.SoftwareImageClassID,
4505 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004506 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004507 },
4508 SectionNumber: aDownloadSectionNo,
4509 SectionData: localSectionData,
4510 }
4511
4512 var options gopacket.SerializeOptions
4513 options.FixLengths = true
4514 buffer := gopacket.NewSerializeBuffer()
4515 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4516 if err != nil {
4517 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4518 "device-id": oo.deviceID})
4519 return err
4520 }
4521 outgoingPacket := buffer.Bytes()
4522
mpagenko15ff4a52021-03-02 10:09:20 +00004523 //for initial debug purpose overrule the requested print state for some frames
4524 printFrame := aPrint
4525 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4526 printFrame = true
4527 }
4528
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004529 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004530 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4531 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004532 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004533 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004534 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004535 if err != nil {
4536 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4537 "device-id": oo.deviceID})
4538 return err
4539 }
4540 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004541 return nil
4542}
4543
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004544//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4545func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004546 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004547 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004548 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4549 "SequNo": strconv.FormatInt(int64(tid), 16),
4550 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4551
mpagenko15ff4a52021-03-02 10:09:20 +00004552 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004553 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004554 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004555 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4556 // Length: 0x28, // Optional, defaults to 40 octets
4557 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004558 if aIsExtendedOmci {
4559 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4560 }
mpagenko15ff4a52021-03-02 10:09:20 +00004561 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004562 MeBasePacket: omci.MeBasePacket{
4563 EntityClass: me.SoftwareImageClassID,
4564 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004565 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004566 },
mpagenko15ff4a52021-03-02 10:09:20 +00004567 CRC32: aImageCrc,
4568 ImageSize: aFileLen,
4569 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4570 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004571 }
mpagenko15ff4a52021-03-02 10:09:20 +00004572
4573 var options gopacket.SerializeOptions
4574 options.FixLengths = true
4575 buffer := gopacket.NewSerializeBuffer()
4576 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4577 if err != nil {
4578 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004579 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004580 return err
mpagenko80622a52021-02-09 16:53:23 +00004581 }
mpagenko15ff4a52021-03-02 10:09:20 +00004582 outgoingPacket := buffer.Bytes()
4583
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004584 omciRxCallbackPair := CallbackPair{CbKey: tid,
4585 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004586 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004587 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004588 if err != nil {
4589 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4590 "device-id": oo.deviceID})
4591 return err
4592 }
4593 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004594 return nil
4595}
4596
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004597// SendActivateSoftware sends ActivateSoftwareRequest
4598func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004599 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004600 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004601 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4602 "SequNo": strconv.FormatInt(int64(tid), 16),
4603 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4604
4605 omciLayer := &omci.OMCI{
4606 TransactionID: tid,
4607 MessageType: omci.ActivateSoftwareRequestType,
4608 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4609 // Length: 0x28, // Optional, defaults to 40 octets
4610 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004611 if aIsExtendedOmci {
4612 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4613 }
mpagenko80622a52021-02-09 16:53:23 +00004614 request := &omci.ActivateSoftwareRequest{
4615 MeBasePacket: omci.MeBasePacket{
4616 EntityClass: me.SoftwareImageClassID,
4617 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004618 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004619 },
4620 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4621 }
4622
4623 var options gopacket.SerializeOptions
4624 options.FixLengths = true
4625 buffer := gopacket.NewSerializeBuffer()
4626 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4627 if err != nil {
4628 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4629 "device-id": oo.deviceID})
4630 return err
4631 }
4632 outgoingPacket := buffer.Bytes()
4633
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004634 omciRxCallbackPair := CallbackPair{CbKey: tid,
4635 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004636 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004637 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004638 if err != nil {
4639 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4640 "device-id": oo.deviceID})
4641 return err
4642 }
4643 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004644 return nil
4645}
mpagenko80622a52021-02-09 16:53:23 +00004646
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004647// SendCommitSoftware sends CommitSoftwareRequest
4648func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004649 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004650 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004651 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4652 "SequNo": strconv.FormatInt(int64(tid), 16),
4653 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4654
4655 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004656 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004657 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004658 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4659 // Length: 0x28, // Optional, defaults to 40 octets
4660 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004661 if aIsExtendedOmci {
4662 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4663 }
mpagenko15ff4a52021-03-02 10:09:20 +00004664 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004665 MeBasePacket: omci.MeBasePacket{
4666 EntityClass: me.SoftwareImageClassID,
4667 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004668 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004669 },
mpagenko80622a52021-02-09 16:53:23 +00004670 }
mpagenko15ff4a52021-03-02 10:09:20 +00004671
4672 var options gopacket.SerializeOptions
4673 options.FixLengths = true
4674 buffer := gopacket.NewSerializeBuffer()
4675 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4676 if err != nil {
4677 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004678 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004679 return err
mpagenko80622a52021-02-09 16:53:23 +00004680 }
mpagenko15ff4a52021-03-02 10:09:20 +00004681 outgoingPacket := buffer.Bytes()
4682
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004683 omciRxCallbackPair := CallbackPair{CbKey: tid,
4684 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004685 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004686 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004687 if err != nil {
4688 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4689 "device-id": oo.deviceID})
4690 return err
4691 }
4692 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004693 return nil
4694}
4695
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004696//SendSelfTestReq sends TestRequest
4697func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4698 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004699 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4700 "SequNo": strconv.FormatInt(int64(tid), 16),
4701 "InstId": strconv.FormatInt(int64(instdID), 16)})
4702 omciLayer := &omci.OMCI{
4703 TransactionID: tid,
4704 MessageType: omci.TestRequestType,
4705 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4706 // Length: 0x28, // Optional, defaults to 40 octets
4707 }
4708
4709 var request *omci.OpticalLineSupervisionTestRequest
4710 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004711 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004712 request = &omci.OpticalLineSupervisionTestRequest{
4713 MeBasePacket: omci.MeBasePacket{
4714 EntityClass: classID,
4715 EntityInstance: instdID,
4716 },
4717 SelectTest: uint8(7), // self test
4718 GeneralPurposeBuffer: uint16(0),
4719 VendorSpecificParameters: uint16(0),
4720 }
4721 default:
4722 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4723 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4724 }
4725 // Test serialization back to former string
4726 var options gopacket.SerializeOptions
4727 options.FixLengths = true
4728
4729 buffer := gopacket.NewSerializeBuffer()
4730 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4731 if err != nil {
4732 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4733 "device-id": oo.deviceID})
4734 return err
4735 }
4736 outgoingPacket := buffer.Bytes()
4737
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004738 omciRxCallbackPair := CallbackPair{CbKey: tid,
4739 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004740 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004741 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004742 if err != nil {
4743 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4744 "device-id": oo.deviceID})
4745 return err
4746 }
4747 logger.Debug(ctx, "send self test request done")
4748 return nil
4749}
4750
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004751//nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004752func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4753
4754 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4755 if err != nil {
4756 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4757 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4758 }
4759 msgLayer := (*packet).Layer(nextLayer)
4760 if msgLayer != nil {
4761 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4762 if failure := (*packet).ErrorLayer(); failure != nil {
4763 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4764 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4765 // can examine for UnkonwnMEs and UnknownAttributes
4766 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
4767 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4768 return false, nil
4769 } else if nextLayer == omci.LayerTypeGetResponse {
4770 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4771 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4772 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4773 if unknownAttrLayer != nil {
4774 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4775 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4776 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4777 }
4778 }
4779 }
4780 }
4781 // Try to decode any further error information
4782 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4783 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4784 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4785 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4786 }
4787 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4788 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4789 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4790 }
4791 } else if failure := (*packet).ErrorLayer(); failure != nil {
4792 // message layer could not be decoded, but at least check if additional failure information is available
4793 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004794 errMsg := decodeFailure.String()
4795 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4796 if strings.Contains(strings.ToLower(errMsg), "table decode") {
4797 // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass
4798 // so that later processing can deal with it
4799 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass",
4800 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4801 return false, nil
4802 }
4803 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004804 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004805 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg})
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004806 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4807 }
4808 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4809 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4810 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4811 } else {
4812 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4813 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4814 }
4815
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004816 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004817 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004818 switch nextLayer {
4819 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004820 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4821 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004822 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004823 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004824 }
4825 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004826 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4827 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004828 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004829 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004830 }
4831 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004832 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4833 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004834 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004835 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004836 }
4837 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004838 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4839 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004840 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004841 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004842 }
4843 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004844 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4845 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004846 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004847 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004848 }
4849 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004850 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4851 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004852 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004853 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004854 }
4855 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004856 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4857 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004858 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004859 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004860 }
4861 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004862 }
4863 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004864 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004865}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004866
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004867func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004868 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004869 if timeout == 0 {
4870 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004871 // enqueue
4872 if aOmciTxRequest.highPrio {
4873 oo.mutexHighPrioTxQueue.Lock()
4874 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4875 oo.mutexHighPrioTxQueue.Unlock()
4876 } else {
4877 oo.mutexLowPrioTxQueue.Lock()
4878 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4879 oo.mutexLowPrioTxQueue.Unlock()
4880 }
4881 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004882 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004883 //the supervised sending with waiting on the response (based on TID) is called in background
4884 // to avoid blocking of the sender for the complete OMCI handshake procedure
4885 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4886 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4887 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004888 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004889}
4890
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004891func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004892 chSuccess := make(chan bool)
4893 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004894 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004895 oo.mutexMonReq.Lock()
4896 oo.monitoredRequests[tid] = aOmciTxRequest
4897 oo.mutexMonReq.Unlock()
4898
4899 retries := aOmciTxRequest.retries
4900 retryCounter := 0
4901loop:
4902 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004903 // enqueue
4904 if aOmciTxRequest.highPrio {
4905 oo.mutexHighPrioTxQueue.Lock()
4906 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4907 oo.mutexHighPrioTxQueue.Unlock()
4908 } else {
4909 oo.mutexLowPrioTxQueue.Lock()
4910 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4911 oo.mutexLowPrioTxQueue.Unlock()
4912 }
4913 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004914
4915 select {
4916 case success := <-chSuccess:
4917 if success {
4918 logger.Debugw(ctx, "reqMon: response received in time",
4919 log.Fields{"tid": tid, "device-id": oo.deviceID})
4920 } else {
4921 logger.Debugw(ctx, "reqMon: wait for response aborted",
4922 log.Fields{"tid": tid, "device-id": oo.deviceID})
4923 }
4924 break loop
4925 case <-time.After(time.Duration(aTimeout) * time.Second):
4926 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004927 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
mpagenko7455fd42021-06-10 16:25:55 +00004928 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004929 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
mpagenko7455fd42021-06-10 16:25:55 +00004930 break loop
4931 } else {
4932 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4933 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4934 }
4935 }
4936 retryCounter++
4937 }
4938 oo.mutexMonReq.Lock()
4939 delete(oo.monitoredRequests, tid)
4940 oo.mutexMonReq.Unlock()
4941}
4942
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004943//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004944func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004945 logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004946 oo.mutexMonReq.RLock()
4947 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004948 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4949 select {
4950 case oo.monitoredRequests[k].chSuccess <- false:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004951 logger.Debugw(ctx, "send cancellation on omciRespChannel",
4952 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004953 default:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004954 logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
4955 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004956 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004957 }
4958 oo.mutexMonReq.RUnlock()
4959}
4960
4961//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4962//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004963func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4964 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004965}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304966
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004967// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4968func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304969 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004970 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304971 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4972 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4973
4974 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004975 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304976 }
4977 var meInstance *me.ManagedEntity
4978 var omciErr me.OmciErrors
4979 if classID == me.EthernetFrameExtendedPmClassID {
4980 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4981 } else {
4982 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4983 }
4984
4985 if omciErr.GetError() == nil {
4986 var omciLayer *omci.OMCI
4987 var msgLayer gopacket.SerializableLayer
4988 var err error
4989 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004990 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4991 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304992 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004993 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4994 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304995 }
4996 if err != nil {
4997 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4998 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4999 return nil, err
5000 }
5001
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005002 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305003 if err != nil {
5004 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
5005 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5006 return nil, err
5007 }
5008
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005009 omciRxCallbackPair := CallbackPair{CbKey: tid,
5010 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305011 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005012 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305013 if err != nil {
5014 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5015 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5016 return nil, err
5017 }
5018 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
5019 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5020 return meInstance, nil
5021 }
5022 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5023 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5024 return nil, omciErr.GetError()
5025}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005026
5027// RLockMutexMonReq lock read access to monitoredRequests
5028func (oo *OmciCC) RLockMutexMonReq() {
5029 oo.mutexMonReq.RLock()
5030}
5031
5032// RUnlockMutexMonReq unlock read access to monitoredRequests
5033func (oo *OmciCC) RUnlockMutexMonReq() {
5034 oo.mutexMonReq.RUnlock()
5035}
5036
5037// GetMonitoredRequest get OmciTransferStructure for an omciTransID
5038func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
5039 value, exist = oo.monitoredRequests[omciTransID]
5040 return value, exist
5041}
5042
5043// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
5044func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
5045 oo.monitoredRequests[omciTransID].chSuccess <- chVal
5046}
Himani Chawlaee10b542021-09-20 16:46:40 +05305047
5048// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
5049func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
5050 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
5051 tid := oo.GetNextTid(highPrio)
5052 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
5053 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
5054
5055 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005056 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05305057 }
5058 var meInstance *me.ManagedEntity
5059 var omciErr me.OmciErrors
5060 if classID == me.EthernetFrameExtendedPmClassID {
5061 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
5062 } else {
5063 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
5064 }
5065
5066 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00005067 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05305068 if err != nil {
5069 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5070 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5071 return nil, err
5072 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005073 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawlaee10b542021-09-20 16:46:40 +05305074 if err != nil {
5075 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
5076 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5077 return nil, err
5078 }
5079 omciRxCallbackPair := CallbackPair{
5080 CbKey: tid,
5081 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
5082 }
5083 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
5084 if err != nil {
5085 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5086 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5087 return nil, err
5088 }
5089 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
5090 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5091 return meInstance, nil
5092 }
5093 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5094 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5095 return nil, omciErr.GetError()
5096}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00005097
5098// PrepareForGarbageCollection - remove references to prepare for garbage collection
5099func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
5100 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
5101 oo.pBaseDeviceHandler = nil
5102 oo.pOnuDeviceEntry = nil
5103 oo.pOnuAlarmManager = nil
5104}