blob: 45ee42905f17f276777c477c1326d9cbb01cac83 [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
962func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530963 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
964 request := &omci.GetAllAlarmsRequest{
965 MeBasePacket: omci.MeBasePacket{
966 EntityClass: me.OnuDataClassID,
967 },
968 AlarmRetrievalMode: byte(alarmRetreivalMode),
969 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000970 tid := oo.GetNextTid(highPrio)
971 pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530972 if err != nil {
973 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
974 "Err": err, "device-id": oo.deviceID})
975 return err
976 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000977 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530978
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000979 omciRxCallbackPair := CallbackPair{
980 CbKey: tid,
981 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530982 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000983 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530984}
985
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000986// SendGetAllAlarmNext gets next alarm ME instance
987func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
988 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
989 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +0530990 "alarmUploadSeqNo": alarmUploadSeqNo})
991 request := &omci.GetAllAlarmsNextRequest{
992 MeBasePacket: omci.MeBasePacket{
993 EntityClass: me.OnuDataClassID,
994 },
995 CommandSequenceNumber: alarmUploadSeqNo,
996 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000997 tid := oo.GetNextTid(highPrio)
998 pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530999 if err != nil {
1000 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
1001 "Err": err, "device-id": oo.deviceID})
1002 return err
1003 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001004 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +05301005
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001006 omciRxCallbackPair := CallbackPair{
1007 CbKey: tid,
1008 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301009 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001010 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +05301011}
1012
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001013// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
1014func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1015 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001016 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001017 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001018
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001019 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001020 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001021 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001022 }
1023 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
1024 if omciErr.GetError() == nil {
1025 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001026 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001027 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001028 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001029 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001030 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001031 }
1032
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001033 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001034 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001035 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001036 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001037 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001038 }
1039
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001040 omciRxCallbackPair := CallbackPair{
1041 CbKey: tid,
1042 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001043 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001044 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001045 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001046 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001047 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001048 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001049 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001050 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001051 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001052 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001053 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001054 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001055 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001056}
1057
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001058// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001059// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001060func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1061 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001062 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001063 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001064
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001065 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
1066 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001067 // By now we just use fix values to fire - this is anyway what the python adapter does
1068 // read ONU-2G from DB ???? //TODO!!!
1069 meParams := me.ParamData{
1070 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001071 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001072 }
1073 meInstance, omciErr := me.NewOnu2G(meParams)
1074 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001075 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001076 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001077 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001078 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001079 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001080 }
1081
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001082 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001083 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001084 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001085 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001086 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001087 }
1088
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001089 omciRxCallbackPair := CallbackPair{
1090 CbKey: tid,
1091 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001092 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001093 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001094 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001095 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001096 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001097 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001098 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001099 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001100 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001101 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001102 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001103 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001104 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001105}
1106
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001107// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1108func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1109 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1110 tid := oo.GetNextTid(highPrio)
1111 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001112 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001113 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001114
1115 meParams := me.ParamData{
1116 EntityID: instID,
1117 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001118 me.MacBridgeServiceProfile_Priority: 0x8000,
1119 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1120 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1121 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1122 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001123 },
1124 }
1125
1126 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1127 if omciErr.GetError() == nil {
1128 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001129 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1130 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001131 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001132 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001133 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001134 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001135 }
1136
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001137 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001138 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001139 logger.Errorw(ctx, "Cannot serialize MBSP create", 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 }
1143
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001144 omciRxCallbackPair := CallbackPair{
1145 CbKey: tid,
1146 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001147 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001148 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001149 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001150 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001151 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001152 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001153 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001154 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001155 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001156 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001157 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001158 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001159 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001160}
1161
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001162// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1163func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1164 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1165 tid := oo.GetNextTid(highPrio)
1166 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001167 if idErr != nil {
1168 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1169 "Err": idErr, "device-id": oo.deviceID})
1170 return nil, idErr
1171 }
1172 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001173 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001174
1175 meParams := me.ParamData{
1176 EntityID: instID,
1177 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001178 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1179 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1180 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1181 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001182 },
1183 }
1184 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1185 if omciErr.GetError() == nil {
1186 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001187 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1188 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001189 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001190 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001191 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001192 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001193 }
1194
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001195 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001196 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001197 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001198 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001199 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001200 }
1201
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001202 omciRxCallbackPair := CallbackPair{
1203 CbKey: tid,
1204 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001205 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001206 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001207 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001208 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001209 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001210 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001211 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001212 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001213 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001214 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001215 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001216 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001217 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001218}
1219
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001220// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1221func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1222 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1223 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001224 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001225 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001226 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001227 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001228
1229 // compare python adapter code WA VOL-1311: this is not done here!
1230 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1231 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1232 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001233 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001234 assType = uint8(10) // for VEIP
1235 }
1236 meParams := me.ParamData{
1237 EntityID: instID,
1238 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001239 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1240 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001241 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001242 },
1243 }
1244 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1245 if omciErr.GetError() == nil {
1246 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001247 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1248 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001249 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001250 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001251 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001252 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001253 }
1254
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001255 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001256 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001257 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001258 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001259 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001260 }
1261
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001262 omciRxCallbackPair := CallbackPair{
1263 CbKey: tid,
1264 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001265 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001266 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001267 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001268 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001269 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001270 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001271 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001272 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001273 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001274 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001276 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001277 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001278}
1279
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001280// SendSetOnuGLS sets OnuG ME instance
1281func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001282 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001283 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001284 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001285 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001286
1287 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1288 meParams := me.ParamData{
1289 EntityID: 0,
1290 Attributes: requestedAttributes,
1291 }
1292 meInstance, omciErr := me.NewOnuG(meParams)
1293 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001294 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001295 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001296 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001297 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001298 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001299 }
1300
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001301 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001302 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001303 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001304 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001305 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001306 }
1307
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001308 omciRxCallbackPair := CallbackPair{
1309 CbKey: tid,
1310 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001311 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001312 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001313 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001314 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001315 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001316 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001317 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001318 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001319 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001320 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001321 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001322 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001323 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001324}
1325
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001326// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1327func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001328 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001329 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001330 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001331 "SequNo": strconv.FormatInt(int64(tid), 16)})
1332
1333 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1334 meParams := me.ParamData{
1335 EntityID: aInstNo,
1336 Attributes: requestedAttributes,
1337 }
1338 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1339 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001340 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001341 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001342 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001343 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001344 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001345 }
1346
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001347 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001348 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001349 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001350 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001351 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001352 }
1353
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001354 omciRxCallbackPair := CallbackPair{
1355 CbKey: tid,
1356 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001357 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001358 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001359 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001360 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001361 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001362 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001363 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001364 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001365 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001366 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001367 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001368 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001369 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001370}
1371
1372/* UniG obsolete by now, left here in case it should be needed once again
1373 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301374func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001375 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001376 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001377 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001379
1380 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1381 meParams := me.ParamData{
1382 EntityID: aInstNo,
1383 Attributes: requestedAttributes,
1384 }
1385 meInstance, omciErr := me.NewUniG(meParams)
1386 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001387 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001388 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001389 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001390 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001391 return nil
1392 }
1393
1394 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1395 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001396 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001397 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001398 return nil
1399 }
1400
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001401 omciRxCallbackPair := CallbackPair{
1402 CbKey: tid,
1403 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001404 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001405 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001406 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001407 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001408 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001409 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001410 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001411 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001412 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001413 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001414 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001415 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001416 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001417}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001418*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001419
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001420// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1421func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001422 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001423 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001424 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001426
1427 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1428 meParams := me.ParamData{
1429 EntityID: aInstNo,
1430 Attributes: requestedAttributes,
1431 }
1432 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1433 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001434 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001435 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001436 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001437 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001438 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001439 }
1440
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001441 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001442 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001443 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001444 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001445 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001446 }
1447
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001448 omciRxCallbackPair := CallbackPair{
1449 CbKey: tid,
1450 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001451 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001452 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001453 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001454 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001455 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001456 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001457 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001458 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001459 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001460 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001461 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001462 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001463 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001464}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001465
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001466// SendGetMe gets ME instance
1467func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001468 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001469
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001470 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001471 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001472 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001473
1474 meParams := me.ParamData{
1475 EntityID: entityID,
1476 Attributes: requestedAttributes,
1477 }
1478 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1479 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301480 meClassIDName := meInstance.GetName()
mpagenko836a1fd2021-11-01 16:12:42 +00001481 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001482 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001483 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 +03001484 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001485 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001486 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001487 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001488 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001489 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001490 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001491 omciRxCallbackPair := CallbackPair{
1492 CbKey: tid,
1493 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001494 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001495 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001496 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001497 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001498 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001499 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001500 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001501 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001502 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001503 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001504 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001505}
1506
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001507// SendGetMeWithAttributeMask gets ME instance with attribute mask
1508func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301509 timeout int, highPrio bool, rxChan chan Message) error {
1510
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001511 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301512 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1513 "SequNo": strconv.FormatInt(int64(tid), 16)})
1514
1515 request := &omci.GetRequest{
1516 MeBasePacket: omci.MeBasePacket{
1517 EntityInstance: entityID,
1518 EntityClass: classID,
1519 },
1520 AttributeMask: requestedAttributesMask,
1521 }
1522
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001523 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301524 if err != nil {
1525 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1526 return err
1527 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001528 omciRxCallbackPair := CallbackPair{
1529 CbKey: tid,
1530 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301531 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001532 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301533 if err != nil {
1534 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1535 return err
1536 }
1537 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1538 return nil
1539}
1540
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001541// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1542func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001543 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001544 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001545 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001546 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1547
1548 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001549 EntityID: aInstID,
1550 Attributes: me.AttributeValueMap{
1551 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001552 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1553 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1554 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1555 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1556 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1557 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1558 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1559 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1560 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001561 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001562 }
1563 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1564 if omciErr.GetError() == nil {
1565 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001566 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1567 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001568 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001569 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001570 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001571 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001572 }
1573
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001574 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001575 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001576 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001577 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001578 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001579 }
1580
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001581 omciRxCallbackPair := CallbackPair{
1582 CbKey: tid,
1583 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001584 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001585 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001586 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001587 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001588 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001589 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001590 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001591 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001592 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001593 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001594 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001595 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001596 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001597}
1598
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001599// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1600func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001601 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001602 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001603 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001604 "SequNo": strconv.FormatInt(int64(tid), 16),
1605 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1606
1607 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1608 if omciErr.GetError() == nil {
1609 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001610 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1611 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001612 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001613 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001614 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001615 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001616 }
1617
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001618 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001619 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001620 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001621 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001622 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001623 }
1624
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001625 omciRxCallbackPair := CallbackPair{
1626 CbKey: tid,
1627 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001628 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001629 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001630 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001631 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001632 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001633 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001634 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001635 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001636 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001637 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001638 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001639 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001640 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001641}
1642
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001643// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1644func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001645 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001646 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001647 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001648 "SequNo": strconv.FormatInt(int64(tid), 16),
1649 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1650
1651 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1652 if omciErr.GetError() == nil {
1653 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001654 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1655 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001656 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001657 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001658 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001659 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001660 }
1661
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001662 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001663 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001664 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001665 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001666 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001667 }
1668
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001669 omciRxCallbackPair := CallbackPair{
1670 CbKey: tid,
1671 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001672 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001673 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001674 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001675 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001676 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001677 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001678 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001679 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001680 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001681 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001682 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001683 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001684 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001685}
1686
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001687// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1688func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1689 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001690 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1691 "SequNo": strconv.FormatInt(int64(tid), 16),
1692 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1693
1694 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1695 if omciErr.GetError() == nil {
1696 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001697 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1698 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001699 if err != nil {
1700 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1701 "Err": err, "device-id": oo.deviceID})
1702 return nil, err
1703 }
1704
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001705 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001706 if err != nil {
1707 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1708 "Err": err, "device-id": oo.deviceID})
1709 return nil, err
1710 }
1711
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001712 omciRxCallbackPair := CallbackPair{
1713 CbKey: tid,
1714 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001715 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001716 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001717 if err != nil {
1718 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1719 "Err": err, "device-id": oo.deviceID})
1720 return nil, err
1721 }
1722 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1723 return meInstance, nil
1724 }
1725 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1726 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1727 return nil, omciErr.GetError()
1728}
1729
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001730// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1731func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001732 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001733 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001734 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001735 "SequNo": strconv.FormatInt(int64(tid), 16),
1736 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1737
1738 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1739 if omciErr.GetError() == nil {
1740 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001741 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1742 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001743 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001744 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001745 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001746 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001747 }
1748
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001749 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001750 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001751 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001752 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001753 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001754 }
1755
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001756 omciRxCallbackPair := CallbackPair{
1757 CbKey: tid,
1758 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001759 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001760 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001761 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001762 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001763 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001764 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001765 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001766 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001767 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001768 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001769 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001770 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001771 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001772}
1773
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001774// SendSetTcontVar sets TCont ME instance
1775func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001776 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001777 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001778 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001779 "SequNo": strconv.FormatInt(int64(tid), 16),
1780 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1781
1782 meInstance, omciErr := me.NewTCont(params[0])
1783 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001784 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001785 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001786 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001787 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001788 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001789 }
1790
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001791 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001792 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001793 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001794 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001795 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001796 }
1797
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001798 omciRxCallbackPair := CallbackPair{
1799 CbKey: tid,
1800 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001801 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001802 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001803 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001804 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001805 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001806 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001807 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001808 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001809 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001810 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001811 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001812 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001813 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001814}
1815
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001816// SendSetPrioQueueVar sets PriorityQueue ME instance
1817func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001818 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001819 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001820 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001821 "SequNo": strconv.FormatInt(int64(tid), 16),
1822 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1823
1824 meInstance, omciErr := me.NewPriorityQueue(params[0])
1825 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001826 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001827 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001828 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001829 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001830 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001831 }
1832
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001833 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001834 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001835 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001836 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001837 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001838 }
1839
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001840 omciRxCallbackPair := CallbackPair{
1841 CbKey: tid,
1842 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001843 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001844 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001845 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001846 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001847 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001848 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001849 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001850 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001851 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001852 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001853 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001854 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001855 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001856}
1857
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001858// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1859func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001860 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001861 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001862 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001863 "SequNo": strconv.FormatInt(int64(tid), 16),
1864 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1865
1866 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1867 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001868 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001869 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001870 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001871 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001872 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001873 }
1874
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001875 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001876 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001877 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001878 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001879 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001880 }
1881
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001882 omciRxCallbackPair := CallbackPair{
1883 CbKey: tid,
1884 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001885 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001886 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001887 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001888 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001889 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001890 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001891 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001892 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001893 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001894 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001895 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001896 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001897 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001898}
mpagenkodff5dda2020-08-28 11:52:01 +00001899
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001900// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1901func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001902 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001903 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001904 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001905 "SequNo": strconv.FormatInt(int64(tid), 16),
1906 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1907
1908 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1909 if omciErr.GetError() == nil {
1910 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001911 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1912 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001913 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001914 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001915 "Err": err, "device-id": oo.deviceID})
1916 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1917 // return (dual format) error code that can be used at caller for immediate error treatment
1918 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001919 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001920 }
1921
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001922 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001923 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001924 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001925 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001926 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001927 }
1928
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001929 omciRxCallbackPair := CallbackPair{
1930 CbKey: tid,
1931 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001932 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001933 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001934 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001935 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001936 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001937 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001938 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001939 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001940 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001941 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001942 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001943 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001944 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001945}
1946
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001947// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001948func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001949 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001950 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001951 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001952 "SequNo": strconv.FormatInt(int64(tid), 16),
1953 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1954
1955 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1956 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001957 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1958 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001959 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001960 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001961 "Err": err, "device-id": oo.deviceID})
1962 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1963 // return (dual format) error code that can be used at caller for immediate error treatment
1964 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001965 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001966 }
1967
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001968 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001969 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001970 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001971 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001972 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001973 }
1974
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001975 omciRxCallbackPair := CallbackPair{
1976 CbKey: tid,
1977 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001978 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001979 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001980 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001981 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001982 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001983 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001984 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001985 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001986 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001987 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001988 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001989 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001990 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001991}
1992
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001993// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
1994func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001995 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001996 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001997 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001998 "SequNo": strconv.FormatInt(int64(tid), 16),
1999 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2000
2001 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2002 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002003 //EnhancedMode not yet supported, used with default options
2004 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
2005 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002006 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002007 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002008 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002009 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002010 }
2011
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002012 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002013 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002014 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002015 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002016 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002017 }
2018
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002019 omciRxCallbackPair := CallbackPair{
2020 CbKey: tid,
2021 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002022 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002023 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002024 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002025 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002026 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002027 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002028 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002030 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002031 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002032 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002033 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002034 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002035}
2036
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002037// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
2038func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002039 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002040 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002041 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00002042 "SequNo": strconv.FormatInt(int64(tid), 16),
2043 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2044
2045 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2046 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002047 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00002048 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002049 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002050 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002051 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002052 }
2053
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002054 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002055 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002056 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002057 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002058 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002059 }
2060
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002061 omciRxCallbackPair := CallbackPair{
2062 CbKey: tid,
2063 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002064 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002065 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002066 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002067 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002068 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002069 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002070 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002071 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002072 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002073 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002074 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002075 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002076 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002077}
mpagenko01e726e2020-10-23 09:45:29 +00002078
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002079// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2080func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002081 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002082 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002083 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002084 "SequNo": strconv.FormatInt(int64(tid), 16),
2085 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2086
2087 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2088 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002089 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002090 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002091 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002092 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002093 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002094 }
2095
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002096 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002097 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002098 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002099 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002100 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002101 }
2102
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002103 omciRxCallbackPair := CallbackPair{
2104 CbKey: tid,
2105 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002106 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002107 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002108 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002109 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002110 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002111 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002112 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002113 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002114 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002115 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002116 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002117 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002118 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002119}
2120
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002121// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2122func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002123 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002124 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002125 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002126 "SequNo": strconv.FormatInt(int64(tid), 16),
2127 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2128
2129 meParams := me.ParamData{EntityID: aInstID}
2130 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2131 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002132 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2133 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002134 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002136 "Err": err, "device-id": oo.deviceID})
2137 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2138 // return (dual format) error code that can be used at caller for immediate error treatment
2139 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002140 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002141 }
2142
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002143 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002144 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002145 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002146 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002147 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002148 }
2149
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002150 omciRxCallbackPair := CallbackPair{
2151 CbKey: tid,
2152 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002153 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002154 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002155 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002156 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002157 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002158 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002159 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002160 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002161 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002162 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002163 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002164 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002165 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002166}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002167
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002168// SendCreateTDVar creates TrafficDescriptor ME instance
2169func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2170 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002171 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2172 "SequNo": strconv.FormatInt(int64(tid), 16),
2173 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2174 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2175 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002176 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002177 if err != nil {
2178 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002179 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002180 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002181 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002182 if err != nil {
2183 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002184 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002185 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002186 omciRxCallbackPair := CallbackPair{
2187 CbKey: tid,
2188 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002189 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002190 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002191 if err != nil {
2192 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002193 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002194 }
2195 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002196 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002197 }
2198 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002199 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002200}
2201
2202// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002203func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002204 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002205 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002206 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2207 "SequNo": strconv.FormatInt(int64(tid), 16),
2208 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2209
2210 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2211 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002212 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002213 if err != nil {
2214 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002215 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002216 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002217 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002218 if err != nil {
2219 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002220 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002221 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002222 omciRxCallbackPair := CallbackPair{
2223 CbKey: tid,
2224 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002225 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002226 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002227 if err != nil {
2228 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002229 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002230 }
2231 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002232 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002233 }
2234 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002235 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002236
2237}
2238
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002239// SendDeleteTD - TODO: add comment
2240func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002242 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002243 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2244 "SequNo": strconv.FormatInt(int64(tid), 16),
2245 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2246
2247 meParams := me.ParamData{EntityID: aInstID}
2248 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2249 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002250 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002251 if err != nil {
2252 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002253 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002254 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002255 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002256 if err != nil {
2257 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002258 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002259 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002260 omciRxCallbackPair := CallbackPair{
2261 CbKey: tid,
2262 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002263 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002264 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002265 if err != nil {
2266 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002267 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002268 }
2269 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002270 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002271 }
2272 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002273 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002274
2275}
2276
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002277// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2278func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002279 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002280 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002281 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002282 "SequNo": strconv.FormatInt(int64(tid), 16),
2283 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2284
2285 meParams := me.ParamData{EntityID: aInstID}
2286 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2287 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002288 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2289 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002290 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002291 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002292 "Err": err, "device-id": oo.deviceID})
2293 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2294 // return (dual format) error code that can be used at caller for immediate error treatment
2295 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002296 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002297 }
2298
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002299 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002300 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002301 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002302 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002303 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002304 }
2305
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002306 omciRxCallbackPair := CallbackPair{
2307 CbKey: tid,
2308 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002309 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002310 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002311 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002312 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002313 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002314 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002315 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002316 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002317 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002318 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002319 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002320 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002321 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002322}
2323
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002324// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2325func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002326 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002327 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002328 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002329 "SequNo": strconv.FormatInt(int64(tid), 16),
2330 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2331
2332 meParams := me.ParamData{EntityID: aInstID}
2333 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2334 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002335 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2336 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002337 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002338 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002339 "Err": err, "device-id": oo.deviceID})
2340 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2341 // return (dual format) error code that can be used at caller for immediate error treatment
2342 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002343 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002344 }
2345
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002346 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002347 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002348 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002349 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002350 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002351 }
2352
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002353 omciRxCallbackPair := CallbackPair{
2354 CbKey: tid,
2355 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002356 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002357 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002358 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002359 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002360 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002361 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002362 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002363 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002364 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002365 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002366 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002367 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002368 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002369}
2370
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002371// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2372func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002373 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002374 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002375 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002376 "SequNo": strconv.FormatInt(int64(tid), 16),
2377 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2378
2379 meParams := me.ParamData{EntityID: aInstID}
2380 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2381 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002382 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2383 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002384 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002385 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002386 "Err": err, "device-id": oo.deviceID})
2387 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2388 // return (dual format) error code that can be used at caller for immediate error treatment
2389 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002390 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002391 }
2392
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002393 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002394 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002395 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002396 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002397 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002398 }
2399
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002400 omciRxCallbackPair := CallbackPair{
2401 CbKey: tid,
2402 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002403 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002404 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002405 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002406 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002407 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002408 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002409 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002410 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002411 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002412 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002413 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002414 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002415 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002416}
2417
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002418// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2419func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002420 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002421 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002422 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002423 "SequNo": strconv.FormatInt(int64(tid), 16),
2424 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2425
2426 meParams := me.ParamData{EntityID: aInstID}
2427 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2428 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002429 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2430 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002431 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002432 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002433 "Err": err, "device-id": oo.deviceID})
2434 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2435 // return (dual format) error code that can be used at caller for immediate error treatment
2436 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002437 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002438 }
2439
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002440 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002441 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002442 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002443 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002444 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002445 }
2446
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002447 omciRxCallbackPair := CallbackPair{
2448 CbKey: tid,
2449 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002450 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002451 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002452 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002453 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002454 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002455 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002456 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002457 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002458 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002459 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002460 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002461 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002462 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002463}
2464
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002465// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2466func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002467 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002468 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002469 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002470 "SequNo": strconv.FormatInt(int64(tid), 16),
2471 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2472
2473 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2474 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002475 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2476 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002477 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002478 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002479 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002480 }
2481
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002482 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002483 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002484 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002485 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002486 }
2487
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002488 omciRxCallbackPair := CallbackPair{CbKey: tid,
2489 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002490 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002491 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002492 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002493 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002494 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002495 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002496 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002497 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002498 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002499 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002500 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002501 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002502}
2503
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002504// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2505func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002506 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002507 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002508 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002509 "SequNo": strconv.FormatInt(int64(tid), 16),
2510 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2511
2512 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2513 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002514 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2515 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002517 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002518 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002519 }
2520
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002521 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002522 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002523 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002524 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002525 }
2526
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002527 omciRxCallbackPair := CallbackPair{CbKey: tid,
2528 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002529 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002530 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002531 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002532 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002533 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002534 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002535 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002536 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002537 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002538 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002539 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002540 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002541}
2542
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002543// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2544func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002545 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002546 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002547 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002548 "SequNo": strconv.FormatInt(int64(tid), 16),
2549 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2550
2551 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2552 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002553 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2554 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002555 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002556 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002557 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002558 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002559 }
2560
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002561 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002562 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002563 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002564 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002565 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002566 }
2567
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002568 omciRxCallbackPair := CallbackPair{CbKey: tid,
2569 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002570 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002571 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002572 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002573 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002574 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002575 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002576 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002577 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002578 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002579 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002580 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002581 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002582 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002583}
2584
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002585// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2586func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002587 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002588 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002589 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002590 "SequNo": strconv.FormatInt(int64(tid), 16),
2591 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2592
2593 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2594 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002595 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2596 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002597 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002598 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002599 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002600 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002601 }
2602
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002603 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002604 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002605 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002606 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002607 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002608 }
2609
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002610 omciRxCallbackPair := CallbackPair{CbKey: tid,
2611 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002612 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002613 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002614 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002615 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002616 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002617 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002618 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002619 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002620 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002621 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002622 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002623 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002624 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002625}
2626
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002627// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2628func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002629 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002630 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002631 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002632 "SequNo": strconv.FormatInt(int64(tid), 16),
2633 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2634
2635 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2636 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002637 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2638 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002639 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002640 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002641 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002642 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002643 }
2644
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002645 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002646 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002647 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002648 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002649 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002650 }
2651
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002652 omciRxCallbackPair := CallbackPair{CbKey: tid,
2653 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002654 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002655 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002656 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002657 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002658 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002659 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002660 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002661 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002662 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002663 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002664 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002665 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002666 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002667}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002668
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002669// SendCreateVoipVoiceCTP nolint: unused
2670func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2671 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2672 tid := oo.GetNextTid(highPrio)
2673 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2674 "SequNo": strconv.FormatInt(int64(tid), 16),
2675 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2676
2677 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2678 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002679 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2680 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002681 if err != nil {
2682 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2683 "device-id": oo.deviceID})
2684 return nil, err
2685 }
2686
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002687 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002688 if err != nil {
2689 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2690 "device-id": oo.deviceID})
2691 return nil, err
2692 }
2693
2694 omciRxCallbackPair := CallbackPair{CbKey: tid,
2695 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2696 }
2697 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2698 if err != nil {
2699 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2700 "device-id": oo.deviceID})
2701 return nil, err
2702 }
2703 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2704 return meInstance, nil
2705 }
2706 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2707 "device-id": oo.deviceID})
2708 return nil, omciErr.GetError()
2709}
2710
2711// SendSetVoipVoiceCTP nolint: unused
2712func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2713 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2714 tid := oo.GetNextTid(highPrio)
2715 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2716 "SequNo": strconv.FormatInt(int64(tid), 16),
2717 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2718
2719 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2720 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002721 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2722 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002723 if err != nil {
2724 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2725 "device-id": oo.deviceID})
2726 return nil, err
2727 }
2728
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002729 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002730 if err != nil {
2731 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2732 "device-id": oo.deviceID})
2733 return nil, err
2734 }
2735
2736 omciRxCallbackPair := CallbackPair{CbKey: tid,
2737 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2738 }
2739 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2740 if err != nil {
2741 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2742 "device-id": oo.deviceID})
2743 return nil, err
2744 }
2745 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2746 return meInstance, nil
2747 }
2748 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2749 "device-id": oo.deviceID})
2750 return nil, omciErr.GetError()
2751}
2752
2753// SendDeleteVoipVoiceCTP nolint: unused
2754func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2755 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2756 tid := oo.GetNextTid(highPrio)
2757 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2758 "SequNo": strconv.FormatInt(int64(tid), 16),
2759 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2760
2761 meParams := me.ParamData{EntityID: aInstID}
2762 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2763 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002764 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2765 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002766 if err != nil {
2767 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2768 "Err": err, "device-id": oo.deviceID})
2769 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2770 // return (dual format) error code that can be used at caller for immediate error treatment
2771 // (relevant to all used sendXX() methods and their error conditions)
2772 return nil, err
2773 }
2774
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002775 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002776 if err != nil {
2777 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2778 "Err": err, "device-id": oo.deviceID})
2779 return nil, err
2780 }
2781
2782 omciRxCallbackPair := CallbackPair{
2783 CbKey: tid,
2784 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2785 }
2786 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2787 if err != nil {
2788 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2789 "Err": err, "device-id": oo.deviceID})
2790 return nil, err
2791 }
2792 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2793 return meInstance, nil
2794 }
2795 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2796 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2797 return nil, omciErr.GetError()
2798}
2799
2800// SendCreateVoipMediaProfile nolint: unused
2801func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2802 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2803 tid := oo.GetNextTid(highPrio)
2804 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2805 "SequNo": strconv.FormatInt(int64(tid), 16),
2806 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2807
2808 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2809 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002810 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2811 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002812 if err != nil {
2813 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2814 "device-id": oo.deviceID})
2815 return nil, err
2816 }
2817
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002818 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002819 if err != nil {
2820 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2821 "device-id": oo.deviceID})
2822 return nil, err
2823 }
2824
2825 omciRxCallbackPair := CallbackPair{CbKey: tid,
2826 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2827 }
2828 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2829 if err != nil {
2830 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2831 "device-id": oo.deviceID})
2832 return nil, err
2833 }
2834 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2835 return meInstance, nil
2836 }
2837 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2838 "device-id": oo.deviceID})
2839 return nil, omciErr.GetError()
2840}
2841
2842// SendSetVoipMediaProfile nolint: unused
2843func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2844 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2845 tid := oo.GetNextTid(highPrio)
2846 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2847 "SequNo": strconv.FormatInt(int64(tid), 16),
2848 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2849
2850 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2851 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002852 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2853 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002854 if err != nil {
2855 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2856 "device-id": oo.deviceID})
2857 return nil, err
2858 }
2859
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002860 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002861 if err != nil {
2862 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2863 "device-id": oo.deviceID})
2864 return nil, err
2865 }
2866
2867 omciRxCallbackPair := CallbackPair{CbKey: tid,
2868 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2869 }
2870 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2871 if err != nil {
2872 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2873 "device-id": oo.deviceID})
2874 return nil, err
2875 }
2876 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2877 return meInstance, nil
2878 }
2879 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2880 "device-id": oo.deviceID})
2881 return nil, omciErr.GetError()
2882}
2883
2884// SendDeleteVoipMediaProfile nolint: unused
2885func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2886 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2887 tid := oo.GetNextTid(highPrio)
2888 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2889 "SequNo": strconv.FormatInt(int64(tid), 16),
2890 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2891
2892 meParams := me.ParamData{EntityID: aInstID}
2893 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2894 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002895 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2896 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002897 if err != nil {
2898 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2899 "Err": err, "device-id": oo.deviceID})
2900 return nil, err
2901 }
2902
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002903 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002904 if err != nil {
2905 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2906 "Err": err, "device-id": oo.deviceID})
2907 return nil, err
2908 }
2909
2910 omciRxCallbackPair := CallbackPair{
2911 CbKey: tid,
2912 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2913 }
2914 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2915 if err != nil {
2916 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2917 "Err": err, "device-id": oo.deviceID})
2918 return nil, err
2919 }
2920 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2921 return meInstance, nil
2922 }
2923 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2924 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2925 return nil, omciErr.GetError()
2926}
2927
2928// SendCreateVoiceServiceProfile nolint: unused
2929func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2930 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2931 tid := oo.GetNextTid(highPrio)
2932 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2933 "SequNo": strconv.FormatInt(int64(tid), 16),
2934 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2935
2936 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2937 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002938 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2939 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002940 if err != nil {
2941 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2942 "device-id": oo.deviceID})
2943 return nil, err
2944 }
2945
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002946 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002947 if err != nil {
2948 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2949 "device-id": oo.deviceID})
2950 return nil, err
2951 }
2952
2953 omciRxCallbackPair := CallbackPair{CbKey: tid,
2954 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2955 }
2956 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2957 if err != nil {
2958 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
2959 "device-id": oo.deviceID})
2960 return nil, err
2961 }
2962 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
2963 return meInstance, nil
2964 }
2965 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2966 "device-id": oo.deviceID})
2967 return nil, omciErr.GetError()
2968}
2969
2970// SendSetVoiceServiceProfile nolint: unused
2971func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2972 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2973 tid := oo.GetNextTid(highPrio)
2974 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2975 "SequNo": strconv.FormatInt(int64(tid), 16),
2976 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2977
2978 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2979 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002980 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2981 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002982 if err != nil {
2983 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
2984 "device-id": oo.deviceID})
2985 return nil, err
2986 }
2987
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002988 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002989 if err != nil {
2990 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
2991 "device-id": oo.deviceID})
2992 return nil, err
2993 }
2994
2995 omciRxCallbackPair := CallbackPair{CbKey: tid,
2996 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2997 }
2998 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2999 if err != nil {
3000 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
3001 "device-id": oo.deviceID})
3002 return nil, err
3003 }
3004 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
3005 return meInstance, nil
3006 }
3007 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3008 "device-id": oo.deviceID})
3009 return nil, omciErr.GetError()
3010}
3011
3012// SendDeleteVoiceServiceProfile nolint: unused
3013func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3014 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3015 tid := oo.GetNextTid(highPrio)
3016 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3017 "SequNo": strconv.FormatInt(int64(tid), 16),
3018 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3019
3020 meParams := me.ParamData{EntityID: aInstID}
3021 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
3022 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003023 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3024 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003025 if err != nil {
3026 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
3027 "Err": err, "device-id": oo.deviceID})
3028 return nil, err
3029 }
3030
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003031 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003032 if err != nil {
3033 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
3034 "Err": err, "device-id": oo.deviceID})
3035 return nil, err
3036 }
3037
3038 omciRxCallbackPair := CallbackPair{
3039 CbKey: tid,
3040 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3041 }
3042 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3043 if err != nil {
3044 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
3045 "Err": err, "device-id": oo.deviceID})
3046 return nil, err
3047 }
3048 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
3049 return meInstance, nil
3050 }
3051 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
3052 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3053 return nil, omciErr.GetError()
3054}
3055
3056// SendCreateSIPUserData nolint: unused
3057func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
3058 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3059 tid := oo.GetNextTid(highPrio)
3060 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
3061 "SequNo": strconv.FormatInt(int64(tid), 16),
3062 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3063
3064 meInstance, omciErr := me.NewSipUserData(params[0])
3065 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003066 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3067 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003068 if err != nil {
3069 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3070 "device-id": oo.deviceID})
3071 return nil, err
3072 }
3073
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003074 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003075 if err != nil {
3076 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3077 "device-id": oo.deviceID})
3078 return nil, err
3079 }
3080
3081 omciRxCallbackPair := CallbackPair{CbKey: tid,
3082 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3083 }
3084 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3085 if err != nil {
3086 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3087 "device-id": oo.deviceID})
3088 return nil, err
3089 }
3090 logger.Debug(ctx, "send SIPUserData-create-msg done")
3091 return meInstance, nil
3092 }
3093 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3094 "device-id": oo.deviceID})
3095 return nil, omciErr.GetError()
3096}
3097
3098// SendSetSIPUserData nolint: unused
3099func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3100 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3101 tid := oo.GetNextTid(highPrio)
3102 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3103 "SequNo": strconv.FormatInt(int64(tid), 16),
3104 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3105
3106 meInstance, omciErr := me.NewSipUserData(params[0])
3107 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003108 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3109 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003110 if err != nil {
3111 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3112 "device-id": oo.deviceID})
3113 return nil, err
3114 }
3115
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003116 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003117 if err != nil {
3118 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3119 "device-id": oo.deviceID})
3120 return nil, err
3121 }
3122
3123 omciRxCallbackPair := CallbackPair{CbKey: tid,
3124 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3125 }
3126 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3127 if err != nil {
3128 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3129 "device-id": oo.deviceID})
3130 return nil, err
3131 }
3132 logger.Debug(ctx, "send SIPUserData-set-msg done")
3133 return meInstance, nil
3134 }
3135 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3136 "device-id": oo.deviceID})
3137 return nil, omciErr.GetError()
3138}
3139
3140// SendDeleteSIPUserData nolint: unused
3141func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3142 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3143 tid := oo.GetNextTid(highPrio)
3144 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3145 "SequNo": strconv.FormatInt(int64(tid), 16),
3146 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3147
3148 meParams := me.ParamData{EntityID: aInstID}
3149 meInstance, omciErr := me.NewSipUserData(meParams)
3150 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003151 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3152 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003153 if err != nil {
3154 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3155 "Err": err, "device-id": oo.deviceID})
3156 return nil, err
3157 }
3158
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003159 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003160 if err != nil {
3161 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3162 "Err": err, "device-id": oo.deviceID})
3163 return nil, err
3164 }
3165
3166 omciRxCallbackPair := CallbackPair{
3167 CbKey: tid,
3168 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3169 }
3170 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3171 if err != nil {
3172 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3173 "Err": err, "device-id": oo.deviceID})
3174 return nil, err
3175 }
3176 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3177 return meInstance, nil
3178 }
3179 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3180 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3181 return nil, omciErr.GetError()
3182}
3183
3184// SendCreateVoipApplicationServiceProfile nolint: unused
3185func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3186 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3187 tid := oo.GetNextTid(highPrio)
3188 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3189 "SequNo": strconv.FormatInt(int64(tid), 16),
3190 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3191
3192 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3193 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003194 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3195 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003196 if err != nil {
3197 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3198 "device-id": oo.deviceID})
3199 return nil, err
3200 }
3201
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003202 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003203 if err != nil {
3204 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3205 "device-id": oo.deviceID})
3206 return nil, err
3207 }
3208
3209 omciRxCallbackPair := CallbackPair{CbKey: tid,
3210 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3211 }
3212 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3213 if err != nil {
3214 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3215 "device-id": oo.deviceID})
3216 return nil, err
3217 }
3218 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3219 return meInstance, nil
3220 }
3221 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3222 "device-id": oo.deviceID})
3223 return nil, omciErr.GetError()
3224}
3225
3226// SendSetVoipApplicationServiceProfile nolint: unused
3227func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3228 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3229 tid := oo.GetNextTid(highPrio)
3230 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3231 "SequNo": strconv.FormatInt(int64(tid), 16),
3232 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3233
3234 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3235 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003236 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3237 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003238 if err != nil {
3239 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3240 "device-id": oo.deviceID})
3241 return nil, err
3242 }
3243
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003244 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003245 if err != nil {
3246 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3247 "device-id": oo.deviceID})
3248 return nil, err
3249 }
3250
3251 omciRxCallbackPair := CallbackPair{CbKey: tid,
3252 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3253 }
3254 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3255 if err != nil {
3256 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3257 "device-id": oo.deviceID})
3258 return nil, err
3259 }
3260 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3261 return meInstance, nil
3262 }
3263 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3264 "device-id": oo.deviceID})
3265 return nil, omciErr.GetError()
3266}
3267
3268// SendDeleteVoipApplicationServiceProfile nolint: unused
3269func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3270 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3271 tid := oo.GetNextTid(highPrio)
3272 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3273 "SequNo": strconv.FormatInt(int64(tid), 16),
3274 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3275
3276 meParams := me.ParamData{EntityID: aInstID}
3277 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3278 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003279 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3280 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003281 if err != nil {
3282 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3283 "Err": err, "device-id": oo.deviceID})
3284 return nil, err
3285 }
3286
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003287 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003288 if err != nil {
3289 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3290 "Err": err, "device-id": oo.deviceID})
3291 return nil, err
3292 }
3293
3294 omciRxCallbackPair := CallbackPair{
3295 CbKey: tid,
3296 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3297 }
3298 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3299 if err != nil {
3300 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3301 "Err": err, "device-id": oo.deviceID})
3302 return nil, err
3303 }
3304 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3305 return meInstance, nil
3306 }
3307 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3308 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3309 return nil, omciErr.GetError()
3310}
3311
3312// SendCreateSIPAgentConfigData nolint: unused
3313func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3314 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3315 tid := oo.GetNextTid(highPrio)
3316 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3317 "SequNo": strconv.FormatInt(int64(tid), 16),
3318 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3319
3320 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3321 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003322 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3323 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003324 if err != nil {
3325 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3326 "device-id": oo.deviceID})
3327 return nil, err
3328 }
3329
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003330 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003331 if err != nil {
3332 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3333 "device-id": oo.deviceID})
3334 return nil, err
3335 }
3336
3337 omciRxCallbackPair := CallbackPair{CbKey: tid,
3338 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3339 }
3340 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3341 if err != nil {
3342 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3343 "device-id": oo.deviceID})
3344 return nil, err
3345 }
3346 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3347 return meInstance, nil
3348 }
3349 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3350 "device-id": oo.deviceID})
3351 return nil, omciErr.GetError()
3352}
3353
3354// SendSetSIPAgentConfigData nolint: unused
3355func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3356 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3357 tid := oo.GetNextTid(highPrio)
3358 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3359 "SequNo": strconv.FormatInt(int64(tid), 16),
3360 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3361
3362 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3363 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003364 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3365 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003366 if err != nil {
3367 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3368 "device-id": oo.deviceID})
3369 return nil, err
3370 }
3371
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003372 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003373 if err != nil {
3374 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3375 "device-id": oo.deviceID})
3376 return nil, err
3377 }
3378
3379 omciRxCallbackPair := CallbackPair{CbKey: tid,
3380 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3381 }
3382 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3383 if err != nil {
3384 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3385 "device-id": oo.deviceID})
3386 return nil, err
3387 }
3388 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3389 return meInstance, nil
3390 }
3391 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3392 "device-id": oo.deviceID})
3393 return nil, omciErr.GetError()
3394}
3395
3396// SendDeleteSIPAgentConfigData nolint: unused
3397func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3398 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3399 tid := oo.GetNextTid(highPrio)
3400 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3401 "SequNo": strconv.FormatInt(int64(tid), 16),
3402 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3403
3404 meParams := me.ParamData{EntityID: aInstID}
3405 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3406 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003407 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3408 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003409 if err != nil {
3410 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3411 "Err": err, "device-id": oo.deviceID})
3412 return nil, err
3413 }
3414
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003415 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003416 if err != nil {
3417 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3418 "Err": err, "device-id": oo.deviceID})
3419 return nil, err
3420 }
3421
3422 omciRxCallbackPair := CallbackPair{
3423 CbKey: tid,
3424 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3425 }
3426 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3427 if err != nil {
3428 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3429 "Err": err, "device-id": oo.deviceID})
3430 return nil, err
3431 }
3432 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3433 return meInstance, nil
3434 }
3435 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3436 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3437 return nil, omciErr.GetError()
3438}
3439
3440// SendCreateTCPUDPConfigData nolint: unused
3441func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3442 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3443 tid := oo.GetNextTid(highPrio)
3444 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3445 "SequNo": strconv.FormatInt(int64(tid), 16),
3446 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3447
3448 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3449 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003450 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3451 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003452 if err != nil {
3453 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3454 "device-id": oo.deviceID})
3455 return nil, err
3456 }
3457
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003458 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003459 if err != nil {
3460 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3461 "device-id": oo.deviceID})
3462 return nil, err
3463 }
3464
3465 omciRxCallbackPair := CallbackPair{CbKey: tid,
3466 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3467 }
3468 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3469 if err != nil {
3470 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3471 "device-id": oo.deviceID})
3472 return nil, err
3473 }
3474 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3475 return meInstance, nil
3476 }
3477 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3478 "device-id": oo.deviceID})
3479 return nil, omciErr.GetError()
3480}
3481
3482// SendSetTCPUDPConfigData nolint: unused
3483func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3484 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3485 tid := oo.GetNextTid(highPrio)
3486 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3487 "SequNo": strconv.FormatInt(int64(tid), 16),
3488 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3489
3490 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3491 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003492 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3493 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003494 if err != nil {
3495 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3496 "device-id": oo.deviceID})
3497 return nil, err
3498 }
3499
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003500 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003501 if err != nil {
3502 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3503 "device-id": oo.deviceID})
3504 return nil, err
3505 }
3506
3507 omciRxCallbackPair := CallbackPair{CbKey: tid,
3508 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3509 }
3510 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3511 if err != nil {
3512 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3513 "device-id": oo.deviceID})
3514 return nil, err
3515 }
3516 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3517 return meInstance, nil
3518 }
3519 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3520 "device-id": oo.deviceID})
3521 return nil, omciErr.GetError()
3522}
3523
3524// SendDeleteTCPUDPConfigData nolint: unused
3525func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3526 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3527 tid := oo.GetNextTid(highPrio)
3528 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3529 "SequNo": strconv.FormatInt(int64(tid), 16),
3530 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3531
3532 meParams := me.ParamData{EntityID: aInstID}
3533 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3534 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003535 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3536 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003537 if err != nil {
3538 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3539 "Err": err, "device-id": oo.deviceID})
3540 return nil, err
3541 }
3542
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003543 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003544 if err != nil {
3545 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3546 "Err": err, "device-id": oo.deviceID})
3547 return nil, err
3548 }
3549
3550 omciRxCallbackPair := CallbackPair{
3551 CbKey: tid,
3552 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3553 }
3554 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3555 if err != nil {
3556 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3557 "Err": err, "device-id": oo.deviceID})
3558 return nil, err
3559 }
3560 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3561 return meInstance, nil
3562 }
3563 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3564 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3565 return nil, omciErr.GetError()
3566}
3567
3568// SendCreateIPHostConfigData nolint: unused
3569func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3570 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3571 tid := oo.GetNextTid(highPrio)
3572 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3573 "SequNo": strconv.FormatInt(int64(tid), 16),
3574 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3575
3576 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3577 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003578 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3579 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003580 if err != nil {
3581 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3582 "device-id": oo.deviceID})
3583 return nil, err
3584 }
3585
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003586 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003587 if err != nil {
3588 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3589 "device-id": oo.deviceID})
3590 return nil, err
3591 }
3592
3593 omciRxCallbackPair := CallbackPair{CbKey: tid,
3594 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3595 }
3596 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3597 if err != nil {
3598 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3599 "device-id": oo.deviceID})
3600 return nil, err
3601 }
3602 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3603 return meInstance, nil
3604 }
3605 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3606 "device-id": oo.deviceID})
3607 return nil, omciErr.GetError()
3608}
3609
3610// SendSetIPHostConfigData nolint: unused
3611func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3612 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3613 tid := oo.GetNextTid(highPrio)
3614 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3615 "SequNo": strconv.FormatInt(int64(tid), 16),
3616 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3617
3618 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3619 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003620 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3621 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003622 if err != nil {
3623 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3624 "device-id": oo.deviceID})
3625 return nil, err
3626 }
3627
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003628 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003629 if err != nil {
3630 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3631 "device-id": oo.deviceID})
3632 return nil, err
3633 }
3634
3635 omciRxCallbackPair := CallbackPair{CbKey: tid,
3636 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3637 }
3638 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3639 if err != nil {
3640 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3641 "device-id": oo.deviceID})
3642 return nil, err
3643 }
3644 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3645 return meInstance, nil
3646 }
3647 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3648 "device-id": oo.deviceID})
3649 return nil, omciErr.GetError()
3650}
3651
3652// SendDeleteIPHostConfigData nolint: unused
3653func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3654 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3655 tid := oo.GetNextTid(highPrio)
3656 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3657 "SequNo": strconv.FormatInt(int64(tid), 16),
3658 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3659
3660 meParams := me.ParamData{EntityID: aInstID}
3661 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3662 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003663 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3664 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003665 if err != nil {
3666 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3667 "Err": err, "device-id": oo.deviceID})
3668 return nil, err
3669 }
3670
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003671 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003672 if err != nil {
3673 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3674 "Err": err, "device-id": oo.deviceID})
3675 return nil, err
3676 }
3677
3678 omciRxCallbackPair := CallbackPair{
3679 CbKey: tid,
3680 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3681 }
3682 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3683 if err != nil {
3684 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3685 "Err": err, "device-id": oo.deviceID})
3686 return nil, err
3687 }
3688 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3689 return meInstance, nil
3690 }
3691 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3692 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3693 return nil, omciErr.GetError()
3694}
3695
3696// SendCreateRTPProfileData nolint: unused
3697func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3698 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3699 tid := oo.GetNextTid(highPrio)
3700 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3701 "SequNo": strconv.FormatInt(int64(tid), 16),
3702 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3703
3704 meInstance, omciErr := me.NewRtpProfileData(params[0])
3705 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003706 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3707 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003708 if err != nil {
3709 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3710 "device-id": oo.deviceID})
3711 return nil, err
3712 }
3713
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003714 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003715 if err != nil {
3716 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3717 "device-id": oo.deviceID})
3718 return nil, err
3719 }
3720
3721 omciRxCallbackPair := CallbackPair{CbKey: tid,
3722 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3723 }
3724 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3725 if err != nil {
3726 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3727 "device-id": oo.deviceID})
3728 return nil, err
3729 }
3730 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3731 return meInstance, nil
3732 }
3733 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3734 "device-id": oo.deviceID})
3735 return nil, omciErr.GetError()
3736}
3737
3738// SendSetRTPProfileData nolint: unused
3739func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3740 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3741 tid := oo.GetNextTid(highPrio)
3742 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3743 "SequNo": strconv.FormatInt(int64(tid), 16),
3744 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3745
3746 meInstance, omciErr := me.NewRtpProfileData(params[0])
3747 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003748 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3749 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003750 if err != nil {
3751 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3752 "device-id": oo.deviceID})
3753 return nil, err
3754 }
3755
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003756 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003757 if err != nil {
3758 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3759 "device-id": oo.deviceID})
3760 return nil, err
3761 }
3762
3763 omciRxCallbackPair := CallbackPair{CbKey: tid,
3764 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3765 }
3766 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3767 if err != nil {
3768 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3769 "device-id": oo.deviceID})
3770 return nil, err
3771 }
3772 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3773 return meInstance, nil
3774 }
3775 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3776 "device-id": oo.deviceID})
3777 return nil, omciErr.GetError()
3778}
3779
3780// SendDeleteRTPProfileData nolint: unused
3781func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3782 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3783 tid := oo.GetNextTid(highPrio)
3784 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3785 "SequNo": strconv.FormatInt(int64(tid), 16),
3786 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3787
3788 meParams := me.ParamData{EntityID: aInstID}
3789 meInstance, omciErr := me.NewRtpProfileData(meParams)
3790 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003791 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3792 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003793 if err != nil {
3794 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3795 "Err": err, "device-id": oo.deviceID})
3796 return nil, err
3797 }
3798
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003799 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003800 if err != nil {
3801 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3802 "Err": err, "device-id": oo.deviceID})
3803 return nil, err
3804 }
3805
3806 omciRxCallbackPair := CallbackPair{
3807 CbKey: tid,
3808 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3809 }
3810 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3811 if err != nil {
3812 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3813 "Err": err, "device-id": oo.deviceID})
3814 return nil, err
3815 }
3816 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3817 return meInstance, nil
3818 }
3819 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3820 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3821 return nil, omciErr.GetError()
3822}
3823
3824// SendCreateNetworkDialPlanTable nolint: unused
3825func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3826 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3827 tid := oo.GetNextTid(highPrio)
3828 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3829 "SequNo": strconv.FormatInt(int64(tid), 16),
3830 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3831
3832 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3833 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003834 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3835 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003836 if err != nil {
3837 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3838 "device-id": oo.deviceID})
3839 return nil, err
3840 }
3841
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003842 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003843 if err != nil {
3844 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3845 "device-id": oo.deviceID})
3846 return nil, err
3847 }
3848
3849 omciRxCallbackPair := CallbackPair{CbKey: tid,
3850 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3851 }
3852 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3853 if err != nil {
3854 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3855 "device-id": oo.deviceID})
3856 return nil, err
3857 }
3858 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3859 return meInstance, nil
3860 }
3861 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3862 "device-id": oo.deviceID})
3863 return nil, omciErr.GetError()
3864}
3865
3866// SendSetNetworkDialPlanTable nolint: unused
3867func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3868 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3869 tid := oo.GetNextTid(highPrio)
3870 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3871 "SequNo": strconv.FormatInt(int64(tid), 16),
3872 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3873
3874 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3875 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003876 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3877 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003878 if err != nil {
3879 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3880 "device-id": oo.deviceID})
3881 return nil, err
3882 }
3883
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003884 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003885 if err != nil {
3886 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3887 "device-id": oo.deviceID})
3888 return nil, err
3889 }
3890
3891 omciRxCallbackPair := CallbackPair{CbKey: tid,
3892 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3893 }
3894 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3895 if err != nil {
3896 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3897 "device-id": oo.deviceID})
3898 return nil, err
3899 }
3900 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3901 return meInstance, nil
3902 }
3903 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3904 "device-id": oo.deviceID})
3905 return nil, omciErr.GetError()
3906}
3907
3908// SendDeleteNetworkDialPlanTable nolint: unused
3909func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3910 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3911 tid := oo.GetNextTid(highPrio)
3912 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3913 "SequNo": strconv.FormatInt(int64(tid), 16),
3914 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3915
3916 meParams := me.ParamData{EntityID: aInstID}
3917 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3918 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003919 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3920 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003921 if err != nil {
3922 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3923 "Err": err, "device-id": oo.deviceID})
3924 return nil, err
3925 }
3926
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003927 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003928 if err != nil {
3929 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3930 "Err": err, "device-id": oo.deviceID})
3931 return nil, err
3932 }
3933
3934 omciRxCallbackPair := CallbackPair{
3935 CbKey: tid,
3936 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3937 }
3938 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3939 if err != nil {
3940 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3941 "Err": err, "device-id": oo.deviceID})
3942 return nil, err
3943 }
3944 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3945 return meInstance, nil
3946 }
3947 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3948 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3949 return nil, omciErr.GetError()
3950}
3951
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003952// SendSyncTime sends SynchronizeTimeRequest
3953func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
3954 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003955 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
3956 "SequNo": strconv.FormatInt(int64(tid), 16)})
3957
3958 omciLayer := &omci.OMCI{
3959 TransactionID: tid,
3960 MessageType: omci.SynchronizeTimeRequestType,
3961 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3962 // Length: 0x28, // Optional, defaults to 40 octets
3963 }
3964 utcTime := time.Now().UTC()
3965 request := &omci.SynchronizeTimeRequest{
3966 MeBasePacket: omci.MeBasePacket{
3967 EntityClass: me.OnuGClassID,
3968 // Default Instance ID is 0
3969 },
3970 Year: uint16(utcTime.Year()),
3971 Month: uint8(utcTime.Month()),
3972 Day: uint8(utcTime.Day()),
3973 Hour: uint8(utcTime.Hour()),
3974 Minute: uint8(utcTime.Minute()),
3975 Second: uint8(utcTime.Second()),
3976 }
3977
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003978 pkt, err := SerializeOmciLayer(ctx, omciLayer, request)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003979 if err != nil {
3980 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
3981 "device-id": oo.deviceID})
3982 return err
3983 }
3984
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003985 omciRxCallbackPair := CallbackPair{CbKey: tid,
3986 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003987 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003988 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003989 if err != nil {
3990 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
3991 "device-id": oo.deviceID})
3992 return err
3993 }
3994 logger.Debug(ctx, "send synchronize time request done")
3995 return nil
3996}
3997
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003998// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
3999func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004000 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004001 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004002 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4003 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4004 meParam := me.ParamData{EntityID: entityID}
4005 var meInstance *me.ManagedEntity
4006 var omciErr me.OmciErrors
4007 if upstream {
4008 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
4009 } else {
4010 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
4011 }
4012 if omciErr.GetError() == nil {
4013 var omciLayer *omci.OMCI
4014 var msgLayer gopacket.SerializableLayer
4015 var err error
4016 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004017 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4018 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004019 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004020 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4021 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004022 }
4023 if err != nil {
4024 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
4025 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004026 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004027 }
4028
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004029 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004030 if err != nil {
4031 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
4032 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004033 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004034 }
4035
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004036 omciRxCallbackPair := CallbackPair{CbKey: tid,
4037 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004038 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004039 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004040 if err != nil {
4041 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
4042 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004043 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004044 }
4045 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
4046 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004047 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004048 }
4049 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
4050 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 +03004051 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004052}
4053
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004054// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
4055func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004056 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004057 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004058 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4059 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4060 meParam := me.ParamData{EntityID: entityID}
4061 var meInstance *me.ManagedEntity
4062 var omciErr me.OmciErrors
4063 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
4064
4065 if omciErr.GetError() == nil {
4066 var omciLayer *omci.OMCI
4067 var msgLayer gopacket.SerializableLayer
4068 var err error
4069 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004070 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4071 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004072 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004073 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4074 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004075 }
4076 if err != nil {
4077 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4078 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004079 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004080 }
4081
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004082 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004083 if err != nil {
4084 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4085 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004086 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004087 }
4088
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004089 omciRxCallbackPair := CallbackPair{CbKey: tid,
4090 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004091 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004092 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004093 if err != nil {
4094 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4095 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004096 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004097 }
4098 logger.Debugw(ctx, "send ethernet uni history data ME done",
4099 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004100 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004101 }
4102 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4103 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004104 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004105}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004106
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004107// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4108func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004109 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004110 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004111 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4112 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4113 meParam := me.ParamData{EntityID: entityID}
4114 var meInstance *me.ManagedEntity
4115 var omciErr me.OmciErrors
4116 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4117
4118 if omciErr.GetError() == nil {
4119 var omciLayer *omci.OMCI
4120 var msgLayer gopacket.SerializableLayer
4121 var err error
4122 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004123 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4124 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004125 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004126 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4127 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004128 }
4129 if err != nil {
4130 logger.Errorw(ctx, "Cannot encode fec history data ME",
4131 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004132 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004133 }
4134
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004135 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004136 if err != nil {
4137 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4138 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004139 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004140 }
4141
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004142 omciRxCallbackPair := CallbackPair{CbKey: tid,
4143 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004144 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004145 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004146 if err != nil {
4147 logger.Errorw(ctx, "Cannot send fec history data ME",
4148 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004149 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004150 }
4151 logger.Debugw(ctx, "send fec history data ME done",
4152 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004153 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004154 }
4155 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4156 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004157 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004158}
4159
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004160// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4161func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004162 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004163 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004164 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4165 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4166 meParam := me.ParamData{EntityID: entityID}
4167 var meInstance *me.ManagedEntity
4168 var omciErr me.OmciErrors
4169 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4170
4171 if omciErr.GetError() == nil {
4172 var omciLayer *omci.OMCI
4173 var msgLayer gopacket.SerializableLayer
4174 var err error
4175 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004176 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4177 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004178 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004179 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4180 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004181 }
4182 if err != nil {
4183 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4184 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004185 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004186 }
4187
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004188 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004189 if err != nil {
4190 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4191 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004192 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004193 }
4194
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004195 omciRxCallbackPair := CallbackPair{CbKey: tid,
4196 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004197 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004198 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004199 if err != nil {
4200 logger.Errorw(ctx, "Cannot send gemport history data ME",
4201 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004202 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004203 }
4204 logger.Debugw(ctx, "send gemport history data ME done",
4205 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004206 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004207 }
4208 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4209 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004210 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004211}
4212
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004213// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4214func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004215 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004216 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004217 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4218 "SequNo": strconv.FormatInt(int64(tid), 16),
4219 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4220
4221 omciLayer := &omci.OMCI{
4222 TransactionID: tid,
4223 MessageType: omci.StartSoftwareDownloadRequestType,
4224 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4225 // Length: 0x28, // Optional, defaults to 40 octets
4226 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004227 if aIsExtendedOmci {
4228 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4229 }
mpagenko80622a52021-02-09 16:53:23 +00004230 request := &omci.StartSoftwareDownloadRequest{
4231 MeBasePacket: omci.MeBasePacket{
4232 EntityClass: me.SoftwareImageClassID,
4233 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004234 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004235 },
4236 WindowSize: aDownloadWindowSize,
4237 ImageSize: aFileLen,
4238 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4239 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4240 }
4241
4242 var options gopacket.SerializeOptions
4243 options.FixLengths = true
4244 buffer := gopacket.NewSerializeBuffer()
4245 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4246 if err != nil {
4247 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4248 "device-id": oo.deviceID})
4249 return err
4250 }
4251 outgoingPacket := buffer.Bytes()
4252
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004253 omciRxCallbackPair := CallbackPair{CbKey: tid,
4254 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004255 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004256 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004257 if err != nil {
4258 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4259 "device-id": oo.deviceID})
4260 return err
4261 }
4262 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004263 return nil
4264}
4265
kesavand011d5162021-11-25 19:21:06 +05304266// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4267//Before invoking this function the oo.mutexTid needs to be be locked so that
4268//GetOnuSwSecNextTid can be invoked without further locking
4269func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4270 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004271 omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) {
kesavand011d5162021-11-25 19:21:06 +05304272 //onuswsections uses only low prioirity tids
4273 tid := oo.GetOnuSwSecNextTid()
4274 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4275 "SequNo": strconv.FormatInt(int64(tid), 16),
4276 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4277
4278 var omciTxReq OmciTransferStructure
4279 msgType := omci.DownloadSectionRequestType
4280
4281 if aAckRequest > 0 {
4282 msgType = omci.DownloadSectionRequestWithResponseType
4283
4284 }
4285 omciLayer := &omci.OMCI{
4286 TransactionID: tid,
4287 MessageType: msgType,
4288 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4289 // Length: 0x28, // Optional, defaults to 40 octets
4290 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004291 if aIsExtendedOmci {
4292 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4293 }
kesavand011d5162021-11-25 19:21:06 +05304294 localSectionData := make([]byte, len(aSection))
4295
4296 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4297 request := &omci.DownloadSectionRequest{
4298 MeBasePacket: omci.MeBasePacket{
4299 EntityClass: me.SoftwareImageClassID,
4300 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004301 Extended: aIsExtendedOmci,
kesavand011d5162021-11-25 19:21:06 +05304302 },
4303 SectionNumber: aDownloadSectionNo,
4304 SectionData: localSectionData,
4305 }
4306
4307 var options gopacket.SerializeOptions
4308 options.FixLengths = true
4309 buffer := gopacket.NewSerializeBuffer()
4310 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4311 if err != nil {
4312 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4313 "device-id": oo.deviceID})
4314 return omciTxReq, err
4315 }
4316 outgoingPacket := buffer.Bytes()
4317
4318 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4319
4320 if aAckRequest > 0 {
4321 // only the last section should have a timeout as an ack is required only for the last section of the window
4322 omciTxReq = OmciTransferStructure{
4323 withFramePrint: true,
4324 OnuSwWindow: omciMsgsPerWindow,
4325 }
4326 return omciTxReq, nil
4327 }
4328
4329 return omciTxReq, nil
4330}
4331
4332//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4333func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4334 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4335 if aOmciTxRequest.OnuSwWindow == nil {
4336 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4337 log.Fields{"device-id": oo.deviceID})
4338 return
4339
4340 }
4341
4342 tid := oo.GetOnuSwSecLastTid()
4343 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4344 omciRxCallbackPair := CallbackPair{CbKey: tid,
4345 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4346 }
4347
4348 aOmciTxRequest.cbPair = omciRxCallbackPair
4349 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4350 oo.mutexRxSchedMap.Lock()
4351 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4352 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4353 oo.mutexRxSchedMap.Unlock()
4354
4355 chSuccess := make(chan bool)
4356 aOmciTxRequest.chSuccess = chSuccess
4357 aOmciTxRequest.timeout = aTimeout
4358 aOmciTxRequest.retries = CDefaultRetries
4359
4360 //tid := aOmciTxRequest.cbPair.CbKey
4361 oo.mutexMonReq.Lock()
4362 oo.monitoredRequests[tid] = aOmciTxRequest
4363 oo.mutexMonReq.Unlock()
4364
4365 retries := aOmciTxRequest.retries
4366 retryCounter := 0
4367 if aTimeout == 0 {
4368 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4369 return
4370 }
4371loop:
4372 for retryCounter <= retries {
4373 // the onu sw sections are enqueued only to the low priority queue
4374 oo.mutexLowPrioTxQueue.Lock()
4375 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4376 oo.mutexLowPrioTxQueue.Unlock()
4377
4378 go oo.sendQueuedRequests(ctx)
4379
4380 select {
4381 case success := <-chSuccess:
4382 if success {
4383 logger.Debugw(ctx, "reqMon: response received in time",
4384 log.Fields{"tid": tid, "device-id": oo.deviceID})
4385 } else {
4386 logger.Debugw(ctx, "reqMon: wait for response aborted",
4387 log.Fields{"tid": tid, "device-id": oo.deviceID})
4388 }
4389 break loop
4390 case <-time.After(time.Duration(aTimeout) * time.Second):
4391 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004392 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
kesavand011d5162021-11-25 19:21:06 +05304393 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004394 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
kesavand011d5162021-11-25 19:21:06 +05304395 break loop
4396 } else {
4397 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4398 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4399 }
4400 }
4401 retryCounter++
4402 }
4403 oo.mutexMonReq.Lock()
4404 delete(oo.monitoredRequests, tid)
4405 oo.mutexMonReq.Unlock()
4406}
4407
4408func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
4409 if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil {
4410 lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4411 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
4412 "TxOmciMessage": hex.EncodeToString(lastSection),
4413 "device-id": oo.deviceID,
4414 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4415 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4416 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4417 }
4418 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4419 if sendErr != nil {
4420 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
4421 return sendErr
4422 }
4423 return nil
4424}
4425
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004426// SendDownloadSection sends DownloadSectionRequestWithResponse
4427func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004428 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004429 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004430 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4431 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004432 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004433
4434 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4435 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004436 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004437 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004438 if aAckRequest > 0 {
4439 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004440 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004441 }
mpagenko80622a52021-02-09 16:53:23 +00004442 omciLayer := &omci.OMCI{
4443 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004444 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004445 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4446 // Length: 0x28, // Optional, defaults to 40 octets
4447 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004448 if aIsExtendedOmci {
4449 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4450 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304451 localSectionData := make([]byte, len(aSection))
4452
mpagenko15ff4a52021-03-02 10:09:20 +00004453 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004454 request := &omci.DownloadSectionRequest{
4455 MeBasePacket: omci.MeBasePacket{
4456 EntityClass: me.SoftwareImageClassID,
4457 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004458 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004459 },
4460 SectionNumber: aDownloadSectionNo,
4461 SectionData: localSectionData,
4462 }
4463
4464 var options gopacket.SerializeOptions
4465 options.FixLengths = true
4466 buffer := gopacket.NewSerializeBuffer()
4467 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4468 if err != nil {
4469 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4470 "device-id": oo.deviceID})
4471 return err
4472 }
4473 outgoingPacket := buffer.Bytes()
4474
mpagenko15ff4a52021-03-02 10:09:20 +00004475 //for initial debug purpose overrule the requested print state for some frames
4476 printFrame := aPrint
4477 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4478 printFrame = true
4479 }
4480
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004481 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004482 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4483 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004484 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004485 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004486 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004487 if err != nil {
4488 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4489 "device-id": oo.deviceID})
4490 return err
4491 }
4492 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004493 return nil
4494}
4495
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004496//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4497func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004498 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004499 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004500 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4501 "SequNo": strconv.FormatInt(int64(tid), 16),
4502 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4503
mpagenko15ff4a52021-03-02 10:09:20 +00004504 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004505 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004506 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004507 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4508 // Length: 0x28, // Optional, defaults to 40 octets
4509 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004510 if aIsExtendedOmci {
4511 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4512 }
mpagenko15ff4a52021-03-02 10:09:20 +00004513 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004514 MeBasePacket: omci.MeBasePacket{
4515 EntityClass: me.SoftwareImageClassID,
4516 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004517 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004518 },
mpagenko15ff4a52021-03-02 10:09:20 +00004519 CRC32: aImageCrc,
4520 ImageSize: aFileLen,
4521 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4522 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004523 }
mpagenko15ff4a52021-03-02 10:09:20 +00004524
4525 var options gopacket.SerializeOptions
4526 options.FixLengths = true
4527 buffer := gopacket.NewSerializeBuffer()
4528 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4529 if err != nil {
4530 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004531 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004532 return err
mpagenko80622a52021-02-09 16:53:23 +00004533 }
mpagenko15ff4a52021-03-02 10:09:20 +00004534 outgoingPacket := buffer.Bytes()
4535
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004536 omciRxCallbackPair := CallbackPair{CbKey: tid,
4537 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004538 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004539 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004540 if err != nil {
4541 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4542 "device-id": oo.deviceID})
4543 return err
4544 }
4545 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004546 return nil
4547}
4548
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004549// SendActivateSoftware sends ActivateSoftwareRequest
4550func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004551 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004552 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004553 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4554 "SequNo": strconv.FormatInt(int64(tid), 16),
4555 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4556
4557 omciLayer := &omci.OMCI{
4558 TransactionID: tid,
4559 MessageType: omci.ActivateSoftwareRequestType,
4560 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4561 // Length: 0x28, // Optional, defaults to 40 octets
4562 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004563 if aIsExtendedOmci {
4564 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4565 }
mpagenko80622a52021-02-09 16:53:23 +00004566 request := &omci.ActivateSoftwareRequest{
4567 MeBasePacket: omci.MeBasePacket{
4568 EntityClass: me.SoftwareImageClassID,
4569 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004570 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004571 },
4572 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4573 }
4574
4575 var options gopacket.SerializeOptions
4576 options.FixLengths = true
4577 buffer := gopacket.NewSerializeBuffer()
4578 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4579 if err != nil {
4580 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4581 "device-id": oo.deviceID})
4582 return err
4583 }
4584 outgoingPacket := buffer.Bytes()
4585
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004586 omciRxCallbackPair := CallbackPair{CbKey: tid,
4587 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004588 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004589 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004590 if err != nil {
4591 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4592 "device-id": oo.deviceID})
4593 return err
4594 }
4595 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004596 return nil
4597}
mpagenko80622a52021-02-09 16:53:23 +00004598
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004599// SendCommitSoftware sends CommitSoftwareRequest
4600func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004601 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004602 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004603 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4604 "SequNo": strconv.FormatInt(int64(tid), 16),
4605 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4606
4607 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004608 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004609 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004610 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4611 // Length: 0x28, // Optional, defaults to 40 octets
4612 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004613 if aIsExtendedOmci {
4614 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4615 }
mpagenko15ff4a52021-03-02 10:09:20 +00004616 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004617 MeBasePacket: omci.MeBasePacket{
4618 EntityClass: me.SoftwareImageClassID,
4619 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004620 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004621 },
mpagenko80622a52021-02-09 16:53:23 +00004622 }
mpagenko15ff4a52021-03-02 10:09:20 +00004623
4624 var options gopacket.SerializeOptions
4625 options.FixLengths = true
4626 buffer := gopacket.NewSerializeBuffer()
4627 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4628 if err != nil {
4629 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004630 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004631 return err
mpagenko80622a52021-02-09 16:53:23 +00004632 }
mpagenko15ff4a52021-03-02 10:09:20 +00004633 outgoingPacket := buffer.Bytes()
4634
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004635 omciRxCallbackPair := CallbackPair{CbKey: tid,
4636 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004637 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004638 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004639 if err != nil {
4640 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4641 "device-id": oo.deviceID})
4642 return err
4643 }
4644 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004645 return nil
4646}
4647
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004648//SendSelfTestReq sends TestRequest
4649func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4650 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004651 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4652 "SequNo": strconv.FormatInt(int64(tid), 16),
4653 "InstId": strconv.FormatInt(int64(instdID), 16)})
4654 omciLayer := &omci.OMCI{
4655 TransactionID: tid,
4656 MessageType: omci.TestRequestType,
4657 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4658 // Length: 0x28, // Optional, defaults to 40 octets
4659 }
4660
4661 var request *omci.OpticalLineSupervisionTestRequest
4662 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004663 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004664 request = &omci.OpticalLineSupervisionTestRequest{
4665 MeBasePacket: omci.MeBasePacket{
4666 EntityClass: classID,
4667 EntityInstance: instdID,
4668 },
4669 SelectTest: uint8(7), // self test
4670 GeneralPurposeBuffer: uint16(0),
4671 VendorSpecificParameters: uint16(0),
4672 }
4673 default:
4674 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4675 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4676 }
4677 // Test serialization back to former string
4678 var options gopacket.SerializeOptions
4679 options.FixLengths = true
4680
4681 buffer := gopacket.NewSerializeBuffer()
4682 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4683 if err != nil {
4684 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4685 "device-id": oo.deviceID})
4686 return err
4687 }
4688 outgoingPacket := buffer.Bytes()
4689
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004690 omciRxCallbackPair := CallbackPair{CbKey: tid,
4691 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004692 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004693 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004694 if err != nil {
4695 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4696 "device-id": oo.deviceID})
4697 return err
4698 }
4699 logger.Debug(ctx, "send self test request done")
4700 return nil
4701}
4702
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004703//nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004704func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4705
4706 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4707 if err != nil {
4708 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4709 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4710 }
4711 msgLayer := (*packet).Layer(nextLayer)
4712 if msgLayer != nil {
4713 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4714 if failure := (*packet).ErrorLayer(); failure != nil {
4715 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4716 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4717 // can examine for UnkonwnMEs and UnknownAttributes
4718 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
4719 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4720 return false, nil
4721 } else if nextLayer == omci.LayerTypeGetResponse {
4722 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4723 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4724 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4725 if unknownAttrLayer != nil {
4726 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4727 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4728 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4729 }
4730 }
4731 }
4732 }
4733 // Try to decode any further error information
4734 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4735 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4736 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4737 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4738 }
4739 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4740 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4741 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4742 }
4743 } else if failure := (*packet).ErrorLayer(); failure != nil {
4744 // message layer could not be decoded, but at least check if additional failure information is available
4745 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004746 errMsg := decodeFailure.String()
4747 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4748 if strings.Contains(strings.ToLower(errMsg), "table decode") {
4749 // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass
4750 // so that later processing can deal with it
4751 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass",
4752 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4753 return false, nil
4754 }
4755 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004756 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004757 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg})
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004758 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4759 }
4760 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4761 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4762 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4763 } else {
4764 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4765 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4766 }
4767
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004768 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004769 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004770 switch nextLayer {
4771 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004772 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4773 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004774 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004775 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004776 }
4777 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004778 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4779 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004780 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004781 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004782 }
4783 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004784 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4785 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004786 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004787 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004788 }
4789 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004790 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4791 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004792 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004793 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004794 }
4795 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004796 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4797 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004798 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004799 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004800 }
4801 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004802 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4803 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004804 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004805 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004806 }
4807 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004808 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4809 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004810 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004811 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004812 }
4813 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004814 }
4815 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004816 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004817}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004818
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004819func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004820 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004821 if timeout == 0 {
4822 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004823 // enqueue
4824 if aOmciTxRequest.highPrio {
4825 oo.mutexHighPrioTxQueue.Lock()
4826 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4827 oo.mutexHighPrioTxQueue.Unlock()
4828 } else {
4829 oo.mutexLowPrioTxQueue.Lock()
4830 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4831 oo.mutexLowPrioTxQueue.Unlock()
4832 }
4833 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004834 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004835 //the supervised sending with waiting on the response (based on TID) is called in background
4836 // to avoid blocking of the sender for the complete OMCI handshake procedure
4837 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4838 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4839 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004840 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004841}
4842
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004843func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004844 chSuccess := make(chan bool)
4845 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004846 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004847 oo.mutexMonReq.Lock()
4848 oo.monitoredRequests[tid] = aOmciTxRequest
4849 oo.mutexMonReq.Unlock()
4850
4851 retries := aOmciTxRequest.retries
4852 retryCounter := 0
4853loop:
4854 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004855 // enqueue
4856 if aOmciTxRequest.highPrio {
4857 oo.mutexHighPrioTxQueue.Lock()
4858 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4859 oo.mutexHighPrioTxQueue.Unlock()
4860 } else {
4861 oo.mutexLowPrioTxQueue.Lock()
4862 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4863 oo.mutexLowPrioTxQueue.Unlock()
4864 }
4865 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004866
4867 select {
4868 case success := <-chSuccess:
4869 if success {
4870 logger.Debugw(ctx, "reqMon: response received in time",
4871 log.Fields{"tid": tid, "device-id": oo.deviceID})
4872 } else {
4873 logger.Debugw(ctx, "reqMon: wait for response aborted",
4874 log.Fields{"tid": tid, "device-id": oo.deviceID})
4875 }
4876 break loop
4877 case <-time.After(time.Duration(aTimeout) * time.Second):
4878 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004879 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
mpagenko7455fd42021-06-10 16:25:55 +00004880 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004881 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
mpagenko7455fd42021-06-10 16:25:55 +00004882 break loop
4883 } else {
4884 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4885 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4886 }
4887 }
4888 retryCounter++
4889 }
4890 oo.mutexMonReq.Lock()
4891 delete(oo.monitoredRequests, tid)
4892 oo.mutexMonReq.Unlock()
4893}
4894
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004895//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004896func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004897 logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004898 oo.mutexMonReq.RLock()
4899 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004900 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4901 select {
4902 case oo.monitoredRequests[k].chSuccess <- false:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004903 logger.Debugw(ctx, "send cancellation on omciRespChannel",
4904 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004905 default:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004906 logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
4907 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004908 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004909 }
4910 oo.mutexMonReq.RUnlock()
4911}
4912
4913//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4914//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004915func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4916 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004917}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304918
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004919// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4920func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304921 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004922 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304923 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4924 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4925
4926 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004927 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304928 }
4929 var meInstance *me.ManagedEntity
4930 var omciErr me.OmciErrors
4931 if classID == me.EthernetFrameExtendedPmClassID {
4932 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4933 } else {
4934 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4935 }
4936
4937 if omciErr.GetError() == nil {
4938 var omciLayer *omci.OMCI
4939 var msgLayer gopacket.SerializableLayer
4940 var err error
4941 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004942 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4943 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304944 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004945 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4946 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304947 }
4948 if err != nil {
4949 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4950 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4951 return nil, err
4952 }
4953
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004954 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304955 if err != nil {
4956 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
4957 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4958 return nil, err
4959 }
4960
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004961 omciRxCallbackPair := CallbackPair{CbKey: tid,
4962 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304963 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004964 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304965 if err != nil {
4966 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4967 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4968 return nil, err
4969 }
4970 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
4971 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4972 return meInstance, nil
4973 }
4974 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4975 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4976 return nil, omciErr.GetError()
4977}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004978
4979// RLockMutexMonReq lock read access to monitoredRequests
4980func (oo *OmciCC) RLockMutexMonReq() {
4981 oo.mutexMonReq.RLock()
4982}
4983
4984// RUnlockMutexMonReq unlock read access to monitoredRequests
4985func (oo *OmciCC) RUnlockMutexMonReq() {
4986 oo.mutexMonReq.RUnlock()
4987}
4988
4989// GetMonitoredRequest get OmciTransferStructure for an omciTransID
4990func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
4991 value, exist = oo.monitoredRequests[omciTransID]
4992 return value, exist
4993}
4994
4995// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
4996func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
4997 oo.monitoredRequests[omciTransID].chSuccess <- chVal
4998}
Himani Chawlaee10b542021-09-20 16:46:40 +05304999
5000// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
5001func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
5002 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
5003 tid := oo.GetNextTid(highPrio)
5004 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
5005 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
5006
5007 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005008 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05305009 }
5010 var meInstance *me.ManagedEntity
5011 var omciErr me.OmciErrors
5012 if classID == me.EthernetFrameExtendedPmClassID {
5013 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
5014 } else {
5015 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
5016 }
5017
5018 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00005019 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05305020 if err != nil {
5021 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5022 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5023 return nil, err
5024 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005025 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawlaee10b542021-09-20 16:46:40 +05305026 if err != nil {
5027 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
5028 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5029 return nil, err
5030 }
5031 omciRxCallbackPair := CallbackPair{
5032 CbKey: tid,
5033 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
5034 }
5035 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
5036 if err != nil {
5037 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5038 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5039 return nil, err
5040 }
5041 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
5042 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5043 return meInstance, nil
5044 }
5045 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5046 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5047 return nil, omciErr.GetError()
5048}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00005049
5050// PrepareForGarbageCollection - remove references to prepare for garbage collection
5051func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
5052 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
5053 oo.pBaseDeviceHandler = nil
5054 oo.pOnuDeviceEntry = nil
5055 oo.pOnuAlarmManager = nil
5056}