blob: 60d37e565d1525248732740597dc8b239dcadc12 [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"
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +000043 "github.com/opencord/voltha-protos/v5/go/extension"
khenaidoo42dcdfd2021-10-19 17:34:12 -040044 ia "github.com/opencord/voltha-protos/v5/go/inter_adapter"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000045)
46
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053048
Holger Hildebrandt9b64e0b2022-04-21 08:02:00 +000049const maxGemPayloadSize = uint16(2048)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000050const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053051
52//const defaultTPID = uint16(0x8100)
53//const broadComDefaultVID = uint16(4091)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000054
55// UnusedTcontAllocID - TODO: add comment
56const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
mpagenko8b07c1b2020-11-26 10:36:31 +000057
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +000058const cOmciDeviceIdentifierPos = 3
mpagenkoc8bba412021-01-15 15:38:44 +000059const cOmciBaseMessageTrailerLen = 40
60
61// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
62type tOmciReceiveError uint8
63
64const (
65 // cOmciMessageReceiveNoError - default start state
66 cOmciMessageReceiveNoError tOmciReceiveError = iota
67 // Error indication wrong trailer length within the message
68 cOmciMessageReceiveErrorTrailerLen
69 // Error indication missing trailer within the message
70 cOmciMessageReceiveErrorMissTrailer
71)
72
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000073// CDefaultRetries - TODO: add comment
74const CDefaultRetries = 2
Holger Hildebrandt366ef192021-05-05 11:07:44 +000075
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000076// ### OMCI related definitions - end
77
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000078//CallbackPairEntry to be used for OMCI send/receive correlation
79type CallbackPairEntry struct {
80 CbRespChannel chan Message
81 CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
82 FramePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000083}
84
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000085//CallbackPair to be used for ReceiveCallback init
86type CallbackPair struct {
87 CbKey uint16
88 CbEntry CallbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000089}
90
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000091// OmciTransferStructure - TODO: add comment
92type OmciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000093 txFrame []byte
94 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000095 retries int
mpagenko80622a52021-02-09 16:53:23 +000096 highPrio bool
97 withFramePrint bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000098 cbPair CallbackPair
Holger Hildebrandt366ef192021-05-05 11:07:44 +000099 chSuccess chan bool
kesavand011d5162021-11-25 19:21:06 +0530100 OnuSwWindow *ia.OmciMessages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000101}
102
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000103type txRxCounters struct {
104 txArFrames uint32
105 txNoArFrames uint32
106 rxAkFrames uint32
107 rxNoAkFrames uint32
108}
109
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000110//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
111type OmciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000112 enabled bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000113 pBaseDeviceHandler IdeviceHandler
114 pOnuDeviceEntry IonuDeviceEntry
115 pOnuAlarmManager IonuAlarmManager
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000116 deviceID string
khenaidoo7d3c5582021-08-11 18:09:44 -0400117 coreClient *vgrpc.Client
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000118 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000119 rxOmciFrameError tOmciReceiveError
120
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000121 mutexCounters sync.RWMutex
122 countersBase txRxCounters
123 countersExt txRxCounters
124 txRetries uint32
125 txTimeouts uint32
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000126
127 // OMCI params
128 mutexTid sync.Mutex
129 tid uint16
130 mutexHpTid sync.Mutex
131 hpTid uint16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000132 UploadSequNo uint16
133 UploadNoOfCmds uint16
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000134
Holger Hildebrandt34555512021-10-01 16:26:59 +0000135 mutexSendQueuedRequests sync.Mutex
136 mutexLowPrioTxQueue sync.Mutex
137 lowPrioTxQueue *list.List
138 mutexHighPrioTxQueue sync.Mutex
139 highPrioTxQueue *list.List
140 mutexRxSchedMap sync.Mutex
141 rxSchedulerMap map[uint16]CallbackPairEntry
142 mutexMonReq sync.RWMutex
143 monitoredRequests map[uint16]OmciTransferStructure
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000144}
145
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000146var responsesWithMibDataSync = []omci.MessageType{
147 omci.CreateResponseType,
148 omci.DeleteResponseType,
149 omci.SetResponseType,
150 omci.StartSoftwareDownloadResponseType,
151 omci.EndSoftwareDownloadResponseType,
152 omci.ActivateSoftwareResponseType,
153 omci.CommitSoftwareResponseType,
154}
155
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000156//NewOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000157//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000158func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
159 onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
160 coreClient *vgrpc.Client) *OmciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000161 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000162 var omciCC OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000163 omciCC.enabled = false
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000164 omciCC.pBaseDeviceHandler = deviceHandler
165 omciCC.pOnuAlarmManager = onuAlarmManager
Himani Chawla4d908332020-08-31 12:30:20 +0530166 omciCC.pOnuDeviceEntry = onuDeviceEntry
167 omciCC.deviceID = deviceID
khenaidoo7d3c5582021-08-11 18:09:44 -0400168 omciCC.coreClient = coreClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000169 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000170 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000171 omciCC.countersBase = txRxCounters{0, 0, 0, 0}
172 omciCC.countersExt = txRxCounters{0, 0, 0, 0}
173 omciCC.txRetries = 0
174 omciCC.txTimeouts = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000175 omciCC.tid = 0x1
176 omciCC.hpTid = 0x8000
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000177 omciCC.UploadSequNo = 0
178 omciCC.UploadNoOfCmds = 0
Holger Hildebrandt34555512021-10-01 16:26:59 +0000179 omciCC.lowPrioTxQueue = list.New()
180 omciCC.highPrioTxQueue = list.New()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000181 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
182 omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000183
184 return &omciCC
185}
186
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000187//Stop stops/resets the omciCC
188func (oo *OmciCC) Stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000189 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000190 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
mpagenko8cd1bf72021-06-22 10:11:19 +0000191 oo.CancelRequestMonitoring(ctx)
Holger Hildebrandt34555512021-10-01 16:26:59 +0000192 // clear the tx queues
193 oo.mutexHighPrioTxQueue.Lock()
194 oo.highPrioTxQueue.Init()
195 oo.mutexHighPrioTxQueue.Unlock()
196 oo.mutexLowPrioTxQueue.Lock()
197 oo.lowPrioTxQueue.Init()
198 oo.mutexLowPrioTxQueue.Unlock()
199 //clear the scheduler map
mpagenko900ee4b2020-10-12 11:56:34 +0000200 oo.mutexRxSchedMap.Lock()
201 for k := range oo.rxSchedulerMap {
Holger Hildebrandt34555512021-10-01 16:26:59 +0000202 delete(oo.rxSchedulerMap, k)
mpagenko900ee4b2020-10-12 11:56:34 +0000203 }
204 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000205 //reset the high prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000206 oo.mutexHpTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000207 oo.hpTid = 0x8000
mpagenko900ee4b2020-10-12 11:56:34 +0000208 oo.mutexHpTid.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000209 //reset the low prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000210 oo.mutexTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000211 oo.tid = 1
mpagenko900ee4b2020-10-12 11:56:34 +0000212 oo.mutexTid.Unlock()
213 //reset control values
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000214 oo.UploadSequNo = 0
215 oo.UploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000216 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000217
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000218 //reset the stats counter
219 oo.mutexCounters.Lock()
220 oo.countersBase = txRxCounters{0, 0, 0, 0}
221 oo.countersExt = txRxCounters{0, 0, 0, 0}
222 oo.txRetries = 0
223 oo.txTimeouts = 0
224 oo.mutexCounters.Unlock()
mpagenko900ee4b2020-10-12 11:56:34 +0000225 return nil
226}
227
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000228// Rx handler for omci messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000229func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000230 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000231 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530232 switch omciMsg.MessageType {
233 case omci.AlarmNotificationType:
234 data := OmciMessage{
235 OmciMsg: omciMsg,
236 OmciPacket: packet,
237 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000238 go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530239 return nil
240 default:
241 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
242 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000243 /*
244 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
245 rxOnuFrames++
246
247 switch msgType {
248 case AlarmNotification:
249 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000250 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000251 // python code was:
252 //if msg_type == EntityOperations.AlarmNotification.value:
253 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
254 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
255 //
256 return errors.New("RxAlarmNotification unimplemented")
257 }
258 case AttributeValueChange:
259 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000260 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000261 // python code was:
262 //elif msg_type == EntityOperations.AttributeValueChange.value:
263 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
264 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
265 //
266 return errors.New("RxAttributeValueChange unimplemented")
267 }
268 case TestResult:
269 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000270 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000271 // python code was:
272 //elif msg_type == EntityOperations.TestResult.value:
273 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
274 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
275 //
276 return errors.New("RxTestResult unimplemented")
277 }
278 default:
279 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000280 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000281 rxOnuDiscards++
282 return errors.New("RxOnuMsgType unimplemented")
283 }
284 }
285 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000286}
287
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000288func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
mpagenko80622a52021-02-09 16:53:23 +0000289 //assuming omci message content is hex coded!
290 // with restricted output of 16bytes would be ...rxMsg[:16]
291 logger.Debugw(ctx, "omci-message-received:", log.Fields{
292 "RxOmciMessage": hex.EncodeToString(rxMsg),
293 "device-id": oo.deviceID})
294}
295
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000296// ReceiveMessage - Rx handler for onu messages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000297// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000298// nolint: gocyclo
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000299func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000300 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000301
302 if len(rxMsg) < 10 {
303 logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort",
304 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
305 if len(rxMsg) > 0 {
306 oo.printRxMessage(ctx, rxMsg)
mpagenkoc8bba412021-01-15 15:38:44 +0000307 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000308 return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID)
309 }
310 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
311 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
312 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
313 // (an extendedFormat message could be destroyed this way!)
314 trailerLenData := rxMsg[42:44]
315 trailerLen := binary.BigEndian.Uint16(trailerLenData)
316 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
317 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
318 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
319 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
320 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
321 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
322 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
323 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
324 }
325 }
326 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
327 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
328 // (an extendedFormat message could be destroyed this way!)
329 // extend/overwrite with trailer
330 trailer := make([]byte, 8)
331 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
332 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
333 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
334 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
335 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
336 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
337 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
338 }
339 } else {
340 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
341 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
342 oo.printRxMessage(ctx, rxMsg)
343 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
344 }
345 } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) {
346 if len(rxMsg) > 1980 {
347 logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort",
348 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
349 oo.printRxMessage(ctx, rxMsg)
350 return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000351 }
352 } else {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000353 logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort",
mpagenkoc8bba412021-01-15 15:38:44 +0000354 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000355 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000356 return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000357 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000358 decodeOptions := gopacket.DecodeOptions{
359 Lazy: true,
360 NoCopy: true,
361 }
362 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000363 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000364 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000365 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200366 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000367 }
368 omciLayer := packet.Layer(omci.LayerTypeOMCI)
369 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000370 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000371 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200372 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000373 }
mpagenko836a1fd2021-11-01 16:12:42 +0000374 // insert some check on detected OMCI decoding issues and log them
375 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
376 // even though allowed from omci-lib due to set relaxed decoding
377 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
378 // (compare mib_sync.go unknownAttrLayer)
379 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
380 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
381 errMsg := failure.Error()
382 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
383 "device-id": oo.deviceID, "issue": errMsg})
384 }
385 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000386 omciMsg, ok := omciLayer.(*omci.OMCI)
387 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000388 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000389 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200390 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000391 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000392 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000393 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
394 "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID})
mpagenko836a1fd2021-11-01 16:12:42 +0000395
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700396 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
397 // We expect to find the TID in the oo.rxSchedulerMap
398 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000399 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000400 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000401 logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000402 if omciMsg.TransactionID == 0 {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000403 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
404 oo.incrementBaseRxNoAkFrames()
405 } else {
406 oo.incrementExtRxNoAkFrames()
407 }
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530408 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000409 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000410 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200411 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000412 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200413 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530414 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000415 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530416 oo.mutexRxSchedMap.Lock()
417 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000418 if ok && rxCallbackEntry.CbFunction != nil {
419 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000420 oo.printRxMessage(ctx, rxMsg)
421 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000422 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
423 oo.incrementBaseRxAkFrames()
424 } else {
425 oo.incrementExtRxAkFrames()
426 }
Himani Chawla4d908332020-08-31 12:30:20 +0530427 //disadvantage of decoupling: error verification made difficult, but anyway the question is
428 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000429 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000430 isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet)
431 if err != nil {
432 // qualified error logging already done in function above
433 if !rxCallbackEntry.FramePrint {
434 oo.printRxMessage(ctx, rxMsg)
435 }
436 return fmt.Errorf("could not decode further layers %s", oo.deviceID)
437 }
438 if isSuccessfulResponse {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000439 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000440 } else {
441 logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type",
442 log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID})
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000443 }
mpagenkoc8bba412021-01-15 15:38:44 +0000444
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700445 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
446 // so do not clean up the TransactionID in that case.
447 if omciMsg.MessageType != omci.TestResponseType {
448 // having posted the response the request is regarded as 'done'
449 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
450 }
Himani Chawla4d908332020-08-31 12:30:20 +0530451 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000452 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000453 }
mpagenko80622a52021-02-09 16:53:23 +0000454 oo.mutexRxSchedMap.Unlock()
455 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
456 oo.printRxMessage(ctx, rxMsg)
457 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000458
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000459 /* py code was:
460 Receive and OMCI message from the proxy channel to the OLT.
461
462 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
463 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
464 """
465 if not self.enabled:
466 return
467
468 try:
469 now = arrow.utcnow()
470 d = None
471
472 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
473 # save the current value of the entity_id_to_class_map, then
474 # replace it with our custom one before decode, and then finally
475 # restore it later. Tried other ways but really made the code messy.
476 saved_me_map = omci_entities.entity_id_to_class_map
477 omci_entities.entity_id_to_class_map = self._me_map
478
479 try:
480 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000481 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000482 except KeyError as e:
483 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000484 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000485 rx_frame = self._decode_unknown_me(msg)
486 self._rx_unknown_me += 1
487
488 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000489 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000490 return
491
492 finally:
493 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
494
495 rx_tid = rx_frame.fields['transaction_id']
496 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000497 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000498 # Filter the Test Result frame and route through receive onu
499 # message method.
500 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000501 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000502 return self._receive_onu_message(rx_frame)
503
504 # Previously unreachable if this is the very first round-trip Rx or we
505 # have been running consecutive errors
506 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000507 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000508 self.reactor.callLater(0, self._publish_connectivity_event, True)
509
510 self._rx_frames += 1
511 self._consecutive_errors = 0
512
513 try:
514 high_priority = self._tid_is_high_priority(rx_tid)
515 index = self._get_priority_index(high_priority)
516
517 # (timestamp, defer, frame, timeout, retry, delayedCall)
518 last_tx_tuple = self._tx_request[index]
519
520 if last_tx_tuple is None or \
521 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
522 # Possible late Rx on a message that timed-out
523 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000524 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000525 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
526 self._rx_unknown_tid += 1
527 self._rx_late += 1
528 return
529
530 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
531 if dc is not None and not dc.cancelled and not dc.called:
532 dc.cancel()
533
534 _secs = self._update_rx_tx_stats(now, ts)
535
536 # Late arrival already serviced by a timeout?
537 if d.called:
538 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000539 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000540 return
541
542 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000543 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000544 if d is not None:
545 return d.errback(failure.Failure(e))
546 return
547
548 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000549 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000550 tx_tid = tx_frame.fields['transaction_id'])
551 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
552
553 # begin success callback chain (will cancel timeout and queue next Tx message)
554 self._rx_response[index] = rx_frame
555 d.callback(rx_frame)
556
557 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000558 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000559 */
560}
561
Himani Chawla6d2ae152020-09-02 13:11:20 +0530562/*
563func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530564 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530565 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530567*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000568
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700569// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000570func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700571 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
572 delete(oo.rxSchedulerMap, tid)
573}
574
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000575// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
576func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
577 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000578
mpagenkoc26d4c02021-05-06 14:27:57 +0000579 if timeout != 0 {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000580 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000581 oo.mutexRxSchedMap.Lock()
582 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000583 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000584 oo.mutexRxSchedMap.Unlock()
585 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000586
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000587 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000588 //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 +0000589 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000590 txFrame,
591 timeout,
592 retry,
593 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000594 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000595 receiveCallbackPair,
596 nil,
kesavand011d5162021-11-25 19:21:06 +0530597 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000598 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000599 oo.mutexMonReq.Lock()
600 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000601 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000602 // do not call processRequestMonitoring in background here to ensure correct sequencing
603 // of requested messages into txQueue (especially for non-response-supervised messages)
604 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000605 return nil
606 }
607 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000608 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000609 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000610}
611
Holger Hildebrandt34555512021-10-01 16:26:59 +0000612func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
613 // Avoid accessing the txQueues from parallel send routines to block
614 // parallel omci send requests at least until SendIAP is 'committed'.
615 // To guarantee window size 1 for one ONU it would be necessary to wait
616 // for the corresponding response too (t.b.d.).
617 oo.mutexSendQueuedRequests.Lock()
618 defer oo.mutexSendQueuedRequests.Unlock()
619 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
620 logger.Errorw(ctx, "Error during sending high prio requests!",
621 log.Fields{"err": err, "device-id": oo.deviceID})
622 return
623 }
624 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
625 logger.Errorw(ctx, "Error during sending low prio requests!",
626 log.Fields{"err": err, "device-id": oo.deviceID})
627 return
628 }
629}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000630
Holger Hildebrandt34555512021-10-01 16:26:59 +0000631func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
632 oo.mutexHighPrioTxQueue.Lock()
633 defer oo.mutexHighPrioTxQueue.Unlock()
634 for oo.highPrioTxQueue.Len() > 0 {
635 queueElement := oo.highPrioTxQueue.Front() // First element
636 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000637 // Element will be removed from the queue regardless of the send success, to prevent
638 // an accumulation of send requests for the same message in the event of an error.
639 // In this case, resend attempts for the message are ensured by our retry
640 // mechanism after omci-timeout.
641 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
Holger Hildebrandt34555512021-10-01 16:26:59 +0000642 return err
mpagenko80622a52021-02-09 16:53:23 +0000643 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000644 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
645 }
646 return nil
647}
648
649func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
650 oo.mutexLowPrioTxQueue.Lock()
651 for oo.lowPrioTxQueue.Len() > 0 {
652 queueElement := oo.lowPrioTxQueue.Front() // First element
kesavand011d5162021-11-25 19:21:06 +0530653 // check if the element is for onu sw section
654 aOmciTxReq := queueElement.Value.(OmciTransferStructure)
655 if aOmciTxReq.OnuSwWindow != nil {
656 if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000657 // Element will be removed from the queue regardless of the send success, to prevent
658 // an accumulation of send requests for the same message in the event of an error.
659 // In this case, resend attempts for the message are ensured by our retry
660 // mechanism after omci-timeout.
661 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530662 oo.mutexLowPrioTxQueue.Unlock()
663 return err
664 }
665 } else {
666 err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure))
667 if err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000668 // Element will be removed from the queue regardless of the send success, to prevent
669 // an accumulation of send requests for the same message in the event of an error.
670 // In this case, resend attempts for the message are ensured by our retry
671 // mechanism after omci-timeout.
672 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530673 oo.mutexLowPrioTxQueue.Unlock()
674 return err
675 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200676 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000677 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
678 // Interrupt the sending of low priority requests to process any high priority requests
679 // that may have arrived in the meantime
680 oo.mutexLowPrioTxQueue.Unlock()
681 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
682 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000683 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000684 oo.mutexLowPrioTxQueue.Lock()
685 }
686
687 oo.mutexLowPrioTxQueue.Unlock()
688 return nil
689}
690
691func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
692 if omciTxRequest.withFramePrint {
693 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
694 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
695 "device-id": oo.deviceID,
696 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
697 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
698 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
699 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400700 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000701 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
702 ChildDeviceId: oo.deviceID,
703 Message: omciTxRequest.txFrame,
704 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
705 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
706 }
707 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
708 if sendErr != nil {
Holger Hildebrandtabfef032022-02-25 12:40:20 +0000709 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 +0000710 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000711 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000712 if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
713 oo.incrementBaseTxArFrames()
714 } else {
715 oo.incrementExtTxArFrames()
716 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717 return nil
718}
719
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000720// GetNextTid - TODO: add comment
721func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000722 var next uint16
723 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000724 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000725 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530726 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000727 if oo.hpTid < 0x8000 {
728 oo.hpTid = 0x8000
729 }
mpagenko900ee4b2020-10-12 11:56:34 +0000730 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000731 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000732 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000733 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530734 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000735 if oo.tid >= 0x8000 {
736 oo.tid = 1
737 }
mpagenko900ee4b2020-10-12 11:56:34 +0000738 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000739 }
740 return next
741}
742
kesavand011d5162021-11-25 19:21:06 +0530743//GetOnuSwSecNextTid get the next low prio tid for the onu sw sections
744//onu sw sections uses only low priority tids
745//The mutexTid lock should be taken prior to using this function
746func (oo *OmciCC) GetOnuSwSecNextTid() uint16 {
747 next := oo.tid
748 oo.tid++
749 if oo.tid >= 0x8000 {
750 oo.tid = 1
751 }
752 return next
753}
754
755//GetOnuSwSecLastTid gets the last allocated tid
756//The mutexTid lock should be taken prior to using this function
757func (oo *OmciCC) GetOnuSwSecLastTid() uint16 {
758 next := oo.tid
759 lastAllocatedTid := next - 1
760 return lastAllocatedTid
761}
762
763//LockMutexTID locks mutexTid
764func (oo *OmciCC) LockMutexTID() {
765 oo.mutexTid.Lock()
766}
767
768//UnLockMutexTID unlocks mutexTid
769func (oo *OmciCC) UnLockMutexTID() {
770 oo.mutexTid.Unlock()
771}
772
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000773// ###################################################################################
774// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000775
776// Serialize - TODO: add comment
777func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000778 omciLayer := &omci.OMCI{
779 TransactionID: tid,
780 MessageType: msgType,
781 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000782 return SerializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000783}
784
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000785// SerializeOmciLayer - TODO: add comment
786func SerializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000787 var options gopacket.SerializeOptions
788 options.FixLengths = true
789
790 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530791 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000792 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000793 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000794 return nil, err
795 }
796 return buffer.Bytes(), nil
797}
798
Himani Chawla4d908332020-08-31 12:30:20 +0530799/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000800func hexEncode(omciPkt []byte) ([]byte, error) {
801 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
802 hex.Encode(dst, omciPkt)
803 return dst, nil
804}
Himani Chawla4d908332020-08-31 12:30:20 +0530805*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000806
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000807//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000808func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000809
dbainbri4d3a0dc2020-12-02 00:33:42 +0000810 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000811 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000812
813 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000814 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000815 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200816 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000817 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000818 oo.mutexMonReq.RLock()
819 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000820 //implement non-blocking channel send to avoid blocking on mutexMonReq later
821 select {
822 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
823 default:
824 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
825 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
826 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000827 } else {
828 logger.Infow(ctx, "reqMon: map entry does not exist!",
829 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
830 }
831 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000832
833 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
834 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000835 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000836 Type: OMCI,
837 Data: OmciMessage{
838 OmciMsg: omciMsg,
839 OmciPacket: packet,
840 },
841 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000842 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000843 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000844
845 return nil
846}
847
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000848// SendMibReset sends MibResetRequest
849func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000850
dbainbri4d3a0dc2020-12-02 00:33:42 +0000851 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000852 request := &omci.MibResetRequest{
853 MeBasePacket: omci.MeBasePacket{
854 EntityClass: me.OnuDataClassID,
855 },
856 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000857 tid := oo.GetNextTid(highPrio)
858 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000859 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000860 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000861 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000862 return err
863 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000864 omciRxCallbackPair := CallbackPair{
865 CbKey: tid,
866 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000867 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000868 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000869}
870
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000871// SendReboot sends RebootRequest
872func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
873 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300874 request := &omci.RebootRequest{
875 MeBasePacket: omci.MeBasePacket{
876 EntityClass: me.OnuGClassID,
877 },
878 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000879 tid := oo.GetNextTid(highPrio)
880 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300881 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000882 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000883 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300884 return err
885 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000886 omciRxCallbackPair := CallbackPair{
887 CbKey: tid,
888 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300889 }
890
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000891 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300892 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000893 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000894 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300895 return err
896 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000897 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300898 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000899 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200900 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300901 return err
902 }
903 return nil
904}
905
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000906// SendMibUpload sends MibUploadRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000907func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000908 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000909
910 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000911
912 omciLayer := &omci.OMCI{
913 TransactionID: tid,
914 MessageType: omci.MibUploadRequestType,
915 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000916 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000917 omciLayer.DeviceIdentifier = omci.ExtendedIdent
918 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000919 request := &omci.MibUploadRequest{
920 MeBasePacket: omci.MeBasePacket{
921 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000922 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000923 },
924 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000925 var options gopacket.SerializeOptions
926 options.FixLengths = true
927
928 buffer := gopacket.NewSerializeBuffer()
929 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000930 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000931 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000932 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000933 return err
934 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000935 oo.UploadSequNo = 0
936 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000937
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000938 omciRxCallbackPair := CallbackPair{
939 CbKey: tid,
940 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000941 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000942 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000943}
944
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000945// SendMibUploadNext sends MibUploadNextRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000946func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000947 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000948
949 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000950
951 omciLayer := &omci.OMCI{
952 TransactionID: tid,
953 MessageType: omci.MibUploadNextRequestType,
954 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000955 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000956 omciLayer.DeviceIdentifier = omci.ExtendedIdent
957 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000958 request := &omci.MibUploadNextRequest{
959 MeBasePacket: omci.MeBasePacket{
960 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000961 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000962 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000963 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000964 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000965 var options gopacket.SerializeOptions
966 options.FixLengths = true
967
968 buffer := gopacket.NewSerializeBuffer()
969 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000970 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000971 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000972 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000973 return err
974 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000975 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000976
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000977 omciRxCallbackPair := CallbackPair{
978 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000979 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
980 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
981 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000982 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000983 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000984 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000985}
986
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000987// SendGetAllAlarm gets all alarm ME instances
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000988func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool, isExtendedOmci bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530989 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000990
991 tid := oo.GetNextTid(highPrio)
992 omciLayer := &omci.OMCI{
993 TransactionID: tid,
994 MessageType: omci.GetAllAlarmsRequestType,
995 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
996 }
997 if isExtendedOmci {
998 omciLayer.DeviceIdentifier = omci.ExtendedIdent
999 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301000 request := &omci.GetAllAlarmsRequest{
1001 MeBasePacket: omci.MeBasePacket{
1002 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001003 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301004 },
1005 AlarmRetrievalMode: byte(alarmRetreivalMode),
1006 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001007 var options gopacket.SerializeOptions
1008 options.FixLengths = true
1009 buffer := gopacket.NewSerializeBuffer()
1010 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301011 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001012 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err,
1013 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301014 return err
1015 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001016 outgoingPacket := buffer.Bytes()
1017
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001018 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +05301019
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001020 omciRxCallbackPair := CallbackPair{
1021 CbKey: tid,
1022 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301023 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001024 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1025 if err != nil {
1026 logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err,
1027 "device-id": oo.deviceID})
1028 return err
1029 }
1030 logger.Debug(ctx, "send GetAllAlarmsRequest done")
1031 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301032}
1033
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001034// SendGetAllAlarmNext gets next alarm ME instance
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001035func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool, isExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001036 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
1037 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +05301038 "alarmUploadSeqNo": alarmUploadSeqNo})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001039
1040 tid := oo.GetNextTid(highPrio)
1041 omciLayer := &omci.OMCI{
1042 TransactionID: tid,
1043 MessageType: omci.GetAllAlarmsNextRequestType,
1044 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
1045 }
1046 if isExtendedOmci {
1047 omciLayer.DeviceIdentifier = omci.ExtendedIdent
1048 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301049 request := &omci.GetAllAlarmsNextRequest{
1050 MeBasePacket: omci.MeBasePacket{
1051 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001052 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301053 },
1054 CommandSequenceNumber: alarmUploadSeqNo,
1055 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001056 var options gopacket.SerializeOptions
1057 options.FixLengths = true
1058 buffer := gopacket.NewSerializeBuffer()
1059 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301060 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001061 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err,
1062 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301063 return err
1064 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001065 outgoingPacket := buffer.Bytes()
1066
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001067 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +05301068
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001069 omciRxCallbackPair := CallbackPair{
1070 CbKey: tid,
1071 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301072 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001073 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1074 if err != nil {
1075 logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err,
1076 "device-id": oo.deviceID})
1077 return err
1078 }
1079 logger.Debug(ctx, "send GetAllAlarmsNextRequest done")
1080 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301081}
1082
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001083// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
1084func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1085 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001086 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001087 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001088
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001089 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001090 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001091 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001092 }
1093 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
1094 if omciErr.GetError() == nil {
1095 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001096 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001097 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001098 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001099 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001100 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001101 }
1102
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001103 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001104 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001105 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001106 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001107 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001108 }
1109
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001110 omciRxCallbackPair := CallbackPair{
1111 CbKey: tid,
1112 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001113 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001114 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001115 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001116 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001117 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001118 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001119 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001120 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001121 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001122 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001123 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001124 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001125 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001126}
1127
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001128// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001129// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001130func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1131 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001132 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001133 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001134
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001135 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
1136 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001137 // By now we just use fix values to fire - this is anyway what the python adapter does
1138 // read ONU-2G from DB ???? //TODO!!!
1139 meParams := me.ParamData{
1140 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001141 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001142 }
1143 meInstance, omciErr := me.NewOnu2G(meParams)
1144 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001145 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001146 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001147 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001148 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001149 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001150 }
1151
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001152 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001153 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001154 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001155 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001156 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001157 }
1158
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001159 omciRxCallbackPair := CallbackPair{
1160 CbKey: tid,
1161 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001162 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001163 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001164 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001165 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001166 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001167 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001168 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001169 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001170 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001171 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001172 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001173 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001174 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001175}
1176
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001177// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1178func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1179 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1180 tid := oo.GetNextTid(highPrio)
1181 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001182 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001183 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001184
1185 meParams := me.ParamData{
1186 EntityID: instID,
1187 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001188 me.MacBridgeServiceProfile_Priority: 0x8000,
1189 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1190 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1191 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1192 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001193 },
1194 }
1195
1196 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1197 if omciErr.GetError() == nil {
1198 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001199 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1200 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001201 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001202 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001203 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001204 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001205 }
1206
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001207 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001208 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001209 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001210 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001211 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001212 }
1213
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001214 omciRxCallbackPair := CallbackPair{
1215 CbKey: tid,
1216 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001217 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001218 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001219 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001221 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001222 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001223 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001224 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001225 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001226 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001227 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001228 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001229 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001230}
1231
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001232// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1233func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1234 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1235 tid := oo.GetNextTid(highPrio)
1236 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001237 if idErr != nil {
1238 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1239 "Err": idErr, "device-id": oo.deviceID})
1240 return nil, idErr
1241 }
1242 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001243 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001244
1245 meParams := me.ParamData{
1246 EntityID: instID,
1247 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001248 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1249 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1250 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1251 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001252 },
1253 }
1254 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1255 if omciErr.GetError() == nil {
1256 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001257 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1258 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001259 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001260 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001261 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001262 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001263 }
1264
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001265 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001266 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001267 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001268 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001269 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001270 }
1271
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001272 omciRxCallbackPair := CallbackPair{
1273 CbKey: tid,
1274 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001275 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001276 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001277 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001278 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001279 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001280 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001281 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001282 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001283 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001284 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001285 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001286 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001287 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001288}
1289
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001290// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1291func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1292 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1293 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001294 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001295 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001296 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001297 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001298
1299 // compare python adapter code WA VOL-1311: this is not done here!
1300 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1301 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1302 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001303 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001304 assType = uint8(10) // for VEIP
1305 }
1306 meParams := me.ParamData{
1307 EntityID: instID,
1308 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001309 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1310 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001311 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001312 },
1313 }
1314 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1315 if omciErr.GetError() == nil {
1316 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001317 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1318 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001319 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001320 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001321 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001322 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001323 }
1324
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001325 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001326 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001327 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001328 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001329 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001330 }
1331
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001332 omciRxCallbackPair := CallbackPair{
1333 CbKey: tid,
1334 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001335 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001336 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001337 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001338 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001339 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001340 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001341 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001342 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001343 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001344 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001345 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001346 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001347 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001348}
1349
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001350// SendSetOnuGLS sets OnuG ME instance
1351func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001352 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001353 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001354 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001355 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001356
1357 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1358 meParams := me.ParamData{
1359 EntityID: 0,
1360 Attributes: requestedAttributes,
1361 }
1362 meInstance, omciErr := me.NewOnuG(meParams)
1363 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001364 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001365 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001366 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001367 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001368 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001369 }
1370
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001371 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001372 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001373 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001374 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001375 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001376 }
1377
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001378 omciRxCallbackPair := CallbackPair{
1379 CbKey: tid,
1380 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001381 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001382 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001383 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001384 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001385 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001386 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001387 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001388 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001389 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001390 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001391 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001392 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001393 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001394}
1395
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001396// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1397func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001398 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001399 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001400 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001401 "SequNo": strconv.FormatInt(int64(tid), 16)})
1402
1403 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1404 meParams := me.ParamData{
1405 EntityID: aInstNo,
1406 Attributes: requestedAttributes,
1407 }
1408 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1409 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001410 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001411 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001412 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001413 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001414 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001415 }
1416
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001417 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001418 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001419 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001420 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001421 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001422 }
1423
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001424 omciRxCallbackPair := CallbackPair{
1425 CbKey: tid,
1426 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001427 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001428 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001429 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001431 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001432 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001433 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001434 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001435 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001436 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001437 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001438 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001439 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001440}
1441
1442/* UniG obsolete by now, left here in case it should be needed once again
1443 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301444func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001445 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001446 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001447 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001448 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001449
1450 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1451 meParams := me.ParamData{
1452 EntityID: aInstNo,
1453 Attributes: requestedAttributes,
1454 }
1455 meInstance, omciErr := me.NewUniG(meParams)
1456 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001457 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001458 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001459 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001460 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001461 return nil
1462 }
1463
1464 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1465 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001466 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001467 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001468 return nil
1469 }
1470
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001471 omciRxCallbackPair := CallbackPair{
1472 CbKey: tid,
1473 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001474 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001475 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001476 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001477 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001478 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001479 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001480 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001481 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001482 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001483 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001484 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001485 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001486 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001487}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001488*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001489
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001490// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1491func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001492 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001493 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001494 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001495 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001496
1497 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1498 meParams := me.ParamData{
1499 EntityID: aInstNo,
1500 Attributes: requestedAttributes,
1501 }
1502 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1503 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001504 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001505 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001506 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001507 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001508 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001509 }
1510
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001511 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001512 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001513 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001514 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001515 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001516 }
1517
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001518 omciRxCallbackPair := CallbackPair{
1519 CbKey: tid,
1520 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001521 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001522 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001523 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001524 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001525 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001526 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001527 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001528 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001529 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001530 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001531 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001532 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001533 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001534}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001535
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001536// SendGetMe gets ME instance
1537func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001538 timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001539
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001540 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001541 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001542 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001543
1544 meParams := me.ParamData{
1545 EntityID: entityID,
1546 Attributes: requestedAttributes,
1547 }
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001548 var messageSet omci.DeviceIdent = omci.BaselineIdent
1549 if isExtendedOmci {
1550 messageSet = omci.ExtendedIdent
1551 }
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001552 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1553 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301554 meClassIDName := meInstance.GetName()
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001555 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid), oframe.FrameFormat(messageSet))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001556 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001557 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 +03001558 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001559 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001560 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001561 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001562 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001563 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001564 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001565 omciRxCallbackPair := CallbackPair{
1566 CbKey: tid,
1567 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001568 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001569 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001570 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001571 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001572 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001573 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001574 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001575 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001576 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001577 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001578 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001579}
1580
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001581// SendGetMeWithAttributeMask gets ME instance with attribute mask
1582func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301583 timeout int, highPrio bool, rxChan chan Message) error {
1584
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001585 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301586 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1587 "SequNo": strconv.FormatInt(int64(tid), 16)})
1588
1589 request := &omci.GetRequest{
1590 MeBasePacket: omci.MeBasePacket{
1591 EntityInstance: entityID,
1592 EntityClass: classID,
1593 },
1594 AttributeMask: requestedAttributesMask,
1595 }
1596
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001597 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301598 if err != nil {
1599 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1600 return err
1601 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001602 omciRxCallbackPair := CallbackPair{
1603 CbKey: tid,
1604 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301605 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001606 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301607 if err != nil {
1608 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1609 return err
1610 }
1611 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1612 return nil
1613}
1614
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001615// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1616func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001617 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001618 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001619 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001620 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1621
1622 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001623 EntityID: aInstID,
1624 Attributes: me.AttributeValueMap{
1625 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001626 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1627 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1628 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1629 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1630 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1631 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1632 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1633 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1634 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001635 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001636 }
1637 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1638 if omciErr.GetError() == nil {
1639 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001640 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1641 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001642 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001643 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001644 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001645 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001646 }
1647
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001648 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001649 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001650 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001651 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001652 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001653 }
1654
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001655 omciRxCallbackPair := CallbackPair{
1656 CbKey: tid,
1657 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001658 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001659 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001660 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001662 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001663 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001664 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001665 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001666 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001667 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001669 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001670 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001671}
1672
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001673// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1674func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001675 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001676 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001677 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001678 "SequNo": strconv.FormatInt(int64(tid), 16),
1679 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1680
1681 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1682 if omciErr.GetError() == nil {
1683 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001684 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1685 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001686 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001687 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001688 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001689 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001690 }
1691
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001692 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001693 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001694 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001695 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001696 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001697 }
1698
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001699 omciRxCallbackPair := CallbackPair{
1700 CbKey: tid,
1701 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001702 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001703 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001704 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001705 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001706 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001707 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001708 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001709 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001710 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001711 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001712 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001713 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001714 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001715}
1716
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001717// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1718func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001719 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001720 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001721 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001722 "SequNo": strconv.FormatInt(int64(tid), 16),
1723 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1724
1725 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1726 if omciErr.GetError() == nil {
1727 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001728 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1729 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001730 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001731 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001732 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001733 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001734 }
1735
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001736 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001737 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001738 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001739 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001740 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001741 }
1742
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001743 omciRxCallbackPair := CallbackPair{
1744 CbKey: tid,
1745 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001746 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001747 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001748 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001749 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001750 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001751 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001752 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001753 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001754 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001755 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001756 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001757 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001758 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001759}
1760
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001761// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1762func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1763 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001764 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1765 "SequNo": strconv.FormatInt(int64(tid), 16),
1766 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1767
1768 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1769 if omciErr.GetError() == nil {
1770 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001771 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1772 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001773 if err != nil {
1774 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1775 "Err": err, "device-id": oo.deviceID})
1776 return nil, err
1777 }
1778
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001779 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001780 if err != nil {
1781 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1782 "Err": err, "device-id": oo.deviceID})
1783 return nil, err
1784 }
1785
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001786 omciRxCallbackPair := CallbackPair{
1787 CbKey: tid,
1788 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001789 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001790 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001791 if err != nil {
1792 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1793 "Err": err, "device-id": oo.deviceID})
1794 return nil, err
1795 }
1796 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1797 return meInstance, nil
1798 }
1799 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1800 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1801 return nil, omciErr.GetError()
1802}
1803
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001804// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1805func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001806 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001807 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001808 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001809 "SequNo": strconv.FormatInt(int64(tid), 16),
1810 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1811
1812 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1813 if omciErr.GetError() == nil {
1814 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001815 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1816 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001817 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001818 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001819 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001820 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001821 }
1822
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001823 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001824 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001825 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001826 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001827 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001828 }
1829
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001830 omciRxCallbackPair := CallbackPair{
1831 CbKey: tid,
1832 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001833 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001834 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001835 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001836 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001837 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001838 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001839 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001840 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001841 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001842 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001843 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001844 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001845 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001846}
1847
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001848// SendSetTcontVar sets TCont ME instance
1849func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001850 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001851 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001852 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001853 "SequNo": strconv.FormatInt(int64(tid), 16),
1854 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1855
1856 meInstance, omciErr := me.NewTCont(params[0])
1857 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001858 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001859 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001860 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001861 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001862 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001863 }
1864
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001865 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001866 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001867 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001868 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001869 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001870 }
1871
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001872 omciRxCallbackPair := CallbackPair{
1873 CbKey: tid,
1874 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001875 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001876 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001877 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001878 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001879 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001880 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001881 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001882 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001883 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001884 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001885 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001886 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001887 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001888}
1889
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001890// SendSetPrioQueueVar sets PriorityQueue ME instance
1891func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001892 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001893 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001894 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001895 "SequNo": strconv.FormatInt(int64(tid), 16),
1896 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1897
1898 meInstance, omciErr := me.NewPriorityQueue(params[0])
1899 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001900 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001901 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001902 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001903 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001904 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001905 }
1906
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001907 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001908 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001909 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001910 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001911 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001912 }
1913
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001914 omciRxCallbackPair := CallbackPair{
1915 CbKey: tid,
1916 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001917 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001918 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001919 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001920 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001921 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001922 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001923 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001924 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001925 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001926 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001927 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001928 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001929 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001930}
1931
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001932// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1933func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001934 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001935 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001936 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001937 "SequNo": strconv.FormatInt(int64(tid), 16),
1938 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1939
1940 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1941 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001942 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001943 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001944 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001945 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001946 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001947 }
1948
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001949 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001950 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001951 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001952 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001953 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001954 }
1955
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001956 omciRxCallbackPair := CallbackPair{
1957 CbKey: tid,
1958 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001959 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001960 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001961 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001962 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001963 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001964 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001965 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001966 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001967 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001968 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001969 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001970 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001971 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001972}
mpagenkodff5dda2020-08-28 11:52:01 +00001973
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001974// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1975func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001976 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001977 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001978 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001979 "SequNo": strconv.FormatInt(int64(tid), 16),
1980 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1981
1982 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1983 if omciErr.GetError() == nil {
1984 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001985 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1986 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001987 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001988 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001989 "Err": err, "device-id": oo.deviceID})
1990 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1991 // return (dual format) error code that can be used at caller for immediate error treatment
1992 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001993 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001994 }
1995
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001996 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001997 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001998 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001999 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002000 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002001 }
2002
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002003 omciRxCallbackPair := CallbackPair{
2004 CbKey: tid,
2005 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002006 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002007 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002008 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002009 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002010 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002011 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002012 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002013 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002014 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002015 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002016 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002017 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002018 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002019}
2020
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002021// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002022func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002023 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002024 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002025 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002026 "SequNo": strconv.FormatInt(int64(tid), 16),
2027 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2028
2029 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
2030 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002031 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
2032 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002033 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002034 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002035 "Err": err, "device-id": oo.deviceID})
2036 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2037 // return (dual format) error code that can be used at caller for immediate error treatment
2038 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002039 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002040 }
2041
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002042 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002043 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002044 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002045 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002046 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002047 }
2048
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002049 omciRxCallbackPair := CallbackPair{
2050 CbKey: tid,
2051 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002052 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002053 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002054 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002055 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002056 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002057 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002058 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002059 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002060 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002061 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002062 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002063 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002064 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002065}
2066
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002067// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
2068func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002069 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002070 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002071 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002072 "SequNo": strconv.FormatInt(int64(tid), 16),
2073 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2074
2075 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2076 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002077 //EnhancedMode not yet supported, used with default options
2078 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
2079 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002080 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002081 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002082 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002083 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002084 }
2085
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002086 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002087 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002088 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002089 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002090 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002091 }
2092
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002093 omciRxCallbackPair := CallbackPair{
2094 CbKey: tid,
2095 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002096 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002097 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002098 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002099 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002100 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002101 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002102 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002103 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002104 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002105 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002106 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002107 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002108 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002109}
2110
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002111// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
2112func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002113 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002114 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002115 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00002116 "SequNo": strconv.FormatInt(int64(tid), 16),
2117 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2118
2119 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2120 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002121 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00002122 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002123 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002124 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002125 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002126 }
2127
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002128 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002129 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002130 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002131 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002132 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002133 }
2134
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002135 omciRxCallbackPair := CallbackPair{
2136 CbKey: tid,
2137 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002138 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002139 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002140 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002141 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002142 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002143 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002144 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002145 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002146 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002147 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002148 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002149 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002150 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002151}
mpagenko01e726e2020-10-23 09:45:29 +00002152
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002153// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2154func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002155 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002156 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002157 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002158 "SequNo": strconv.FormatInt(int64(tid), 16),
2159 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2160
2161 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2162 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002163 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002164 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002165 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002166 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002167 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002168 }
2169
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002170 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002171 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002172 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002173 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002174 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002175 }
2176
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002177 omciRxCallbackPair := CallbackPair{
2178 CbKey: tid,
2179 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002180 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002181 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002182 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002183 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002184 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002185 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002186 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002187 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002188 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002189 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002190 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002191 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002192 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002193}
2194
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002195// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2196func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002197 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002198 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002199 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002200 "SequNo": strconv.FormatInt(int64(tid), 16),
2201 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2202
2203 meParams := me.ParamData{EntityID: aInstID}
2204 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2205 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002206 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2207 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002208 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002209 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002210 "Err": err, "device-id": oo.deviceID})
2211 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2212 // return (dual format) error code that can be used at caller for immediate error treatment
2213 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002214 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002215 }
2216
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002217 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002218 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002219 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002220 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002221 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002222 }
2223
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002224 omciRxCallbackPair := CallbackPair{
2225 CbKey: tid,
2226 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002227 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002228 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002229 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002230 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002231 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002232 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002233 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002235 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002236 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002237 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002238 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002239 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002240}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002241
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002242// SendCreateTDVar creates TrafficDescriptor ME instance
2243func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2244 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002245 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2246 "SequNo": strconv.FormatInt(int64(tid), 16),
2247 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2248 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2249 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002250 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002251 if err != nil {
2252 logger.Errorw(ctx, "Cannot encode TD for create", 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 create", 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 create", 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-Create-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// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002277func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002278 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002279 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002280 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2281 "SequNo": strconv.FormatInt(int64(tid), 16),
2282 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2283
2284 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2285 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002286 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002287 if err != nil {
2288 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002289 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002290 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002291 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002292 if err != nil {
2293 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002294 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002295 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002296 omciRxCallbackPair := CallbackPair{
2297 CbKey: tid,
2298 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002299 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002300 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002301 if err != nil {
2302 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002303 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002304 }
2305 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002306 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002307 }
2308 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002309 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002310
2311}
2312
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002313// SendDeleteTD - TODO: add comment
2314func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002315 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002316 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002317 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2318 "SequNo": strconv.FormatInt(int64(tid), 16),
2319 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2320
2321 meParams := me.ParamData{EntityID: aInstID}
2322 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2323 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002324 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002325 if err != nil {
2326 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002327 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002328 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002329 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002330 if err != nil {
2331 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002332 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002333 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002334 omciRxCallbackPair := CallbackPair{
2335 CbKey: tid,
2336 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002337 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002338 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002339 if err != nil {
2340 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002341 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002342 }
2343 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002344 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002345 }
2346 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002347 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002348
2349}
2350
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002351// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2352func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002353 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002354 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002355 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002356 "SequNo": strconv.FormatInt(int64(tid), 16),
2357 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2358
2359 meParams := me.ParamData{EntityID: aInstID}
2360 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2361 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002362 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2363 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002364 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002365 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002366 "Err": err, "device-id": oo.deviceID})
2367 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2368 // return (dual format) error code that can be used at caller for immediate error treatment
2369 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002370 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002371 }
2372
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002373 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002374 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002375 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002376 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002377 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002378 }
2379
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002380 omciRxCallbackPair := CallbackPair{
2381 CbKey: tid,
2382 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002383 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002384 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002385 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002386 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002387 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002388 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002389 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002390 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002391 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002392 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002393 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002394 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002395 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002396}
2397
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002398// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2399func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002400 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002401 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002402 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002403 "SequNo": strconv.FormatInt(int64(tid), 16),
2404 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2405
2406 meParams := me.ParamData{EntityID: aInstID}
2407 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2408 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002409 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2410 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002411 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002412 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002413 "Err": err, "device-id": oo.deviceID})
2414 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2415 // return (dual format) error code that can be used at caller for immediate error treatment
2416 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002417 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002418 }
2419
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002420 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002421 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002422 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002423 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002424 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002425 }
2426
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002427 omciRxCallbackPair := CallbackPair{
2428 CbKey: tid,
2429 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002430 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002431 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002432 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002433 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002434 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002435 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002436 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002437 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002438 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002439 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002440 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002441 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002442 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002443}
2444
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002445// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2446func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002447 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002448 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002449 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002450 "SequNo": strconv.FormatInt(int64(tid), 16),
2451 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2452
2453 meParams := me.ParamData{EntityID: aInstID}
2454 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2455 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002456 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2457 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002458 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002459 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002460 "Err": err, "device-id": oo.deviceID})
2461 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2462 // return (dual format) error code that can be used at caller for immediate error treatment
2463 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002464 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002465 }
2466
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002467 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002468 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002469 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002470 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002471 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002472 }
2473
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002474 omciRxCallbackPair := CallbackPair{
2475 CbKey: tid,
2476 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002477 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002478 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002479 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002480 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002481 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002482 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002483 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002484 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002485 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002486 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002487 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002488 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002489 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002490}
2491
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002492// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2493func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002494 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002495 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002496 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002497 "SequNo": strconv.FormatInt(int64(tid), 16),
2498 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2499
2500 meParams := me.ParamData{EntityID: aInstID}
2501 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2502 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002503 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2504 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002505 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002506 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002507 "Err": err, "device-id": oo.deviceID})
2508 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2509 // return (dual format) error code that can be used at caller for immediate error treatment
2510 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002511 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002512 }
2513
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002514 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002515 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002516 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002517 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002518 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002519 }
2520
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002521 omciRxCallbackPair := CallbackPair{
2522 CbKey: tid,
2523 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002524 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002525 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002526 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002527 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002528 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002529 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002530 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002531 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002532 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002533 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002534 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002535 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002536 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002537}
2538
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002539// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2540func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002541 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002542 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002543 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002544 "SequNo": strconv.FormatInt(int64(tid), 16),
2545 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2546
2547 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2548 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002549 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2550 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002551 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002552 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002553 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002554 }
2555
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002556 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002557 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002558 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002559 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002560 }
2561
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002562 omciRxCallbackPair := CallbackPair{CbKey: tid,
2563 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002564 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002565 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002566 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002567 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002568 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002569 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002570 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002571 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002572 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002573 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002574 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002575 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002576}
2577
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002578// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2579func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002580 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002581 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002582 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002583 "SequNo": strconv.FormatInt(int64(tid), 16),
2584 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2585
2586 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2587 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002588 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2589 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002590 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002591 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002592 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002593 }
2594
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002595 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002596 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002597 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002598 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002599 }
2600
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002601 omciRxCallbackPair := CallbackPair{CbKey: tid,
2602 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002603 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002604 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002605 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002606 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002607 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002608 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002609 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002610 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002611 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002612 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002613 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002614 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002615}
2616
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002617// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2618func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002619 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002620 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002621 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002622 "SequNo": strconv.FormatInt(int64(tid), 16),
2623 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2624
2625 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2626 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002627 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2628 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002629 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002630 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002631 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002632 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002633 }
2634
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002635 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002636 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002637 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002638 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002639 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002640 }
2641
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002642 omciRxCallbackPair := CallbackPair{CbKey: tid,
2643 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002644 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002645 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002646 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002647 logger.Errorw(ctx, "Cannot send MulticastOperationProfile 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002651 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002652 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002653 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002654 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002655 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002656 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002657}
2658
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002659// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2660func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002661 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002662 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002663 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002664 "SequNo": strconv.FormatInt(int64(tid), 16),
2665 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2666
2667 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2668 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002669 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2670 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002671 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002672 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002673 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002674 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002675 }
2676
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002677 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002678 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002679 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002680 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002681 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002682 }
2683
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002684 omciRxCallbackPair := CallbackPair{CbKey: tid,
2685 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002686 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002687 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002688 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002689 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002690 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002691 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002692 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002693 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002694 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002695 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002696 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002697 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002698 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002699}
2700
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002701// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2702func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002703 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002704 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002705 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002706 "SequNo": strconv.FormatInt(int64(tid), 16),
2707 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2708
2709 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2710 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002711 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2712 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002713 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002714 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002715 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002716 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002717 }
2718
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002719 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002720 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002721 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002722 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002723 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002724 }
2725
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002726 omciRxCallbackPair := CallbackPair{CbKey: tid,
2727 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002728 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002729 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002730 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002731 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002732 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002733 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002734 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002735 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002736 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002737 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002738 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002739 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002740 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002741}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002742
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002743// SendCreateVoipVoiceCTP nolint: unused
2744func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2745 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2746 tid := oo.GetNextTid(highPrio)
2747 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2748 "SequNo": strconv.FormatInt(int64(tid), 16),
2749 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2750
2751 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2752 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002753 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2754 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002755 if err != nil {
2756 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2757 "device-id": oo.deviceID})
2758 return nil, err
2759 }
2760
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002761 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002762 if err != nil {
2763 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2764 "device-id": oo.deviceID})
2765 return nil, err
2766 }
2767
2768 omciRxCallbackPair := CallbackPair{CbKey: tid,
2769 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2770 }
2771 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2772 if err != nil {
2773 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2774 "device-id": oo.deviceID})
2775 return nil, err
2776 }
2777 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2778 return meInstance, nil
2779 }
2780 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2781 "device-id": oo.deviceID})
2782 return nil, omciErr.GetError()
2783}
2784
2785// SendSetVoipVoiceCTP nolint: unused
2786func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2787 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2788 tid := oo.GetNextTid(highPrio)
2789 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2790 "SequNo": strconv.FormatInt(int64(tid), 16),
2791 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2792
2793 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2794 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002795 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2796 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002797 if err != nil {
2798 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2799 "device-id": oo.deviceID})
2800 return nil, err
2801 }
2802
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002803 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002804 if err != nil {
2805 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2806 "device-id": oo.deviceID})
2807 return nil, err
2808 }
2809
2810 omciRxCallbackPair := CallbackPair{CbKey: tid,
2811 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2812 }
2813 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2814 if err != nil {
2815 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2816 "device-id": oo.deviceID})
2817 return nil, err
2818 }
2819 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2820 return meInstance, nil
2821 }
2822 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2823 "device-id": oo.deviceID})
2824 return nil, omciErr.GetError()
2825}
2826
2827// SendDeleteVoipVoiceCTP nolint: unused
2828func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2829 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2830 tid := oo.GetNextTid(highPrio)
2831 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2832 "SequNo": strconv.FormatInt(int64(tid), 16),
2833 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2834
2835 meParams := me.ParamData{EntityID: aInstID}
2836 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2837 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002838 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2839 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002840 if err != nil {
2841 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2842 "Err": err, "device-id": oo.deviceID})
2843 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2844 // return (dual format) error code that can be used at caller for immediate error treatment
2845 // (relevant to all used sendXX() methods and their error conditions)
2846 return nil, err
2847 }
2848
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002849 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002850 if err != nil {
2851 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2852 "Err": err, "device-id": oo.deviceID})
2853 return nil, err
2854 }
2855
2856 omciRxCallbackPair := CallbackPair{
2857 CbKey: tid,
2858 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2859 }
2860 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2861 if err != nil {
2862 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2863 "Err": err, "device-id": oo.deviceID})
2864 return nil, err
2865 }
2866 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2867 return meInstance, nil
2868 }
2869 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2870 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2871 return nil, omciErr.GetError()
2872}
2873
2874// SendCreateVoipMediaProfile nolint: unused
2875func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2876 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2877 tid := oo.GetNextTid(highPrio)
2878 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2879 "SequNo": strconv.FormatInt(int64(tid), 16),
2880 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2881
2882 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2883 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002884 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2885 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002886 if err != nil {
2887 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2888 "device-id": oo.deviceID})
2889 return nil, err
2890 }
2891
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002892 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002893 if err != nil {
2894 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2895 "device-id": oo.deviceID})
2896 return nil, err
2897 }
2898
2899 omciRxCallbackPair := CallbackPair{CbKey: tid,
2900 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2901 }
2902 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2903 if err != nil {
2904 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2905 "device-id": oo.deviceID})
2906 return nil, err
2907 }
2908 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2909 return meInstance, nil
2910 }
2911 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2912 "device-id": oo.deviceID})
2913 return nil, omciErr.GetError()
2914}
2915
2916// SendSetVoipMediaProfile nolint: unused
2917func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2918 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2919 tid := oo.GetNextTid(highPrio)
2920 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2921 "SequNo": strconv.FormatInt(int64(tid), 16),
2922 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2923
2924 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2925 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002926 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2927 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002928 if err != nil {
2929 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2930 "device-id": oo.deviceID})
2931 return nil, err
2932 }
2933
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002934 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002935 if err != nil {
2936 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2937 "device-id": oo.deviceID})
2938 return nil, err
2939 }
2940
2941 omciRxCallbackPair := CallbackPair{CbKey: tid,
2942 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2943 }
2944 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2945 if err != nil {
2946 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2947 "device-id": oo.deviceID})
2948 return nil, err
2949 }
2950 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2951 return meInstance, nil
2952 }
2953 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2954 "device-id": oo.deviceID})
2955 return nil, omciErr.GetError()
2956}
2957
2958// SendDeleteVoipMediaProfile nolint: unused
2959func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2960 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2961 tid := oo.GetNextTid(highPrio)
2962 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2963 "SequNo": strconv.FormatInt(int64(tid), 16),
2964 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2965
2966 meParams := me.ParamData{EntityID: aInstID}
2967 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2968 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002969 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2970 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002971 if err != nil {
2972 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2973 "Err": err, "device-id": oo.deviceID})
2974 return nil, err
2975 }
2976
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002977 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002978 if err != nil {
2979 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2980 "Err": err, "device-id": oo.deviceID})
2981 return nil, err
2982 }
2983
2984 omciRxCallbackPair := CallbackPair{
2985 CbKey: tid,
2986 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2987 }
2988 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2989 if err != nil {
2990 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2991 "Err": err, "device-id": oo.deviceID})
2992 return nil, err
2993 }
2994 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2995 return meInstance, nil
2996 }
2997 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2998 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2999 return nil, omciErr.GetError()
3000}
3001
3002// SendCreateVoiceServiceProfile nolint: unused
3003func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3004 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3005 tid := oo.GetNextTid(highPrio)
3006 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3007 "SequNo": strconv.FormatInt(int64(tid), 16),
3008 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3009
3010 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3011 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003012 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3013 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003014 if err != nil {
3015 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
3016 "device-id": oo.deviceID})
3017 return nil, err
3018 }
3019
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003020 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003021 if err != nil {
3022 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
3023 "device-id": oo.deviceID})
3024 return nil, err
3025 }
3026
3027 omciRxCallbackPair := CallbackPair{CbKey: tid,
3028 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3029 }
3030 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3031 if err != nil {
3032 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
3033 "device-id": oo.deviceID})
3034 return nil, err
3035 }
3036 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
3037 return meInstance, nil
3038 }
3039 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3040 "device-id": oo.deviceID})
3041 return nil, omciErr.GetError()
3042}
3043
3044// SendSetVoiceServiceProfile nolint: unused
3045func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3046 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3047 tid := oo.GetNextTid(highPrio)
3048 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3049 "SequNo": strconv.FormatInt(int64(tid), 16),
3050 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3051
3052 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3053 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003054 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3055 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003056 if err != nil {
3057 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
3058 "device-id": oo.deviceID})
3059 return nil, err
3060 }
3061
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003062 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003063 if err != nil {
3064 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
3065 "device-id": oo.deviceID})
3066 return nil, err
3067 }
3068
3069 omciRxCallbackPair := CallbackPair{CbKey: tid,
3070 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3071 }
3072 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3073 if err != nil {
3074 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
3075 "device-id": oo.deviceID})
3076 return nil, err
3077 }
3078 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
3079 return meInstance, nil
3080 }
3081 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3082 "device-id": oo.deviceID})
3083 return nil, omciErr.GetError()
3084}
3085
3086// SendDeleteVoiceServiceProfile nolint: unused
3087func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3088 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3089 tid := oo.GetNextTid(highPrio)
3090 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3091 "SequNo": strconv.FormatInt(int64(tid), 16),
3092 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3093
3094 meParams := me.ParamData{EntityID: aInstID}
3095 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
3096 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003097 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3098 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003099 if err != nil {
3100 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
3101 "Err": err, "device-id": oo.deviceID})
3102 return nil, err
3103 }
3104
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003105 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003106 if err != nil {
3107 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
3108 "Err": err, "device-id": oo.deviceID})
3109 return nil, err
3110 }
3111
3112 omciRxCallbackPair := CallbackPair{
3113 CbKey: tid,
3114 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3115 }
3116 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3117 if err != nil {
3118 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
3119 "Err": err, "device-id": oo.deviceID})
3120 return nil, err
3121 }
3122 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
3123 return meInstance, nil
3124 }
3125 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
3126 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3127 return nil, omciErr.GetError()
3128}
3129
3130// SendCreateSIPUserData nolint: unused
3131func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
3132 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3133 tid := oo.GetNextTid(highPrio)
3134 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
3135 "SequNo": strconv.FormatInt(int64(tid), 16),
3136 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3137
3138 meInstance, omciErr := me.NewSipUserData(params[0])
3139 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003140 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3141 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003142 if err != nil {
3143 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3144 "device-id": oo.deviceID})
3145 return nil, err
3146 }
3147
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003148 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003149 if err != nil {
3150 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3151 "device-id": oo.deviceID})
3152 return nil, err
3153 }
3154
3155 omciRxCallbackPair := CallbackPair{CbKey: tid,
3156 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3157 }
3158 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3159 if err != nil {
3160 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3161 "device-id": oo.deviceID})
3162 return nil, err
3163 }
3164 logger.Debug(ctx, "send SIPUserData-create-msg done")
3165 return meInstance, nil
3166 }
3167 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3168 "device-id": oo.deviceID})
3169 return nil, omciErr.GetError()
3170}
3171
3172// SendSetSIPUserData nolint: unused
3173func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3174 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3175 tid := oo.GetNextTid(highPrio)
3176 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3177 "SequNo": strconv.FormatInt(int64(tid), 16),
3178 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3179
3180 meInstance, omciErr := me.NewSipUserData(params[0])
3181 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003182 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3183 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003184 if err != nil {
3185 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3186 "device-id": oo.deviceID})
3187 return nil, err
3188 }
3189
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003190 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003191 if err != nil {
3192 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3193 "device-id": oo.deviceID})
3194 return nil, err
3195 }
3196
3197 omciRxCallbackPair := CallbackPair{CbKey: tid,
3198 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3199 }
3200 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3201 if err != nil {
3202 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3203 "device-id": oo.deviceID})
3204 return nil, err
3205 }
3206 logger.Debug(ctx, "send SIPUserData-set-msg done")
3207 return meInstance, nil
3208 }
3209 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3210 "device-id": oo.deviceID})
3211 return nil, omciErr.GetError()
3212}
3213
3214// SendDeleteSIPUserData nolint: unused
3215func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3216 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3217 tid := oo.GetNextTid(highPrio)
3218 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3219 "SequNo": strconv.FormatInt(int64(tid), 16),
3220 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3221
3222 meParams := me.ParamData{EntityID: aInstID}
3223 meInstance, omciErr := me.NewSipUserData(meParams)
3224 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003225 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3226 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003227 if err != nil {
3228 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3229 "Err": err, "device-id": oo.deviceID})
3230 return nil, err
3231 }
3232
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003233 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003234 if err != nil {
3235 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3236 "Err": err, "device-id": oo.deviceID})
3237 return nil, err
3238 }
3239
3240 omciRxCallbackPair := CallbackPair{
3241 CbKey: tid,
3242 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3243 }
3244 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3245 if err != nil {
3246 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3247 "Err": err, "device-id": oo.deviceID})
3248 return nil, err
3249 }
3250 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3251 return meInstance, nil
3252 }
3253 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3254 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3255 return nil, omciErr.GetError()
3256}
3257
3258// SendCreateVoipApplicationServiceProfile nolint: unused
3259func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3260 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3261 tid := oo.GetNextTid(highPrio)
3262 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3263 "SequNo": strconv.FormatInt(int64(tid), 16),
3264 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3265
3266 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3267 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003268 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3269 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003270 if err != nil {
3271 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3272 "device-id": oo.deviceID})
3273 return nil, err
3274 }
3275
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003276 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003277 if err != nil {
3278 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3279 "device-id": oo.deviceID})
3280 return nil, err
3281 }
3282
3283 omciRxCallbackPair := CallbackPair{CbKey: tid,
3284 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3285 }
3286 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3287 if err != nil {
3288 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3289 "device-id": oo.deviceID})
3290 return nil, err
3291 }
3292 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3293 return meInstance, nil
3294 }
3295 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3296 "device-id": oo.deviceID})
3297 return nil, omciErr.GetError()
3298}
3299
3300// SendSetVoipApplicationServiceProfile nolint: unused
3301func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3302 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3303 tid := oo.GetNextTid(highPrio)
3304 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3305 "SequNo": strconv.FormatInt(int64(tid), 16),
3306 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3307
3308 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3309 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003310 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3311 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003312 if err != nil {
3313 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3314 "device-id": oo.deviceID})
3315 return nil, err
3316 }
3317
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003318 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003319 if err != nil {
3320 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3321 "device-id": oo.deviceID})
3322 return nil, err
3323 }
3324
3325 omciRxCallbackPair := CallbackPair{CbKey: tid,
3326 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3327 }
3328 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3329 if err != nil {
3330 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3331 "device-id": oo.deviceID})
3332 return nil, err
3333 }
3334 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3335 return meInstance, nil
3336 }
3337 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3338 "device-id": oo.deviceID})
3339 return nil, omciErr.GetError()
3340}
3341
3342// SendDeleteVoipApplicationServiceProfile nolint: unused
3343func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3344 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3345 tid := oo.GetNextTid(highPrio)
3346 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3347 "SequNo": strconv.FormatInt(int64(tid), 16),
3348 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3349
3350 meParams := me.ParamData{EntityID: aInstID}
3351 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3352 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003353 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3354 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003355 if err != nil {
3356 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3357 "Err": err, "device-id": oo.deviceID})
3358 return nil, err
3359 }
3360
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003361 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003362 if err != nil {
3363 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3364 "Err": err, "device-id": oo.deviceID})
3365 return nil, err
3366 }
3367
3368 omciRxCallbackPair := CallbackPair{
3369 CbKey: tid,
3370 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3371 }
3372 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3373 if err != nil {
3374 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3375 "Err": err, "device-id": oo.deviceID})
3376 return nil, err
3377 }
3378 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3379 return meInstance, nil
3380 }
3381 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3382 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3383 return nil, omciErr.GetError()
3384}
3385
3386// SendCreateSIPAgentConfigData nolint: unused
3387func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3388 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3389 tid := oo.GetNextTid(highPrio)
3390 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3391 "SequNo": strconv.FormatInt(int64(tid), 16),
3392 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3393
3394 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3395 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003396 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3397 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003398 if err != nil {
3399 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3400 "device-id": oo.deviceID})
3401 return nil, err
3402 }
3403
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003404 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003405 if err != nil {
3406 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3407 "device-id": oo.deviceID})
3408 return nil, err
3409 }
3410
3411 omciRxCallbackPair := CallbackPair{CbKey: tid,
3412 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3413 }
3414 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3415 if err != nil {
3416 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3417 "device-id": oo.deviceID})
3418 return nil, err
3419 }
3420 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3421 return meInstance, nil
3422 }
3423 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3424 "device-id": oo.deviceID})
3425 return nil, omciErr.GetError()
3426}
3427
3428// SendSetSIPAgentConfigData nolint: unused
3429func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3430 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3431 tid := oo.GetNextTid(highPrio)
3432 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3433 "SequNo": strconv.FormatInt(int64(tid), 16),
3434 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3435
3436 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3437 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003438 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3439 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003440 if err != nil {
3441 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3442 "device-id": oo.deviceID})
3443 return nil, err
3444 }
3445
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003446 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003447 if err != nil {
3448 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3449 "device-id": oo.deviceID})
3450 return nil, err
3451 }
3452
3453 omciRxCallbackPair := CallbackPair{CbKey: tid,
3454 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3455 }
3456 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3457 if err != nil {
3458 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3459 "device-id": oo.deviceID})
3460 return nil, err
3461 }
3462 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3463 return meInstance, nil
3464 }
3465 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3466 "device-id": oo.deviceID})
3467 return nil, omciErr.GetError()
3468}
3469
3470// SendDeleteSIPAgentConfigData nolint: unused
3471func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3472 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3473 tid := oo.GetNextTid(highPrio)
3474 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3475 "SequNo": strconv.FormatInt(int64(tid), 16),
3476 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3477
3478 meParams := me.ParamData{EntityID: aInstID}
3479 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3480 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003481 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3482 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003483 if err != nil {
3484 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3485 "Err": err, "device-id": oo.deviceID})
3486 return nil, err
3487 }
3488
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003489 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003490 if err != nil {
3491 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3492 "Err": err, "device-id": oo.deviceID})
3493 return nil, err
3494 }
3495
3496 omciRxCallbackPair := CallbackPair{
3497 CbKey: tid,
3498 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3499 }
3500 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3501 if err != nil {
3502 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3503 "Err": err, "device-id": oo.deviceID})
3504 return nil, err
3505 }
3506 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3507 return meInstance, nil
3508 }
3509 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3510 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3511 return nil, omciErr.GetError()
3512}
3513
3514// SendCreateTCPUDPConfigData nolint: unused
3515func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3516 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3517 tid := oo.GetNextTid(highPrio)
3518 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3519 "SequNo": strconv.FormatInt(int64(tid), 16),
3520 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3521
3522 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3523 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003524 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3525 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003526 if err != nil {
3527 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3528 "device-id": oo.deviceID})
3529 return nil, err
3530 }
3531
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003532 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003533 if err != nil {
3534 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3535 "device-id": oo.deviceID})
3536 return nil, err
3537 }
3538
3539 omciRxCallbackPair := CallbackPair{CbKey: tid,
3540 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3541 }
3542 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3543 if err != nil {
3544 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3545 "device-id": oo.deviceID})
3546 return nil, err
3547 }
3548 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3549 return meInstance, nil
3550 }
3551 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3552 "device-id": oo.deviceID})
3553 return nil, omciErr.GetError()
3554}
3555
3556// SendSetTCPUDPConfigData nolint: unused
3557func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3558 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3559 tid := oo.GetNextTid(highPrio)
3560 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3561 "SequNo": strconv.FormatInt(int64(tid), 16),
3562 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3563
3564 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3565 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003566 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3567 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003568 if err != nil {
3569 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3570 "device-id": oo.deviceID})
3571 return nil, err
3572 }
3573
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003574 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003575 if err != nil {
3576 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3577 "device-id": oo.deviceID})
3578 return nil, err
3579 }
3580
3581 omciRxCallbackPair := CallbackPair{CbKey: tid,
3582 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3583 }
3584 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3585 if err != nil {
3586 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3587 "device-id": oo.deviceID})
3588 return nil, err
3589 }
3590 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3591 return meInstance, nil
3592 }
3593 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3594 "device-id": oo.deviceID})
3595 return nil, omciErr.GetError()
3596}
3597
3598// SendDeleteTCPUDPConfigData nolint: unused
3599func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3600 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3601 tid := oo.GetNextTid(highPrio)
3602 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3603 "SequNo": strconv.FormatInt(int64(tid), 16),
3604 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3605
3606 meParams := me.ParamData{EntityID: aInstID}
3607 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3608 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003609 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3610 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003611 if err != nil {
3612 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3613 "Err": err, "device-id": oo.deviceID})
3614 return nil, err
3615 }
3616
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003617 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003618 if err != nil {
3619 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3620 "Err": err, "device-id": oo.deviceID})
3621 return nil, err
3622 }
3623
3624 omciRxCallbackPair := CallbackPair{
3625 CbKey: tid,
3626 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3627 }
3628 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3629 if err != nil {
3630 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3631 "Err": err, "device-id": oo.deviceID})
3632 return nil, err
3633 }
3634 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3635 return meInstance, nil
3636 }
3637 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3638 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3639 return nil, omciErr.GetError()
3640}
3641
3642// SendCreateIPHostConfigData nolint: unused
3643func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3644 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3645 tid := oo.GetNextTid(highPrio)
3646 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3647 "SequNo": strconv.FormatInt(int64(tid), 16),
3648 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3649
3650 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3651 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003652 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3653 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003654 if err != nil {
3655 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3656 "device-id": oo.deviceID})
3657 return nil, err
3658 }
3659
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003660 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003661 if err != nil {
3662 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3663 "device-id": oo.deviceID})
3664 return nil, err
3665 }
3666
3667 omciRxCallbackPair := CallbackPair{CbKey: tid,
3668 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3669 }
3670 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3671 if err != nil {
3672 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3673 "device-id": oo.deviceID})
3674 return nil, err
3675 }
3676 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3677 return meInstance, nil
3678 }
3679 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3680 "device-id": oo.deviceID})
3681 return nil, omciErr.GetError()
3682}
3683
3684// SendSetIPHostConfigData nolint: unused
3685func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3686 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3687 tid := oo.GetNextTid(highPrio)
3688 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3689 "SequNo": strconv.FormatInt(int64(tid), 16),
3690 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3691
3692 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3693 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003694 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3695 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003696 if err != nil {
3697 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3698 "device-id": oo.deviceID})
3699 return nil, err
3700 }
3701
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003702 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003703 if err != nil {
3704 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3705 "device-id": oo.deviceID})
3706 return nil, err
3707 }
3708
3709 omciRxCallbackPair := CallbackPair{CbKey: tid,
3710 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3711 }
3712 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3713 if err != nil {
3714 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3715 "device-id": oo.deviceID})
3716 return nil, err
3717 }
3718 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3719 return meInstance, nil
3720 }
3721 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3722 "device-id": oo.deviceID})
3723 return nil, omciErr.GetError()
3724}
3725
3726// SendDeleteIPHostConfigData nolint: unused
3727func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3728 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3729 tid := oo.GetNextTid(highPrio)
3730 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3731 "SequNo": strconv.FormatInt(int64(tid), 16),
3732 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3733
3734 meParams := me.ParamData{EntityID: aInstID}
3735 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3736 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003737 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3738 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003739 if err != nil {
3740 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3741 "Err": err, "device-id": oo.deviceID})
3742 return nil, err
3743 }
3744
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003745 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003746 if err != nil {
3747 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3748 "Err": err, "device-id": oo.deviceID})
3749 return nil, err
3750 }
3751
3752 omciRxCallbackPair := CallbackPair{
3753 CbKey: tid,
3754 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3755 }
3756 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3757 if err != nil {
3758 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3759 "Err": err, "device-id": oo.deviceID})
3760 return nil, err
3761 }
3762 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3763 return meInstance, nil
3764 }
3765 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3766 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3767 return nil, omciErr.GetError()
3768}
3769
3770// SendCreateRTPProfileData nolint: unused
3771func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3772 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3773 tid := oo.GetNextTid(highPrio)
3774 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3775 "SequNo": strconv.FormatInt(int64(tid), 16),
3776 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3777
3778 meInstance, omciErr := me.NewRtpProfileData(params[0])
3779 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003780 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3781 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003782 if err != nil {
3783 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3784 "device-id": oo.deviceID})
3785 return nil, err
3786 }
3787
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003788 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003789 if err != nil {
3790 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3791 "device-id": oo.deviceID})
3792 return nil, err
3793 }
3794
3795 omciRxCallbackPair := CallbackPair{CbKey: tid,
3796 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3797 }
3798 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3799 if err != nil {
3800 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3801 "device-id": oo.deviceID})
3802 return nil, err
3803 }
3804 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3805 return meInstance, nil
3806 }
3807 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3808 "device-id": oo.deviceID})
3809 return nil, omciErr.GetError()
3810}
3811
3812// SendSetRTPProfileData nolint: unused
3813func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3814 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3815 tid := oo.GetNextTid(highPrio)
3816 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3817 "SequNo": strconv.FormatInt(int64(tid), 16),
3818 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3819
3820 meInstance, omciErr := me.NewRtpProfileData(params[0])
3821 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003822 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3823 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003824 if err != nil {
3825 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3826 "device-id": oo.deviceID})
3827 return nil, err
3828 }
3829
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003830 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003831 if err != nil {
3832 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3833 "device-id": oo.deviceID})
3834 return nil, err
3835 }
3836
3837 omciRxCallbackPair := CallbackPair{CbKey: tid,
3838 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3839 }
3840 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3841 if err != nil {
3842 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3843 "device-id": oo.deviceID})
3844 return nil, err
3845 }
3846 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3847 return meInstance, nil
3848 }
3849 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3850 "device-id": oo.deviceID})
3851 return nil, omciErr.GetError()
3852}
3853
3854// SendDeleteRTPProfileData nolint: unused
3855func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3856 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3857 tid := oo.GetNextTid(highPrio)
3858 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3859 "SequNo": strconv.FormatInt(int64(tid), 16),
3860 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3861
3862 meParams := me.ParamData{EntityID: aInstID}
3863 meInstance, omciErr := me.NewRtpProfileData(meParams)
3864 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003865 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3866 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003867 if err != nil {
3868 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3869 "Err": err, "device-id": oo.deviceID})
3870 return nil, err
3871 }
3872
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003873 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003874 if err != nil {
3875 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3876 "Err": err, "device-id": oo.deviceID})
3877 return nil, err
3878 }
3879
3880 omciRxCallbackPair := CallbackPair{
3881 CbKey: tid,
3882 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3883 }
3884 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3885 if err != nil {
3886 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3887 "Err": err, "device-id": oo.deviceID})
3888 return nil, err
3889 }
3890 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3891 return meInstance, nil
3892 }
3893 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3894 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3895 return nil, omciErr.GetError()
3896}
3897
3898// SendCreateNetworkDialPlanTable nolint: unused
3899func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3900 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3901 tid := oo.GetNextTid(highPrio)
3902 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3903 "SequNo": strconv.FormatInt(int64(tid), 16),
3904 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3905
3906 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3907 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003908 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3909 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003910 if err != nil {
3911 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3912 "device-id": oo.deviceID})
3913 return nil, err
3914 }
3915
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003916 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003917 if err != nil {
3918 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3919 "device-id": oo.deviceID})
3920 return nil, err
3921 }
3922
3923 omciRxCallbackPair := CallbackPair{CbKey: tid,
3924 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3925 }
3926 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3927 if err != nil {
3928 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3929 "device-id": oo.deviceID})
3930 return nil, err
3931 }
3932 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3933 return meInstance, nil
3934 }
3935 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3936 "device-id": oo.deviceID})
3937 return nil, omciErr.GetError()
3938}
3939
3940// SendSetNetworkDialPlanTable nolint: unused
3941func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3942 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3943 tid := oo.GetNextTid(highPrio)
3944 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3945 "SequNo": strconv.FormatInt(int64(tid), 16),
3946 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3947
3948 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3949 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003950 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3951 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003952 if err != nil {
3953 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3954 "device-id": oo.deviceID})
3955 return nil, err
3956 }
3957
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003958 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003959 if err != nil {
3960 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3961 "device-id": oo.deviceID})
3962 return nil, err
3963 }
3964
3965 omciRxCallbackPair := CallbackPair{CbKey: tid,
3966 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3967 }
3968 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3969 if err != nil {
3970 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3971 "device-id": oo.deviceID})
3972 return nil, err
3973 }
3974 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3975 return meInstance, nil
3976 }
3977 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3978 "device-id": oo.deviceID})
3979 return nil, omciErr.GetError()
3980}
3981
3982// SendDeleteNetworkDialPlanTable nolint: unused
3983func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3984 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3985 tid := oo.GetNextTid(highPrio)
3986 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3987 "SequNo": strconv.FormatInt(int64(tid), 16),
3988 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3989
3990 meParams := me.ParamData{EntityID: aInstID}
3991 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3992 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003993 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3994 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003995 if err != nil {
3996 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3997 "Err": err, "device-id": oo.deviceID})
3998 return nil, err
3999 }
4000
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004001 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03004002 if err != nil {
4003 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
4004 "Err": err, "device-id": oo.deviceID})
4005 return nil, err
4006 }
4007
4008 omciRxCallbackPair := CallbackPair{
4009 CbKey: tid,
4010 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4011 }
4012 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4013 if err != nil {
4014 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
4015 "Err": err, "device-id": oo.deviceID})
4016 return nil, err
4017 }
4018 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
4019 return meInstance, nil
4020 }
4021 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
4022 "Err": omciErr.GetError(), "device-id": oo.deviceID})
4023 return nil, omciErr.GetError()
4024}
4025
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004026// SendSyncTime sends SynchronizeTimeRequest
4027func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
4028 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004029 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
4030 "SequNo": strconv.FormatInt(int64(tid), 16)})
4031
4032 omciLayer := &omci.OMCI{
4033 TransactionID: tid,
4034 MessageType: omci.SynchronizeTimeRequestType,
4035 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4036 // Length: 0x28, // Optional, defaults to 40 octets
4037 }
4038 utcTime := time.Now().UTC()
4039 request := &omci.SynchronizeTimeRequest{
4040 MeBasePacket: omci.MeBasePacket{
4041 EntityClass: me.OnuGClassID,
4042 // Default Instance ID is 0
4043 },
4044 Year: uint16(utcTime.Year()),
4045 Month: uint8(utcTime.Month()),
4046 Day: uint8(utcTime.Day()),
4047 Hour: uint8(utcTime.Hour()),
4048 Minute: uint8(utcTime.Minute()),
4049 Second: uint8(utcTime.Second()),
4050 }
4051
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004052 pkt, err := SerializeOmciLayer(ctx, omciLayer, request)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004053 if err != nil {
4054 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
4055 "device-id": oo.deviceID})
4056 return err
4057 }
4058
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004059 omciRxCallbackPair := CallbackPair{CbKey: tid,
4060 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004061 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004062 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004063 if err != nil {
4064 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
4065 "device-id": oo.deviceID})
4066 return err
4067 }
4068 logger.Debug(ctx, "send synchronize time request done")
4069 return nil
4070}
4071
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004072// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
4073func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004074 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004075 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004076 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4077 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4078 meParam := me.ParamData{EntityID: entityID}
4079 var meInstance *me.ManagedEntity
4080 var omciErr me.OmciErrors
4081 if upstream {
4082 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
4083 } else {
4084 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
4085 }
4086 if omciErr.GetError() == nil {
4087 var omciLayer *omci.OMCI
4088 var msgLayer gopacket.SerializableLayer
4089 var err error
4090 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004091 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4092 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004093 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004094 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4095 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004096 }
4097 if err != nil {
4098 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
4099 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004100 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004101 }
4102
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004103 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004104 if err != nil {
4105 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
4106 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004107 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004108 }
4109
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004110 omciRxCallbackPair := CallbackPair{CbKey: tid,
4111 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004112 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004113 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004114 if err != nil {
4115 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
4116 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004117 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004118 }
4119 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
4120 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004121 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004122 }
4123 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
4124 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 +03004125 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004126}
4127
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004128// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
4129func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004130 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004131 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004132 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4133 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4134 meParam := me.ParamData{EntityID: entityID}
4135 var meInstance *me.ManagedEntity
4136 var omciErr me.OmciErrors
4137 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
4138
4139 if omciErr.GetError() == nil {
4140 var omciLayer *omci.OMCI
4141 var msgLayer gopacket.SerializableLayer
4142 var err error
4143 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004144 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4145 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004146 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004147 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4148 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004149 }
4150 if err != nil {
4151 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4152 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004153 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004154 }
4155
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004156 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004157 if err != nil {
4158 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4159 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004160 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004161 }
4162
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004163 omciRxCallbackPair := CallbackPair{CbKey: tid,
4164 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004165 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004166 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004167 if err != nil {
4168 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4169 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004170 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004171 }
4172 logger.Debugw(ctx, "send ethernet uni history data ME done",
4173 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004174 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004175 }
4176 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4177 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004178 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004179}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004180
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004181// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4182func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004183 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004184 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004185 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4186 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4187 meParam := me.ParamData{EntityID: entityID}
4188 var meInstance *me.ManagedEntity
4189 var omciErr me.OmciErrors
4190 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4191
4192 if omciErr.GetError() == nil {
4193 var omciLayer *omci.OMCI
4194 var msgLayer gopacket.SerializableLayer
4195 var err error
4196 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004197 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4198 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004199 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004200 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4201 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004202 }
4203 if err != nil {
4204 logger.Errorw(ctx, "Cannot encode fec history data ME",
4205 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004206 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004207 }
4208
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004209 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004210 if err != nil {
4211 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4212 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004213 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004214 }
4215
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004216 omciRxCallbackPair := CallbackPair{CbKey: tid,
4217 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004218 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004219 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004220 if err != nil {
4221 logger.Errorw(ctx, "Cannot send fec history data ME",
4222 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004223 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004224 }
4225 logger.Debugw(ctx, "send fec history data ME done",
4226 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004227 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004228 }
4229 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4230 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004231 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004232}
4233
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004234// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4235func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004236 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004237 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004238 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4239 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4240 meParam := me.ParamData{EntityID: entityID}
4241 var meInstance *me.ManagedEntity
4242 var omciErr me.OmciErrors
4243 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4244
4245 if omciErr.GetError() == nil {
4246 var omciLayer *omci.OMCI
4247 var msgLayer gopacket.SerializableLayer
4248 var err error
4249 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004250 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4251 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004252 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004253 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4254 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004255 }
4256 if err != nil {
4257 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4258 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004259 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004260 }
4261
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004262 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004263 if err != nil {
4264 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4265 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004266 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004267 }
4268
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004269 omciRxCallbackPair := CallbackPair{CbKey: tid,
4270 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004271 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004272 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004273 if err != nil {
4274 logger.Errorw(ctx, "Cannot send gemport history data ME",
4275 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004276 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004277 }
4278 logger.Debugw(ctx, "send gemport history data ME done",
4279 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004280 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004281 }
4282 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4283 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004284 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004285}
4286
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004287// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4288func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004289 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004290 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004291 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4292 "SequNo": strconv.FormatInt(int64(tid), 16),
4293 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4294
4295 omciLayer := &omci.OMCI{
4296 TransactionID: tid,
4297 MessageType: omci.StartSoftwareDownloadRequestType,
4298 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4299 // Length: 0x28, // Optional, defaults to 40 octets
4300 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004301 if aIsExtendedOmci {
4302 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4303 }
mpagenko80622a52021-02-09 16:53:23 +00004304 request := &omci.StartSoftwareDownloadRequest{
4305 MeBasePacket: omci.MeBasePacket{
4306 EntityClass: me.SoftwareImageClassID,
4307 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004308 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004309 },
4310 WindowSize: aDownloadWindowSize,
4311 ImageSize: aFileLen,
4312 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4313 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4314 }
4315
4316 var options gopacket.SerializeOptions
4317 options.FixLengths = true
4318 buffer := gopacket.NewSerializeBuffer()
4319 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4320 if err != nil {
4321 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4322 "device-id": oo.deviceID})
4323 return err
4324 }
4325 outgoingPacket := buffer.Bytes()
4326
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004327 omciRxCallbackPair := CallbackPair{CbKey: tid,
4328 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004329 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004330 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004331 if err != nil {
4332 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4333 "device-id": oo.deviceID})
4334 return err
4335 }
4336 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004337 return nil
4338}
4339
kesavand011d5162021-11-25 19:21:06 +05304340// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4341//Before invoking this function the oo.mutexTid needs to be be locked so that
4342//GetOnuSwSecNextTid can be invoked without further locking
4343func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4344 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004345 omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) {
kesavand011d5162021-11-25 19:21:06 +05304346 //onuswsections uses only low prioirity tids
4347 tid := oo.GetOnuSwSecNextTid()
4348 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4349 "SequNo": strconv.FormatInt(int64(tid), 16),
4350 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4351
4352 var omciTxReq OmciTransferStructure
4353 msgType := omci.DownloadSectionRequestType
4354
4355 if aAckRequest > 0 {
4356 msgType = omci.DownloadSectionRequestWithResponseType
4357
4358 }
4359 omciLayer := &omci.OMCI{
4360 TransactionID: tid,
4361 MessageType: msgType,
4362 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4363 // Length: 0x28, // Optional, defaults to 40 octets
4364 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004365 if aIsExtendedOmci {
4366 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4367 }
kesavand011d5162021-11-25 19:21:06 +05304368 localSectionData := make([]byte, len(aSection))
4369
4370 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4371 request := &omci.DownloadSectionRequest{
4372 MeBasePacket: omci.MeBasePacket{
4373 EntityClass: me.SoftwareImageClassID,
4374 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004375 Extended: aIsExtendedOmci,
kesavand011d5162021-11-25 19:21:06 +05304376 },
4377 SectionNumber: aDownloadSectionNo,
4378 SectionData: localSectionData,
4379 }
4380
4381 var options gopacket.SerializeOptions
4382 options.FixLengths = true
4383 buffer := gopacket.NewSerializeBuffer()
4384 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4385 if err != nil {
4386 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4387 "device-id": oo.deviceID})
4388 return omciTxReq, err
4389 }
4390 outgoingPacket := buffer.Bytes()
4391
4392 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4393
4394 if aAckRequest > 0 {
4395 // only the last section should have a timeout as an ack is required only for the last section of the window
4396 omciTxReq = OmciTransferStructure{
4397 withFramePrint: true,
4398 OnuSwWindow: omciMsgsPerWindow,
4399 }
4400 return omciTxReq, nil
4401 }
4402
4403 return omciTxReq, nil
4404}
4405
4406//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4407func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4408 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4409 if aOmciTxRequest.OnuSwWindow == nil {
4410 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4411 log.Fields{"device-id": oo.deviceID})
4412 return
4413
4414 }
4415
4416 tid := oo.GetOnuSwSecLastTid()
4417 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4418 omciRxCallbackPair := CallbackPair{CbKey: tid,
4419 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4420 }
4421
4422 aOmciTxRequest.cbPair = omciRxCallbackPair
4423 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4424 oo.mutexRxSchedMap.Lock()
4425 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4426 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4427 oo.mutexRxSchedMap.Unlock()
4428
4429 chSuccess := make(chan bool)
4430 aOmciTxRequest.chSuccess = chSuccess
4431 aOmciTxRequest.timeout = aTimeout
4432 aOmciTxRequest.retries = CDefaultRetries
4433
4434 //tid := aOmciTxRequest.cbPair.CbKey
4435 oo.mutexMonReq.Lock()
4436 oo.monitoredRequests[tid] = aOmciTxRequest
4437 oo.mutexMonReq.Unlock()
4438
4439 retries := aOmciTxRequest.retries
4440 retryCounter := 0
4441 if aTimeout == 0 {
4442 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4443 return
4444 }
4445loop:
4446 for retryCounter <= retries {
4447 // the onu sw sections are enqueued only to the low priority queue
4448 oo.mutexLowPrioTxQueue.Lock()
4449 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4450 oo.mutexLowPrioTxQueue.Unlock()
4451
4452 go oo.sendQueuedRequests(ctx)
4453
4454 select {
4455 case success := <-chSuccess:
4456 if success {
4457 logger.Debugw(ctx, "reqMon: response received in time",
4458 log.Fields{"tid": tid, "device-id": oo.deviceID})
4459 } else {
4460 logger.Debugw(ctx, "reqMon: wait for response aborted",
4461 log.Fields{"tid": tid, "device-id": oo.deviceID})
4462 }
4463 break loop
4464 case <-time.After(time.Duration(aTimeout) * time.Second):
4465 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004466 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
kesavand011d5162021-11-25 19:21:06 +05304467 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004468 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004469 oo.incrementTxTimesouts()
kesavand011d5162021-11-25 19:21:06 +05304470 break loop
4471 } else {
4472 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4473 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004474 oo.incrementTxRetries()
kesavand011d5162021-11-25 19:21:06 +05304475 }
4476 }
4477 retryCounter++
4478 }
4479 oo.mutexMonReq.Lock()
4480 delete(oo.monitoredRequests, tid)
4481 oo.mutexMonReq.Unlock()
4482}
4483
4484func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004485 var lastSection []byte
4486 if omciTxRequest.OnuSwWindow != nil {
4487 lastSection = omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4488 } else {
4489 logger.Errorw(ctx, "invalid sw window received", log.Fields{"device-id": oo.deviceID})
4490 return fmt.Errorf("invalid sw window received")
4491 }
4492 if omciTxRequest.withFramePrint {
4493 logger.Debugw(ctx, "sw-section-omci-message-to-send:", log.Fields{
kesavand011d5162021-11-25 19:21:06 +05304494 "TxOmciMessage": hex.EncodeToString(lastSection),
4495 "device-id": oo.deviceID,
4496 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4497 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4498 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4499 }
4500 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4501 if sendErr != nil {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004502 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"device-id": oo.deviceID, "error": sendErr})
kesavand011d5162021-11-25 19:21:06 +05304503 return sendErr
4504 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004505 numberOfNoArSections := len(omciTxRequest.OnuSwWindow.Messages) - 1 // last section of window is sent with AR expected
4506 if lastSection[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
4507 oo.increaseBaseTxNoArFramesBy(ctx, uint32(numberOfNoArSections))
4508 oo.incrementBaseTxArFrames()
4509 } else {
4510 oo.increaseExtTxNoArFramesBy(ctx, uint32(numberOfNoArSections))
4511 oo.incrementExtTxArFrames()
4512 }
kesavand011d5162021-11-25 19:21:06 +05304513 return nil
4514}
4515
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004516// SendDownloadSection sends DownloadSectionRequestWithResponse
4517func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004518 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004519 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004520 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4521 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004522 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004523
4524 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4525 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004526 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004527 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004528 if aAckRequest > 0 {
4529 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004530 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004531 }
mpagenko80622a52021-02-09 16:53:23 +00004532 omciLayer := &omci.OMCI{
4533 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004534 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004535 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4536 // Length: 0x28, // Optional, defaults to 40 octets
4537 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004538 if aIsExtendedOmci {
4539 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4540 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304541 localSectionData := make([]byte, len(aSection))
4542
mpagenko15ff4a52021-03-02 10:09:20 +00004543 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004544 request := &omci.DownloadSectionRequest{
4545 MeBasePacket: omci.MeBasePacket{
4546 EntityClass: me.SoftwareImageClassID,
4547 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004548 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004549 },
4550 SectionNumber: aDownloadSectionNo,
4551 SectionData: localSectionData,
4552 }
4553
4554 var options gopacket.SerializeOptions
4555 options.FixLengths = true
4556 buffer := gopacket.NewSerializeBuffer()
4557 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4558 if err != nil {
4559 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4560 "device-id": oo.deviceID})
4561 return err
4562 }
4563 outgoingPacket := buffer.Bytes()
4564
mpagenko15ff4a52021-03-02 10:09:20 +00004565 //for initial debug purpose overrule the requested print state for some frames
4566 printFrame := aPrint
4567 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4568 printFrame = true
4569 }
4570
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004571 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004572 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4573 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004574 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004575 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004576 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004577 if err != nil {
4578 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4579 "device-id": oo.deviceID})
4580 return err
4581 }
4582 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004583 return nil
4584}
4585
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004586//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4587func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004588 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004589 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004590 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4591 "SequNo": strconv.FormatInt(int64(tid), 16),
4592 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4593
mpagenko15ff4a52021-03-02 10:09:20 +00004594 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004595 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004596 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004597 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4598 // Length: 0x28, // Optional, defaults to 40 octets
4599 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004600 if aIsExtendedOmci {
4601 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4602 }
mpagenko15ff4a52021-03-02 10:09:20 +00004603 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004604 MeBasePacket: omci.MeBasePacket{
4605 EntityClass: me.SoftwareImageClassID,
4606 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004607 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004608 },
mpagenko15ff4a52021-03-02 10:09:20 +00004609 CRC32: aImageCrc,
4610 ImageSize: aFileLen,
4611 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4612 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004613 }
mpagenko15ff4a52021-03-02 10:09:20 +00004614
4615 var options gopacket.SerializeOptions
4616 options.FixLengths = true
4617 buffer := gopacket.NewSerializeBuffer()
4618 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4619 if err != nil {
4620 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004621 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004622 return err
mpagenko80622a52021-02-09 16:53:23 +00004623 }
mpagenko15ff4a52021-03-02 10:09:20 +00004624 outgoingPacket := buffer.Bytes()
4625
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004626 omciRxCallbackPair := CallbackPair{CbKey: tid,
4627 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004628 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004629 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004630 if err != nil {
4631 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4632 "device-id": oo.deviceID})
4633 return err
4634 }
4635 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004636 return nil
4637}
4638
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004639// SendActivateSoftware sends ActivateSoftwareRequest
4640func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004641 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004642 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004643 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4644 "SequNo": strconv.FormatInt(int64(tid), 16),
4645 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4646
4647 omciLayer := &omci.OMCI{
4648 TransactionID: tid,
4649 MessageType: omci.ActivateSoftwareRequestType,
4650 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4651 // Length: 0x28, // Optional, defaults to 40 octets
4652 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004653 if aIsExtendedOmci {
4654 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4655 }
mpagenko80622a52021-02-09 16:53:23 +00004656 request := &omci.ActivateSoftwareRequest{
4657 MeBasePacket: omci.MeBasePacket{
4658 EntityClass: me.SoftwareImageClassID,
4659 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004660 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004661 },
4662 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4663 }
4664
4665 var options gopacket.SerializeOptions
4666 options.FixLengths = true
4667 buffer := gopacket.NewSerializeBuffer()
4668 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4669 if err != nil {
4670 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4671 "device-id": oo.deviceID})
4672 return err
4673 }
4674 outgoingPacket := buffer.Bytes()
4675
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004676 omciRxCallbackPair := CallbackPair{CbKey: tid,
4677 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004678 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004679 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004680 if err != nil {
4681 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4682 "device-id": oo.deviceID})
4683 return err
4684 }
4685 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004686 return nil
4687}
mpagenko80622a52021-02-09 16:53:23 +00004688
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004689// SendCommitSoftware sends CommitSoftwareRequest
4690func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004691 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004692 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004693 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4694 "SequNo": strconv.FormatInt(int64(tid), 16),
4695 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4696
4697 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004698 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004699 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004700 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4701 // Length: 0x28, // Optional, defaults to 40 octets
4702 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004703 if aIsExtendedOmci {
4704 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4705 }
mpagenko15ff4a52021-03-02 10:09:20 +00004706 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004707 MeBasePacket: omci.MeBasePacket{
4708 EntityClass: me.SoftwareImageClassID,
4709 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004710 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004711 },
mpagenko80622a52021-02-09 16:53:23 +00004712 }
mpagenko15ff4a52021-03-02 10:09:20 +00004713
4714 var options gopacket.SerializeOptions
4715 options.FixLengths = true
4716 buffer := gopacket.NewSerializeBuffer()
4717 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4718 if err != nil {
4719 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004720 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004721 return err
mpagenko80622a52021-02-09 16:53:23 +00004722 }
mpagenko15ff4a52021-03-02 10:09:20 +00004723 outgoingPacket := buffer.Bytes()
4724
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004725 omciRxCallbackPair := CallbackPair{CbKey: tid,
4726 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004727 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004728 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004729 if err != nil {
4730 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4731 "device-id": oo.deviceID})
4732 return err
4733 }
4734 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004735 return nil
4736}
4737
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004738//SendSelfTestReq sends TestRequest
4739func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4740 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004741 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4742 "SequNo": strconv.FormatInt(int64(tid), 16),
4743 "InstId": strconv.FormatInt(int64(instdID), 16)})
4744 omciLayer := &omci.OMCI{
4745 TransactionID: tid,
4746 MessageType: omci.TestRequestType,
4747 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4748 // Length: 0x28, // Optional, defaults to 40 octets
4749 }
4750
4751 var request *omci.OpticalLineSupervisionTestRequest
4752 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004753 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004754 request = &omci.OpticalLineSupervisionTestRequest{
4755 MeBasePacket: omci.MeBasePacket{
4756 EntityClass: classID,
4757 EntityInstance: instdID,
4758 },
4759 SelectTest: uint8(7), // self test
4760 GeneralPurposeBuffer: uint16(0),
4761 VendorSpecificParameters: uint16(0),
4762 }
4763 default:
4764 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4765 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4766 }
4767 // Test serialization back to former string
4768 var options gopacket.SerializeOptions
4769 options.FixLengths = true
4770
4771 buffer := gopacket.NewSerializeBuffer()
4772 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4773 if err != nil {
4774 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4775 "device-id": oo.deviceID})
4776 return err
4777 }
4778 outgoingPacket := buffer.Bytes()
4779
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004780 omciRxCallbackPair := CallbackPair{CbKey: tid,
4781 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004782 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004783 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004784 if err != nil {
4785 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4786 "device-id": oo.deviceID})
4787 return err
4788 }
4789 logger.Debug(ctx, "send self test request done")
4790 return nil
4791}
4792
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004793//nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004794func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4795
4796 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4797 if err != nil {
4798 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4799 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4800 }
4801 msgLayer := (*packet).Layer(nextLayer)
4802 if msgLayer != nil {
4803 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4804 if failure := (*packet).ErrorLayer(); failure != nil {
4805 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4806 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4807 // can examine for UnkonwnMEs and UnknownAttributes
4808 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
4809 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4810 return false, nil
4811 } else if nextLayer == omci.LayerTypeGetResponse {
4812 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4813 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4814 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4815 if unknownAttrLayer != nil {
4816 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4817 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4818 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4819 }
4820 }
4821 }
4822 }
4823 // Try to decode any further error information
4824 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4825 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4826 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4827 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4828 }
4829 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4830 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4831 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4832 }
4833 } else if failure := (*packet).ErrorLayer(); failure != nil {
4834 // message layer could not be decoded, but at least check if additional failure information is available
4835 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004836 errMsg := decodeFailure.String()
4837 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4838 if strings.Contains(strings.ToLower(errMsg), "table decode") {
4839 // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass
4840 // so that later processing can deal with it
4841 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass",
4842 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4843 return false, nil
4844 }
4845 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004846 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004847 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg})
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004848 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4849 }
4850 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4851 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4852 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4853 } else {
4854 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4855 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4856 }
4857
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004858 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004859 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004860 switch nextLayer {
4861 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004862 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4863 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004864 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004865 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004866 }
4867 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004868 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4869 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004870 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004871 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004872 }
4873 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004874 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4875 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004876 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004877 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004878 }
4879 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004880 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4881 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004882 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004883 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004884 }
4885 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004886 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4887 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004888 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004889 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004890 }
4891 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004892 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4893 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004894 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004895 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004896 }
4897 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004898 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4899 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004900 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004901 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004902 }
4903 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004904 }
4905 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004906 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004907}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004908
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004909func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004910 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004911 if timeout == 0 {
4912 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004913 // enqueue
4914 if aOmciTxRequest.highPrio {
4915 oo.mutexHighPrioTxQueue.Lock()
4916 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4917 oo.mutexHighPrioTxQueue.Unlock()
4918 } else {
4919 oo.mutexLowPrioTxQueue.Lock()
4920 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4921 oo.mutexLowPrioTxQueue.Unlock()
4922 }
4923 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004924 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004925 //the supervised sending with waiting on the response (based on TID) is called in background
4926 // to avoid blocking of the sender for the complete OMCI handshake procedure
4927 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4928 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4929 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004930 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004931}
4932
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004933func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004934 chSuccess := make(chan bool)
4935 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004936 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004937 oo.mutexMonReq.Lock()
4938 oo.monitoredRequests[tid] = aOmciTxRequest
4939 oo.mutexMonReq.Unlock()
4940
4941 retries := aOmciTxRequest.retries
4942 retryCounter := 0
4943loop:
4944 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004945 // enqueue
4946 if aOmciTxRequest.highPrio {
4947 oo.mutexHighPrioTxQueue.Lock()
4948 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4949 oo.mutexHighPrioTxQueue.Unlock()
4950 } else {
4951 oo.mutexLowPrioTxQueue.Lock()
4952 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4953 oo.mutexLowPrioTxQueue.Unlock()
4954 }
4955 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004956
4957 select {
4958 case success := <-chSuccess:
4959 if success {
4960 logger.Debugw(ctx, "reqMon: response received in time",
4961 log.Fields{"tid": tid, "device-id": oo.deviceID})
4962 } else {
4963 logger.Debugw(ctx, "reqMon: wait for response aborted",
4964 log.Fields{"tid": tid, "device-id": oo.deviceID})
4965 }
4966 break loop
4967 case <-time.After(time.Duration(aTimeout) * time.Second):
4968 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004969 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
mpagenko7455fd42021-06-10 16:25:55 +00004970 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004971 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004972 oo.incrementTxTimesouts()
mpagenko7455fd42021-06-10 16:25:55 +00004973 break loop
4974 } else {
4975 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4976 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004977 oo.incrementTxRetries()
mpagenko7455fd42021-06-10 16:25:55 +00004978 }
4979 }
4980 retryCounter++
4981 }
4982 oo.mutexMonReq.Lock()
4983 delete(oo.monitoredRequests, tid)
4984 oo.mutexMonReq.Unlock()
4985}
4986
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004987//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004988func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004989 logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004990 oo.mutexMonReq.RLock()
4991 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004992 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4993 select {
4994 case oo.monitoredRequests[k].chSuccess <- false:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004995 logger.Debugw(ctx, "send cancellation on omciRespChannel",
4996 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00004997 default:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00004998 logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
4999 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00005000 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005001 }
5002 oo.mutexMonReq.RUnlock()
5003}
5004
5005//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
5006//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005007func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
5008 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005009}
Himani Chawla43f95ff2021-06-03 00:24:12 +05305010
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005011// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
5012func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05305013 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005014 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305015 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
5016 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
5017
5018 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005019 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305020 }
5021 var meInstance *me.ManagedEntity
5022 var omciErr me.OmciErrors
5023 if classID == me.EthernetFrameExtendedPmClassID {
5024 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
5025 } else {
5026 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
5027 }
5028
5029 if omciErr.GetError() == nil {
5030 var omciLayer *omci.OMCI
5031 var msgLayer gopacket.SerializableLayer
5032 var err error
5033 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00005034 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
5035 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05305036 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00005037 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
5038 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05305039 }
5040 if err != nil {
5041 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5042 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5043 return nil, err
5044 }
5045
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005046 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305047 if err != nil {
5048 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
5049 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5050 return nil, err
5051 }
5052
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005053 omciRxCallbackPair := CallbackPair{CbKey: tid,
5054 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305055 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005056 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305057 if err != nil {
5058 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5059 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5060 return nil, err
5061 }
5062 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
5063 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5064 return meInstance, nil
5065 }
5066 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5067 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5068 return nil, omciErr.GetError()
5069}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005070
5071// RLockMutexMonReq lock read access to monitoredRequests
5072func (oo *OmciCC) RLockMutexMonReq() {
5073 oo.mutexMonReq.RLock()
5074}
5075
5076// RUnlockMutexMonReq unlock read access to monitoredRequests
5077func (oo *OmciCC) RUnlockMutexMonReq() {
5078 oo.mutexMonReq.RUnlock()
5079}
5080
5081// GetMonitoredRequest get OmciTransferStructure for an omciTransID
5082func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
5083 value, exist = oo.monitoredRequests[omciTransID]
5084 return value, exist
5085}
5086
5087// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
5088func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
5089 oo.monitoredRequests[omciTransID].chSuccess <- chVal
5090}
Himani Chawlaee10b542021-09-20 16:46:40 +05305091
5092// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
5093func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
5094 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
5095 tid := oo.GetNextTid(highPrio)
5096 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
5097 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
5098
5099 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005100 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05305101 }
5102 var meInstance *me.ManagedEntity
5103 var omciErr me.OmciErrors
5104 if classID == me.EthernetFrameExtendedPmClassID {
5105 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
5106 } else {
5107 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
5108 }
5109
5110 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00005111 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05305112 if err != nil {
5113 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5114 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5115 return nil, err
5116 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005117 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawlaee10b542021-09-20 16:46:40 +05305118 if err != nil {
5119 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
5120 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5121 return nil, err
5122 }
5123 omciRxCallbackPair := CallbackPair{
5124 CbKey: tid,
5125 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
5126 }
5127 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
5128 if err != nil {
5129 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5130 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5131 return nil, err
5132 }
5133 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
5134 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5135 return meInstance, nil
5136 }
5137 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5138 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5139 return nil, omciErr.GetError()
5140}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00005141
5142// PrepareForGarbageCollection - remove references to prepare for garbage collection
5143func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
5144 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
5145 oo.pBaseDeviceHandler = nil
5146 oo.pOnuDeviceEntry = nil
5147 oo.pOnuAlarmManager = nil
5148}
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00005149
5150// GetOmciCounters - TODO: add comment
5151func (oo *OmciCC) GetOmciCounters() *extension.SingleGetValueResponse {
5152 oo.mutexCounters.RLock()
5153 defer oo.mutexCounters.RUnlock()
5154 resp := extension.SingleGetValueResponse{
5155 Response: &extension.GetValueResponse{
5156 Status: extension.GetValueResponse_OK,
5157 Response: &extension.GetValueResponse_OnuOmciStats{
5158 OnuOmciStats: &extension.GetOnuOmciTxRxStatsResponse{},
5159 },
5160 },
5161 }
5162 resp.Response.GetOnuOmciStats().BaseTxArFrames = oo.countersBase.txArFrames
5163 resp.Response.GetOnuOmciStats().BaseTxNoArFrames = oo.countersBase.txNoArFrames
5164 resp.Response.GetOnuOmciStats().BaseRxAkFrames = oo.countersBase.rxAkFrames
5165 resp.Response.GetOnuOmciStats().BaseRxNoAkFrames = oo.countersBase.rxNoAkFrames
5166 resp.Response.GetOnuOmciStats().ExtTxArFrames = oo.countersExt.txArFrames
5167 resp.Response.GetOnuOmciStats().ExtTxNoArFrames = oo.countersExt.txNoArFrames
5168 resp.Response.GetOnuOmciStats().ExtRxAkFrames = oo.countersExt.rxAkFrames
5169 resp.Response.GetOnuOmciStats().ExtRxNoAkFrames = oo.countersExt.rxNoAkFrames
5170 resp.Response.GetOnuOmciStats().TxOmciCounterRetries = oo.txRetries
5171 resp.Response.GetOnuOmciStats().TxOmciCounterTimeouts = oo.txTimeouts
5172 return &resp
5173}
5174
5175// For more speed, separate functions for each counter
5176
5177func (oo *OmciCC) incrementBaseTxArFrames() {
5178 oo.mutexCounters.Lock()
5179 defer oo.mutexCounters.Unlock()
5180 oo.countersBase.txArFrames++
5181}
5182
5183func (oo *OmciCC) incrementExtTxArFrames() {
5184 oo.mutexCounters.Lock()
5185 defer oo.mutexCounters.Unlock()
5186 oo.countersExt.txArFrames++
5187}
5188
5189func (oo *OmciCC) incrementBaseRxAkFrames() {
5190 oo.mutexCounters.Lock()
5191 defer oo.mutexCounters.Unlock()
5192 oo.countersBase.rxAkFrames++
5193}
5194
5195func (oo *OmciCC) incrementExtRxAkFrames() {
5196 oo.mutexCounters.Lock()
5197 defer oo.mutexCounters.Unlock()
5198 oo.countersExt.rxAkFrames++
5199}
5200
5201func (oo *OmciCC) increaseBaseTxNoArFramesBy(ctx context.Context, value uint32) {
5202 oo.mutexCounters.Lock()
5203 defer oo.mutexCounters.Unlock()
5204 oo.countersBase.txNoArFrames += value
5205}
5206
5207func (oo *OmciCC) increaseExtTxNoArFramesBy(ctx context.Context, value uint32) {
5208 oo.mutexCounters.Lock()
5209 defer oo.mutexCounters.Unlock()
5210 oo.countersExt.txNoArFrames += value
5211}
5212
5213func (oo *OmciCC) incrementBaseRxNoAkFrames() {
5214 oo.mutexCounters.Lock()
5215 defer oo.mutexCounters.Unlock()
5216 oo.countersBase.rxNoAkFrames++
5217}
5218
5219func (oo *OmciCC) incrementExtRxNoAkFrames() {
5220 oo.mutexCounters.Lock()
5221 defer oo.mutexCounters.Unlock()
5222 oo.countersExt.rxNoAkFrames++
5223}
5224
5225func (oo *OmciCC) incrementTxRetries() {
5226 oo.mutexCounters.Lock()
5227 defer oo.mutexCounters.Unlock()
5228 oo.txRetries++
5229}
5230
5231func (oo *OmciCC) incrementTxTimesouts() {
5232 oo.mutexCounters.Lock()
5233 defer oo.mutexCounters.Unlock()
5234 oo.txTimeouts++
5235}