blob: 6cb15b7f068c61742f8922f301cbeb118f020489 [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
Joey Armstronge8c091f2023-01-17 16:56:26 -05002 * Copyright 2020-2023 Open Networking Foundation (ONF) and the ONF Contributors
Holger Hildebrandtfa074992020-03-27 15:42:06 +00003 *
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
Holger Hildebrandt7e138462023-03-29 12:12:14 +0000120 confFailMEs []me.ClassID
121 mutexConfFailMEs sync.RWMutex
mpagenkoc8bba412021-01-15 15:38:44 +0000122
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000123 mutexCounters sync.RWMutex
124 countersBase txRxCounters
125 countersExt txRxCounters
126 txRetries uint32
127 txTimeouts uint32
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000128
129 // OMCI params
130 mutexTid sync.Mutex
131 tid uint16
132 mutexHpTid sync.Mutex
133 hpTid uint16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000134 UploadSequNo uint16
135 UploadNoOfCmds uint16
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000136
Holger Hildebrandt556d56c2022-12-07 09:23:49 +0000137 mutexSendQueuedRequests sync.Mutex
138 mutexLowPrioTxQueue sync.Mutex
139 lowPrioTxQueue *list.List
140 mutexHighPrioTxQueue sync.Mutex
141 highPrioTxQueue *list.List
142 mutexRxSchedMap sync.Mutex
143 rxSchedulerMap map[uint16]CallbackPairEntry
144 mutexMonReq sync.RWMutex
145 monitoredRequests map[uint16]OmciTransferStructure
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000146}
147
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000148var responsesWithMibDataSync = []omci.MessageType{
149 omci.CreateResponseType,
150 omci.DeleteResponseType,
151 omci.SetResponseType,
152 omci.StartSoftwareDownloadResponseType,
153 omci.EndSoftwareDownloadResponseType,
154 omci.ActivateSoftwareResponseType,
155 omci.CommitSoftwareResponseType,
156}
157
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000158//NewOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000159//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000160func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
161 onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
162 coreClient *vgrpc.Client) *OmciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000163 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000164 var omciCC OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000165 omciCC.enabled = false
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000166 omciCC.pBaseDeviceHandler = deviceHandler
167 omciCC.pOnuAlarmManager = onuAlarmManager
Himani Chawla4d908332020-08-31 12:30:20 +0530168 omciCC.pOnuDeviceEntry = onuDeviceEntry
169 omciCC.deviceID = deviceID
khenaidoo7d3c5582021-08-11 18:09:44 -0400170 omciCC.coreClient = coreClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000171 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000172 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandt7e138462023-03-29 12:12:14 +0000173 omciCC.confFailMEs = nil
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000174 omciCC.countersBase = txRxCounters{0, 0, 0, 0}
175 omciCC.countersExt = txRxCounters{0, 0, 0, 0}
176 omciCC.txRetries = 0
177 omciCC.txTimeouts = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000178 omciCC.tid = 0x1
179 omciCC.hpTid = 0x8000
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000180 omciCC.UploadSequNo = 0
181 omciCC.UploadNoOfCmds = 0
Holger Hildebrandt34555512021-10-01 16:26:59 +0000182 omciCC.lowPrioTxQueue = list.New()
183 omciCC.highPrioTxQueue = list.New()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000184 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
185 omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000186 return &omciCC
187}
188
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000189//Stop stops/resets the omciCC
190func (oo *OmciCC) Stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000191 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000192 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
mpagenko8cd1bf72021-06-22 10:11:19 +0000193 oo.CancelRequestMonitoring(ctx)
Holger Hildebrandt34555512021-10-01 16:26:59 +0000194 // clear the tx queues
195 oo.mutexHighPrioTxQueue.Lock()
196 oo.highPrioTxQueue.Init()
197 oo.mutexHighPrioTxQueue.Unlock()
198 oo.mutexLowPrioTxQueue.Lock()
199 oo.lowPrioTxQueue.Init()
200 oo.mutexLowPrioTxQueue.Unlock()
201 //clear the scheduler map
mpagenko900ee4b2020-10-12 11:56:34 +0000202 oo.mutexRxSchedMap.Lock()
203 for k := range oo.rxSchedulerMap {
Holger Hildebrandt34555512021-10-01 16:26:59 +0000204 delete(oo.rxSchedulerMap, k)
mpagenko900ee4b2020-10-12 11:56:34 +0000205 }
206 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000207 //reset the high prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000208 oo.mutexHpTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000209 oo.hpTid = 0x8000
mpagenko900ee4b2020-10-12 11:56:34 +0000210 oo.mutexHpTid.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000211 //reset the low prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000212 oo.mutexTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000213 oo.tid = 1
mpagenko900ee4b2020-10-12 11:56:34 +0000214 oo.mutexTid.Unlock()
215 //reset control values
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000216 oo.UploadSequNo = 0
217 oo.UploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000218 oo.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandt7e138462023-03-29 12:12:14 +0000219 oo.ResetConfFailMEs()
mpagenko900ee4b2020-10-12 11:56:34 +0000220
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000221 //reset the stats counter
222 oo.mutexCounters.Lock()
223 oo.countersBase = txRxCounters{0, 0, 0, 0}
224 oo.countersExt = txRxCounters{0, 0, 0, 0}
225 oo.txRetries = 0
226 oo.txTimeouts = 0
227 oo.mutexCounters.Unlock()
mpagenko900ee4b2020-10-12 11:56:34 +0000228 return nil
229}
230
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000231// Rx handler for omci messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000232func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000233 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000234 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530235 switch omciMsg.MessageType {
236 case omci.AlarmNotificationType:
237 data := OmciMessage{
238 OmciMsg: omciMsg,
239 OmciPacket: packet,
240 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000241 go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530242 return nil
243 default:
244 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
245 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000246 /*
247 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
248 rxOnuFrames++
249
250 switch msgType {
251 case AlarmNotification:
252 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000253 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000254 // python code was:
255 //if msg_type == EntityOperations.AlarmNotification.value:
256 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
257 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
258 //
259 return errors.New("RxAlarmNotification unimplemented")
260 }
261 case AttributeValueChange:
262 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000263 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000264 // python code was:
265 //elif msg_type == EntityOperations.AttributeValueChange.value:
266 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
267 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
268 //
269 return errors.New("RxAttributeValueChange unimplemented")
270 }
271 case TestResult:
272 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000273 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000274 // python code was:
275 //elif msg_type == EntityOperations.TestResult.value:
276 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
277 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
278 //
279 return errors.New("RxTestResult unimplemented")
280 }
281 default:
282 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000283 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000284 rxOnuDiscards++
285 return errors.New("RxOnuMsgType unimplemented")
286 }
287 }
288 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000289}
290
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000291func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
mpagenko80622a52021-02-09 16:53:23 +0000292 //assuming omci message content is hex coded!
293 // with restricted output of 16bytes would be ...rxMsg[:16]
294 logger.Debugw(ctx, "omci-message-received:", log.Fields{
295 "RxOmciMessage": hex.EncodeToString(rxMsg),
296 "device-id": oo.deviceID})
297}
298
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000299// ReceiveMessage - Rx handler for onu messages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000300// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000301// nolint: gocyclo
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000302func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000303 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000304
305 if len(rxMsg) < 10 {
306 logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort",
307 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
308 if len(rxMsg) > 0 {
309 oo.printRxMessage(ctx, rxMsg)
mpagenkoc8bba412021-01-15 15:38:44 +0000310 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000311 return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID)
312 }
313 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
314 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
315 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
316 // (an extendedFormat message could be destroyed this way!)
317 trailerLenData := rxMsg[42:44]
318 trailerLen := binary.BigEndian.Uint16(trailerLenData)
319 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
320 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
321 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
322 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
323 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
324 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
325 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
326 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
327 }
328 }
329 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
330 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
331 // (an extendedFormat message could be destroyed this way!)
332 // extend/overwrite with trailer
333 trailer := make([]byte, 8)
334 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
335 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
336 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
337 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
338 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
339 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
340 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
341 }
342 } else {
343 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
344 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
345 oo.printRxMessage(ctx, rxMsg)
346 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
347 }
348 } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) {
349 if len(rxMsg) > 1980 {
350 logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort",
351 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
352 oo.printRxMessage(ctx, rxMsg)
353 return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000354 }
355 } else {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000356 logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort",
mpagenkoc8bba412021-01-15 15:38:44 +0000357 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000358 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000359 return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000360 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000361 decodeOptions := gopacket.DecodeOptions{
362 Lazy: true,
363 NoCopy: true,
364 }
365 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000366 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000367 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000368 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200369 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000370 }
371 omciLayer := packet.Layer(omci.LayerTypeOMCI)
372 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000373 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000374 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200375 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000376 }
mpagenko836a1fd2021-11-01 16:12:42 +0000377 // insert some check on detected OMCI decoding issues and log them
378 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
379 // even though allowed from omci-lib due to set relaxed decoding
380 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
381 // (compare mib_sync.go unknownAttrLayer)
382 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
383 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
384 errMsg := failure.Error()
385 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
386 "device-id": oo.deviceID, "issue": errMsg})
387 }
388 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000389 omciMsg, ok := omciLayer.(*omci.OMCI)
390 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000391 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000392 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200393 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000394 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000395 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000396 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
397 "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID})
mpagenko836a1fd2021-11-01 16:12:42 +0000398
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700399 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
400 // We expect to find the TID in the oo.rxSchedulerMap
401 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000402 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000403 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000404 logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000405 if omciMsg.TransactionID == 0 {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000406 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
407 oo.incrementBaseRxNoAkFrames()
408 } else {
409 oo.incrementExtRxNoAkFrames()
410 }
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530411 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000412 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000413 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200414 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000415 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200416 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530417 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000418 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530419 oo.mutexRxSchedMap.Lock()
420 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000421 if ok && rxCallbackEntry.CbFunction != nil {
Holger Hildebrandt68854a82022-09-05 07:00:21 +0000422
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000423 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000424 oo.printRxMessage(ctx, rxMsg)
425 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000426 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
427 oo.incrementBaseRxAkFrames()
428 } else {
429 oo.incrementExtRxAkFrames()
430 }
Himani Chawla4d908332020-08-31 12:30:20 +0530431 //disadvantage of decoupling: error verification made difficult, but anyway the question is
432 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000433 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000434 isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet)
435 if err != nil {
436 // qualified error logging already done in function above
437 if !rxCallbackEntry.FramePrint {
438 oo.printRxMessage(ctx, rxMsg)
439 }
440 return fmt.Errorf("could not decode further layers %s", oo.deviceID)
441 }
442 if isSuccessfulResponse {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000443 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000444 } else {
445 logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type",
446 log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID})
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000447 }
mpagenkoc8bba412021-01-15 15:38:44 +0000448
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700449 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
450 // so do not clean up the TransactionID in that case.
451 if omciMsg.MessageType != omci.TestResponseType {
452 // having posted the response the request is regarded as 'done'
453 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
454 }
Himani Chawla4d908332020-08-31 12:30:20 +0530455 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000456 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000457 }
mpagenko80622a52021-02-09 16:53:23 +0000458 oo.mutexRxSchedMap.Unlock()
459 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
460 oo.printRxMessage(ctx, rxMsg)
461 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000462
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000463 /* py code was:
464 Receive and OMCI message from the proxy channel to the OLT.
465
466 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
467 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
468 """
469 if not self.enabled:
470 return
471
472 try:
473 now = arrow.utcnow()
474 d = None
475
476 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
477 # save the current value of the entity_id_to_class_map, then
478 # replace it with our custom one before decode, and then finally
479 # restore it later. Tried other ways but really made the code messy.
480 saved_me_map = omci_entities.entity_id_to_class_map
481 omci_entities.entity_id_to_class_map = self._me_map
482
483 try:
484 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000485 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000486 except KeyError as e:
487 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000488 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000489 rx_frame = self._decode_unknown_me(msg)
490 self._rx_unknown_me += 1
491
492 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000493 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000494 return
495
496 finally:
497 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
498
499 rx_tid = rx_frame.fields['transaction_id']
500 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000501 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000502 # Filter the Test Result frame and route through receive onu
503 # message method.
504 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000505 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000506 return self._receive_onu_message(rx_frame)
507
508 # Previously unreachable if this is the very first round-trip Rx or we
509 # have been running consecutive errors
510 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000511 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000512 self.reactor.callLater(0, self._publish_connectivity_event, True)
513
514 self._rx_frames += 1
515 self._consecutive_errors = 0
516
517 try:
518 high_priority = self._tid_is_high_priority(rx_tid)
519 index = self._get_priority_index(high_priority)
520
521 # (timestamp, defer, frame, timeout, retry, delayedCall)
522 last_tx_tuple = self._tx_request[index]
523
524 if last_tx_tuple is None or \
525 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
526 # Possible late Rx on a message that timed-out
527 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000528 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000529 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
530 self._rx_unknown_tid += 1
531 self._rx_late += 1
532 return
533
534 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
535 if dc is not None and not dc.cancelled and not dc.called:
536 dc.cancel()
537
538 _secs = self._update_rx_tx_stats(now, ts)
539
540 # Late arrival already serviced by a timeout?
541 if d.called:
542 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000543 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000544 return
545
546 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000547 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000548 if d is not None:
549 return d.errback(failure.Failure(e))
550 return
551
552 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000553 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554 tx_tid = tx_frame.fields['transaction_id'])
555 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
556
557 # begin success callback chain (will cancel timeout and queue next Tx message)
558 self._rx_response[index] = rx_frame
559 d.callback(rx_frame)
560
561 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000562 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000563 */
564}
565
Himani Chawla6d2ae152020-09-02 13:11:20 +0530566/*
567func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530568 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530569 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000570}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530571*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000572
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700573// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000574func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700575 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
576 delete(oo.rxSchedulerMap, tid)
577}
578
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000579// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
580func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
581 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000582
mpagenkoc26d4c02021-05-06 14:27:57 +0000583 if timeout != 0 {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000584 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000585 oo.mutexRxSchedMap.Lock()
586 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000587 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000588 oo.mutexRxSchedMap.Unlock()
589 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000590
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000591 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000592 //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 +0000593 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000594 txFrame,
595 timeout,
596 retry,
597 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000598 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000599 receiveCallbackPair,
600 nil,
kesavand011d5162021-11-25 19:21:06 +0530601 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000602 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000603 oo.mutexMonReq.Lock()
604 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000605 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000606 // do not call processRequestMonitoring in background here to ensure correct sequencing
607 // of requested messages into txQueue (especially for non-response-supervised messages)
608 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000609 return nil
610 }
611 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000612 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000613 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000614}
615
Holger Hildebrandt34555512021-10-01 16:26:59 +0000616func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
617 // Avoid accessing the txQueues from parallel send routines to block
618 // parallel omci send requests at least until SendIAP is 'committed'.
619 // To guarantee window size 1 for one ONU it would be necessary to wait
620 // for the corresponding response too (t.b.d.).
621 oo.mutexSendQueuedRequests.Lock()
622 defer oo.mutexSendQueuedRequests.Unlock()
623 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
624 logger.Errorw(ctx, "Error during sending high prio requests!",
625 log.Fields{"err": err, "device-id": oo.deviceID})
626 return
627 }
628 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
629 logger.Errorw(ctx, "Error during sending low prio requests!",
630 log.Fields{"err": err, "device-id": oo.deviceID})
631 return
632 }
633}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000634
Holger Hildebrandt34555512021-10-01 16:26:59 +0000635func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
636 oo.mutexHighPrioTxQueue.Lock()
637 defer oo.mutexHighPrioTxQueue.Unlock()
638 for oo.highPrioTxQueue.Len() > 0 {
639 queueElement := oo.highPrioTxQueue.Front() // First element
640 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000641 // Element will be removed from the queue regardless of the send success, to prevent
642 // an accumulation of send requests for the same message in the event of an error.
643 // In this case, resend attempts for the message are ensured by our retry
644 // mechanism after omci-timeout.
645 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
Holger Hildebrandt34555512021-10-01 16:26:59 +0000646 return err
mpagenko80622a52021-02-09 16:53:23 +0000647 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000648 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
649 }
650 return nil
651}
652
653func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
654 oo.mutexLowPrioTxQueue.Lock()
655 for oo.lowPrioTxQueue.Len() > 0 {
656 queueElement := oo.lowPrioTxQueue.Front() // First element
kesavand011d5162021-11-25 19:21:06 +0530657 // check if the element is for onu sw section
658 aOmciTxReq := queueElement.Value.(OmciTransferStructure)
659 if aOmciTxReq.OnuSwWindow != nil {
660 if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000661 // Element will be removed from the queue regardless of the send success, to prevent
662 // an accumulation of send requests for the same message in the event of an error.
663 // In this case, resend attempts for the message are ensured by our retry
664 // mechanism after omci-timeout.
665 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530666 oo.mutexLowPrioTxQueue.Unlock()
667 return err
668 }
669 } else {
670 err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure))
671 if err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000672 // Element will be removed from the queue regardless of the send success, to prevent
673 // an accumulation of send requests for the same message in the event of an error.
674 // In this case, resend attempts for the message are ensured by our retry
675 // mechanism after omci-timeout.
676 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530677 oo.mutexLowPrioTxQueue.Unlock()
678 return err
679 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200680 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000681 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
682 // Interrupt the sending of low priority requests to process any high priority requests
683 // that may have arrived in the meantime
684 oo.mutexLowPrioTxQueue.Unlock()
685 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
686 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000687 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000688 oo.mutexLowPrioTxQueue.Lock()
689 }
690
691 oo.mutexLowPrioTxQueue.Unlock()
692 return nil
693}
694
695func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
696 if omciTxRequest.withFramePrint {
697 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
698 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
699 "device-id": oo.deviceID,
700 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
701 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
702 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
703 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400704 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000705 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
706 ChildDeviceId: oo.deviceID,
707 Message: omciTxRequest.txFrame,
708 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
709 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
710 }
711 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
712 if sendErr != nil {
Holger Hildebrandtabfef032022-02-25 12:40:20 +0000713 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 +0000714 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000715 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000716 if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
717 oo.incrementBaseTxArFrames()
718 } else {
719 oo.incrementExtTxArFrames()
720 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000721 return nil
722}
723
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000724// GetNextTid - TODO: add comment
725func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000726 var next uint16
727 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000728 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000729 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530730 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000731 if oo.hpTid < 0x8000 {
732 oo.hpTid = 0x8000
733 }
mpagenko900ee4b2020-10-12 11:56:34 +0000734 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000735 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000736 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000737 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530738 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000739 if oo.tid >= 0x8000 {
740 oo.tid = 1
741 }
mpagenko900ee4b2020-10-12 11:56:34 +0000742 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000743 }
744 return next
745}
746
kesavand011d5162021-11-25 19:21:06 +0530747//GetOnuSwSecNextTid get the next low prio tid for the onu sw sections
748//onu sw sections uses only low priority tids
749//The mutexTid lock should be taken prior to using this function
750func (oo *OmciCC) GetOnuSwSecNextTid() uint16 {
751 next := oo.tid
752 oo.tid++
753 if oo.tid >= 0x8000 {
754 oo.tid = 1
755 }
756 return next
757}
758
759//GetOnuSwSecLastTid gets the last allocated tid
760//The mutexTid lock should be taken prior to using this function
761func (oo *OmciCC) GetOnuSwSecLastTid() uint16 {
762 next := oo.tid
763 lastAllocatedTid := next - 1
764 return lastAllocatedTid
765}
766
767//LockMutexTID locks mutexTid
768func (oo *OmciCC) LockMutexTID() {
769 oo.mutexTid.Lock()
770}
771
772//UnLockMutexTID unlocks mutexTid
773func (oo *OmciCC) UnLockMutexTID() {
774 oo.mutexTid.Unlock()
775}
776
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000777// ###################################################################################
778// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000779
780// Serialize - TODO: add comment
781func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000782 omciLayer := &omci.OMCI{
783 TransactionID: tid,
784 MessageType: msgType,
785 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000786 return SerializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000787}
788
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000789// SerializeOmciLayer - TODO: add comment
790func SerializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000791 var options gopacket.SerializeOptions
792 options.FixLengths = true
793
794 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530795 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000796 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000797 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000798 return nil, err
799 }
800 return buffer.Bytes(), nil
801}
802
Himani Chawla4d908332020-08-31 12:30:20 +0530803/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000804func hexEncode(omciPkt []byte) ([]byte, error) {
805 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
806 hex.Encode(dst, omciPkt)
807 return dst, nil
808}
Himani Chawla4d908332020-08-31 12:30:20 +0530809*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000810
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000811//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000812func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000813
dbainbri4d3a0dc2020-12-02 00:33:42 +0000814 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000815 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000816
817 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000818 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000819 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200820 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000821 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000822 oo.mutexMonReq.RLock()
823 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000824 //implement non-blocking channel send to avoid blocking on mutexMonReq later
825 select {
826 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
827 default:
828 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
829 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
830 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000831 } else {
832 logger.Infow(ctx, "reqMon: map entry does not exist!",
833 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
834 }
835 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000836
837 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
838 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000839 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000840 Type: OMCI,
841 Data: OmciMessage{
842 OmciMsg: omciMsg,
843 OmciPacket: packet,
844 },
845 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000846 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000847 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000848
849 return nil
850}
851
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000852// SendMibReset sends MibResetRequest
853func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000854
dbainbri4d3a0dc2020-12-02 00:33:42 +0000855 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000856 request := &omci.MibResetRequest{
857 MeBasePacket: omci.MeBasePacket{
858 EntityClass: me.OnuDataClassID,
859 },
860 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000861 tid := oo.GetNextTid(highPrio)
862 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000863 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000864 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000865 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000866 return err
867 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000868 omciRxCallbackPair := CallbackPair{
869 CbKey: tid,
870 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000871 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000872 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000873}
874
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000875// SendReboot sends RebootRequest
876func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
877 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300878 request := &omci.RebootRequest{
879 MeBasePacket: omci.MeBasePacket{
880 EntityClass: me.OnuGClassID,
881 },
882 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000883 tid := oo.GetNextTid(highPrio)
884 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300885 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000886 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000887 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300888 return err
889 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000890 omciRxCallbackPair := CallbackPair{
891 CbKey: tid,
892 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300893 }
894
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000895 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300896 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000897 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000898 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300899 return err
900 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000901 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300902 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000903 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200904 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300905 return err
906 }
907 return nil
908}
909
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000910// SendMibUpload sends MibUploadRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000911func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000912 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000913
914 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000915
916 omciLayer := &omci.OMCI{
917 TransactionID: tid,
918 MessageType: omci.MibUploadRequestType,
919 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000920 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000921 omciLayer.DeviceIdentifier = omci.ExtendedIdent
922 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000923 request := &omci.MibUploadRequest{
924 MeBasePacket: omci.MeBasePacket{
925 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000926 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000927 },
928 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000929 var options gopacket.SerializeOptions
930 options.FixLengths = true
931
932 buffer := gopacket.NewSerializeBuffer()
933 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000934 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000935 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000936 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000937 return err
938 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000939 oo.UploadSequNo = 0
940 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000941
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000942 omciRxCallbackPair := CallbackPair{
943 CbKey: tid,
944 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000945 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000946 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000947}
948
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000949// SendMibUploadNext sends MibUploadNextRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000950func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000951 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000952
953 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000954
955 omciLayer := &omci.OMCI{
956 TransactionID: tid,
957 MessageType: omci.MibUploadNextRequestType,
958 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000959 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000960 omciLayer.DeviceIdentifier = omci.ExtendedIdent
961 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000962 request := &omci.MibUploadNextRequest{
963 MeBasePacket: omci.MeBasePacket{
964 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000965 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000966 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000967 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000968 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000969 var options gopacket.SerializeOptions
970 options.FixLengths = true
971
972 buffer := gopacket.NewSerializeBuffer()
973 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000974 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000975 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000976 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000977 return err
978 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000979 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000980
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000981 omciRxCallbackPair := CallbackPair{
982 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000983 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
984 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
985 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000986 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000987 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000988 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000989}
990
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000991// SendGetAllAlarm gets all alarm ME instances
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000992func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool, isExtendedOmci bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530993 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000994
995 tid := oo.GetNextTid(highPrio)
996 omciLayer := &omci.OMCI{
997 TransactionID: tid,
998 MessageType: omci.GetAllAlarmsRequestType,
999 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
1000 }
1001 if isExtendedOmci {
1002 omciLayer.DeviceIdentifier = omci.ExtendedIdent
1003 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301004 request := &omci.GetAllAlarmsRequest{
1005 MeBasePacket: omci.MeBasePacket{
1006 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001007 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301008 },
1009 AlarmRetrievalMode: byte(alarmRetreivalMode),
1010 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001011 var options gopacket.SerializeOptions
1012 options.FixLengths = true
1013 buffer := gopacket.NewSerializeBuffer()
1014 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301015 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001016 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err,
1017 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301018 return err
1019 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001020 outgoingPacket := buffer.Bytes()
1021
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001022 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +05301023
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001024 omciRxCallbackPair := CallbackPair{
1025 CbKey: tid,
1026 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301027 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001028 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1029 if err != nil {
1030 logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err,
1031 "device-id": oo.deviceID})
1032 return err
1033 }
1034 logger.Debug(ctx, "send GetAllAlarmsRequest done")
1035 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301036}
1037
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001038// SendGetAllAlarmNext gets next alarm ME instance
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001039func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool, isExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001040 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
1041 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +05301042 "alarmUploadSeqNo": alarmUploadSeqNo})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001043
1044 tid := oo.GetNextTid(highPrio)
1045 omciLayer := &omci.OMCI{
1046 TransactionID: tid,
1047 MessageType: omci.GetAllAlarmsNextRequestType,
1048 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
1049 }
1050 if isExtendedOmci {
1051 omciLayer.DeviceIdentifier = omci.ExtendedIdent
1052 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301053 request := &omci.GetAllAlarmsNextRequest{
1054 MeBasePacket: omci.MeBasePacket{
1055 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001056 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301057 },
1058 CommandSequenceNumber: alarmUploadSeqNo,
1059 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001060 var options gopacket.SerializeOptions
1061 options.FixLengths = true
1062 buffer := gopacket.NewSerializeBuffer()
1063 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301064 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001065 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err,
1066 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301067 return err
1068 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001069 outgoingPacket := buffer.Bytes()
1070
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001071 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +05301072
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001073 omciRxCallbackPair := CallbackPair{
1074 CbKey: tid,
1075 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301076 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001077 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1078 if err != nil {
1079 logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err,
1080 "device-id": oo.deviceID})
1081 return err
1082 }
1083 logger.Debug(ctx, "send GetAllAlarmsNextRequest done")
1084 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301085}
1086
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001087// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
1088func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1089 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001090 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001091 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001092
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001093 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001094 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001095 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001096 }
1097 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
1098 if omciErr.GetError() == nil {
1099 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001100 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001101 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001102 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001103 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001104 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001105 }
1106
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001107 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001108 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001109 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001110 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001111 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001112 }
1113
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001114 omciRxCallbackPair := CallbackPair{
1115 CbKey: tid,
1116 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001117 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001118 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001119 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001120 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001121 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001122 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001123 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001124 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001125 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001126 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001127 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001128 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001129 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001130}
1131
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001132// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001133// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001134func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1135 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001136 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001137 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001138
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001139 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
1140 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001141 // By now we just use fix values to fire - this is anyway what the python adapter does
1142 // read ONU-2G from DB ???? //TODO!!!
1143 meParams := me.ParamData{
1144 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001145 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001146 }
1147 meInstance, omciErr := me.NewOnu2G(meParams)
1148 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001149 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001150 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001151 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001152 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001153 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001154 }
1155
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001156 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001157 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001158 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001159 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001160 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001161 }
1162
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001163 omciRxCallbackPair := CallbackPair{
1164 CbKey: tid,
1165 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001166 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001167 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001168 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001169 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001170 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001171 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001172 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001173 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001174 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001175 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001176 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001177 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001178 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001179}
1180
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001181// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1182func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1183 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1184 tid := oo.GetNextTid(highPrio)
1185 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001186 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001187 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001188
1189 meParams := me.ParamData{
1190 EntityID: instID,
1191 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001192 me.MacBridgeServiceProfile_Priority: 0x8000,
1193 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1194 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1195 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1196 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001197 },
1198 }
1199
1200 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1201 if omciErr.GetError() == nil {
1202 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001203 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1204 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001205 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001206 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001207 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001208 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001209 }
1210
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001211 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001212 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001213 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001214 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001215 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001216 }
1217
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001218 omciRxCallbackPair := CallbackPair{
1219 CbKey: tid,
1220 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001221 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001222 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001223 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001224 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001225 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001226 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001227 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001228 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001229 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001230 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001231 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001232 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001233 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001234}
1235
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001236// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1237func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1238 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1239 tid := oo.GetNextTid(highPrio)
1240 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001241 if idErr != nil {
1242 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1243 "Err": idErr, "device-id": oo.deviceID})
1244 return nil, idErr
1245 }
1246 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001247 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001248
1249 meParams := me.ParamData{
1250 EntityID: instID,
1251 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001252 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1253 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1254 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1255 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001256 },
1257 }
1258 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1259 if omciErr.GetError() == nil {
1260 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001261 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1262 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001263 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001264 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001265 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001266 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001267 }
1268
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001269 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001270 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001271 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001272 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001273 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001274 }
1275
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001276 omciRxCallbackPair := CallbackPair{
1277 CbKey: tid,
1278 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001279 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001280 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001281 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001282 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001283 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001284 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001285 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001286 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001287 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001288 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001289 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001290 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001291 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001292}
1293
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001294// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1295func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1296 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1297 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001298 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001299 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001300 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001301 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001302
1303 // compare python adapter code WA VOL-1311: this is not done here!
1304 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1305 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1306 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001307 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001308 assType = uint8(10) // for VEIP
1309 }
1310 meParams := me.ParamData{
1311 EntityID: instID,
1312 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001313 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1314 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001315 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001316 },
1317 }
1318 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1319 if omciErr.GetError() == nil {
1320 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001321 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1322 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001323 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001324 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001325 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001326 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001327 }
1328
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001329 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001330 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001331 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001332 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001333 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001334 }
1335
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001336 omciRxCallbackPair := CallbackPair{
1337 CbKey: tid,
1338 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001339 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001340 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001341 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001342 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001343 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001344 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001345 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001346 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001347 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001348 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001349 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001350 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001351 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001352}
1353
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001354// SendSetOnuGLS sets OnuG ME instance
1355func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001356 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001357 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001358 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001359 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001360
1361 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1362 meParams := me.ParamData{
1363 EntityID: 0,
1364 Attributes: requestedAttributes,
1365 }
1366 meInstance, omciErr := me.NewOnuG(meParams)
1367 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001368 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001369 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001370 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001371 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001372 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001373 }
1374
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001375 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001376 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001377 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001378 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001379 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001380 }
1381
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001382 omciRxCallbackPair := CallbackPair{
1383 CbKey: tid,
1384 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001385 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001386 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001387 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001388 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001389 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001390 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001391 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001392 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001393 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001394 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001395 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001396 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001397 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001398}
1399
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001400// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1401func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001402 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001403 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001404 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001405 "SequNo": strconv.FormatInt(int64(tid), 16)})
1406
1407 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1408 meParams := me.ParamData{
1409 EntityID: aInstNo,
1410 Attributes: requestedAttributes,
1411 }
1412 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1413 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001414 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001415 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001416 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001417 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001418 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001419 }
1420
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001421 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001422 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001423 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001424 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001425 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001426 }
1427
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001428 omciRxCallbackPair := CallbackPair{
1429 CbKey: tid,
1430 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001431 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001432 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001433 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001434 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001435 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001436 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001437 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001438 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001439 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001440 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001441 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001442 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001443 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001444}
1445
1446/* UniG obsolete by now, left here in case it should be needed once again
1447 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301448func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001449 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001450 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001451 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001452 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001453
1454 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1455 meParams := me.ParamData{
1456 EntityID: aInstNo,
1457 Attributes: requestedAttributes,
1458 }
1459 meInstance, omciErr := me.NewUniG(meParams)
1460 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001461 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001462 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001463 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001464 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001465 return nil
1466 }
1467
1468 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1469 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001470 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001471 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001472 return nil
1473 }
1474
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001475 omciRxCallbackPair := CallbackPair{
1476 CbKey: tid,
1477 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001478 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001479 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001480 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001481 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001482 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001483 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001484 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001485 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001486 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001487 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001488 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001489 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001490 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001491}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001492*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001493
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001494// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1495func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001496 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001497 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001498 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001499 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001500
1501 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1502 meParams := me.ParamData{
1503 EntityID: aInstNo,
1504 Attributes: requestedAttributes,
1505 }
1506 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1507 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001508 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001509 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001510 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001511 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001512 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001513 }
1514
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001515 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001519 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001520 }
1521
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001522 omciRxCallbackPair := CallbackPair{
1523 CbKey: tid,
1524 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001525 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001526 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001527 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001528 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001529 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001530 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001531 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001532 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001533 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001534 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001535 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001536 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001537 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001538}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001539
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001540// SendGetMe gets ME instance
1541func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001542 timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001543
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001544 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001545 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001546 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001547
1548 meParams := me.ParamData{
1549 EntityID: entityID,
1550 Attributes: requestedAttributes,
1551 }
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001552 var messageSet omci.DeviceIdent = omci.BaselineIdent
1553 if isExtendedOmci {
1554 messageSet = omci.ExtendedIdent
1555 }
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001556 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1557 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301558 meClassIDName := meInstance.GetName()
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001559 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid), oframe.FrameFormat(messageSet))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001560 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001561 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 +03001562 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001563 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001564 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001565 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001566 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001567 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001568 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001569 omciRxCallbackPair := CallbackPair{
1570 CbKey: tid,
1571 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001572 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001573 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001574 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001575 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001576 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001577 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001578 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001579 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001580 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001581 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001582 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001583}
1584
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001585// SendGetMeWithAttributeMask gets ME instance with attribute mask
1586func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301587 timeout int, highPrio bool, rxChan chan Message) error {
1588
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001589 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301590 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1591 "SequNo": strconv.FormatInt(int64(tid), 16)})
1592
1593 request := &omci.GetRequest{
1594 MeBasePacket: omci.MeBasePacket{
1595 EntityInstance: entityID,
1596 EntityClass: classID,
1597 },
1598 AttributeMask: requestedAttributesMask,
1599 }
1600
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001601 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301602 if err != nil {
1603 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1604 return err
1605 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001606 omciRxCallbackPair := CallbackPair{
1607 CbKey: tid,
1608 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301609 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001610 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301611 if err != nil {
1612 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1613 return err
1614 }
1615 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1616 return nil
1617}
1618
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001619// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1620func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001621 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001622 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001623 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001624 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1625
1626 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001627 EntityID: aInstID,
1628 Attributes: me.AttributeValueMap{
1629 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001630 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1631 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1632 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1633 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1634 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1635 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1636 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1637 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1638 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001639 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001640 }
1641 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1642 if omciErr.GetError() == nil {
1643 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001644 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1645 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001646 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001647 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001648 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001649 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001650 }
1651
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001652 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001653 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001654 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001655 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001656 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001657 }
1658
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001659 omciRxCallbackPair := CallbackPair{
1660 CbKey: tid,
1661 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001662 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001663 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001664 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001665 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001666 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001667 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001668 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001669 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001670 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001671 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001672 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001673 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001674 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001675}
1676
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001677// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1678func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001679 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001680 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001681 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001682 "SequNo": strconv.FormatInt(int64(tid), 16),
1683 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1684
1685 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1686 if omciErr.GetError() == nil {
1687 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001688 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1689 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001690 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001691 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001692 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001693 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001694 }
1695
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001696 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001697 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001698 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001699 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001700 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001701 }
1702
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001703 omciRxCallbackPair := CallbackPair{
1704 CbKey: tid,
1705 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001706 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001707 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001708 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001709 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001710 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001711 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001712 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001713 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001714 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001715 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001716 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001717 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001718 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001719}
1720
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001721// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1722func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001723 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001724 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001725 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001726 "SequNo": strconv.FormatInt(int64(tid), 16),
1727 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1728
1729 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1730 if omciErr.GetError() == nil {
1731 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001732 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1733 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001734 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001735 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001736 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001737 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001738 }
1739
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001740 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001741 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001742 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001743 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001744 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001745 }
1746
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001747 omciRxCallbackPair := CallbackPair{
1748 CbKey: tid,
1749 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001750 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001751 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001752 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001753 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001754 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001755 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001756 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001757 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001758 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001759 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001760 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001761 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001762 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001763}
1764
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001765// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1766func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1767 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001768 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1769 "SequNo": strconv.FormatInt(int64(tid), 16),
1770 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1771
1772 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1773 if omciErr.GetError() == nil {
1774 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001775 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1776 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001777 if err != nil {
1778 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1779 "Err": err, "device-id": oo.deviceID})
1780 return nil, err
1781 }
1782
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001783 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001784 if err != nil {
1785 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1786 "Err": err, "device-id": oo.deviceID})
1787 return nil, err
1788 }
1789
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001790 omciRxCallbackPair := CallbackPair{
1791 CbKey: tid,
1792 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001793 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001794 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001795 if err != nil {
1796 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1797 "Err": err, "device-id": oo.deviceID})
1798 return nil, err
1799 }
1800 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1801 return meInstance, nil
1802 }
1803 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1804 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1805 return nil, omciErr.GetError()
1806}
1807
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001808// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1809func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001810 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001811 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001812 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001813 "SequNo": strconv.FormatInt(int64(tid), 16),
1814 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1815
1816 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1817 if omciErr.GetError() == nil {
1818 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001819 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1820 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001821 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001822 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001823 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001824 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001825 }
1826
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001827 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001828 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001829 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001830 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001831 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001832 }
1833
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001834 omciRxCallbackPair := CallbackPair{
1835 CbKey: tid,
1836 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001837 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001838 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001839 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001840 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001841 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001842 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001843 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001844 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001845 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001846 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001847 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001848 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001849 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001850}
1851
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001852// SendSetTcontVar sets TCont ME instance
1853func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001854 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001855 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001856 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001857 "SequNo": strconv.FormatInt(int64(tid), 16),
1858 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1859
1860 meInstance, omciErr := me.NewTCont(params[0])
1861 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001862 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001863 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001864 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001865 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001866 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001867 }
1868
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001869 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001870 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001871 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001872 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001873 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001874 }
1875
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001876 omciRxCallbackPair := CallbackPair{
1877 CbKey: tid,
1878 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001879 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001880 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001881 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001882 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001883 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001884 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001885 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001886 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001887 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001888 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001889 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001890 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001891 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001892}
1893
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001894// SendSetPrioQueueVar sets PriorityQueue ME instance
1895func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001896 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001897 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001899 "SequNo": strconv.FormatInt(int64(tid), 16),
1900 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1901
1902 meInstance, omciErr := me.NewPriorityQueue(params[0])
1903 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001904 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001905 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001906 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001907 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001908 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001909 }
1910
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001911 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001912 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001913 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001914 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001915 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001916 }
1917
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001918 omciRxCallbackPair := CallbackPair{
1919 CbKey: tid,
1920 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001921 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001922 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001923 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001924 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001925 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001926 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001927 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001928 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001929 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001930 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001931 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001932 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001933 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001934}
1935
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001936// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1937func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001938 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001939 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001940 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001941 "SequNo": strconv.FormatInt(int64(tid), 16),
1942 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1943
1944 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1945 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001946 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001947 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001948 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001949 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001950 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001951 }
1952
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001953 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001954 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001955 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001956 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001957 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001958 }
1959
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001960 omciRxCallbackPair := CallbackPair{
1961 CbKey: tid,
1962 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001963 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001964 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001965 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001966 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001967 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001968 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001969 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001970 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001971 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001972 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001973 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001974 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001975 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001976}
mpagenkodff5dda2020-08-28 11:52:01 +00001977
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001978// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1979func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001980 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001981 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001982 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001983 "SequNo": strconv.FormatInt(int64(tid), 16),
1984 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1985
1986 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1987 if omciErr.GetError() == nil {
1988 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001989 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1990 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001991 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001992 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001993 "Err": err, "device-id": oo.deviceID})
1994 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1995 // return (dual format) error code that can be used at caller for immediate error treatment
1996 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001997 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001998 }
1999
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002000 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002001 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002002 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002003 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002004 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002005 }
2006
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002007 omciRxCallbackPair := CallbackPair{
2008 CbKey: tid,
2009 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002010 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002011 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002012 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002013 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002014 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002015 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002016 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002017 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002018 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002019 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002020 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002021 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002022 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002023}
2024
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002025// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002026func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002027 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002028 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002030 "SequNo": strconv.FormatInt(int64(tid), 16),
2031 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2032
2033 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
2034 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002035 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
2036 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002037 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002038 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002039 "Err": err, "device-id": oo.deviceID})
2040 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2041 // return (dual format) error code that can be used at caller for immediate error treatment
2042 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002043 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002044 }
2045
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002046 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002047 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002048 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002049 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002050 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002051 }
2052
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002053 omciRxCallbackPair := CallbackPair{
2054 CbKey: tid,
2055 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002056 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002057 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002058 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002059 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002060 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002061 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002062 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002063 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002064 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002065 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002066 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002067 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002068 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002069}
2070
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002071// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
2072func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002073 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002074 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002075 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002076 "SequNo": strconv.FormatInt(int64(tid), 16),
2077 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2078
2079 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2080 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002081 //EnhancedMode not yet supported, used with default options
2082 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
2083 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002084 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002085 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002086 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002087 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002088 }
2089
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002090 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002091 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002092 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002093 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002094 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002095 }
2096
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002097 omciRxCallbackPair := CallbackPair{
2098 CbKey: tid,
2099 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002100 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002101 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002102 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002103 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002104 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002105 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002106 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002107 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002108 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002109 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002110 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002111 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002112 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002113}
2114
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002115// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
2116func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002117 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002118 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002119 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00002120 "SequNo": strconv.FormatInt(int64(tid), 16),
2121 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2122
2123 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2124 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002125 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00002126 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002127 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002128 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002129 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002130 }
2131
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002132 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002133 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002134 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002135 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002136 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002137 }
2138
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002139 omciRxCallbackPair := CallbackPair{
2140 CbKey: tid,
2141 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002142 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002143 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002144 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002145 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002146 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002147 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002148 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002149 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002150 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002151 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002152 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002153 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002154 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002155}
mpagenko01e726e2020-10-23 09:45:29 +00002156
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002157// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2158func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002159 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002160 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002161 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002162 "SequNo": strconv.FormatInt(int64(tid), 16),
2163 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2164
2165 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2166 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002167 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002168 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002169 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002170 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002171 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002172 }
2173
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002174 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002175 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002176 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002177 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002178 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002179 }
2180
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002181 omciRxCallbackPair := CallbackPair{
2182 CbKey: tid,
2183 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002184 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002185 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002187 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002188 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002189 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002190 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002191 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002192 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002193 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002194 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002195 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002196 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002197}
2198
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002199// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2200func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002201 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002202 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002203 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002204 "SequNo": strconv.FormatInt(int64(tid), 16),
2205 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2206
2207 meParams := me.ParamData{EntityID: aInstID}
2208 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2209 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002210 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2211 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002212 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002213 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002214 "Err": err, "device-id": oo.deviceID})
2215 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2216 // return (dual format) error code that can be used at caller for immediate error treatment
2217 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002218 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002219 }
2220
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002221 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002222 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002223 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002224 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002225 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002226 }
2227
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002228 omciRxCallbackPair := CallbackPair{
2229 CbKey: tid,
2230 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002231 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002232 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002233 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002235 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002236 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002237 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002238 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002239 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002240 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002241 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002242 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002243 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002244}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002245
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002246// SendCreateTDVar creates TrafficDescriptor ME instance
2247func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2248 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002249 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2250 "SequNo": strconv.FormatInt(int64(tid), 16),
2251 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2252 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2253 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002254 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002255 if err != nil {
2256 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002257 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002258 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002259 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002260 if err != nil {
2261 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002262 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002263 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002264 omciRxCallbackPair := CallbackPair{
2265 CbKey: tid,
2266 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002267 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002268 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002269 if err != nil {
2270 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002271 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002272 }
2273 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002274 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002275 }
2276 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002277 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002278}
2279
2280// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002281func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002282 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002283 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002284 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2285 "SequNo": strconv.FormatInt(int64(tid), 16),
2286 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2287
2288 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2289 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002290 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002291 if err != nil {
2292 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002293 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002294 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002295 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002296 if err != nil {
2297 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002298 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002299 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002300 omciRxCallbackPair := CallbackPair{
2301 CbKey: tid,
2302 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002303 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002304 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002305 if err != nil {
2306 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002307 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002308 }
2309 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002310 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002311 }
2312 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002313 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002314
2315}
2316
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002317// SendDeleteTD - TODO: add comment
2318func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002319 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002320 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002321 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2322 "SequNo": strconv.FormatInt(int64(tid), 16),
2323 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2324
2325 meParams := me.ParamData{EntityID: aInstID}
2326 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2327 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002328 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002329 if err != nil {
2330 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002331 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002332 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002333 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002334 if err != nil {
2335 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002336 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002337 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002338 omciRxCallbackPair := CallbackPair{
2339 CbKey: tid,
2340 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002341 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002342 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002343 if err != nil {
2344 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002345 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002346 }
2347 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002348 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002349 }
2350 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002351 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002352
2353}
2354
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002355// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2356func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002357 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002358 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002359 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002360 "SequNo": strconv.FormatInt(int64(tid), 16),
2361 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2362
2363 meParams := me.ParamData{EntityID: aInstID}
2364 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2365 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002366 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2367 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002368 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002369 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002370 "Err": err, "device-id": oo.deviceID})
2371 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2372 // return (dual format) error code that can be used at caller for immediate error treatment
2373 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002374 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002375 }
2376
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002377 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002378 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002379 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002380 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002381 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002382 }
2383
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002384 omciRxCallbackPair := CallbackPair{
2385 CbKey: tid,
2386 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002387 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002388 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002389 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002390 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002391 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002392 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002394 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002395 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002396 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002397 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002398 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002399 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002400}
2401
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002402// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2403func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002404 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002405 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002406 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002407 "SequNo": strconv.FormatInt(int64(tid), 16),
2408 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2409
2410 meParams := me.ParamData{EntityID: aInstID}
2411 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2412 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002413 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2414 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002415 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002416 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002417 "Err": err, "device-id": oo.deviceID})
2418 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2419 // return (dual format) error code that can be used at caller for immediate error treatment
2420 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002421 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002422 }
2423
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002424 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002425 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002426 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002427 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002428 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002429 }
2430
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002431 omciRxCallbackPair := CallbackPair{
2432 CbKey: tid,
2433 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002434 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002435 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002436 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002437 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002438 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002439 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002440 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002441 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002442 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002443 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002444 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002445 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002446 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002447}
2448
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002449// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2450func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002451 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002452 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002453 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002454 "SequNo": strconv.FormatInt(int64(tid), 16),
2455 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2456
2457 meParams := me.ParamData{EntityID: aInstID}
2458 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2459 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002460 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2461 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002462 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002463 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002464 "Err": err, "device-id": oo.deviceID})
2465 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2466 // return (dual format) error code that can be used at caller for immediate error treatment
2467 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002468 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002469 }
2470
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002471 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002472 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002473 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002474 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002475 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002476 }
2477
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002478 omciRxCallbackPair := CallbackPair{
2479 CbKey: tid,
2480 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002481 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002482 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002483 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002484 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002485 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002486 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002487 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002488 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002489 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002490 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002491 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002492 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002493 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002494}
2495
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002496// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2497func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002498 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002499 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002500 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002501 "SequNo": strconv.FormatInt(int64(tid), 16),
2502 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2503
2504 meParams := me.ParamData{EntityID: aInstID}
2505 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2506 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002507 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2508 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002509 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002510 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002511 "Err": err, "device-id": oo.deviceID})
2512 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2513 // return (dual format) error code that can be used at caller for immediate error treatment
2514 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002515 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002516 }
2517
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002518 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002519 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002520 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002521 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002522 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002523 }
2524
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002525 omciRxCallbackPair := CallbackPair{
2526 CbKey: tid,
2527 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002528 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002529 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002530 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002531 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002532 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002533 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002534 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002535 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002536 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002537 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002538 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002539 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002540 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002541}
2542
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002543// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2544func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002545 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002546 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002547 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002548 "SequNo": strconv.FormatInt(int64(tid), 16),
2549 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2550
2551 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2552 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002553 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2554 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002555 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002556 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002557 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002558 }
2559
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002560 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002561 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002562 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002563 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002564 }
2565
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002566 omciRxCallbackPair := CallbackPair{CbKey: tid,
2567 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002568 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002569 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002570 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002571 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002572 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002573 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002574 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002575 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002576 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002577 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002578 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002579 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002580}
2581
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002582// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2583func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002584 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002585 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002586 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002587 "SequNo": strconv.FormatInt(int64(tid), 16),
2588 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2589
2590 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2591 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002592 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2593 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002594 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002595 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002596 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002597 }
2598
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002599 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002600 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002601 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002602 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002603 }
2604
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002605 omciRxCallbackPair := CallbackPair{CbKey: tid,
2606 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002607 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002608 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002609 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002610 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002611 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002612 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002613 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002614 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002615 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002616 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002617 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002618 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002619}
2620
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002621// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2622func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002623 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002624 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002625 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002626 "SequNo": strconv.FormatInt(int64(tid), 16),
2627 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2628
2629 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2630 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002631 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2632 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002633 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002634 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002635 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002636 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002637 }
2638
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002639 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002640 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002641 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002642 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002643 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002644 }
2645
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002646 omciRxCallbackPair := CallbackPair{CbKey: tid,
2647 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002648 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002649 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002650 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002651 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002652 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002653 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002654 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002655 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002656 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002657 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002658 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002659 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002660 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002661}
2662
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002663// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2664func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002665 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002666 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002667 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002668 "SequNo": strconv.FormatInt(int64(tid), 16),
2669 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2670
2671 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2672 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002673 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2674 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002675 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002676 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002677 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002678 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002679 }
2680
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002681 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002682 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002683 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002684 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002685 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002686 }
2687
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002688 omciRxCallbackPair := CallbackPair{CbKey: tid,
2689 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002690 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002691 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002692 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002693 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002694 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002695 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002696 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002697 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002698 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002699 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002700 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002701 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002702 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002703}
2704
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002705// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2706func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002707 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002708 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002709 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002710 "SequNo": strconv.FormatInt(int64(tid), 16),
2711 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2712
2713 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2714 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002715 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2716 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002717 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002718 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002719 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002720 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002721 }
2722
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002723 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002724 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002725 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002726 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002727 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002728 }
2729
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002730 omciRxCallbackPair := CallbackPair{CbKey: tid,
2731 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002732 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002733 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002734 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002735 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002736 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002737 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002738 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002739 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002740 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002741 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002742 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002743 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002744 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002745}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002746
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002747// SendCreateVoipVoiceCTP nolint: unused
2748func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2749 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2750 tid := oo.GetNextTid(highPrio)
2751 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2752 "SequNo": strconv.FormatInt(int64(tid), 16),
2753 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2754
2755 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2756 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002757 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2758 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002759 if err != nil {
2760 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2761 "device-id": oo.deviceID})
2762 return nil, err
2763 }
2764
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002765 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002766 if err != nil {
2767 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2768 "device-id": oo.deviceID})
2769 return nil, err
2770 }
2771
2772 omciRxCallbackPair := CallbackPair{CbKey: tid,
2773 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2774 }
2775 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2776 if err != nil {
2777 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2778 "device-id": oo.deviceID})
2779 return nil, err
2780 }
2781 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2782 return meInstance, nil
2783 }
2784 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2785 "device-id": oo.deviceID})
2786 return nil, omciErr.GetError()
2787}
2788
2789// SendSetVoipVoiceCTP nolint: unused
2790func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2791 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2792 tid := oo.GetNextTid(highPrio)
2793 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2794 "SequNo": strconv.FormatInt(int64(tid), 16),
2795 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2796
2797 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2798 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002799 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2800 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002801 if err != nil {
2802 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2803 "device-id": oo.deviceID})
2804 return nil, err
2805 }
2806
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002807 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002808 if err != nil {
2809 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2810 "device-id": oo.deviceID})
2811 return nil, err
2812 }
2813
2814 omciRxCallbackPair := CallbackPair{CbKey: tid,
2815 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2816 }
2817 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2818 if err != nil {
2819 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2820 "device-id": oo.deviceID})
2821 return nil, err
2822 }
2823 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2824 return meInstance, nil
2825 }
2826 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2827 "device-id": oo.deviceID})
2828 return nil, omciErr.GetError()
2829}
2830
2831// SendDeleteVoipVoiceCTP nolint: unused
2832func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2833 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2834 tid := oo.GetNextTid(highPrio)
2835 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2836 "SequNo": strconv.FormatInt(int64(tid), 16),
2837 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2838
2839 meParams := me.ParamData{EntityID: aInstID}
2840 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2841 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002842 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2843 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002844 if err != nil {
2845 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2846 "Err": err, "device-id": oo.deviceID})
2847 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2848 // return (dual format) error code that can be used at caller for immediate error treatment
2849 // (relevant to all used sendXX() methods and their error conditions)
2850 return nil, err
2851 }
2852
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002853 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002854 if err != nil {
2855 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2856 "Err": err, "device-id": oo.deviceID})
2857 return nil, err
2858 }
2859
2860 omciRxCallbackPair := CallbackPair{
2861 CbKey: tid,
2862 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2863 }
2864 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2865 if err != nil {
2866 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2867 "Err": err, "device-id": oo.deviceID})
2868 return nil, err
2869 }
2870 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2871 return meInstance, nil
2872 }
2873 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2874 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2875 return nil, omciErr.GetError()
2876}
2877
2878// SendCreateVoipMediaProfile nolint: unused
2879func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2880 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2881 tid := oo.GetNextTid(highPrio)
2882 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2883 "SequNo": strconv.FormatInt(int64(tid), 16),
2884 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2885
2886 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2887 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002888 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2889 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002890 if err != nil {
2891 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2892 "device-id": oo.deviceID})
2893 return nil, err
2894 }
2895
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002896 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002897 if err != nil {
2898 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2899 "device-id": oo.deviceID})
2900 return nil, err
2901 }
2902
2903 omciRxCallbackPair := CallbackPair{CbKey: tid,
2904 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2905 }
2906 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2907 if err != nil {
2908 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2909 "device-id": oo.deviceID})
2910 return nil, err
2911 }
2912 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2913 return meInstance, nil
2914 }
2915 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2916 "device-id": oo.deviceID})
2917 return nil, omciErr.GetError()
2918}
2919
2920// SendSetVoipMediaProfile nolint: unused
2921func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2922 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2923 tid := oo.GetNextTid(highPrio)
2924 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2925 "SequNo": strconv.FormatInt(int64(tid), 16),
2926 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2927
2928 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2929 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002930 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2931 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002932 if err != nil {
2933 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2934 "device-id": oo.deviceID})
2935 return nil, err
2936 }
2937
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002938 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002939 if err != nil {
2940 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2941 "device-id": oo.deviceID})
2942 return nil, err
2943 }
2944
2945 omciRxCallbackPair := CallbackPair{CbKey: tid,
2946 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2947 }
2948 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2949 if err != nil {
2950 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2951 "device-id": oo.deviceID})
2952 return nil, err
2953 }
2954 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2955 return meInstance, nil
2956 }
2957 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2958 "device-id": oo.deviceID})
2959 return nil, omciErr.GetError()
2960}
2961
2962// SendDeleteVoipMediaProfile nolint: unused
2963func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2964 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2965 tid := oo.GetNextTid(highPrio)
2966 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2967 "SequNo": strconv.FormatInt(int64(tid), 16),
2968 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2969
2970 meParams := me.ParamData{EntityID: aInstID}
2971 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2972 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002973 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2974 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002975 if err != nil {
2976 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2977 "Err": err, "device-id": oo.deviceID})
2978 return nil, err
2979 }
2980
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002981 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002982 if err != nil {
2983 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2984 "Err": err, "device-id": oo.deviceID})
2985 return nil, err
2986 }
2987
2988 omciRxCallbackPair := CallbackPair{
2989 CbKey: tid,
2990 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2991 }
2992 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2993 if err != nil {
2994 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2995 "Err": err, "device-id": oo.deviceID})
2996 return nil, err
2997 }
2998 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2999 return meInstance, nil
3000 }
3001 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
3002 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3003 return nil, omciErr.GetError()
3004}
3005
3006// SendCreateVoiceServiceProfile nolint: unused
3007func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3008 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3009 tid := oo.GetNextTid(highPrio)
3010 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3011 "SequNo": strconv.FormatInt(int64(tid), 16),
3012 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3013
3014 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3015 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003016 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3017 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003018 if err != nil {
3019 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
3020 "device-id": oo.deviceID})
3021 return nil, err
3022 }
3023
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003024 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003025 if err != nil {
3026 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
3027 "device-id": oo.deviceID})
3028 return nil, err
3029 }
3030
3031 omciRxCallbackPair := CallbackPair{CbKey: tid,
3032 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3033 }
3034 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3035 if err != nil {
3036 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
3037 "device-id": oo.deviceID})
3038 return nil, err
3039 }
3040 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
3041 return meInstance, nil
3042 }
3043 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3044 "device-id": oo.deviceID})
3045 return nil, omciErr.GetError()
3046}
3047
3048// SendSetVoiceServiceProfile nolint: unused
3049func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3050 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3051 tid := oo.GetNextTid(highPrio)
3052 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3053 "SequNo": strconv.FormatInt(int64(tid), 16),
3054 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3055
3056 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3057 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003058 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3059 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003060 if err != nil {
3061 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
3062 "device-id": oo.deviceID})
3063 return nil, err
3064 }
3065
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003066 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003067 if err != nil {
3068 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
3069 "device-id": oo.deviceID})
3070 return nil, err
3071 }
3072
3073 omciRxCallbackPair := CallbackPair{CbKey: tid,
3074 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3075 }
3076 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3077 if err != nil {
3078 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
3079 "device-id": oo.deviceID})
3080 return nil, err
3081 }
3082 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
3083 return meInstance, nil
3084 }
3085 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3086 "device-id": oo.deviceID})
3087 return nil, omciErr.GetError()
3088}
3089
3090// SendDeleteVoiceServiceProfile nolint: unused
3091func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3092 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3093 tid := oo.GetNextTid(highPrio)
3094 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3095 "SequNo": strconv.FormatInt(int64(tid), 16),
3096 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3097
3098 meParams := me.ParamData{EntityID: aInstID}
3099 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
3100 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003101 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3102 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003103 if err != nil {
3104 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
3105 "Err": err, "device-id": oo.deviceID})
3106 return nil, err
3107 }
3108
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003109 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003110 if err != nil {
3111 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
3112 "Err": err, "device-id": oo.deviceID})
3113 return nil, err
3114 }
3115
3116 omciRxCallbackPair := CallbackPair{
3117 CbKey: tid,
3118 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3119 }
3120 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3121 if err != nil {
3122 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
3123 "Err": err, "device-id": oo.deviceID})
3124 return nil, err
3125 }
3126 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
3127 return meInstance, nil
3128 }
3129 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
3130 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3131 return nil, omciErr.GetError()
3132}
3133
3134// SendCreateSIPUserData nolint: unused
3135func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
3136 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3137 tid := oo.GetNextTid(highPrio)
3138 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
3139 "SequNo": strconv.FormatInt(int64(tid), 16),
3140 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3141
3142 meInstance, omciErr := me.NewSipUserData(params[0])
3143 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003144 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3145 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003146 if err != nil {
3147 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3148 "device-id": oo.deviceID})
3149 return nil, err
3150 }
3151
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003152 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003153 if err != nil {
3154 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3155 "device-id": oo.deviceID})
3156 return nil, err
3157 }
3158
3159 omciRxCallbackPair := CallbackPair{CbKey: tid,
3160 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3161 }
3162 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3163 if err != nil {
3164 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3165 "device-id": oo.deviceID})
3166 return nil, err
3167 }
3168 logger.Debug(ctx, "send SIPUserData-create-msg done")
3169 return meInstance, nil
3170 }
3171 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3172 "device-id": oo.deviceID})
3173 return nil, omciErr.GetError()
3174}
3175
3176// SendSetSIPUserData nolint: unused
3177func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3178 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3179 tid := oo.GetNextTid(highPrio)
3180 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3181 "SequNo": strconv.FormatInt(int64(tid), 16),
3182 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3183
3184 meInstance, omciErr := me.NewSipUserData(params[0])
3185 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003186 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3187 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003188 if err != nil {
3189 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3190 "device-id": oo.deviceID})
3191 return nil, err
3192 }
3193
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003194 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003195 if err != nil {
3196 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3197 "device-id": oo.deviceID})
3198 return nil, err
3199 }
3200
3201 omciRxCallbackPair := CallbackPair{CbKey: tid,
3202 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3203 }
3204 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3205 if err != nil {
3206 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3207 "device-id": oo.deviceID})
3208 return nil, err
3209 }
3210 logger.Debug(ctx, "send SIPUserData-set-msg done")
3211 return meInstance, nil
3212 }
3213 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3214 "device-id": oo.deviceID})
3215 return nil, omciErr.GetError()
3216}
3217
3218// SendDeleteSIPUserData nolint: unused
3219func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3220 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3221 tid := oo.GetNextTid(highPrio)
3222 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3223 "SequNo": strconv.FormatInt(int64(tid), 16),
3224 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3225
3226 meParams := me.ParamData{EntityID: aInstID}
3227 meInstance, omciErr := me.NewSipUserData(meParams)
3228 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003229 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3230 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003231 if err != nil {
3232 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3233 "Err": err, "device-id": oo.deviceID})
3234 return nil, err
3235 }
3236
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003237 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003238 if err != nil {
3239 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3240 "Err": err, "device-id": oo.deviceID})
3241 return nil, err
3242 }
3243
3244 omciRxCallbackPair := CallbackPair{
3245 CbKey: tid,
3246 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3247 }
3248 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3249 if err != nil {
3250 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3251 "Err": err, "device-id": oo.deviceID})
3252 return nil, err
3253 }
3254 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3255 return meInstance, nil
3256 }
3257 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3258 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3259 return nil, omciErr.GetError()
3260}
3261
3262// SendCreateVoipApplicationServiceProfile nolint: unused
3263func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3264 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3265 tid := oo.GetNextTid(highPrio)
3266 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3267 "SequNo": strconv.FormatInt(int64(tid), 16),
3268 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3269
3270 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3271 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003272 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3273 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003274 if err != nil {
3275 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3276 "device-id": oo.deviceID})
3277 return nil, err
3278 }
3279
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003280 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003281 if err != nil {
3282 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3283 "device-id": oo.deviceID})
3284 return nil, err
3285 }
3286
3287 omciRxCallbackPair := CallbackPair{CbKey: tid,
3288 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3289 }
3290 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3291 if err != nil {
3292 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3293 "device-id": oo.deviceID})
3294 return nil, err
3295 }
3296 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3297 return meInstance, nil
3298 }
3299 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3300 "device-id": oo.deviceID})
3301 return nil, omciErr.GetError()
3302}
3303
3304// SendSetVoipApplicationServiceProfile nolint: unused
3305func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3306 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3307 tid := oo.GetNextTid(highPrio)
3308 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3309 "SequNo": strconv.FormatInt(int64(tid), 16),
3310 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3311
3312 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3313 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003314 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3315 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003316 if err != nil {
3317 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3318 "device-id": oo.deviceID})
3319 return nil, err
3320 }
3321
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003322 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003323 if err != nil {
3324 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3325 "device-id": oo.deviceID})
3326 return nil, err
3327 }
3328
3329 omciRxCallbackPair := CallbackPair{CbKey: tid,
3330 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3331 }
3332 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3333 if err != nil {
3334 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3335 "device-id": oo.deviceID})
3336 return nil, err
3337 }
3338 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3339 return meInstance, nil
3340 }
3341 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3342 "device-id": oo.deviceID})
3343 return nil, omciErr.GetError()
3344}
3345
3346// SendDeleteVoipApplicationServiceProfile nolint: unused
3347func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3348 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3349 tid := oo.GetNextTid(highPrio)
3350 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3351 "SequNo": strconv.FormatInt(int64(tid), 16),
3352 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3353
3354 meParams := me.ParamData{EntityID: aInstID}
3355 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3356 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003357 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3358 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003359 if err != nil {
3360 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3361 "Err": err, "device-id": oo.deviceID})
3362 return nil, err
3363 }
3364
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003365 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003366 if err != nil {
3367 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3368 "Err": err, "device-id": oo.deviceID})
3369 return nil, err
3370 }
3371
3372 omciRxCallbackPair := CallbackPair{
3373 CbKey: tid,
3374 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3375 }
3376 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3377 if err != nil {
3378 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3379 "Err": err, "device-id": oo.deviceID})
3380 return nil, err
3381 }
3382 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3383 return meInstance, nil
3384 }
3385 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3386 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3387 return nil, omciErr.GetError()
3388}
3389
3390// SendCreateSIPAgentConfigData nolint: unused
3391func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3392 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3393 tid := oo.GetNextTid(highPrio)
3394 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3395 "SequNo": strconv.FormatInt(int64(tid), 16),
3396 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3397
3398 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3399 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003400 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3401 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003402 if err != nil {
3403 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3404 "device-id": oo.deviceID})
3405 return nil, err
3406 }
3407
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003408 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003409 if err != nil {
3410 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3411 "device-id": oo.deviceID})
3412 return nil, err
3413 }
3414
3415 omciRxCallbackPair := CallbackPair{CbKey: tid,
3416 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3417 }
3418 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3419 if err != nil {
3420 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3421 "device-id": oo.deviceID})
3422 return nil, err
3423 }
3424 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3425 return meInstance, nil
3426 }
3427 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3428 "device-id": oo.deviceID})
3429 return nil, omciErr.GetError()
3430}
3431
3432// SendSetSIPAgentConfigData nolint: unused
3433func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3434 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3435 tid := oo.GetNextTid(highPrio)
3436 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3437 "SequNo": strconv.FormatInt(int64(tid), 16),
3438 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3439
3440 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3441 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003442 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3443 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003444 if err != nil {
3445 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3446 "device-id": oo.deviceID})
3447 return nil, err
3448 }
3449
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003450 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003451 if err != nil {
3452 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3453 "device-id": oo.deviceID})
3454 return nil, err
3455 }
3456
3457 omciRxCallbackPair := CallbackPair{CbKey: tid,
3458 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3459 }
3460 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3461 if err != nil {
3462 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3463 "device-id": oo.deviceID})
3464 return nil, err
3465 }
3466 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3467 return meInstance, nil
3468 }
3469 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3470 "device-id": oo.deviceID})
3471 return nil, omciErr.GetError()
3472}
3473
3474// SendDeleteSIPAgentConfigData nolint: unused
3475func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3476 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3477 tid := oo.GetNextTid(highPrio)
3478 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3479 "SequNo": strconv.FormatInt(int64(tid), 16),
3480 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3481
3482 meParams := me.ParamData{EntityID: aInstID}
3483 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3484 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003485 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3486 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003487 if err != nil {
3488 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3489 "Err": err, "device-id": oo.deviceID})
3490 return nil, err
3491 }
3492
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003493 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003494 if err != nil {
3495 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3496 "Err": err, "device-id": oo.deviceID})
3497 return nil, err
3498 }
3499
3500 omciRxCallbackPair := CallbackPair{
3501 CbKey: tid,
3502 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3503 }
3504 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3505 if err != nil {
3506 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3507 "Err": err, "device-id": oo.deviceID})
3508 return nil, err
3509 }
3510 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3511 return meInstance, nil
3512 }
3513 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3514 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3515 return nil, omciErr.GetError()
3516}
3517
3518// SendCreateTCPUDPConfigData nolint: unused
3519func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3520 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3521 tid := oo.GetNextTid(highPrio)
3522 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3523 "SequNo": strconv.FormatInt(int64(tid), 16),
3524 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3525
3526 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3527 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003528 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3529 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003530 if err != nil {
3531 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3532 "device-id": oo.deviceID})
3533 return nil, err
3534 }
3535
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003536 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003537 if err != nil {
3538 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3539 "device-id": oo.deviceID})
3540 return nil, err
3541 }
3542
3543 omciRxCallbackPair := CallbackPair{CbKey: tid,
3544 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3545 }
3546 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3547 if err != nil {
3548 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3549 "device-id": oo.deviceID})
3550 return nil, err
3551 }
3552 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3553 return meInstance, nil
3554 }
3555 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3556 "device-id": oo.deviceID})
3557 return nil, omciErr.GetError()
3558}
3559
3560// SendSetTCPUDPConfigData nolint: unused
3561func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3562 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3563 tid := oo.GetNextTid(highPrio)
3564 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3565 "SequNo": strconv.FormatInt(int64(tid), 16),
3566 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3567
3568 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3569 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003570 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3571 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003572 if err != nil {
3573 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3574 "device-id": oo.deviceID})
3575 return nil, err
3576 }
3577
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003578 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003579 if err != nil {
3580 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3581 "device-id": oo.deviceID})
3582 return nil, err
3583 }
3584
3585 omciRxCallbackPair := CallbackPair{CbKey: tid,
3586 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3587 }
3588 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3589 if err != nil {
3590 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3591 "device-id": oo.deviceID})
3592 return nil, err
3593 }
3594 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3595 return meInstance, nil
3596 }
3597 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3598 "device-id": oo.deviceID})
3599 return nil, omciErr.GetError()
3600}
3601
3602// SendDeleteTCPUDPConfigData nolint: unused
3603func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3604 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3605 tid := oo.GetNextTid(highPrio)
3606 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3607 "SequNo": strconv.FormatInt(int64(tid), 16),
3608 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3609
3610 meParams := me.ParamData{EntityID: aInstID}
3611 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3612 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003613 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3614 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003615 if err != nil {
3616 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3617 "Err": err, "device-id": oo.deviceID})
3618 return nil, err
3619 }
3620
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003621 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003622 if err != nil {
3623 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3624 "Err": err, "device-id": oo.deviceID})
3625 return nil, err
3626 }
3627
3628 omciRxCallbackPair := CallbackPair{
3629 CbKey: tid,
3630 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3631 }
3632 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3633 if err != nil {
3634 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3635 "Err": err, "device-id": oo.deviceID})
3636 return nil, err
3637 }
3638 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3639 return meInstance, nil
3640 }
3641 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3642 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3643 return nil, omciErr.GetError()
3644}
3645
3646// SendCreateIPHostConfigData nolint: unused
3647func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3648 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3649 tid := oo.GetNextTid(highPrio)
3650 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3651 "SequNo": strconv.FormatInt(int64(tid), 16),
3652 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3653
3654 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3655 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003656 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3657 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003658 if err != nil {
3659 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3660 "device-id": oo.deviceID})
3661 return nil, err
3662 }
3663
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003664 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003665 if err != nil {
3666 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3667 "device-id": oo.deviceID})
3668 return nil, err
3669 }
3670
3671 omciRxCallbackPair := CallbackPair{CbKey: tid,
3672 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3673 }
3674 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3675 if err != nil {
3676 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3677 "device-id": oo.deviceID})
3678 return nil, err
3679 }
3680 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3681 return meInstance, nil
3682 }
3683 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3684 "device-id": oo.deviceID})
3685 return nil, omciErr.GetError()
3686}
3687
3688// SendSetIPHostConfigData nolint: unused
3689func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3690 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3691 tid := oo.GetNextTid(highPrio)
3692 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3693 "SequNo": strconv.FormatInt(int64(tid), 16),
3694 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3695
3696 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3697 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003698 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3699 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003700 if err != nil {
3701 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3702 "device-id": oo.deviceID})
3703 return nil, err
3704 }
3705
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003706 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003707 if err != nil {
3708 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3709 "device-id": oo.deviceID})
3710 return nil, err
3711 }
3712
3713 omciRxCallbackPair := CallbackPair{CbKey: tid,
3714 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3715 }
3716 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3717 if err != nil {
3718 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3719 "device-id": oo.deviceID})
3720 return nil, err
3721 }
3722 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3723 return meInstance, nil
3724 }
3725 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3726 "device-id": oo.deviceID})
3727 return nil, omciErr.GetError()
3728}
3729
3730// SendDeleteIPHostConfigData nolint: unused
3731func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3732 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3733 tid := oo.GetNextTid(highPrio)
3734 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3735 "SequNo": strconv.FormatInt(int64(tid), 16),
3736 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3737
3738 meParams := me.ParamData{EntityID: aInstID}
3739 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3740 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003741 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3742 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003743 if err != nil {
3744 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3745 "Err": err, "device-id": oo.deviceID})
3746 return nil, err
3747 }
3748
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003749 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003750 if err != nil {
3751 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3752 "Err": err, "device-id": oo.deviceID})
3753 return nil, err
3754 }
3755
3756 omciRxCallbackPair := CallbackPair{
3757 CbKey: tid,
3758 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3759 }
3760 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3761 if err != nil {
3762 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3763 "Err": err, "device-id": oo.deviceID})
3764 return nil, err
3765 }
3766 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3767 return meInstance, nil
3768 }
3769 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3770 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3771 return nil, omciErr.GetError()
3772}
3773
3774// SendCreateRTPProfileData nolint: unused
3775func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3776 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3777 tid := oo.GetNextTid(highPrio)
3778 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3779 "SequNo": strconv.FormatInt(int64(tid), 16),
3780 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3781
3782 meInstance, omciErr := me.NewRtpProfileData(params[0])
3783 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003784 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3785 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003786 if err != nil {
3787 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3788 "device-id": oo.deviceID})
3789 return nil, err
3790 }
3791
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003792 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003793 if err != nil {
3794 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3795 "device-id": oo.deviceID})
3796 return nil, err
3797 }
3798
3799 omciRxCallbackPair := CallbackPair{CbKey: tid,
3800 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3801 }
3802 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3803 if err != nil {
3804 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3805 "device-id": oo.deviceID})
3806 return nil, err
3807 }
3808 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3809 return meInstance, nil
3810 }
3811 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3812 "device-id": oo.deviceID})
3813 return nil, omciErr.GetError()
3814}
3815
3816// SendSetRTPProfileData nolint: unused
3817func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3818 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3819 tid := oo.GetNextTid(highPrio)
3820 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3821 "SequNo": strconv.FormatInt(int64(tid), 16),
3822 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3823
3824 meInstance, omciErr := me.NewRtpProfileData(params[0])
3825 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003826 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3827 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003828 if err != nil {
3829 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3830 "device-id": oo.deviceID})
3831 return nil, err
3832 }
3833
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003834 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003835 if err != nil {
3836 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3837 "device-id": oo.deviceID})
3838 return nil, err
3839 }
3840
3841 omciRxCallbackPair := CallbackPair{CbKey: tid,
3842 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3843 }
3844 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3845 if err != nil {
3846 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3847 "device-id": oo.deviceID})
3848 return nil, err
3849 }
3850 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3851 return meInstance, nil
3852 }
3853 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3854 "device-id": oo.deviceID})
3855 return nil, omciErr.GetError()
3856}
3857
3858// SendDeleteRTPProfileData nolint: unused
3859func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3860 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3861 tid := oo.GetNextTid(highPrio)
3862 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3863 "SequNo": strconv.FormatInt(int64(tid), 16),
3864 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3865
3866 meParams := me.ParamData{EntityID: aInstID}
3867 meInstance, omciErr := me.NewRtpProfileData(meParams)
3868 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003869 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3870 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003871 if err != nil {
3872 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3873 "Err": err, "device-id": oo.deviceID})
3874 return nil, err
3875 }
3876
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003877 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003878 if err != nil {
3879 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3880 "Err": err, "device-id": oo.deviceID})
3881 return nil, err
3882 }
3883
3884 omciRxCallbackPair := CallbackPair{
3885 CbKey: tid,
3886 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3887 }
3888 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3889 if err != nil {
3890 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3891 "Err": err, "device-id": oo.deviceID})
3892 return nil, err
3893 }
3894 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3895 return meInstance, nil
3896 }
3897 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3898 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3899 return nil, omciErr.GetError()
3900}
3901
3902// SendCreateNetworkDialPlanTable nolint: unused
3903func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3904 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3905 tid := oo.GetNextTid(highPrio)
3906 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3907 "SequNo": strconv.FormatInt(int64(tid), 16),
3908 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3909
3910 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3911 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003912 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3913 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003914 if err != nil {
3915 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3916 "device-id": oo.deviceID})
3917 return nil, err
3918 }
3919
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003920 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003921 if err != nil {
3922 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3923 "device-id": oo.deviceID})
3924 return nil, err
3925 }
3926
3927 omciRxCallbackPair := CallbackPair{CbKey: tid,
3928 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3929 }
3930 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3931 if err != nil {
3932 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3933 "device-id": oo.deviceID})
3934 return nil, err
3935 }
3936 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3937 return meInstance, nil
3938 }
3939 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3940 "device-id": oo.deviceID})
3941 return nil, omciErr.GetError()
3942}
3943
3944// SendSetNetworkDialPlanTable nolint: unused
3945func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3946 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3947 tid := oo.GetNextTid(highPrio)
3948 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3949 "SequNo": strconv.FormatInt(int64(tid), 16),
3950 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3951
3952 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3953 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003954 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3955 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003956 if err != nil {
3957 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3958 "device-id": oo.deviceID})
3959 return nil, err
3960 }
3961
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003962 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003963 if err != nil {
3964 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3965 "device-id": oo.deviceID})
3966 return nil, err
3967 }
3968
3969 omciRxCallbackPair := CallbackPair{CbKey: tid,
3970 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3971 }
3972 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3973 if err != nil {
3974 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3975 "device-id": oo.deviceID})
3976 return nil, err
3977 }
3978 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3979 return meInstance, nil
3980 }
3981 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3982 "device-id": oo.deviceID})
3983 return nil, omciErr.GetError()
3984}
3985
3986// SendDeleteNetworkDialPlanTable nolint: unused
3987func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3988 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3989 tid := oo.GetNextTid(highPrio)
3990 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3991 "SequNo": strconv.FormatInt(int64(tid), 16),
3992 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3993
3994 meParams := me.ParamData{EntityID: aInstID}
3995 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3996 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003997 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3998 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003999 if err != nil {
4000 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
4001 "Err": err, "device-id": oo.deviceID})
4002 return nil, err
4003 }
4004
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004005 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03004006 if err != nil {
4007 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
4008 "Err": err, "device-id": oo.deviceID})
4009 return nil, err
4010 }
4011
4012 omciRxCallbackPair := CallbackPair{
4013 CbKey: tid,
4014 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4015 }
4016 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4017 if err != nil {
4018 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
4019 "Err": err, "device-id": oo.deviceID})
4020 return nil, err
4021 }
4022 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
4023 return meInstance, nil
4024 }
4025 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
4026 "Err": omciErr.GetError(), "device-id": oo.deviceID})
4027 return nil, omciErr.GetError()
4028}
4029
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004030// SendSyncTime sends SynchronizeTimeRequest
4031func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
4032 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004033 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
4034 "SequNo": strconv.FormatInt(int64(tid), 16)})
4035
4036 omciLayer := &omci.OMCI{
4037 TransactionID: tid,
4038 MessageType: omci.SynchronizeTimeRequestType,
4039 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4040 // Length: 0x28, // Optional, defaults to 40 octets
4041 }
4042 utcTime := time.Now().UTC()
4043 request := &omci.SynchronizeTimeRequest{
4044 MeBasePacket: omci.MeBasePacket{
4045 EntityClass: me.OnuGClassID,
4046 // Default Instance ID is 0
4047 },
4048 Year: uint16(utcTime.Year()),
4049 Month: uint8(utcTime.Month()),
4050 Day: uint8(utcTime.Day()),
4051 Hour: uint8(utcTime.Hour()),
4052 Minute: uint8(utcTime.Minute()),
4053 Second: uint8(utcTime.Second()),
4054 }
4055
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004056 pkt, err := SerializeOmciLayer(ctx, omciLayer, request)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004057 if err != nil {
4058 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
4059 "device-id": oo.deviceID})
4060 return err
4061 }
4062
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004063 omciRxCallbackPair := CallbackPair{CbKey: tid,
4064 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004065 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004066 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004067 if err != nil {
4068 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
4069 "device-id": oo.deviceID})
4070 return err
4071 }
4072 logger.Debug(ctx, "send synchronize time request done")
4073 return nil
4074}
4075
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004076// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
4077func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004078 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004079 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004080 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4081 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4082 meParam := me.ParamData{EntityID: entityID}
4083 var meInstance *me.ManagedEntity
4084 var omciErr me.OmciErrors
4085 if upstream {
4086 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
4087 } else {
4088 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
4089 }
4090 if omciErr.GetError() == nil {
4091 var omciLayer *omci.OMCI
4092 var msgLayer gopacket.SerializableLayer
4093 var err error
4094 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004095 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4096 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004097 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004098 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4099 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004100 }
4101 if err != nil {
4102 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
4103 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004104 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004105 }
4106
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004107 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004108 if err != nil {
4109 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
4110 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004111 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004112 }
4113
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004114 omciRxCallbackPair := CallbackPair{CbKey: tid,
4115 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004116 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004117 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004118 if err != nil {
4119 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
4120 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004121 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004122 }
4123 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
4124 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004125 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004126 }
4127 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
4128 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 +03004129 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004130}
4131
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004132// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
4133func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004134 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004135 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004136 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4137 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4138 meParam := me.ParamData{EntityID: entityID}
4139 var meInstance *me.ManagedEntity
4140 var omciErr me.OmciErrors
4141 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
4142
4143 if omciErr.GetError() == nil {
4144 var omciLayer *omci.OMCI
4145 var msgLayer gopacket.SerializableLayer
4146 var err error
4147 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004148 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4149 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004150 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004151 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4152 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004153 }
4154 if err != nil {
4155 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4156 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004157 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004158 }
4159
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004160 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004161 if err != nil {
4162 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4163 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004164 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004165 }
4166
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004167 omciRxCallbackPair := CallbackPair{CbKey: tid,
4168 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004169 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004170 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004171 if err != nil {
4172 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4173 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004174 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004175 }
4176 logger.Debugw(ctx, "send ethernet uni history data ME done",
4177 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004178 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004179 }
4180 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4181 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004182 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004183}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004184
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004185// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4186func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004187 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004188 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004189 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4190 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4191 meParam := me.ParamData{EntityID: entityID}
4192 var meInstance *me.ManagedEntity
4193 var omciErr me.OmciErrors
4194 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4195
4196 if omciErr.GetError() == nil {
4197 var omciLayer *omci.OMCI
4198 var msgLayer gopacket.SerializableLayer
4199 var err error
4200 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004201 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4202 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004203 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004204 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4205 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004206 }
4207 if err != nil {
4208 logger.Errorw(ctx, "Cannot encode fec history data ME",
4209 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004210 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004211 }
4212
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004213 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004214 if err != nil {
4215 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4216 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004217 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004218 }
4219
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004220 omciRxCallbackPair := CallbackPair{CbKey: tid,
4221 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004222 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004223 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004224 if err != nil {
4225 logger.Errorw(ctx, "Cannot send fec history data ME",
4226 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004227 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004228 }
4229 logger.Debugw(ctx, "send fec history data ME done",
4230 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004231 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004232 }
4233 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4234 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004235 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004236}
4237
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004238// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4239func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004240 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004241 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004242 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4243 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4244 meParam := me.ParamData{EntityID: entityID}
4245 var meInstance *me.ManagedEntity
4246 var omciErr me.OmciErrors
4247 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4248
4249 if omciErr.GetError() == nil {
4250 var omciLayer *omci.OMCI
4251 var msgLayer gopacket.SerializableLayer
4252 var err error
4253 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004254 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4255 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004256 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004257 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4258 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004259 }
4260 if err != nil {
4261 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4262 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004263 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004264 }
4265
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004266 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004267 if err != nil {
4268 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4269 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004270 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004271 }
4272
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004273 omciRxCallbackPair := CallbackPair{CbKey: tid,
4274 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004275 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004276 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004277 if err != nil {
4278 logger.Errorw(ctx, "Cannot send gemport history data ME",
4279 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004280 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004281 }
4282 logger.Debugw(ctx, "send gemport history data ME done",
4283 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004284 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004285 }
4286 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4287 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004288 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004289}
4290
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004291// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4292func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004293 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004294 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004295 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4296 "SequNo": strconv.FormatInt(int64(tid), 16),
4297 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4298
4299 omciLayer := &omci.OMCI{
4300 TransactionID: tid,
4301 MessageType: omci.StartSoftwareDownloadRequestType,
4302 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4303 // Length: 0x28, // Optional, defaults to 40 octets
4304 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004305 if aIsExtendedOmci {
4306 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4307 }
mpagenko80622a52021-02-09 16:53:23 +00004308 request := &omci.StartSoftwareDownloadRequest{
4309 MeBasePacket: omci.MeBasePacket{
4310 EntityClass: me.SoftwareImageClassID,
4311 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004312 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004313 },
4314 WindowSize: aDownloadWindowSize,
4315 ImageSize: aFileLen,
4316 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4317 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4318 }
4319
4320 var options gopacket.SerializeOptions
4321 options.FixLengths = true
4322 buffer := gopacket.NewSerializeBuffer()
4323 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4324 if err != nil {
4325 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4326 "device-id": oo.deviceID})
4327 return err
4328 }
4329 outgoingPacket := buffer.Bytes()
4330
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004331 omciRxCallbackPair := CallbackPair{CbKey: tid,
4332 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004333 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004334 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004335 if err != nil {
4336 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4337 "device-id": oo.deviceID})
4338 return err
4339 }
4340 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004341 return nil
4342}
4343
kesavand011d5162021-11-25 19:21:06 +05304344// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4345//Before invoking this function the oo.mutexTid needs to be be locked so that
4346//GetOnuSwSecNextTid can be invoked without further locking
4347func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4348 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004349 omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) {
kesavand011d5162021-11-25 19:21:06 +05304350 //onuswsections uses only low prioirity tids
4351 tid := oo.GetOnuSwSecNextTid()
4352 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4353 "SequNo": strconv.FormatInt(int64(tid), 16),
4354 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4355
4356 var omciTxReq OmciTransferStructure
4357 msgType := omci.DownloadSectionRequestType
4358
4359 if aAckRequest > 0 {
4360 msgType = omci.DownloadSectionRequestWithResponseType
4361
4362 }
4363 omciLayer := &omci.OMCI{
4364 TransactionID: tid,
4365 MessageType: msgType,
4366 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4367 // Length: 0x28, // Optional, defaults to 40 octets
4368 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004369 if aIsExtendedOmci {
4370 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4371 }
kesavand011d5162021-11-25 19:21:06 +05304372 localSectionData := make([]byte, len(aSection))
4373
4374 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4375 request := &omci.DownloadSectionRequest{
4376 MeBasePacket: omci.MeBasePacket{
4377 EntityClass: me.SoftwareImageClassID,
4378 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004379 Extended: aIsExtendedOmci,
kesavand011d5162021-11-25 19:21:06 +05304380 },
4381 SectionNumber: aDownloadSectionNo,
4382 SectionData: localSectionData,
4383 }
4384
4385 var options gopacket.SerializeOptions
4386 options.FixLengths = true
4387 buffer := gopacket.NewSerializeBuffer()
4388 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4389 if err != nil {
4390 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4391 "device-id": oo.deviceID})
4392 return omciTxReq, err
4393 }
4394 outgoingPacket := buffer.Bytes()
4395
4396 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4397
4398 if aAckRequest > 0 {
4399 // only the last section should have a timeout as an ack is required only for the last section of the window
4400 omciTxReq = OmciTransferStructure{
4401 withFramePrint: true,
4402 OnuSwWindow: omciMsgsPerWindow,
4403 }
4404 return omciTxReq, nil
4405 }
4406
4407 return omciTxReq, nil
4408}
4409
4410//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4411func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4412 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4413 if aOmciTxRequest.OnuSwWindow == nil {
4414 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4415 log.Fields{"device-id": oo.deviceID})
4416 return
4417
4418 }
4419
4420 tid := oo.GetOnuSwSecLastTid()
4421 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4422 omciRxCallbackPair := CallbackPair{CbKey: tid,
4423 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4424 }
4425
4426 aOmciTxRequest.cbPair = omciRxCallbackPair
4427 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4428 oo.mutexRxSchedMap.Lock()
4429 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4430 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4431 oo.mutexRxSchedMap.Unlock()
4432
4433 chSuccess := make(chan bool)
4434 aOmciTxRequest.chSuccess = chSuccess
4435 aOmciTxRequest.timeout = aTimeout
4436 aOmciTxRequest.retries = CDefaultRetries
4437
4438 //tid := aOmciTxRequest.cbPair.CbKey
4439 oo.mutexMonReq.Lock()
4440 oo.monitoredRequests[tid] = aOmciTxRequest
4441 oo.mutexMonReq.Unlock()
4442
4443 retries := aOmciTxRequest.retries
4444 retryCounter := 0
4445 if aTimeout == 0 {
4446 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4447 return
4448 }
4449loop:
4450 for retryCounter <= retries {
4451 // the onu sw sections are enqueued only to the low priority queue
4452 oo.mutexLowPrioTxQueue.Lock()
4453 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4454 oo.mutexLowPrioTxQueue.Unlock()
4455
4456 go oo.sendQueuedRequests(ctx)
4457
4458 select {
4459 case success := <-chSuccess:
4460 if success {
4461 logger.Debugw(ctx, "reqMon: response received in time",
4462 log.Fields{"tid": tid, "device-id": oo.deviceID})
4463 } else {
4464 logger.Debugw(ctx, "reqMon: wait for response aborted",
4465 log.Fields{"tid": tid, "device-id": oo.deviceID})
4466 }
4467 break loop
4468 case <-time.After(time.Duration(aTimeout) * time.Second):
4469 if retryCounter == retries {
Holger Hildebrandt2b107642022-12-09 07:56:23 +00004470 if oo.pBaseDeviceHandler.IsOltAvailable() {
4471 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
4472 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4473 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
4474 } else {
4475 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!",
4476 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4477 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004478 oo.incrementTxTimesouts()
kesavand011d5162021-11-25 19:21:06 +05304479 break loop
4480 } else {
4481 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4482 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004483 oo.incrementTxRetries()
kesavand011d5162021-11-25 19:21:06 +05304484 }
4485 }
4486 retryCounter++
4487 }
4488 oo.mutexMonReq.Lock()
4489 delete(oo.monitoredRequests, tid)
4490 oo.mutexMonReq.Unlock()
4491}
4492
4493func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004494 var lastSection []byte
4495 if omciTxRequest.OnuSwWindow != nil {
4496 lastSection = omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4497 } else {
4498 logger.Errorw(ctx, "invalid sw window received", log.Fields{"device-id": oo.deviceID})
4499 return fmt.Errorf("invalid sw window received")
4500 }
4501 if omciTxRequest.withFramePrint {
4502 logger.Debugw(ctx, "sw-section-omci-message-to-send:", log.Fields{
kesavand011d5162021-11-25 19:21:06 +05304503 "TxOmciMessage": hex.EncodeToString(lastSection),
4504 "device-id": oo.deviceID,
4505 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4506 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4507 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4508 }
4509 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4510 if sendErr != nil {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004511 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"device-id": oo.deviceID, "error": sendErr})
kesavand011d5162021-11-25 19:21:06 +05304512 return sendErr
4513 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004514 numberOfNoArSections := len(omciTxRequest.OnuSwWindow.Messages) - 1 // last section of window is sent with AR expected
4515 if lastSection[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
4516 oo.increaseBaseTxNoArFramesBy(ctx, uint32(numberOfNoArSections))
4517 oo.incrementBaseTxArFrames()
4518 } else {
4519 oo.increaseExtTxNoArFramesBy(ctx, uint32(numberOfNoArSections))
4520 oo.incrementExtTxArFrames()
4521 }
kesavand011d5162021-11-25 19:21:06 +05304522 return nil
4523}
4524
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004525// SendDownloadSection sends DownloadSectionRequestWithResponse
4526func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004527 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004528 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004529 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4530 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004531 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004532
4533 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4534 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004535 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004536 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004537 if aAckRequest > 0 {
4538 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004539 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004540 }
mpagenko80622a52021-02-09 16:53:23 +00004541 omciLayer := &omci.OMCI{
4542 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004543 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004544 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4545 // Length: 0x28, // Optional, defaults to 40 octets
4546 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004547 if aIsExtendedOmci {
4548 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4549 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304550 localSectionData := make([]byte, len(aSection))
4551
mpagenko15ff4a52021-03-02 10:09:20 +00004552 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004553 request := &omci.DownloadSectionRequest{
4554 MeBasePacket: omci.MeBasePacket{
4555 EntityClass: me.SoftwareImageClassID,
4556 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004557 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004558 },
4559 SectionNumber: aDownloadSectionNo,
4560 SectionData: localSectionData,
4561 }
4562
4563 var options gopacket.SerializeOptions
4564 options.FixLengths = true
4565 buffer := gopacket.NewSerializeBuffer()
4566 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4567 if err != nil {
4568 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4569 "device-id": oo.deviceID})
4570 return err
4571 }
4572 outgoingPacket := buffer.Bytes()
4573
mpagenko15ff4a52021-03-02 10:09:20 +00004574 //for initial debug purpose overrule the requested print state for some frames
4575 printFrame := aPrint
4576 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4577 printFrame = true
4578 }
4579
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004580 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004581 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4582 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004583 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004584 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004585 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004586 if err != nil {
4587 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4588 "device-id": oo.deviceID})
4589 return err
4590 }
4591 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004592 return nil
4593}
4594
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004595//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4596func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004597 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004598 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004599 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4600 "SequNo": strconv.FormatInt(int64(tid), 16),
4601 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4602
mpagenko15ff4a52021-03-02 10:09:20 +00004603 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004604 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004605 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004606 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4607 // Length: 0x28, // Optional, defaults to 40 octets
4608 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004609 if aIsExtendedOmci {
4610 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4611 }
mpagenko15ff4a52021-03-02 10:09:20 +00004612 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004613 MeBasePacket: omci.MeBasePacket{
4614 EntityClass: me.SoftwareImageClassID,
4615 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004616 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004617 },
mpagenko15ff4a52021-03-02 10:09:20 +00004618 CRC32: aImageCrc,
4619 ImageSize: aFileLen,
4620 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4621 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004622 }
mpagenko15ff4a52021-03-02 10:09:20 +00004623
4624 var options gopacket.SerializeOptions
4625 options.FixLengths = true
4626 buffer := gopacket.NewSerializeBuffer()
4627 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4628 if err != nil {
4629 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004630 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004631 return err
mpagenko80622a52021-02-09 16:53:23 +00004632 }
mpagenko15ff4a52021-03-02 10:09:20 +00004633 outgoingPacket := buffer.Bytes()
4634
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004635 omciRxCallbackPair := CallbackPair{CbKey: tid,
4636 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004637 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004638 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004639 if err != nil {
4640 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4641 "device-id": oo.deviceID})
4642 return err
4643 }
4644 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004645 return nil
4646}
4647
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004648// SendActivateSoftware sends ActivateSoftwareRequest
4649func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004650 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004651 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004652 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4653 "SequNo": strconv.FormatInt(int64(tid), 16),
4654 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4655
4656 omciLayer := &omci.OMCI{
4657 TransactionID: tid,
4658 MessageType: omci.ActivateSoftwareRequestType,
4659 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4660 // Length: 0x28, // Optional, defaults to 40 octets
4661 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004662 if aIsExtendedOmci {
4663 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4664 }
mpagenko80622a52021-02-09 16:53:23 +00004665 request := &omci.ActivateSoftwareRequest{
4666 MeBasePacket: omci.MeBasePacket{
4667 EntityClass: me.SoftwareImageClassID,
4668 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004669 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004670 },
4671 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4672 }
4673
4674 var options gopacket.SerializeOptions
4675 options.FixLengths = true
4676 buffer := gopacket.NewSerializeBuffer()
4677 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4678 if err != nil {
4679 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4680 "device-id": oo.deviceID})
4681 return err
4682 }
4683 outgoingPacket := buffer.Bytes()
4684
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004685 omciRxCallbackPair := CallbackPair{CbKey: tid,
4686 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004687 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004688 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004689 if err != nil {
4690 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4691 "device-id": oo.deviceID})
4692 return err
4693 }
4694 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004695 return nil
4696}
mpagenko80622a52021-02-09 16:53:23 +00004697
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004698// SendCommitSoftware sends CommitSoftwareRequest
4699func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004700 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004701 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004702 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4703 "SequNo": strconv.FormatInt(int64(tid), 16),
4704 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4705
4706 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004707 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004708 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004709 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4710 // Length: 0x28, // Optional, defaults to 40 octets
4711 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004712 if aIsExtendedOmci {
4713 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4714 }
mpagenko15ff4a52021-03-02 10:09:20 +00004715 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004716 MeBasePacket: omci.MeBasePacket{
4717 EntityClass: me.SoftwareImageClassID,
4718 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004719 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004720 },
mpagenko80622a52021-02-09 16:53:23 +00004721 }
mpagenko15ff4a52021-03-02 10:09:20 +00004722
4723 var options gopacket.SerializeOptions
4724 options.FixLengths = true
4725 buffer := gopacket.NewSerializeBuffer()
4726 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4727 if err != nil {
4728 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004729 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004730 return err
mpagenko80622a52021-02-09 16:53:23 +00004731 }
mpagenko15ff4a52021-03-02 10:09:20 +00004732 outgoingPacket := buffer.Bytes()
4733
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004734 omciRxCallbackPair := CallbackPair{CbKey: tid,
4735 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004736 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004737 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004738 if err != nil {
4739 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4740 "device-id": oo.deviceID})
4741 return err
4742 }
4743 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004744 return nil
4745}
4746
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004747//SendSelfTestReq sends TestRequest
4748func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4749 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004750 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4751 "SequNo": strconv.FormatInt(int64(tid), 16),
4752 "InstId": strconv.FormatInt(int64(instdID), 16)})
4753 omciLayer := &omci.OMCI{
4754 TransactionID: tid,
4755 MessageType: omci.TestRequestType,
4756 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4757 // Length: 0x28, // Optional, defaults to 40 octets
4758 }
4759
4760 var request *omci.OpticalLineSupervisionTestRequest
4761 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004762 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004763 request = &omci.OpticalLineSupervisionTestRequest{
4764 MeBasePacket: omci.MeBasePacket{
4765 EntityClass: classID,
4766 EntityInstance: instdID,
4767 },
4768 SelectTest: uint8(7), // self test
4769 GeneralPurposeBuffer: uint16(0),
4770 VendorSpecificParameters: uint16(0),
4771 }
4772 default:
4773 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4774 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4775 }
4776 // Test serialization back to former string
4777 var options gopacket.SerializeOptions
4778 options.FixLengths = true
4779
4780 buffer := gopacket.NewSerializeBuffer()
4781 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4782 if err != nil {
4783 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4784 "device-id": oo.deviceID})
4785 return err
4786 }
4787 outgoingPacket := buffer.Bytes()
4788
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004789 omciRxCallbackPair := CallbackPair{CbKey: tid,
4790 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004791 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004792 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004793 if err != nil {
4794 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4795 "device-id": oo.deviceID})
4796 return err
4797 }
4798 logger.Debug(ctx, "send self test request done")
4799 return nil
4800}
4801
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004802//nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004803func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4804
4805 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4806 if err != nil {
4807 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4808 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4809 }
4810 msgLayer := (*packet).Layer(nextLayer)
4811 if msgLayer != nil {
4812 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4813 if failure := (*packet).ErrorLayer(); failure != nil {
4814 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4815 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4816 // can examine for UnkonwnMEs and UnknownAttributes
4817 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
4818 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4819 return false, nil
4820 } else if nextLayer == omci.LayerTypeGetResponse {
4821 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4822 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4823 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4824 if unknownAttrLayer != nil {
4825 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4826 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4827 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4828 }
4829 }
4830 }
4831 }
4832 // Try to decode any further error information
4833 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4834 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4835 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4836 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4837 }
4838 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4839 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4840 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4841 }
4842 } else if failure := (*packet).ErrorLayer(); failure != nil {
4843 // message layer could not be decoded, but at least check if additional failure information is available
4844 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004845 errMsg := decodeFailure.String()
4846 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4847 if strings.Contains(strings.ToLower(errMsg), "table decode") {
4848 // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass
4849 // so that later processing can deal with it
4850 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass",
4851 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4852 return false, nil
4853 }
4854 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004855 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004856 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg})
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004857 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4858 }
4859 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4860 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4861 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4862 } else {
4863 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4864 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4865 }
4866
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004867 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004868 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004869 switch nextLayer {
4870 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004871 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4872 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004873 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004874 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004875 }
4876 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004877 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4878 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004879 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004880 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004881 }
4882 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004883 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4884 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004885 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004886 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004887 }
4888 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004889 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4890 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004891 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004892 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004893 }
4894 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004895 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4896 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004897 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004898 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004899 }
4900 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004901 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4902 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004903 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004904 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004905 }
4906 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004907 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4908 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004909 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004910 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004911 }
4912 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004913 }
4914 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004915 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004916}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004917
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004918func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004919 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004920 if timeout == 0 {
4921 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004922 // enqueue
4923 if aOmciTxRequest.highPrio {
4924 oo.mutexHighPrioTxQueue.Lock()
4925 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4926 oo.mutexHighPrioTxQueue.Unlock()
4927 } else {
4928 oo.mutexLowPrioTxQueue.Lock()
4929 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4930 oo.mutexLowPrioTxQueue.Unlock()
4931 }
4932 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004933 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004934 //the supervised sending with waiting on the response (based on TID) is called in background
4935 // to avoid blocking of the sender for the complete OMCI handshake procedure
4936 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4937 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4938 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004939 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004940}
4941
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004942func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004943 chSuccess := make(chan bool)
4944 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004945 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004946 oo.mutexMonReq.Lock()
4947 oo.monitoredRequests[tid] = aOmciTxRequest
4948 oo.mutexMonReq.Unlock()
4949
4950 retries := aOmciTxRequest.retries
4951 retryCounter := 0
4952loop:
4953 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004954 // enqueue
4955 if aOmciTxRequest.highPrio {
4956 oo.mutexHighPrioTxQueue.Lock()
4957 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4958 oo.mutexHighPrioTxQueue.Unlock()
4959 } else {
4960 oo.mutexLowPrioTxQueue.Lock()
4961 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4962 oo.mutexLowPrioTxQueue.Unlock()
4963 }
4964 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004965
4966 select {
4967 case success := <-chSuccess:
4968 if success {
4969 logger.Debugw(ctx, "reqMon: response received in time",
4970 log.Fields{"tid": tid, "device-id": oo.deviceID})
4971 } else {
4972 logger.Debugw(ctx, "reqMon: wait for response aborted",
4973 log.Fields{"tid": tid, "device-id": oo.deviceID})
4974 }
4975 break loop
4976 case <-time.After(time.Duration(aTimeout) * time.Second):
4977 if retryCounter == retries {
Holger Hildebrandt2b107642022-12-09 07:56:23 +00004978 if oo.pBaseDeviceHandler.IsOltAvailable() {
4979 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
4980 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4981 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
4982 } else {
4983 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!",
4984 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4985 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004986 oo.incrementTxTimesouts()
mpagenko7455fd42021-06-10 16:25:55 +00004987 break loop
4988 } else {
4989 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4990 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004991 oo.incrementTxRetries()
mpagenko7455fd42021-06-10 16:25:55 +00004992 }
4993 }
4994 retryCounter++
4995 }
4996 oo.mutexMonReq.Lock()
4997 delete(oo.monitoredRequests, tid)
4998 oo.mutexMonReq.Unlock()
4999}
5000
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005001//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005002func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt12609a12022-03-25 13:23:25 +00005003 logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005004 oo.mutexMonReq.RLock()
5005 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00005006 //implement non-blocking channel send to avoid blocking on mutexMonReq later
5007 select {
5008 case oo.monitoredRequests[k].chSuccess <- false:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00005009 logger.Debugw(ctx, "send cancellation on omciRespChannel",
5010 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00005011 default:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00005012 logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
5013 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00005014 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005015 }
5016 oo.mutexMonReq.RUnlock()
5017}
5018
5019//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
5020//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005021func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
5022 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005023}
Himani Chawla43f95ff2021-06-03 00:24:12 +05305024
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005025// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
5026func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05305027 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005028 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305029 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
5030 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
5031
5032 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005033 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305034 }
5035 var meInstance *me.ManagedEntity
5036 var omciErr me.OmciErrors
5037 if classID == me.EthernetFrameExtendedPmClassID {
5038 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
5039 } else {
5040 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
5041 }
5042
5043 if omciErr.GetError() == nil {
5044 var omciLayer *omci.OMCI
5045 var msgLayer gopacket.SerializableLayer
5046 var err error
5047 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00005048 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
5049 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05305050 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00005051 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
5052 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05305053 }
5054 if err != nil {
5055 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5056 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5057 return nil, err
5058 }
5059
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005060 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305061 if err != nil {
5062 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
5063 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5064 return nil, err
5065 }
5066
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005067 omciRxCallbackPair := CallbackPair{CbKey: tid,
5068 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305069 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005070 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305071 if err != nil {
5072 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5073 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5074 return nil, err
5075 }
5076 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
5077 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5078 return meInstance, nil
5079 }
5080 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5081 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5082 return nil, omciErr.GetError()
5083}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005084
5085// RLockMutexMonReq lock read access to monitoredRequests
5086func (oo *OmciCC) RLockMutexMonReq() {
5087 oo.mutexMonReq.RLock()
5088}
5089
5090// RUnlockMutexMonReq unlock read access to monitoredRequests
5091func (oo *OmciCC) RUnlockMutexMonReq() {
5092 oo.mutexMonReq.RUnlock()
5093}
5094
5095// GetMonitoredRequest get OmciTransferStructure for an omciTransID
5096func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
5097 value, exist = oo.monitoredRequests[omciTransID]
5098 return value, exist
5099}
5100
5101// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
5102func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
5103 oo.monitoredRequests[omciTransID].chSuccess <- chVal
5104}
Himani Chawlaee10b542021-09-20 16:46:40 +05305105
5106// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
5107func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
5108 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
5109 tid := oo.GetNextTid(highPrio)
5110 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
5111 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
5112
5113 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005114 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05305115 }
5116 var meInstance *me.ManagedEntity
5117 var omciErr me.OmciErrors
5118 if classID == me.EthernetFrameExtendedPmClassID {
5119 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
5120 } else {
5121 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
5122 }
5123
5124 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00005125 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05305126 if err != nil {
5127 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5128 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5129 return nil, err
5130 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005131 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawlaee10b542021-09-20 16:46:40 +05305132 if err != nil {
5133 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
5134 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5135 return nil, err
5136 }
5137 omciRxCallbackPair := CallbackPair{
5138 CbKey: tid,
5139 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
5140 }
5141 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
5142 if err != nil {
5143 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5144 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5145 return nil, err
5146 }
5147 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
5148 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5149 return meInstance, nil
5150 }
5151 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5152 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5153 return nil, omciErr.GetError()
5154}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00005155
5156// PrepareForGarbageCollection - remove references to prepare for garbage collection
5157func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
5158 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
5159 oo.pBaseDeviceHandler = nil
5160 oo.pOnuDeviceEntry = nil
5161 oo.pOnuAlarmManager = nil
5162}
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00005163
5164// GetOmciCounters - TODO: add comment
5165func (oo *OmciCC) GetOmciCounters() *extension.SingleGetValueResponse {
5166 oo.mutexCounters.RLock()
5167 defer oo.mutexCounters.RUnlock()
5168 resp := extension.SingleGetValueResponse{
5169 Response: &extension.GetValueResponse{
5170 Status: extension.GetValueResponse_OK,
5171 Response: &extension.GetValueResponse_OnuOmciStats{
5172 OnuOmciStats: &extension.GetOnuOmciTxRxStatsResponse{},
5173 },
5174 },
5175 }
5176 resp.Response.GetOnuOmciStats().BaseTxArFrames = oo.countersBase.txArFrames
5177 resp.Response.GetOnuOmciStats().BaseTxNoArFrames = oo.countersBase.txNoArFrames
5178 resp.Response.GetOnuOmciStats().BaseRxAkFrames = oo.countersBase.rxAkFrames
5179 resp.Response.GetOnuOmciStats().BaseRxNoAkFrames = oo.countersBase.rxNoAkFrames
5180 resp.Response.GetOnuOmciStats().ExtTxArFrames = oo.countersExt.txArFrames
5181 resp.Response.GetOnuOmciStats().ExtTxNoArFrames = oo.countersExt.txNoArFrames
5182 resp.Response.GetOnuOmciStats().ExtRxAkFrames = oo.countersExt.rxAkFrames
5183 resp.Response.GetOnuOmciStats().ExtRxNoAkFrames = oo.countersExt.rxNoAkFrames
5184 resp.Response.GetOnuOmciStats().TxOmciCounterRetries = oo.txRetries
5185 resp.Response.GetOnuOmciStats().TxOmciCounterTimeouts = oo.txTimeouts
5186 return &resp
5187}
5188
5189// For more speed, separate functions for each counter
5190
5191func (oo *OmciCC) incrementBaseTxArFrames() {
5192 oo.mutexCounters.Lock()
5193 defer oo.mutexCounters.Unlock()
5194 oo.countersBase.txArFrames++
5195}
5196
5197func (oo *OmciCC) incrementExtTxArFrames() {
5198 oo.mutexCounters.Lock()
5199 defer oo.mutexCounters.Unlock()
5200 oo.countersExt.txArFrames++
5201}
5202
5203func (oo *OmciCC) incrementBaseRxAkFrames() {
5204 oo.mutexCounters.Lock()
5205 defer oo.mutexCounters.Unlock()
5206 oo.countersBase.rxAkFrames++
5207}
5208
5209func (oo *OmciCC) incrementExtRxAkFrames() {
5210 oo.mutexCounters.Lock()
5211 defer oo.mutexCounters.Unlock()
5212 oo.countersExt.rxAkFrames++
5213}
5214
5215func (oo *OmciCC) increaseBaseTxNoArFramesBy(ctx context.Context, value uint32) {
5216 oo.mutexCounters.Lock()
5217 defer oo.mutexCounters.Unlock()
5218 oo.countersBase.txNoArFrames += value
5219}
5220
5221func (oo *OmciCC) increaseExtTxNoArFramesBy(ctx context.Context, value uint32) {
5222 oo.mutexCounters.Lock()
5223 defer oo.mutexCounters.Unlock()
5224 oo.countersExt.txNoArFrames += value
5225}
5226
5227func (oo *OmciCC) incrementBaseRxNoAkFrames() {
5228 oo.mutexCounters.Lock()
5229 defer oo.mutexCounters.Unlock()
5230 oo.countersBase.rxNoAkFrames++
5231}
5232
5233func (oo *OmciCC) incrementExtRxNoAkFrames() {
5234 oo.mutexCounters.Lock()
5235 defer oo.mutexCounters.Unlock()
5236 oo.countersExt.rxNoAkFrames++
5237}
5238
5239func (oo *OmciCC) incrementTxRetries() {
5240 oo.mutexCounters.Lock()
5241 defer oo.mutexCounters.Unlock()
5242 oo.txRetries++
5243}
5244
5245func (oo *OmciCC) incrementTxTimesouts() {
5246 oo.mutexCounters.Lock()
5247 defer oo.mutexCounters.Unlock()
5248 oo.txTimeouts++
5249}
Holger Hildebrandt7e138462023-03-29 12:12:14 +00005250
5251// NotifyAboutOnuConfigFailure - trigger ONU DeviceEvent to notify about ONU config failure
5252func (oo *OmciCC) NotifyAboutOnuConfigFailure(ctx context.Context, errID string, meClassID me.ClassID, meEntityID uint16,
5253 meName string, meResult me.Results) {
5254 var description string
5255 if !oo.confFailMeAlreadyHandled(meClassID) {
5256 switch errID {
5257 case OnuConfigFailureResponseErr:
5258 description = OnuConfigFailureResponseErrDesc + meResult.String() +
5259 ", OMCI ME: " + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) + " (only first instance reported)"
5260 case OnuConfigFailureTimeout:
5261 description = OnuConfigFailureTimeoutDesc + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) +
5262 " (only first instance reported)"
5263 default:
5264 logger.Warnw(ctx, "method called with undefined errID", log.Fields{"errID": errID, "device-id": oo.deviceID})
5265 return
5266 }
5267 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, errID, description)
5268 oo.appendConfFailMe(meClassID)
5269 }
5270}
5271
5272func (oo *OmciCC) confFailMeAlreadyHandled(meClassID me.ClassID) bool {
5273 oo.mutexConfFailMEs.RLock()
5274 defer oo.mutexConfFailMEs.RUnlock()
5275 for _, v := range oo.confFailMEs {
5276 if v == meClassID {
5277 return true
5278 }
5279 }
5280 return false
5281}
5282
5283func (oo *OmciCC) appendConfFailMe(meClassID me.ClassID) {
5284 oo.mutexConfFailMEs.Lock()
5285 defer oo.mutexConfFailMEs.Unlock()
5286 oo.confFailMEs = append(oo.confFailMEs, meClassID)
5287}
5288
5289// ResetConfFailMEs - reset list of stored config failure MEs
5290func (oo *OmciCC) ResetConfFailMEs() {
5291 oo.mutexConfFailMEs.Lock()
5292 defer oo.mutexConfFailMEs.Unlock()
5293 oo.confFailMEs = nil
5294}