blob: 0f3c3e7895dc99302b168b76663e8e688a1bf640 [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
Joey Armstrong89c812c2024-01-12 19:00:20 -05002 * Copyright 2020-2024 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
nikesh.krishnan1ffb8132023-05-23 03:44:13 +053017// Package common provides global definitions
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000018package 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
nikesh.krishnan1ffb8132023-05-23 03:44:13 +053078// CallbackPairEntry to be used for OMCI send/receive correlation
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000079type 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
nikesh.krishnan1ffb8132023-05-23 03:44:13 +053085// CallbackPair to be used for ReceiveCallback init
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000086type 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
Joey Armstrong89c812c2024-01-12 19:00:20 -0500110// OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000111type 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
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530158// NewOmciCC constructor returns a new instance of a OmciCC
159// 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
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530189// Stop stops/resets the omciCC
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000190func (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
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530300//
301// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
302//
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000303// nolint: gocyclo
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000304func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000305 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000306
307 if len(rxMsg) < 10 {
308 logger.Errorw(ctx, "rxOmciMessage has wrong length in general - abort",
309 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
310 if len(rxMsg) > 0 {
311 oo.printRxMessage(ctx, rxMsg)
mpagenkoc8bba412021-01-15 15:38:44 +0000312 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000313 return fmt.Errorf("rxOmciMessage has wrong length in general - abort %s", oo.deviceID)
314 }
315 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
316 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
317 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
318 // (an extendedFormat message could be destroyed this way!)
319 trailerLenData := rxMsg[42:44]
320 trailerLen := binary.BigEndian.Uint16(trailerLenData)
321 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
322 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
323 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
324 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
325 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
326 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
327 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
328 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
329 }
330 }
331 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
332 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
333 // (an extendedFormat message could be destroyed this way!)
334 // extend/overwrite with trailer
335 trailer := make([]byte, 8)
336 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
337 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
338 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
339 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
340 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
341 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
342 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
343 }
344 } else {
345 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
346 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
347 oo.printRxMessage(ctx, rxMsg)
348 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
349 }
350 } else if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.ExtendedIdent) {
351 if len(rxMsg) > 1980 {
352 logger.Errorw(ctx, "rxOmciMessage has wrong length for OmciExtendedFormat - abort",
353 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
354 oo.printRxMessage(ctx, rxMsg)
355 return fmt.Errorf("rxOmciMessage has wrong length for OmciExtendedFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000356 }
357 } else {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000358 logger.Errorw(ctx, "rxOmciMessage has wrong Device Identifier - abort",
mpagenkoc8bba412021-01-15 15:38:44 +0000359 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000360 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000361 return fmt.Errorf("rxOmciMessage has wrong Device Identifier %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000362 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000363 decodeOptions := gopacket.DecodeOptions{
364 Lazy: true,
365 NoCopy: true,
366 }
367 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000368 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000369 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000370 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200371 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000372 }
373 omciLayer := packet.Layer(omci.LayerTypeOMCI)
374 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000375 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000376 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200377 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000378 }
mpagenko836a1fd2021-11-01 16:12:42 +0000379 // insert some check on detected OMCI decoding issues and log them
380 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
381 // even though allowed from omci-lib due to set relaxed decoding
382 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
383 // (compare mib_sync.go unknownAttrLayer)
384 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
385 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
386 errMsg := failure.Error()
387 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
388 "device-id": oo.deviceID, "issue": errMsg})
389 }
390 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000391 omciMsg, ok := omciLayer.(*omci.OMCI)
392 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000393 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000394 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200395 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000396 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000397 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000398 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
399 "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID})
mpagenko836a1fd2021-11-01 16:12:42 +0000400
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700401 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
402 // We expect to find the TID in the oo.rxSchedulerMap
403 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000404 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000405 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000406 logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000407 if omciMsg.TransactionID == 0 {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000408 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
409 oo.incrementBaseRxNoAkFrames()
410 } else {
411 oo.incrementExtRxNoAkFrames()
412 }
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530413 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000414 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000415 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200416 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000417 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200418 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530419 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000420 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530421 oo.mutexRxSchedMap.Lock()
422 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000423 if ok && rxCallbackEntry.CbFunction != nil {
Holger Hildebrandt68854a82022-09-05 07:00:21 +0000424
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000425 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000426 oo.printRxMessage(ctx, rxMsg)
427 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000428 if rxMsg[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
429 oo.incrementBaseRxAkFrames()
430 } else {
431 oo.incrementExtRxAkFrames()
432 }
Himani Chawla4d908332020-08-31 12:30:20 +0530433 //disadvantage of decoupling: error verification made difficult, but anyway the question is
434 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000435 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000436 isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet)
437 if err != nil {
438 // qualified error logging already done in function above
439 if !rxCallbackEntry.FramePrint {
440 oo.printRxMessage(ctx, rxMsg)
441 }
442 return fmt.Errorf("could not decode further layers %s", oo.deviceID)
443 }
444 if isSuccessfulResponse {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000445 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000446 } else {
447 logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type",
448 log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID})
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000449 }
mpagenkoc8bba412021-01-15 15:38:44 +0000450
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700451 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
452 // so do not clean up the TransactionID in that case.
453 if omciMsg.MessageType != omci.TestResponseType {
454 // having posted the response the request is regarded as 'done'
455 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
456 }
Himani Chawla4d908332020-08-31 12:30:20 +0530457 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000458 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000459 }
mpagenko80622a52021-02-09 16:53:23 +0000460 oo.mutexRxSchedMap.Unlock()
461 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
462 oo.printRxMessage(ctx, rxMsg)
463 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000464
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000465 /* py code was:
466 Receive and OMCI message from the proxy channel to the OLT.
467
468 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
469 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
470 """
471 if not self.enabled:
472 return
473
474 try:
475 now = arrow.utcnow()
476 d = None
477
478 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
479 # save the current value of the entity_id_to_class_map, then
480 # replace it with our custom one before decode, and then finally
481 # restore it later. Tried other ways but really made the code messy.
482 saved_me_map = omci_entities.entity_id_to_class_map
483 omci_entities.entity_id_to_class_map = self._me_map
484
485 try:
486 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000487 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000488 except KeyError as e:
489 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000490 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000491 rx_frame = self._decode_unknown_me(msg)
492 self._rx_unknown_me += 1
493
494 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000495 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000496 return
497
498 finally:
499 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
500
501 rx_tid = rx_frame.fields['transaction_id']
502 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000503 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000504 # Filter the Test Result frame and route through receive onu
505 # message method.
506 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000507 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000508 return self._receive_onu_message(rx_frame)
509
510 # Previously unreachable if this is the very first round-trip Rx or we
511 # have been running consecutive errors
512 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000513 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000514 self.reactor.callLater(0, self._publish_connectivity_event, True)
515
516 self._rx_frames += 1
517 self._consecutive_errors = 0
518
519 try:
520 high_priority = self._tid_is_high_priority(rx_tid)
521 index = self._get_priority_index(high_priority)
522
523 # (timestamp, defer, frame, timeout, retry, delayedCall)
524 last_tx_tuple = self._tx_request[index]
525
526 if last_tx_tuple is None or \
527 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
528 # Possible late Rx on a message that timed-out
529 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000530 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000531 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
532 self._rx_unknown_tid += 1
533 self._rx_late += 1
534 return
535
536 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
537 if dc is not None and not dc.cancelled and not dc.called:
538 dc.cancel()
539
540 _secs = self._update_rx_tx_stats(now, ts)
541
542 # Late arrival already serviced by a timeout?
543 if d.called:
544 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000545 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000546 return
547
548 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000549 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000550 if d is not None:
551 return d.errback(failure.Failure(e))
552 return
553
554 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000555 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000556 tx_tid = tx_frame.fields['transaction_id'])
557 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
558
559 # begin success callback chain (will cancel timeout and queue next Tx message)
560 self._rx_response[index] = rx_frame
561 d.callback(rx_frame)
562
563 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000564 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000565 */
566}
567
Himani Chawla6d2ae152020-09-02 13:11:20 +0530568/*
569func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530570 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530571 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000572}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530573*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000574
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700575// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000576func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700577 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
578 delete(oo.rxSchedulerMap, tid)
579}
580
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000581// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
582func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
583 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000584
mpagenkoc26d4c02021-05-06 14:27:57 +0000585 if timeout != 0 {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000586 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TransCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000587 oo.mutexRxSchedMap.Lock()
588 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000589 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000590 oo.mutexRxSchedMap.Unlock()
591 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000592
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000593 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000594 //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 +0000595 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000596 txFrame,
597 timeout,
598 retry,
599 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000600 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000601 receiveCallbackPair,
602 nil,
kesavand011d5162021-11-25 19:21:06 +0530603 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000605 oo.mutexMonReq.Lock()
606 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000607 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000608 // do not call processRequestMonitoring in background here to ensure correct sequencing
609 // of requested messages into txQueue (especially for non-response-supervised messages)
610 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000611 return nil
612 }
613 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000614 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000615 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000616}
617
Holger Hildebrandt34555512021-10-01 16:26:59 +0000618func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
619 // Avoid accessing the txQueues from parallel send routines to block
620 // parallel omci send requests at least until SendIAP is 'committed'.
621 // To guarantee window size 1 for one ONU it would be necessary to wait
622 // for the corresponding response too (t.b.d.).
623 oo.mutexSendQueuedRequests.Lock()
624 defer oo.mutexSendQueuedRequests.Unlock()
625 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
626 logger.Errorw(ctx, "Error during sending high prio requests!",
627 log.Fields{"err": err, "device-id": oo.deviceID})
628 return
629 }
630 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
631 logger.Errorw(ctx, "Error during sending low prio requests!",
632 log.Fields{"err": err, "device-id": oo.deviceID})
633 return
634 }
635}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000636
Holger Hildebrandt34555512021-10-01 16:26:59 +0000637func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
638 oo.mutexHighPrioTxQueue.Lock()
639 defer oo.mutexHighPrioTxQueue.Unlock()
640 for oo.highPrioTxQueue.Len() > 0 {
641 queueElement := oo.highPrioTxQueue.Front() // First element
642 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000643 // Element will be removed from the queue regardless of the send success, to prevent
644 // an accumulation of send requests for the same message in the event of an error.
645 // In this case, resend attempts for the message are ensured by our retry
646 // mechanism after omci-timeout.
647 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
Holger Hildebrandt34555512021-10-01 16:26:59 +0000648 return err
mpagenko80622a52021-02-09 16:53:23 +0000649 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000650 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
651 }
652 return nil
653}
654
655func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
656 oo.mutexLowPrioTxQueue.Lock()
657 for oo.lowPrioTxQueue.Len() > 0 {
658 queueElement := oo.lowPrioTxQueue.Front() // First element
kesavand011d5162021-11-25 19:21:06 +0530659 // check if the element is for onu sw section
660 aOmciTxReq := queueElement.Value.(OmciTransferStructure)
661 if aOmciTxReq.OnuSwWindow != nil {
662 if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000663 // Element will be removed from the queue regardless of the send success, to prevent
664 // an accumulation of send requests for the same message in the event of an error.
665 // In this case, resend attempts for the message are ensured by our retry
666 // mechanism after omci-timeout.
667 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530668 oo.mutexLowPrioTxQueue.Unlock()
669 return err
670 }
671 } else {
672 err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure))
673 if err != nil {
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000674 // Element will be removed from the queue regardless of the send success, to prevent
675 // an accumulation of send requests for the same message in the event of an error.
676 // In this case, resend attempts for the message are ensured by our retry
677 // mechanism after omci-timeout.
678 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
kesavand011d5162021-11-25 19:21:06 +0530679 oo.mutexLowPrioTxQueue.Unlock()
680 return err
681 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200682 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000683 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
684 // Interrupt the sending of low priority requests to process any high priority requests
685 // that may have arrived in the meantime
686 oo.mutexLowPrioTxQueue.Unlock()
687 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
688 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000689 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000690 oo.mutexLowPrioTxQueue.Lock()
691 }
692
693 oo.mutexLowPrioTxQueue.Unlock()
694 return nil
695}
696
697func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
698 if omciTxRequest.withFramePrint {
699 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
700 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
701 "device-id": oo.deviceID,
702 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
703 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
704 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
705 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400706 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000707 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
708 ChildDeviceId: oo.deviceID,
709 Message: omciTxRequest.txFrame,
710 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
711 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
712 }
713 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
714 if sendErr != nil {
Holger Hildebrandtabfef032022-02-25 12:40:20 +0000715 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 +0000716 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +0000718 if omciTxRequest.txFrame[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
719 oo.incrementBaseTxArFrames()
720 } else {
721 oo.incrementExtTxArFrames()
722 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000723 return nil
724}
725
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000726// GetNextTid - TODO: add comment
727func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000728 var next uint16
729 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000730 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000731 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530732 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000733 if oo.hpTid < 0x8000 {
734 oo.hpTid = 0x8000
735 }
mpagenko900ee4b2020-10-12 11:56:34 +0000736 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000737 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000738 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000739 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530740 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000741 if oo.tid >= 0x8000 {
742 oo.tid = 1
743 }
mpagenko900ee4b2020-10-12 11:56:34 +0000744 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000745 }
746 return next
747}
748
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530749// GetOnuSwSecNextTid get the next low prio tid for the onu sw sections
750// onu sw sections uses only low priority tids
751// The mutexTid lock should be taken prior to using this function
kesavand011d5162021-11-25 19:21:06 +0530752func (oo *OmciCC) GetOnuSwSecNextTid() uint16 {
753 next := oo.tid
754 oo.tid++
755 if oo.tid >= 0x8000 {
756 oo.tid = 1
757 }
758 return next
759}
760
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530761// GetOnuSwSecLastTid gets the last allocated tid
762// The mutexTid lock should be taken prior to using this function
kesavand011d5162021-11-25 19:21:06 +0530763func (oo *OmciCC) GetOnuSwSecLastTid() uint16 {
764 next := oo.tid
765 lastAllocatedTid := next - 1
766 return lastAllocatedTid
767}
768
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530769// LockMutexTID locks mutexTid
kesavand011d5162021-11-25 19:21:06 +0530770func (oo *OmciCC) LockMutexTID() {
771 oo.mutexTid.Lock()
772}
773
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530774// UnLockMutexTID unlocks mutexTid
kesavand011d5162021-11-25 19:21:06 +0530775func (oo *OmciCC) UnLockMutexTID() {
776 oo.mutexTid.Unlock()
777}
778
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000779// ###################################################################################
780// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000781
782// Serialize - TODO: add comment
783func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000784 omciLayer := &omci.OMCI{
785 TransactionID: tid,
786 MessageType: msgType,
787 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000788 return SerializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000789}
790
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +0000791// SerializeOmciLayer - TODO: add comment
792func SerializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000793 var options gopacket.SerializeOptions
794 options.FixLengths = true
795
796 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530797 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000798 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000799 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000800 return nil, err
801 }
802 return buffer.Bytes(), nil
803}
804
Himani Chawla4d908332020-08-31 12:30:20 +0530805/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000806func hexEncode(omciPkt []byte) ([]byte, error) {
807 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
808 hex.Encode(dst, omciPkt)
809 return dst, nil
810}
Himani Chawla4d908332020-08-31 12:30:20 +0530811*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000812
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530813// supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000814func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000815
dbainbri4d3a0dc2020-12-02 00:33:42 +0000816 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000817 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000818
819 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000820 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000821 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200822 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000823 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000824 oo.mutexMonReq.RLock()
825 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000826 //implement non-blocking channel send to avoid blocking on mutexMonReq later
827 select {
828 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
829 default:
830 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
831 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
832 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000833 } else {
834 logger.Infow(ctx, "reqMon: map entry does not exist!",
835 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
836 }
837 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000838
839 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
840 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000841 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000842 Type: OMCI,
843 Data: OmciMessage{
844 OmciMsg: omciMsg,
845 OmciPacket: packet,
846 },
847 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000848 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000849 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000850
851 return nil
852}
853
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000854// SendMibReset sends MibResetRequest
855func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000856
nikesh.krishnan1ffb8132023-05-23 03:44:13 +0530857 logger.Infow(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000858 request := &omci.MibResetRequest{
859 MeBasePacket: omci.MeBasePacket{
860 EntityClass: me.OnuDataClassID,
861 },
862 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000863 tid := oo.GetNextTid(highPrio)
864 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000865 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000866 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000867 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000868 return err
869 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000870 omciRxCallbackPair := CallbackPair{
871 CbKey: tid,
872 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000873 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000874 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000875}
876
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000877// SendReboot sends RebootRequest
878func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
879 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300880 request := &omci.RebootRequest{
881 MeBasePacket: omci.MeBasePacket{
882 EntityClass: me.OnuGClassID,
883 },
884 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000885 tid := oo.GetNextTid(highPrio)
886 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300887 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000888 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000889 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300890 return err
891 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000892 omciRxCallbackPair := CallbackPair{
893 CbKey: tid,
894 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300895 }
896
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000897 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300898 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000899 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000900 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300901 return err
902 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000903 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300904 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000905 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200906 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300907 return err
908 }
909 return nil
910}
911
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000912// SendMibUpload sends MibUploadRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000913func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000914 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000915
916 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000917
918 omciLayer := &omci.OMCI{
919 TransactionID: tid,
920 MessageType: omci.MibUploadRequestType,
921 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000922 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000923 omciLayer.DeviceIdentifier = omci.ExtendedIdent
924 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000925 request := &omci.MibUploadRequest{
926 MeBasePacket: omci.MeBasePacket{
927 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000928 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000929 },
930 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000931 var options gopacket.SerializeOptions
932 options.FixLengths = true
933
934 buffer := gopacket.NewSerializeBuffer()
935 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000936 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000937 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000938 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000939 return err
940 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000941 oo.UploadSequNo = 0
942 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000943
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000944 omciRxCallbackPair := CallbackPair{
945 CbKey: tid,
946 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000947 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000948 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000949}
950
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000951// SendMibUploadNext sends MibUploadNextRequest
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000952func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool, isExtOmciSupported bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000953 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000954
955 tid := oo.GetNextTid(highPrio)
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000956
957 omciLayer := &omci.OMCI{
958 TransactionID: tid,
959 MessageType: omci.MibUploadNextRequestType,
960 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000961 if isExtOmciSupported {
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000962 omciLayer.DeviceIdentifier = omci.ExtendedIdent
963 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000964 request := &omci.MibUploadNextRequest{
965 MeBasePacket: omci.MeBasePacket{
966 EntityClass: me.OnuDataClassID,
Holger Hildebrandt5458d892022-05-31 09:52:06 +0000967 Extended: isExtOmciSupported,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000968 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000969 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000970 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000971 var options gopacket.SerializeOptions
972 options.FixLengths = true
973
974 buffer := gopacket.NewSerializeBuffer()
975 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000976 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000977 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000978 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000979 return err
980 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000981 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000982
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000983 omciRxCallbackPair := CallbackPair{
984 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000985 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
986 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
987 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000988 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000989 }
Holger Hildebrandt0edf5b02022-05-04 14:19:43 +0000990 return oo.Send(ctx, buffer.Bytes(), timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000991}
992
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000993// SendGetAllAlarm gets all alarm ME instances
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000994func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool, isExtendedOmci bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530995 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +0000996
997 tid := oo.GetNextTid(highPrio)
998 omciLayer := &omci.OMCI{
999 TransactionID: tid,
1000 MessageType: omci.GetAllAlarmsRequestType,
1001 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
1002 }
1003 if isExtendedOmci {
1004 omciLayer.DeviceIdentifier = omci.ExtendedIdent
1005 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301006 request := &omci.GetAllAlarmsRequest{
1007 MeBasePacket: omci.MeBasePacket{
1008 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001009 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301010 },
1011 AlarmRetrievalMode: byte(alarmRetreivalMode),
1012 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001013 var options gopacket.SerializeOptions
1014 options.FixLengths = true
1015 buffer := gopacket.NewSerializeBuffer()
1016 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301017 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001018 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{"Err": err,
1019 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301020 return err
1021 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001022 outgoingPacket := buffer.Bytes()
1023
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001024 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +05301025
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001026 omciRxCallbackPair := CallbackPair{
1027 CbKey: tid,
1028 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301029 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001030 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1031 if err != nil {
1032 logger.Errorw(ctx, "Cannot send GetAllAlarmsRequest", log.Fields{"Err": err,
1033 "device-id": oo.deviceID})
1034 return err
1035 }
1036 logger.Debug(ctx, "send GetAllAlarmsRequest done")
1037 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301038}
1039
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001040// SendGetAllAlarmNext gets next alarm ME instance
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001041func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool, isExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001042 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
1043 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +05301044 "alarmUploadSeqNo": alarmUploadSeqNo})
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001045
1046 tid := oo.GetNextTid(highPrio)
1047 omciLayer := &omci.OMCI{
1048 TransactionID: tid,
1049 MessageType: omci.GetAllAlarmsNextRequestType,
1050 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
1051 }
1052 if isExtendedOmci {
1053 omciLayer.DeviceIdentifier = omci.ExtendedIdent
1054 }
Himani Chawlad3dac422021-03-13 02:31:31 +05301055 request := &omci.GetAllAlarmsNextRequest{
1056 MeBasePacket: omci.MeBasePacket{
1057 EntityClass: me.OnuDataClassID,
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001058 Extended: isExtendedOmci,
Himani Chawlad3dac422021-03-13 02:31:31 +05301059 },
1060 CommandSequenceNumber: alarmUploadSeqNo,
1061 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001062 var options gopacket.SerializeOptions
1063 options.FixLengths = true
1064 buffer := gopacket.NewSerializeBuffer()
1065 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
Himani Chawlad3dac422021-03-13 02:31:31 +05301066 if err != nil {
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001067 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{"Err": err,
1068 "device-id": oo.deviceID})
Himani Chawlad3dac422021-03-13 02:31:31 +05301069 return err
1070 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001071 outgoingPacket := buffer.Bytes()
1072
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001073 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +05301074
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001075 omciRxCallbackPair := CallbackPair{
1076 CbKey: tid,
1077 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +05301078 }
Holger Hildebrandt3b29a8a2022-07-11 05:55:13 +00001079 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
1080 if err != nil {
1081 logger.Errorw(ctx, "Cannot send GetAllAlarmsNextRequest", log.Fields{"Err": err,
1082 "device-id": oo.deviceID})
1083 return err
1084 }
1085 logger.Debug(ctx, "send GetAllAlarmsNextRequest done")
1086 return nil
Himani Chawlad3dac422021-03-13 02:31:31 +05301087}
1088
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001089// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
1090func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1091 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001092 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001093 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001094
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001095 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001096 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001097 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001098 }
1099 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
1100 if omciErr.GetError() == nil {
1101 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001102 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001103 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001104 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001105 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001106 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001107 }
1108
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001109 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001110 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001111 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001112 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001113 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001114 }
1115
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001116 omciRxCallbackPair := CallbackPair{
1117 CbKey: tid,
1118 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001119 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001120 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001121 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001122 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001123 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001124 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001125 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001126 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001127 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001128 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001129 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001130 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001131 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001132}
1133
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001134// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001135// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001136func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1137 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001138 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001139 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001140
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001141 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
1142 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001143 // By now we just use fix values to fire - this is anyway what the python adapter does
1144 // read ONU-2G from DB ???? //TODO!!!
1145 meParams := me.ParamData{
1146 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001147 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001148 }
1149 meInstance, omciErr := me.NewOnu2G(meParams)
1150 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001151 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001152 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001153 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001154 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001155 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001156 }
1157
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001158 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001159 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001160 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001161 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001162 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001163 }
1164
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001165 omciRxCallbackPair := CallbackPair{
1166 CbKey: tid,
1167 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001168 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001169 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001170 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001171 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001172 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001173 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001174 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001175 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001176 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001177 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001178 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001179 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001180 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001181}
1182
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001183// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1184func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1185 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1186 tid := oo.GetNextTid(highPrio)
1187 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001188 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001189 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001190
1191 meParams := me.ParamData{
1192 EntityID: instID,
1193 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001194 me.MacBridgeServiceProfile_Priority: 0x8000,
1195 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1196 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1197 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1198 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001199 },
1200 }
1201
1202 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1203 if omciErr.GetError() == nil {
1204 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001205 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1206 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001207 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001208 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001209 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001210 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001211 }
1212
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001213 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001214 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001215 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001216 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001217 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001218 }
1219
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001220 omciRxCallbackPair := CallbackPair{
1221 CbKey: tid,
1222 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001223 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001224 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001225 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001226 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001227 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001228 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001229 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001230 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001231 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001232 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001233 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001234 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001235 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001236}
1237
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001238// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1239func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1240 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1241 tid := oo.GetNextTid(highPrio)
1242 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001243 if idErr != nil {
1244 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1245 "Err": idErr, "device-id": oo.deviceID})
1246 return nil, idErr
1247 }
1248 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001249 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001250
1251 meParams := me.ParamData{
1252 EntityID: instID,
1253 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001254 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1255 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1256 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1257 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001258 },
1259 }
1260 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1261 if omciErr.GetError() == nil {
1262 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001263 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1264 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001265 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001267 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001268 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001269 }
1270
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001271 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001272 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001273 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001274 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001275 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001276 }
1277
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001278 omciRxCallbackPair := CallbackPair{
1279 CbKey: tid,
1280 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001281 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001282 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001283 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001284 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001285 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001286 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001287 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001288 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001289 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001290 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001291 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001292 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001293 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001294}
1295
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001296// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1297func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1298 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1299 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001300 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001301 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001302 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001303 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001304
1305 // compare python adapter code WA VOL-1311: this is not done here!
1306 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1307 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1308 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001309 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001310 assType = uint8(10) // for VEIP
1311 }
1312 meParams := me.ParamData{
1313 EntityID: instID,
1314 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001315 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1316 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001317 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001318 },
1319 }
1320 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1321 if omciErr.GetError() == nil {
1322 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001323 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1324 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001325 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001326 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001327 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001328 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001329 }
1330
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001331 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001332 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001333 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001334 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001335 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001336 }
1337
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001338 omciRxCallbackPair := CallbackPair{
1339 CbKey: tid,
1340 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001341 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001342 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001343 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001344 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001345 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001346 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001347 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001348 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001349 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001350 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001351 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001352 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001353 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001354}
1355
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001356// SendSetOnuGLS sets OnuG ME instance
1357func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001358 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001359 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001360 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001361 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001362
1363 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1364 meParams := me.ParamData{
1365 EntityID: 0,
1366 Attributes: requestedAttributes,
1367 }
1368 meInstance, omciErr := me.NewOnuG(meParams)
1369 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001370 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001371 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001372 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001373 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001374 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001375 }
1376
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001377 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001378 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001379 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001380 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001381 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001382 }
1383
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001384 omciRxCallbackPair := CallbackPair{
1385 CbKey: tid,
1386 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001387 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001388 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001389 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001390 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001391 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001392 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001394 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001395 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001396 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001397 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001398 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001399 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001400}
1401
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001402// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1403func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001404 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001405 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001406 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001407 "SequNo": strconv.FormatInt(int64(tid), 16)})
1408
1409 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1410 meParams := me.ParamData{
1411 EntityID: aInstNo,
1412 Attributes: requestedAttributes,
1413 }
1414 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1415 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001416 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001417 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001418 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001419 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001420 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001421 }
1422
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001423 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001424 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001425 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001426 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001427 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001428 }
1429
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001430 omciRxCallbackPair := CallbackPair{
1431 CbKey: tid,
1432 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001433 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001434 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001435 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001436 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001437 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001438 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001439 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001440 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001441 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001442 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001443 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001444 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001445 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001446}
1447
1448/* UniG obsolete by now, left here in case it should be needed once again
1449 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301450func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001451 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001452 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001453 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001454 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001455
1456 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1457 meParams := me.ParamData{
1458 EntityID: aInstNo,
1459 Attributes: requestedAttributes,
1460 }
1461 meInstance, omciErr := me.NewUniG(meParams)
1462 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001463 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001464 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001465 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001466 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001467 return nil
1468 }
1469
1470 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1471 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001472 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001473 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001474 return nil
1475 }
1476
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001477 omciRxCallbackPair := CallbackPair{
1478 CbKey: tid,
1479 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001480 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001481 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001482 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001483 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001484 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001485 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001486 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001487 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001488 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001489 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001490 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001491 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001492 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001493}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001494*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001495
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001496// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1497func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001498 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001499 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001500 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001502
1503 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1504 meParams := me.ParamData{
1505 EntityID: aInstNo,
1506 Attributes: requestedAttributes,
1507 }
1508 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1509 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001510 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001511 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001512 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001513 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001514 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001515 }
1516
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001517 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001518 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001519 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001520 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001521 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001522 }
1523
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001524 omciRxCallbackPair := CallbackPair{
1525 CbKey: tid,
1526 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001527 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001528 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001529 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001530 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001531 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001532 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001533 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001534 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001535 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001536 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001537 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001538 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001539 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001540}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001541
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001542// SendGetMe gets ME instance
1543func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001544 timeout int, highPrio bool, rxChan chan Message, isExtendedOmci bool) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001545
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001546 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001547 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001548 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001549
1550 meParams := me.ParamData{
1551 EntityID: entityID,
1552 Attributes: requestedAttributes,
1553 }
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001554 var messageSet omci.DeviceIdent = omci.BaselineIdent
1555 if isExtendedOmci {
1556 messageSet = omci.ExtendedIdent
1557 }
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001558 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1559 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301560 meClassIDName := meInstance.GetName()
Holger Hildebrandtd930cb22022-06-17 09:24:50 +00001561 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid), oframe.FrameFormat(messageSet))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001562 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001563 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 +03001564 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001565 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001566 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001567 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001568 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001569 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001570 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001571 omciRxCallbackPair := CallbackPair{
1572 CbKey: tid,
1573 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001574 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001575 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001576 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001577 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001578 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001579 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001580 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001581 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001582 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001583 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001584 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001585}
1586
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001587// SendGetMeWithAttributeMask gets ME instance with attribute mask
1588func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301589 timeout int, highPrio bool, rxChan chan Message) error {
1590
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001591 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301592 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1593 "SequNo": strconv.FormatInt(int64(tid), 16)})
1594
1595 request := &omci.GetRequest{
1596 MeBasePacket: omci.MeBasePacket{
1597 EntityInstance: entityID,
1598 EntityClass: classID,
1599 },
1600 AttributeMask: requestedAttributesMask,
1601 }
1602
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001603 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301604 if err != nil {
1605 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1606 return err
1607 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001608 omciRxCallbackPair := CallbackPair{
1609 CbKey: tid,
1610 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301611 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001612 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301613 if err != nil {
1614 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1615 return err
1616 }
1617 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1618 return nil
1619}
1620
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001621// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1622func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001623 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001624 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001625 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001626 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1627
1628 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001629 EntityID: aInstID,
1630 Attributes: me.AttributeValueMap{
1631 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001632 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1633 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1634 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1635 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1636 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1637 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1638 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1639 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1640 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001641 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001642 }
1643 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1644 if omciErr.GetError() == nil {
1645 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001646 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1647 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001648 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001649 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001650 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001651 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001652 }
1653
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001654 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001655 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001656 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001657 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001658 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001659 }
1660
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001661 omciRxCallbackPair := CallbackPair{
1662 CbKey: tid,
1663 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001664 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001665 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001666 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001667 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001668 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001669 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001670 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001671 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001672 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001673 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001674 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001675 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001676 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001677}
1678
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001679// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1680func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001681 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001682 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001683 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001684 "SequNo": strconv.FormatInt(int64(tid), 16),
1685 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1686
1687 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1688 if omciErr.GetError() == nil {
1689 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001690 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1691 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001692 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001693 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001694 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001695 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001696 }
1697
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001698 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001699 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001700 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001701 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001702 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001703 }
1704
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001705 omciRxCallbackPair := CallbackPair{
1706 CbKey: tid,
1707 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001708 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001709 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001710 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001711 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001712 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001713 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001714 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001715 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001716 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001717 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001718 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001719 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001720 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001721}
1722
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001723// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1724func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001725 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001726 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001727 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001728 "SequNo": strconv.FormatInt(int64(tid), 16),
1729 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1730
1731 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1732 if omciErr.GetError() == nil {
1733 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001734 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1735 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001736 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001737 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001738 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001739 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001740 }
1741
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001742 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001743 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001744 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001745 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001746 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001747 }
1748
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001749 omciRxCallbackPair := CallbackPair{
1750 CbKey: tid,
1751 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001752 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001753 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001756 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001757 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001758 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001759 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001760 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001761 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001762 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001763 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001764 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001765}
1766
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001767// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1768func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1769 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001770 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1771 "SequNo": strconv.FormatInt(int64(tid), 16),
1772 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1773
1774 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1775 if omciErr.GetError() == nil {
1776 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001777 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1778 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001779 if err != nil {
1780 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1781 "Err": err, "device-id": oo.deviceID})
1782 return nil, err
1783 }
1784
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001785 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001786 if err != nil {
1787 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1788 "Err": err, "device-id": oo.deviceID})
1789 return nil, err
1790 }
1791
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001792 omciRxCallbackPair := CallbackPair{
1793 CbKey: tid,
1794 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001795 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001796 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001797 if err != nil {
1798 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1799 "Err": err, "device-id": oo.deviceID})
1800 return nil, err
1801 }
1802 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1803 return meInstance, nil
1804 }
1805 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1806 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1807 return nil, omciErr.GetError()
1808}
1809
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001810// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1811func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001812 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001813 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001815 "SequNo": strconv.FormatInt(int64(tid), 16),
1816 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1817
1818 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1819 if omciErr.GetError() == nil {
1820 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001821 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1822 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001823 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001824 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001825 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001826 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001827 }
1828
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001829 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001830 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001831 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001832 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001833 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001834 }
1835
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001836 omciRxCallbackPair := CallbackPair{
1837 CbKey: tid,
1838 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001839 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001840 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001841 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001842 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001843 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001844 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001845 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001846 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001847 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001848 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001849 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001850 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001851 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001852}
1853
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001854// SendSetTcontVar sets TCont ME instance
1855func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001856 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001857 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001858 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001859 "SequNo": strconv.FormatInt(int64(tid), 16),
1860 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1861
1862 meInstance, omciErr := me.NewTCont(params[0])
1863 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001864 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001865 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001866 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001867 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001868 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001869 }
1870
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001871 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001872 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001873 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001874 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001875 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001876 }
1877
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001878 omciRxCallbackPair := CallbackPair{
1879 CbKey: tid,
1880 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001881 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001882 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001883 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001884 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001885 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001886 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001887 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001888 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001889 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001890 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001891 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001892 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001893 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001894}
1895
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001896// SendSetPrioQueueVar sets PriorityQueue ME instance
1897func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001898 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001899 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001900 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001901 "SequNo": strconv.FormatInt(int64(tid), 16),
1902 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1903
1904 meInstance, omciErr := me.NewPriorityQueue(params[0])
1905 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001906 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001907 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001908 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001909 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001910 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001911 }
1912
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001913 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001914 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001915 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001916 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001917 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001918 }
1919
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001920 omciRxCallbackPair := CallbackPair{
1921 CbKey: tid,
1922 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001923 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001924 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001925 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001926 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001927 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001928 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001929 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001930 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001931 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001932 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001933 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001934 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001935 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001936}
1937
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001938// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1939func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001940 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001941 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001942 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001943 "SequNo": strconv.FormatInt(int64(tid), 16),
1944 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1945
1946 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1947 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001948 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001949 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001950 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001951 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001952 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001953 }
1954
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00001955 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001956 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001957 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001958 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001959 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001960 }
1961
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001962 omciRxCallbackPair := CallbackPair{
1963 CbKey: tid,
1964 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001965 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001966 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001967 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001968 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001969 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001970 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001971 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001972 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001973 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001974 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001975 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001976 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001977 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001978}
mpagenkodff5dda2020-08-28 11:52:01 +00001979
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001980// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1981func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001982 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001983 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001984 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001985 "SequNo": strconv.FormatInt(int64(tid), 16),
1986 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1987
1988 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1989 if omciErr.GetError() == nil {
1990 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001991 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1992 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001993 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001994 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001995 "Err": err, "device-id": oo.deviceID})
1996 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1997 // return (dual format) error code that can be used at caller for immediate error treatment
1998 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001999 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002000 }
2001
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002002 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002003 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002004 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002005 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002006 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002007 }
2008
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002009 omciRxCallbackPair := CallbackPair{
2010 CbKey: tid,
2011 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002012 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002013 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002014 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002015 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002016 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002017 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002018 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002019 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002020 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002021 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002022 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002023 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002024 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002025}
2026
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002027// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002028func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002029 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002030 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002031 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002032 "SequNo": strconv.FormatInt(int64(tid), 16),
2033 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2034
2035 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
2036 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002037 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
2038 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002039 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002040 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002041 "Err": err, "device-id": oo.deviceID})
2042 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2043 // return (dual format) error code that can be used at caller for immediate error treatment
2044 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002045 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002046 }
2047
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002048 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002049 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002050 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002051 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002052 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002053 }
2054
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002055 omciRxCallbackPair := CallbackPair{
2056 CbKey: tid,
2057 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002058 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002059 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002060 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002061 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002062 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002063 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002064 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002065 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002066 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002067 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002068 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002069 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002070 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00002071}
2072
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002073// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
2074func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002075 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002076 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002077 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002078 "SequNo": strconv.FormatInt(int64(tid), 16),
2079 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2080
2081 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2082 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002083 //EnhancedMode not yet supported, used with default options
2084 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
2085 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002086 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002087 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002088 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002089 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002090 }
2091
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002092 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002093 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002094 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002095 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002096 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002097 }
2098
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002099 omciRxCallbackPair := CallbackPair{
2100 CbKey: tid,
2101 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002102 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002103 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002104 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002105 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002106 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002107 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002108 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002109 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002110 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002111 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002112 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002113 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002114 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002115}
2116
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002117// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
2118func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002119 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002120 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002121 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00002122 "SequNo": strconv.FormatInt(int64(tid), 16),
2123 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2124
2125 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2126 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002127 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00002128 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002129 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002130 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002131 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002132 }
2133
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002134 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00002135 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002136 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002137 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002138 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002139 }
2140
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002141 omciRxCallbackPair := CallbackPair{
2142 CbKey: tid,
2143 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00002144 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002145 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00002146 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002147 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002148 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002149 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002150 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002151 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002152 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002153 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002154 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002155 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002156 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002157}
mpagenko01e726e2020-10-23 09:45:29 +00002158
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002159// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2160func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002161 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002162 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002163 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002164 "SequNo": strconv.FormatInt(int64(tid), 16),
2165 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2166
2167 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2168 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002169 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002170 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002171 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002172 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002173 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002174 }
2175
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002176 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002177 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002178 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002179 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002180 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002181 }
2182
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002183 omciRxCallbackPair := CallbackPair{
2184 CbKey: tid,
2185 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002186 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002187 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002188 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002189 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002190 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002191 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002192 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002193 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002194 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002195 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002196 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002197 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002198 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002199}
2200
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002201// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2202func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002203 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002204 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002205 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002206 "SequNo": strconv.FormatInt(int64(tid), 16),
2207 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2208
2209 meParams := me.ParamData{EntityID: aInstID}
2210 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2211 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002212 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2213 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002214 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002215 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002216 "Err": err, "device-id": oo.deviceID})
2217 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2218 // return (dual format) error code that can be used at caller for immediate error treatment
2219 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002220 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002221 }
2222
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002223 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002224 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002225 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002226 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002227 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002228 }
2229
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002230 omciRxCallbackPair := CallbackPair{
2231 CbKey: tid,
2232 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002233 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002234 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002235 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002236 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002237 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002238 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002239 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002240 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002242 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002243 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002244 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002245 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002246}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002247
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002248// SendCreateTDVar creates TrafficDescriptor ME instance
2249func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2250 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002251 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2252 "SequNo": strconv.FormatInt(int64(tid), 16),
2253 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2254 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2255 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002256 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002257 if err != nil {
2258 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002259 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002260 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002261 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002262 if err != nil {
2263 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002264 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002265 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002266 omciRxCallbackPair := CallbackPair{
2267 CbKey: tid,
2268 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002269 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002270 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002271 if err != nil {
2272 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002273 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002274 }
2275 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002276 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002277 }
2278 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002279 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002280}
2281
2282// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002283func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002284 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002285 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002286 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2287 "SequNo": strconv.FormatInt(int64(tid), 16),
2288 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2289
2290 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2291 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002292 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002293 if err != nil {
2294 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002295 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002296 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002297 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002298 if err != nil {
2299 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002300 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002301 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002302 omciRxCallbackPair := CallbackPair{
2303 CbKey: tid,
2304 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002305 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002306 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002307 if err != nil {
2308 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002309 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002310 }
2311 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002312 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002313 }
2314 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002315 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002316
2317}
2318
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002319// SendDeleteTD - TODO: add comment
2320func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002321 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002322 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002323 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2324 "SequNo": strconv.FormatInt(int64(tid), 16),
2325 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2326
2327 meParams := me.ParamData{EntityID: aInstID}
2328 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2329 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002330 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002331 if err != nil {
2332 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002333 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002334 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002335 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab6441962021-03-10 10:58:48 +03002336 if err != nil {
2337 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002338 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002339 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002340 omciRxCallbackPair := CallbackPair{
2341 CbKey: tid,
2342 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002343 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002344 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002345 if err != nil {
2346 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002347 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002348 }
2349 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002350 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002351 }
2352 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002353 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002354
2355}
2356
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002357// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2358func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002359 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002360 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002361 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002362 "SequNo": strconv.FormatInt(int64(tid), 16),
2363 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2364
2365 meParams := me.ParamData{EntityID: aInstID}
2366 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2367 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002368 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2369 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002370 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002371 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002372 "Err": err, "device-id": oo.deviceID})
2373 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2374 // return (dual format) error code that can be used at caller for immediate error treatment
2375 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002376 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002377 }
2378
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002379 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002380 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002381 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002382 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002383 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002384 }
2385
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002386 omciRxCallbackPair := CallbackPair{
2387 CbKey: tid,
2388 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002389 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002390 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002391 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002392 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002393 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002394 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002395 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002396 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002397 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002398 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002399 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002400 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002401 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002402}
2403
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002404// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2405func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002406 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002407 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002408 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002409 "SequNo": strconv.FormatInt(int64(tid), 16),
2410 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2411
2412 meParams := me.ParamData{EntityID: aInstID}
2413 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2414 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002415 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2416 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002417 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002418 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002419 "Err": err, "device-id": oo.deviceID})
2420 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2421 // return (dual format) error code that can be used at caller for immediate error treatment
2422 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002423 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002424 }
2425
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002426 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002427 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002428 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002429 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002430 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002431 }
2432
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002433 omciRxCallbackPair := CallbackPair{
2434 CbKey: tid,
2435 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002436 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002437 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002438 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002439 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002440 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002441 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002442 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002443 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002444 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002445 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002446 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002447 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002448 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002449}
2450
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002451// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2452func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002453 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002454 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002455 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002456 "SequNo": strconv.FormatInt(int64(tid), 16),
2457 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2458
2459 meParams := me.ParamData{EntityID: aInstID}
2460 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2461 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002462 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2463 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002464 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002465 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002466 "Err": err, "device-id": oo.deviceID})
2467 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2468 // return (dual format) error code that can be used at caller for immediate error treatment
2469 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002470 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002471 }
2472
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002473 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002474 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002475 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002476 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002477 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002478 }
2479
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002480 omciRxCallbackPair := CallbackPair{
2481 CbKey: tid,
2482 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002483 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002484 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002485 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002486 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002487 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002488 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002489 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002490 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002491 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002492 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002493 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002494 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002495 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002496}
2497
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002498// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2499func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002500 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002501 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002502 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002503 "SequNo": strconv.FormatInt(int64(tid), 16),
2504 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2505
2506 meParams := me.ParamData{EntityID: aInstID}
2507 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2508 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002509 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2510 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002511 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002512 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002513 "Err": err, "device-id": oo.deviceID})
2514 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2515 // return (dual format) error code that can be used at caller for immediate error treatment
2516 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002517 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002518 }
2519
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002520 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002521 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002522 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002523 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002524 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002525 }
2526
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002527 omciRxCallbackPair := CallbackPair{
2528 CbKey: tid,
2529 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002530 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002531 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002532 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002533 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002534 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002535 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002536 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002537 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002538 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002539 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002540 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002541 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002542 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002543}
2544
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002545// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2546func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002547 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002548 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002549 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002550 "SequNo": strconv.FormatInt(int64(tid), 16),
2551 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2552
2553 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2554 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002555 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2556 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002557 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002558 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002559 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002560 }
2561
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002562 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002563 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002564 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002565 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002566 }
2567
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002568 omciRxCallbackPair := CallbackPair{CbKey: tid,
2569 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002570 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002571 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002572 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002573 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002574 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002575 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002576 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002577 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002578 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002579 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002580 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002581 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002582}
2583
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002584// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2585func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002586 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002587 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002588 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002589 "SequNo": strconv.FormatInt(int64(tid), 16),
2590 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2591
2592 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2593 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002594 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2595 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002596 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002597 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002598 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002599 }
2600
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002601 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002602 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002603 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002604 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002605 }
2606
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002607 omciRxCallbackPair := CallbackPair{CbKey: tid,
2608 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002609 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002610 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002611 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002612 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002613 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002614 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002615 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002616 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002617 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002618 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002619 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002620 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002621}
2622
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002623// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2624func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002625 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002626 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002627 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002628 "SequNo": strconv.FormatInt(int64(tid), 16),
2629 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2630
2631 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2632 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002633 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2634 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002635 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002636 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002637 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002638 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002639 }
2640
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002641 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002642 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002643 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002644 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002645 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002646 }
2647
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002648 omciRxCallbackPair := CallbackPair{CbKey: tid,
2649 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002650 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002651 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002652 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002653 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002654 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002655 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002656 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002657 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002658 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002659 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002660 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002661 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002662 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002663}
2664
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002665// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2666func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002667 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002668 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002669 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002670 "SequNo": strconv.FormatInt(int64(tid), 16),
2671 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2672
2673 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2674 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002675 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2676 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002677 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002678 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002679 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002680 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002681 }
2682
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002683 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002684 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002685 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002686 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002687 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002688 }
2689
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002690 omciRxCallbackPair := CallbackPair{CbKey: tid,
2691 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002692 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002693 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002694 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002695 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002696 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002697 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002698 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002699 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002700 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002701 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002702 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002703 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002704 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002705}
2706
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002707// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2708func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002709 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002710 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002711 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002712 "SequNo": strconv.FormatInt(int64(tid), 16),
2713 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2714
2715 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2716 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002717 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2718 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002719 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002720 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002721 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002722 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002723 }
2724
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002725 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002726 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002727 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002728 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002729 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002730 }
2731
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002732 omciRxCallbackPair := CallbackPair{CbKey: tid,
2733 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002734 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002735 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002736 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002737 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002738 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002739 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002740 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002741 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002742 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002743 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002744 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002745 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002746 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002747}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002748
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002749// SendCreateVoipVoiceCTP nolint: unused
2750func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2751 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2752 tid := oo.GetNextTid(highPrio)
2753 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2754 "SequNo": strconv.FormatInt(int64(tid), 16),
2755 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2756
2757 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2758 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002759 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2760 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002761 if err != nil {
2762 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2763 "device-id": oo.deviceID})
2764 return nil, err
2765 }
2766
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002767 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002768 if err != nil {
2769 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2770 "device-id": oo.deviceID})
2771 return nil, err
2772 }
2773
2774 omciRxCallbackPair := CallbackPair{CbKey: tid,
2775 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2776 }
2777 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2778 if err != nil {
2779 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2780 "device-id": oo.deviceID})
2781 return nil, err
2782 }
2783 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2784 return meInstance, nil
2785 }
2786 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2787 "device-id": oo.deviceID})
2788 return nil, omciErr.GetError()
2789}
2790
2791// SendSetVoipVoiceCTP nolint: unused
2792func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2793 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2794 tid := oo.GetNextTid(highPrio)
2795 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2796 "SequNo": strconv.FormatInt(int64(tid), 16),
2797 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2798
2799 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2800 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002801 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2802 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002803 if err != nil {
2804 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2805 "device-id": oo.deviceID})
2806 return nil, err
2807 }
2808
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002809 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002810 if err != nil {
2811 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2812 "device-id": oo.deviceID})
2813 return nil, err
2814 }
2815
2816 omciRxCallbackPair := CallbackPair{CbKey: tid,
2817 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2818 }
2819 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2820 if err != nil {
2821 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2822 "device-id": oo.deviceID})
2823 return nil, err
2824 }
2825 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2826 return meInstance, nil
2827 }
2828 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2829 "device-id": oo.deviceID})
2830 return nil, omciErr.GetError()
2831}
2832
2833// SendDeleteVoipVoiceCTP nolint: unused
2834func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2835 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2836 tid := oo.GetNextTid(highPrio)
2837 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2838 "SequNo": strconv.FormatInt(int64(tid), 16),
2839 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2840
2841 meParams := me.ParamData{EntityID: aInstID}
2842 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2843 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002844 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2845 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002846 if err != nil {
2847 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2848 "Err": err, "device-id": oo.deviceID})
2849 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2850 // return (dual format) error code that can be used at caller for immediate error treatment
2851 // (relevant to all used sendXX() methods and their error conditions)
2852 return nil, err
2853 }
2854
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002855 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002856 if err != nil {
2857 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2858 "Err": err, "device-id": oo.deviceID})
2859 return nil, err
2860 }
2861
2862 omciRxCallbackPair := CallbackPair{
2863 CbKey: tid,
2864 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2865 }
2866 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2867 if err != nil {
2868 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2869 "Err": err, "device-id": oo.deviceID})
2870 return nil, err
2871 }
2872 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2873 return meInstance, nil
2874 }
2875 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2876 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2877 return nil, omciErr.GetError()
2878}
2879
2880// SendCreateVoipMediaProfile nolint: unused
2881func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2882 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2883 tid := oo.GetNextTid(highPrio)
2884 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2885 "SequNo": strconv.FormatInt(int64(tid), 16),
2886 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2887
2888 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2889 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002890 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2891 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002892 if err != nil {
2893 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2894 "device-id": oo.deviceID})
2895 return nil, err
2896 }
2897
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002898 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002899 if err != nil {
2900 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2901 "device-id": oo.deviceID})
2902 return nil, err
2903 }
2904
2905 omciRxCallbackPair := CallbackPair{CbKey: tid,
2906 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2907 }
2908 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2909 if err != nil {
2910 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2911 "device-id": oo.deviceID})
2912 return nil, err
2913 }
2914 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2915 return meInstance, nil
2916 }
2917 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2918 "device-id": oo.deviceID})
2919 return nil, omciErr.GetError()
2920}
2921
2922// SendSetVoipMediaProfile nolint: unused
2923func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2924 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2925 tid := oo.GetNextTid(highPrio)
2926 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2927 "SequNo": strconv.FormatInt(int64(tid), 16),
2928 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2929
2930 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2931 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002932 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2933 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002934 if err != nil {
2935 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2936 "device-id": oo.deviceID})
2937 return nil, err
2938 }
2939
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002940 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002941 if err != nil {
2942 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2943 "device-id": oo.deviceID})
2944 return nil, err
2945 }
2946
2947 omciRxCallbackPair := CallbackPair{CbKey: tid,
2948 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2949 }
2950 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2951 if err != nil {
2952 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2953 "device-id": oo.deviceID})
2954 return nil, err
2955 }
2956 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2957 return meInstance, nil
2958 }
2959 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2960 "device-id": oo.deviceID})
2961 return nil, omciErr.GetError()
2962}
2963
2964// SendDeleteVoipMediaProfile nolint: unused
2965func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2966 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2967 tid := oo.GetNextTid(highPrio)
2968 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2969 "SequNo": strconv.FormatInt(int64(tid), 16),
2970 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2971
2972 meParams := me.ParamData{EntityID: aInstID}
2973 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2974 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002975 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2976 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002977 if err != nil {
2978 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2979 "Err": err, "device-id": oo.deviceID})
2980 return nil, err
2981 }
2982
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00002983 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002984 if err != nil {
2985 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2986 "Err": err, "device-id": oo.deviceID})
2987 return nil, err
2988 }
2989
2990 omciRxCallbackPair := CallbackPair{
2991 CbKey: tid,
2992 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2993 }
2994 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2995 if err != nil {
2996 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2997 "Err": err, "device-id": oo.deviceID})
2998 return nil, err
2999 }
3000 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
3001 return meInstance, nil
3002 }
3003 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
3004 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3005 return nil, omciErr.GetError()
3006}
3007
3008// SendCreateVoiceServiceProfile nolint: unused
3009func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3010 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3011 tid := oo.GetNextTid(highPrio)
3012 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3013 "SequNo": strconv.FormatInt(int64(tid), 16),
3014 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3015
3016 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3017 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003018 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3019 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003020 if err != nil {
3021 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
3022 "device-id": oo.deviceID})
3023 return nil, err
3024 }
3025
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003026 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003027 if err != nil {
3028 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
3029 "device-id": oo.deviceID})
3030 return nil, err
3031 }
3032
3033 omciRxCallbackPair := CallbackPair{CbKey: tid,
3034 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3035 }
3036 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3037 if err != nil {
3038 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
3039 "device-id": oo.deviceID})
3040 return nil, err
3041 }
3042 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
3043 return meInstance, nil
3044 }
3045 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3046 "device-id": oo.deviceID})
3047 return nil, omciErr.GetError()
3048}
3049
3050// SendSetVoiceServiceProfile nolint: unused
3051func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3052 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3053 tid := oo.GetNextTid(highPrio)
3054 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3055 "SequNo": strconv.FormatInt(int64(tid), 16),
3056 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3057
3058 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
3059 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003060 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3061 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003062 if err != nil {
3063 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
3064 "device-id": oo.deviceID})
3065 return nil, err
3066 }
3067
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003068 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003069 if err != nil {
3070 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
3071 "device-id": oo.deviceID})
3072 return nil, err
3073 }
3074
3075 omciRxCallbackPair := CallbackPair{CbKey: tid,
3076 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3077 }
3078 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3079 if err != nil {
3080 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
3081 "device-id": oo.deviceID})
3082 return nil, err
3083 }
3084 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
3085 return meInstance, nil
3086 }
3087 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3088 "device-id": oo.deviceID})
3089 return nil, omciErr.GetError()
3090}
3091
3092// SendDeleteVoiceServiceProfile nolint: unused
3093func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
3094 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3095 tid := oo.GetNextTid(highPrio)
3096 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3097 "SequNo": strconv.FormatInt(int64(tid), 16),
3098 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3099
3100 meParams := me.ParamData{EntityID: aInstID}
3101 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
3102 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003103 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3104 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003105 if err != nil {
3106 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
3107 "Err": err, "device-id": oo.deviceID})
3108 return nil, err
3109 }
3110
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003111 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003112 if err != nil {
3113 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
3114 "Err": err, "device-id": oo.deviceID})
3115 return nil, err
3116 }
3117
3118 omciRxCallbackPair := CallbackPair{
3119 CbKey: tid,
3120 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3121 }
3122 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3123 if err != nil {
3124 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
3125 "Err": err, "device-id": oo.deviceID})
3126 return nil, err
3127 }
3128 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
3129 return meInstance, nil
3130 }
3131 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
3132 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3133 return nil, omciErr.GetError()
3134}
3135
3136// SendCreateSIPUserData nolint: unused
3137func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
3138 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3139 tid := oo.GetNextTid(highPrio)
3140 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
3141 "SequNo": strconv.FormatInt(int64(tid), 16),
3142 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3143
3144 meInstance, omciErr := me.NewSipUserData(params[0])
3145 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003146 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3147 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003148 if err != nil {
3149 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3150 "device-id": oo.deviceID})
3151 return nil, err
3152 }
3153
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003154 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003155 if err != nil {
3156 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3157 "device-id": oo.deviceID})
3158 return nil, err
3159 }
3160
3161 omciRxCallbackPair := CallbackPair{CbKey: tid,
3162 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3163 }
3164 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3165 if err != nil {
3166 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3167 "device-id": oo.deviceID})
3168 return nil, err
3169 }
3170 logger.Debug(ctx, "send SIPUserData-create-msg done")
3171 return meInstance, nil
3172 }
3173 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3174 "device-id": oo.deviceID})
3175 return nil, omciErr.GetError()
3176}
3177
3178// SendSetSIPUserData nolint: unused
3179func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3180 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3181 tid := oo.GetNextTid(highPrio)
3182 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3183 "SequNo": strconv.FormatInt(int64(tid), 16),
3184 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3185
3186 meInstance, omciErr := me.NewSipUserData(params[0])
3187 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003188 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3189 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003190 if err != nil {
3191 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3192 "device-id": oo.deviceID})
3193 return nil, err
3194 }
3195
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003196 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003197 if err != nil {
3198 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3199 "device-id": oo.deviceID})
3200 return nil, err
3201 }
3202
3203 omciRxCallbackPair := CallbackPair{CbKey: tid,
3204 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3205 }
3206 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3207 if err != nil {
3208 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3209 "device-id": oo.deviceID})
3210 return nil, err
3211 }
3212 logger.Debug(ctx, "send SIPUserData-set-msg done")
3213 return meInstance, nil
3214 }
3215 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3216 "device-id": oo.deviceID})
3217 return nil, omciErr.GetError()
3218}
3219
3220// SendDeleteSIPUserData nolint: unused
3221func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3222 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3223 tid := oo.GetNextTid(highPrio)
3224 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3225 "SequNo": strconv.FormatInt(int64(tid), 16),
3226 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3227
3228 meParams := me.ParamData{EntityID: aInstID}
3229 meInstance, omciErr := me.NewSipUserData(meParams)
3230 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003231 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3232 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003233 if err != nil {
3234 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3235 "Err": err, "device-id": oo.deviceID})
3236 return nil, err
3237 }
3238
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003239 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003240 if err != nil {
3241 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3242 "Err": err, "device-id": oo.deviceID})
3243 return nil, err
3244 }
3245
3246 omciRxCallbackPair := CallbackPair{
3247 CbKey: tid,
3248 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3249 }
3250 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3251 if err != nil {
3252 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3253 "Err": err, "device-id": oo.deviceID})
3254 return nil, err
3255 }
3256 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3257 return meInstance, nil
3258 }
3259 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3260 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3261 return nil, omciErr.GetError()
3262}
3263
3264// SendCreateVoipApplicationServiceProfile nolint: unused
3265func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3266 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3267 tid := oo.GetNextTid(highPrio)
3268 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3269 "SequNo": strconv.FormatInt(int64(tid), 16),
3270 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3271
3272 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3273 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003274 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3275 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003276 if err != nil {
3277 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3278 "device-id": oo.deviceID})
3279 return nil, err
3280 }
3281
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003282 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003283 if err != nil {
3284 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3285 "device-id": oo.deviceID})
3286 return nil, err
3287 }
3288
3289 omciRxCallbackPair := CallbackPair{CbKey: tid,
3290 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3291 }
3292 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3293 if err != nil {
3294 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3295 "device-id": oo.deviceID})
3296 return nil, err
3297 }
3298 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3299 return meInstance, nil
3300 }
3301 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3302 "device-id": oo.deviceID})
3303 return nil, omciErr.GetError()
3304}
3305
3306// SendSetVoipApplicationServiceProfile nolint: unused
3307func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3308 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3309 tid := oo.GetNextTid(highPrio)
3310 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3311 "SequNo": strconv.FormatInt(int64(tid), 16),
3312 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3313
3314 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3315 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003316 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3317 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003318 if err != nil {
3319 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3320 "device-id": oo.deviceID})
3321 return nil, err
3322 }
3323
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003324 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003325 if err != nil {
3326 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3327 "device-id": oo.deviceID})
3328 return nil, err
3329 }
3330
3331 omciRxCallbackPair := CallbackPair{CbKey: tid,
3332 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3333 }
3334 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3335 if err != nil {
3336 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3337 "device-id": oo.deviceID})
3338 return nil, err
3339 }
3340 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3341 return meInstance, nil
3342 }
3343 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3344 "device-id": oo.deviceID})
3345 return nil, omciErr.GetError()
3346}
3347
3348// SendDeleteVoipApplicationServiceProfile nolint: unused
3349func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3350 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3351 tid := oo.GetNextTid(highPrio)
3352 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3353 "SequNo": strconv.FormatInt(int64(tid), 16),
3354 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3355
3356 meParams := me.ParamData{EntityID: aInstID}
3357 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3358 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003359 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3360 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003361 if err != nil {
3362 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3363 "Err": err, "device-id": oo.deviceID})
3364 return nil, err
3365 }
3366
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003367 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003368 if err != nil {
3369 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3370 "Err": err, "device-id": oo.deviceID})
3371 return nil, err
3372 }
3373
3374 omciRxCallbackPair := CallbackPair{
3375 CbKey: tid,
3376 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3377 }
3378 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3379 if err != nil {
3380 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3381 "Err": err, "device-id": oo.deviceID})
3382 return nil, err
3383 }
3384 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3385 return meInstance, nil
3386 }
3387 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3388 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3389 return nil, omciErr.GetError()
3390}
3391
3392// SendCreateSIPAgentConfigData nolint: unused
3393func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3394 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3395 tid := oo.GetNextTid(highPrio)
3396 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3397 "SequNo": strconv.FormatInt(int64(tid), 16),
3398 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3399
3400 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3401 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003402 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3403 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003404 if err != nil {
3405 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3406 "device-id": oo.deviceID})
3407 return nil, err
3408 }
3409
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003410 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003411 if err != nil {
3412 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3413 "device-id": oo.deviceID})
3414 return nil, err
3415 }
3416
3417 omciRxCallbackPair := CallbackPair{CbKey: tid,
3418 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3419 }
3420 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3421 if err != nil {
3422 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3423 "device-id": oo.deviceID})
3424 return nil, err
3425 }
3426 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3427 return meInstance, nil
3428 }
3429 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3430 "device-id": oo.deviceID})
3431 return nil, omciErr.GetError()
3432}
3433
3434// SendSetSIPAgentConfigData nolint: unused
3435func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3436 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3437 tid := oo.GetNextTid(highPrio)
3438 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3439 "SequNo": strconv.FormatInt(int64(tid), 16),
3440 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3441
3442 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3443 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003444 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3445 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003446 if err != nil {
3447 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3448 "device-id": oo.deviceID})
3449 return nil, err
3450 }
3451
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003452 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003453 if err != nil {
3454 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3455 "device-id": oo.deviceID})
3456 return nil, err
3457 }
3458
3459 omciRxCallbackPair := CallbackPair{CbKey: tid,
3460 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3461 }
3462 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3463 if err != nil {
3464 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3465 "device-id": oo.deviceID})
3466 return nil, err
3467 }
3468 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3469 return meInstance, nil
3470 }
3471 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3472 "device-id": oo.deviceID})
3473 return nil, omciErr.GetError()
3474}
3475
3476// SendDeleteSIPAgentConfigData nolint: unused
3477func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3478 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3479 tid := oo.GetNextTid(highPrio)
3480 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3481 "SequNo": strconv.FormatInt(int64(tid), 16),
3482 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3483
3484 meParams := me.ParamData{EntityID: aInstID}
3485 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3486 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003487 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3488 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003489 if err != nil {
3490 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3491 "Err": err, "device-id": oo.deviceID})
3492 return nil, err
3493 }
3494
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003495 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003496 if err != nil {
3497 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3498 "Err": err, "device-id": oo.deviceID})
3499 return nil, err
3500 }
3501
3502 omciRxCallbackPair := CallbackPair{
3503 CbKey: tid,
3504 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3505 }
3506 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3507 if err != nil {
3508 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3509 "Err": err, "device-id": oo.deviceID})
3510 return nil, err
3511 }
3512 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3513 return meInstance, nil
3514 }
3515 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3516 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3517 return nil, omciErr.GetError()
3518}
3519
3520// SendCreateTCPUDPConfigData nolint: unused
3521func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3522 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3523 tid := oo.GetNextTid(highPrio)
3524 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3525 "SequNo": strconv.FormatInt(int64(tid), 16),
3526 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3527
3528 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3529 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003530 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3531 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003532 if err != nil {
3533 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3534 "device-id": oo.deviceID})
3535 return nil, err
3536 }
3537
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003538 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003539 if err != nil {
3540 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3541 "device-id": oo.deviceID})
3542 return nil, err
3543 }
3544
3545 omciRxCallbackPair := CallbackPair{CbKey: tid,
3546 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3547 }
3548 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3549 if err != nil {
3550 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3551 "device-id": oo.deviceID})
3552 return nil, err
3553 }
3554 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3555 return meInstance, nil
3556 }
3557 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3558 "device-id": oo.deviceID})
3559 return nil, omciErr.GetError()
3560}
3561
3562// SendSetTCPUDPConfigData nolint: unused
3563func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3564 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3565 tid := oo.GetNextTid(highPrio)
3566 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3567 "SequNo": strconv.FormatInt(int64(tid), 16),
3568 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3569
3570 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3571 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003572 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3573 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003574 if err != nil {
3575 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3576 "device-id": oo.deviceID})
3577 return nil, err
3578 }
3579
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003580 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003581 if err != nil {
3582 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3583 "device-id": oo.deviceID})
3584 return nil, err
3585 }
3586
3587 omciRxCallbackPair := CallbackPair{CbKey: tid,
3588 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3589 }
3590 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3591 if err != nil {
3592 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3593 "device-id": oo.deviceID})
3594 return nil, err
3595 }
3596 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3597 return meInstance, nil
3598 }
3599 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3600 "device-id": oo.deviceID})
3601 return nil, omciErr.GetError()
3602}
3603
3604// SendDeleteTCPUDPConfigData nolint: unused
3605func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3606 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3607 tid := oo.GetNextTid(highPrio)
3608 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3609 "SequNo": strconv.FormatInt(int64(tid), 16),
3610 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3611
3612 meParams := me.ParamData{EntityID: aInstID}
3613 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3614 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003615 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3616 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003617 if err != nil {
3618 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3619 "Err": err, "device-id": oo.deviceID})
3620 return nil, err
3621 }
3622
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003623 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003624 if err != nil {
3625 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3626 "Err": err, "device-id": oo.deviceID})
3627 return nil, err
3628 }
3629
3630 omciRxCallbackPair := CallbackPair{
3631 CbKey: tid,
3632 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3633 }
3634 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3635 if err != nil {
3636 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3637 "Err": err, "device-id": oo.deviceID})
3638 return nil, err
3639 }
3640 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3641 return meInstance, nil
3642 }
3643 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3644 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3645 return nil, omciErr.GetError()
3646}
3647
3648// SendCreateIPHostConfigData nolint: unused
3649func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3650 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3651 tid := oo.GetNextTid(highPrio)
3652 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3653 "SequNo": strconv.FormatInt(int64(tid), 16),
3654 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3655
3656 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3657 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003658 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3659 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003660 if err != nil {
3661 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3662 "device-id": oo.deviceID})
3663 return nil, err
3664 }
3665
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003666 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003667 if err != nil {
3668 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3669 "device-id": oo.deviceID})
3670 return nil, err
3671 }
3672
3673 omciRxCallbackPair := CallbackPair{CbKey: tid,
3674 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3675 }
3676 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3677 if err != nil {
3678 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3679 "device-id": oo.deviceID})
3680 return nil, err
3681 }
3682 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3683 return meInstance, nil
3684 }
3685 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3686 "device-id": oo.deviceID})
3687 return nil, omciErr.GetError()
3688}
3689
3690// SendSetIPHostConfigData nolint: unused
3691func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3692 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3693 tid := oo.GetNextTid(highPrio)
3694 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3695 "SequNo": strconv.FormatInt(int64(tid), 16),
3696 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3697
3698 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3699 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003700 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3701 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003702 if err != nil {
3703 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3704 "device-id": oo.deviceID})
3705 return nil, err
3706 }
3707
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003708 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003709 if err != nil {
3710 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3711 "device-id": oo.deviceID})
3712 return nil, err
3713 }
3714
3715 omciRxCallbackPair := CallbackPair{CbKey: tid,
3716 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3717 }
3718 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3719 if err != nil {
3720 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3721 "device-id": oo.deviceID})
3722 return nil, err
3723 }
3724 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3725 return meInstance, nil
3726 }
3727 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3728 "device-id": oo.deviceID})
3729 return nil, omciErr.GetError()
3730}
3731
3732// SendDeleteIPHostConfigData nolint: unused
3733func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3734 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3735 tid := oo.GetNextTid(highPrio)
3736 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3737 "SequNo": strconv.FormatInt(int64(tid), 16),
3738 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3739
3740 meParams := me.ParamData{EntityID: aInstID}
3741 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3742 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003743 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3744 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003745 if err != nil {
3746 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3747 "Err": err, "device-id": oo.deviceID})
3748 return nil, err
3749 }
3750
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003751 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003752 if err != nil {
3753 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3754 "Err": err, "device-id": oo.deviceID})
3755 return nil, err
3756 }
3757
3758 omciRxCallbackPair := CallbackPair{
3759 CbKey: tid,
3760 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3761 }
3762 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3763 if err != nil {
3764 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3765 "Err": err, "device-id": oo.deviceID})
3766 return nil, err
3767 }
3768 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3769 return meInstance, nil
3770 }
3771 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3772 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3773 return nil, omciErr.GetError()
3774}
3775
3776// SendCreateRTPProfileData nolint: unused
3777func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3778 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3779 tid := oo.GetNextTid(highPrio)
3780 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3781 "SequNo": strconv.FormatInt(int64(tid), 16),
3782 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3783
3784 meInstance, omciErr := me.NewRtpProfileData(params[0])
3785 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003786 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3787 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003788 if err != nil {
3789 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3790 "device-id": oo.deviceID})
3791 return nil, err
3792 }
3793
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003794 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003795 if err != nil {
3796 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3797 "device-id": oo.deviceID})
3798 return nil, err
3799 }
3800
3801 omciRxCallbackPair := CallbackPair{CbKey: tid,
3802 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3803 }
3804 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3805 if err != nil {
3806 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3807 "device-id": oo.deviceID})
3808 return nil, err
3809 }
3810 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3811 return meInstance, nil
3812 }
3813 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3814 "device-id": oo.deviceID})
3815 return nil, omciErr.GetError()
3816}
3817
3818// SendSetRTPProfileData nolint: unused
3819func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3820 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3821 tid := oo.GetNextTid(highPrio)
3822 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3823 "SequNo": strconv.FormatInt(int64(tid), 16),
3824 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3825
3826 meInstance, omciErr := me.NewRtpProfileData(params[0])
3827 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003828 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3829 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003830 if err != nil {
3831 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3832 "device-id": oo.deviceID})
3833 return nil, err
3834 }
3835
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003836 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003837 if err != nil {
3838 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3839 "device-id": oo.deviceID})
3840 return nil, err
3841 }
3842
3843 omciRxCallbackPair := CallbackPair{CbKey: tid,
3844 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3845 }
3846 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3847 if err != nil {
3848 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3849 "device-id": oo.deviceID})
3850 return nil, err
3851 }
3852 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3853 return meInstance, nil
3854 }
3855 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3856 "device-id": oo.deviceID})
3857 return nil, omciErr.GetError()
3858}
3859
3860// SendDeleteRTPProfileData nolint: unused
3861func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3862 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3863 tid := oo.GetNextTid(highPrio)
3864 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3865 "SequNo": strconv.FormatInt(int64(tid), 16),
3866 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3867
3868 meParams := me.ParamData{EntityID: aInstID}
3869 meInstance, omciErr := me.NewRtpProfileData(meParams)
3870 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003871 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3872 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003873 if err != nil {
3874 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3875 "Err": err, "device-id": oo.deviceID})
3876 return nil, err
3877 }
3878
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003879 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003880 if err != nil {
3881 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3882 "Err": err, "device-id": oo.deviceID})
3883 return nil, err
3884 }
3885
3886 omciRxCallbackPair := CallbackPair{
3887 CbKey: tid,
3888 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3889 }
3890 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3891 if err != nil {
3892 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3893 "Err": err, "device-id": oo.deviceID})
3894 return nil, err
3895 }
3896 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3897 return meInstance, nil
3898 }
3899 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3900 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3901 return nil, omciErr.GetError()
3902}
3903
3904// SendCreateNetworkDialPlanTable nolint: unused
3905func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3906 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3907 tid := oo.GetNextTid(highPrio)
3908 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3909 "SequNo": strconv.FormatInt(int64(tid), 16),
3910 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3911
3912 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3913 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003914 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3915 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003916 if err != nil {
3917 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3918 "device-id": oo.deviceID})
3919 return nil, err
3920 }
3921
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003922 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003923 if err != nil {
3924 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3925 "device-id": oo.deviceID})
3926 return nil, err
3927 }
3928
3929 omciRxCallbackPair := CallbackPair{CbKey: tid,
3930 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3931 }
3932 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3933 if err != nil {
3934 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3935 "device-id": oo.deviceID})
3936 return nil, err
3937 }
3938 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3939 return meInstance, nil
3940 }
3941 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3942 "device-id": oo.deviceID})
3943 return nil, omciErr.GetError()
3944}
3945
3946// SendSetNetworkDialPlanTable nolint: unused
3947func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3948 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3949 tid := oo.GetNextTid(highPrio)
3950 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3951 "SequNo": strconv.FormatInt(int64(tid), 16),
3952 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3953
3954 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3955 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003956 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3957 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003958 if err != nil {
3959 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3960 "device-id": oo.deviceID})
3961 return nil, err
3962 }
3963
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00003964 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003965 if err != nil {
3966 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3967 "device-id": oo.deviceID})
3968 return nil, err
3969 }
3970
3971 omciRxCallbackPair := CallbackPair{CbKey: tid,
3972 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3973 }
3974 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3975 if err != nil {
3976 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3977 "device-id": oo.deviceID})
3978 return nil, err
3979 }
3980 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3981 return meInstance, nil
3982 }
3983 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3984 "device-id": oo.deviceID})
3985 return nil, omciErr.GetError()
3986}
3987
3988// SendDeleteNetworkDialPlanTable nolint: unused
3989func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3990 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3991 tid := oo.GetNextTid(highPrio)
3992 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3993 "SequNo": strconv.FormatInt(int64(tid), 16),
3994 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3995
3996 meParams := me.ParamData{EntityID: aInstID}
3997 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3998 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003999 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
4000 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03004001 if err != nil {
4002 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
4003 "Err": err, "device-id": oo.deviceID})
4004 return nil, err
4005 }
4006
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004007 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03004008 if err != nil {
4009 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
4010 "Err": err, "device-id": oo.deviceID})
4011 return nil, err
4012 }
4013
4014 omciRxCallbackPair := CallbackPair{
4015 CbKey: tid,
4016 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4017 }
4018 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4019 if err != nil {
4020 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
4021 "Err": err, "device-id": oo.deviceID})
4022 return nil, err
4023 }
4024 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
4025 return meInstance, nil
4026 }
4027 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
4028 "Err": omciErr.GetError(), "device-id": oo.deviceID})
4029 return nil, omciErr.GetError()
4030}
4031
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004032// SendSyncTime sends SynchronizeTimeRequest
4033func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
4034 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004035 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
4036 "SequNo": strconv.FormatInt(int64(tid), 16)})
4037
4038 omciLayer := &omci.OMCI{
4039 TransactionID: tid,
4040 MessageType: omci.SynchronizeTimeRequestType,
4041 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4042 // Length: 0x28, // Optional, defaults to 40 octets
4043 }
4044 utcTime := time.Now().UTC()
4045 request := &omci.SynchronizeTimeRequest{
4046 MeBasePacket: omci.MeBasePacket{
4047 EntityClass: me.OnuGClassID,
4048 // Default Instance ID is 0
4049 },
4050 Year: uint16(utcTime.Year()),
4051 Month: uint8(utcTime.Month()),
4052 Day: uint8(utcTime.Day()),
4053 Hour: uint8(utcTime.Hour()),
4054 Minute: uint8(utcTime.Minute()),
4055 Second: uint8(utcTime.Second()),
4056 }
4057
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004058 pkt, err := SerializeOmciLayer(ctx, omciLayer, request)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004059 if err != nil {
4060 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
4061 "device-id": oo.deviceID})
4062 return err
4063 }
4064
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004065 omciRxCallbackPair := CallbackPair{CbKey: tid,
4066 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004067 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004068 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004069 if err != nil {
4070 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
4071 "device-id": oo.deviceID})
4072 return err
4073 }
4074 logger.Debug(ctx, "send synchronize time request done")
4075 return nil
4076}
4077
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004078// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
4079func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004080 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004081 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004082 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4083 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4084 meParam := me.ParamData{EntityID: entityID}
4085 var meInstance *me.ManagedEntity
4086 var omciErr me.OmciErrors
4087 if upstream {
4088 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
4089 } else {
4090 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
4091 }
4092 if omciErr.GetError() == nil {
4093 var omciLayer *omci.OMCI
4094 var msgLayer gopacket.SerializableLayer
4095 var err error
4096 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004097 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4098 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004099 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004100 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4101 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004102 }
4103 if err != nil {
4104 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
4105 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004106 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004107 }
4108
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004109 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004110 if err != nil {
4111 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
4112 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004113 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004114 }
4115
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004116 omciRxCallbackPair := CallbackPair{CbKey: tid,
4117 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004118 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004119 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004120 if err != nil {
4121 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
4122 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004123 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004124 }
4125 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
4126 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004127 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004128 }
4129 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
4130 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 +03004131 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004132}
4133
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004134// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
4135func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004136 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004137 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004138 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4139 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4140 meParam := me.ParamData{EntityID: entityID}
4141 var meInstance *me.ManagedEntity
4142 var omciErr me.OmciErrors
4143 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
4144
4145 if omciErr.GetError() == nil {
4146 var omciLayer *omci.OMCI
4147 var msgLayer gopacket.SerializableLayer
4148 var err error
4149 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004150 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4151 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004152 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004153 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4154 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004155 }
4156 if err != nil {
4157 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4158 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004159 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004160 }
4161
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004162 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004163 if err != nil {
4164 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4165 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004166 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004167 }
4168
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004169 omciRxCallbackPair := CallbackPair{CbKey: tid,
4170 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004171 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004172 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004173 if err != nil {
4174 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4175 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004176 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004177 }
4178 logger.Debugw(ctx, "send ethernet uni history data ME done",
4179 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004180 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004181 }
4182 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4183 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004184 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004185}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004186
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004187// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4188func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004189 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004190 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004191 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4192 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4193 meParam := me.ParamData{EntityID: entityID}
4194 var meInstance *me.ManagedEntity
4195 var omciErr me.OmciErrors
4196 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4197
4198 if omciErr.GetError() == nil {
4199 var omciLayer *omci.OMCI
4200 var msgLayer gopacket.SerializableLayer
4201 var err error
4202 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004203 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4204 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004205 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004206 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4207 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004208 }
4209 if err != nil {
4210 logger.Errorw(ctx, "Cannot encode fec history data ME",
4211 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004212 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004213 }
4214
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004215 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004216 if err != nil {
4217 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4218 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004219 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004220 }
4221
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004222 omciRxCallbackPair := CallbackPair{CbKey: tid,
4223 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004224 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004225 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004226 if err != nil {
4227 logger.Errorw(ctx, "Cannot send fec history data ME",
4228 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004229 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004230 }
4231 logger.Debugw(ctx, "send fec history data ME done",
4232 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004233 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004234 }
4235 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4236 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004237 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004238}
4239
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004240// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4241func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004242 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004243 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004244 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4245 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4246 meParam := me.ParamData{EntityID: entityID}
4247 var meInstance *me.ManagedEntity
4248 var omciErr me.OmciErrors
4249 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4250
4251 if omciErr.GetError() == nil {
4252 var omciLayer *omci.OMCI
4253 var msgLayer gopacket.SerializableLayer
4254 var err error
4255 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004256 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4257 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004258 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004259 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4260 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004261 }
4262 if err != nil {
4263 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4264 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004265 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004266 }
4267
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00004268 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004269 if err != nil {
4270 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4271 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004272 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004273 }
4274
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004275 omciRxCallbackPair := CallbackPair{CbKey: tid,
4276 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004277 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004278 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004279 if err != nil {
4280 logger.Errorw(ctx, "Cannot send gemport history data ME",
4281 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004282 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004283 }
4284 logger.Debugw(ctx, "send gemport history data ME done",
4285 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004286 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004287 }
4288 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4289 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004290 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004291}
4292
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004293// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4294func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004295 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004296 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004297 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4298 "SequNo": strconv.FormatInt(int64(tid), 16),
4299 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4300
4301 omciLayer := &omci.OMCI{
4302 TransactionID: tid,
4303 MessageType: omci.StartSoftwareDownloadRequestType,
4304 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4305 // Length: 0x28, // Optional, defaults to 40 octets
4306 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004307 if aIsExtendedOmci {
4308 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4309 }
mpagenko80622a52021-02-09 16:53:23 +00004310 request := &omci.StartSoftwareDownloadRequest{
4311 MeBasePacket: omci.MeBasePacket{
4312 EntityClass: me.SoftwareImageClassID,
4313 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004314 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004315 },
4316 WindowSize: aDownloadWindowSize,
4317 ImageSize: aFileLen,
4318 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4319 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4320 }
4321
4322 var options gopacket.SerializeOptions
4323 options.FixLengths = true
4324 buffer := gopacket.NewSerializeBuffer()
4325 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4326 if err != nil {
4327 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4328 "device-id": oo.deviceID})
4329 return err
4330 }
4331 outgoingPacket := buffer.Bytes()
4332
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004333 omciRxCallbackPair := CallbackPair{CbKey: tid,
4334 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004335 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004336 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004337 if err != nil {
4338 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4339 "device-id": oo.deviceID})
4340 return err
4341 }
4342 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004343 return nil
4344}
4345
kesavand011d5162021-11-25 19:21:06 +05304346// PrepareOnuSectionsOfWindow prepares a list of sections for each window
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05304347// Before invoking this function the oo.mutexTid needs to be be locked so that
4348// GetOnuSwSecNextTid can be invoked without further locking
kesavand011d5162021-11-25 19:21:06 +05304349func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4350 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004351 omciMsgsPerWindow *ia.OmciMessages, aIsExtendedOmci bool) (OmciTransferStructure, error) {
kesavand011d5162021-11-25 19:21:06 +05304352 //onuswsections uses only low prioirity tids
4353 tid := oo.GetOnuSwSecNextTid()
4354 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4355 "SequNo": strconv.FormatInt(int64(tid), 16),
4356 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4357
4358 var omciTxReq OmciTransferStructure
4359 msgType := omci.DownloadSectionRequestType
4360
4361 if aAckRequest > 0 {
4362 msgType = omci.DownloadSectionRequestWithResponseType
4363
4364 }
4365 omciLayer := &omci.OMCI{
4366 TransactionID: tid,
4367 MessageType: msgType,
4368 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4369 // Length: 0x28, // Optional, defaults to 40 octets
4370 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004371 if aIsExtendedOmci {
4372 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4373 }
kesavand011d5162021-11-25 19:21:06 +05304374 localSectionData := make([]byte, len(aSection))
4375
4376 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4377 request := &omci.DownloadSectionRequest{
4378 MeBasePacket: omci.MeBasePacket{
4379 EntityClass: me.SoftwareImageClassID,
4380 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004381 Extended: aIsExtendedOmci,
kesavand011d5162021-11-25 19:21:06 +05304382 },
4383 SectionNumber: aDownloadSectionNo,
4384 SectionData: localSectionData,
4385 }
4386
4387 var options gopacket.SerializeOptions
4388 options.FixLengths = true
4389 buffer := gopacket.NewSerializeBuffer()
4390 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4391 if err != nil {
4392 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4393 "device-id": oo.deviceID})
4394 return omciTxReq, err
4395 }
4396 outgoingPacket := buffer.Bytes()
4397
4398 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4399
4400 if aAckRequest > 0 {
4401 // only the last section should have a timeout as an ack is required only for the last section of the window
4402 omciTxReq = OmciTransferStructure{
4403 withFramePrint: true,
4404 OnuSwWindow: omciMsgsPerWindow,
4405 }
4406 return omciTxReq, nil
4407 }
4408
4409 return omciTxReq, nil
4410}
4411
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05304412// SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
kesavand011d5162021-11-25 19:21:06 +05304413func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4414 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4415 if aOmciTxRequest.OnuSwWindow == nil {
4416 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4417 log.Fields{"device-id": oo.deviceID})
4418 return
4419
4420 }
4421
4422 tid := oo.GetOnuSwSecLastTid()
4423 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4424 omciRxCallbackPair := CallbackPair{CbKey: tid,
4425 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4426 }
4427
4428 aOmciTxRequest.cbPair = omciRxCallbackPair
4429 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4430 oo.mutexRxSchedMap.Lock()
4431 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4432 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4433 oo.mutexRxSchedMap.Unlock()
4434
4435 chSuccess := make(chan bool)
4436 aOmciTxRequest.chSuccess = chSuccess
4437 aOmciTxRequest.timeout = aTimeout
4438 aOmciTxRequest.retries = CDefaultRetries
4439
4440 //tid := aOmciTxRequest.cbPair.CbKey
4441 oo.mutexMonReq.Lock()
4442 oo.monitoredRequests[tid] = aOmciTxRequest
4443 oo.mutexMonReq.Unlock()
4444
4445 retries := aOmciTxRequest.retries
4446 retryCounter := 0
4447 if aTimeout == 0 {
4448 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4449 return
4450 }
4451loop:
4452 for retryCounter <= retries {
4453 // the onu sw sections are enqueued only to the low priority queue
4454 oo.mutexLowPrioTxQueue.Lock()
4455 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4456 oo.mutexLowPrioTxQueue.Unlock()
4457
4458 go oo.sendQueuedRequests(ctx)
4459
4460 select {
4461 case success := <-chSuccess:
4462 if success {
4463 logger.Debugw(ctx, "reqMon: response received in time",
4464 log.Fields{"tid": tid, "device-id": oo.deviceID})
4465 } else {
4466 logger.Debugw(ctx, "reqMon: wait for response aborted",
4467 log.Fields{"tid": tid, "device-id": oo.deviceID})
4468 }
4469 break loop
4470 case <-time.After(time.Duration(aTimeout) * time.Second):
4471 if retryCounter == retries {
Holger Hildebrandt2b107642022-12-09 07:56:23 +00004472 if oo.pBaseDeviceHandler.IsOltAvailable() {
4473 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
4474 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4475 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
4476 } else {
4477 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!",
4478 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4479 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004480 oo.incrementTxTimesouts()
kesavand011d5162021-11-25 19:21:06 +05304481 break loop
4482 } else {
4483 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4484 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004485 oo.incrementTxRetries()
kesavand011d5162021-11-25 19:21:06 +05304486 }
4487 }
4488 retryCounter++
4489 }
4490 oo.mutexMonReq.Lock()
4491 delete(oo.monitoredRequests, tid)
4492 oo.mutexMonReq.Unlock()
4493}
4494
4495func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004496 var lastSection []byte
4497 if omciTxRequest.OnuSwWindow != nil {
4498 lastSection = omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4499 } else {
4500 logger.Errorw(ctx, "invalid sw window received", log.Fields{"device-id": oo.deviceID})
4501 return fmt.Errorf("invalid sw window received")
4502 }
4503 if omciTxRequest.withFramePrint {
4504 logger.Debugw(ctx, "sw-section-omci-message-to-send:", log.Fields{
kesavand011d5162021-11-25 19:21:06 +05304505 "TxOmciMessage": hex.EncodeToString(lastSection),
4506 "device-id": oo.deviceID,
4507 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4508 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4509 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4510 }
4511 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4512 if sendErr != nil {
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004513 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"device-id": oo.deviceID, "error": sendErr})
kesavand011d5162021-11-25 19:21:06 +05304514 return sendErr
4515 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004516 numberOfNoArSections := len(omciTxRequest.OnuSwWindow.Messages) - 1 // last section of window is sent with AR expected
4517 if lastSection[cOmciDeviceIdentifierPos] == byte(omci.BaselineIdent) {
4518 oo.increaseBaseTxNoArFramesBy(ctx, uint32(numberOfNoArSections))
4519 oo.incrementBaseTxArFrames()
4520 } else {
4521 oo.increaseExtTxNoArFramesBy(ctx, uint32(numberOfNoArSections))
4522 oo.incrementExtTxArFrames()
4523 }
kesavand011d5162021-11-25 19:21:06 +05304524 return nil
4525}
4526
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004527// SendDownloadSection sends DownloadSectionRequestWithResponse
4528func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004529 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004530 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004531 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4532 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004533 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004534
4535 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4536 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004537 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004538 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004539 if aAckRequest > 0 {
4540 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004541 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004542 }
mpagenko80622a52021-02-09 16:53:23 +00004543 omciLayer := &omci.OMCI{
4544 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004545 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004546 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4547 // Length: 0x28, // Optional, defaults to 40 octets
4548 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004549 if aIsExtendedOmci {
4550 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4551 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304552 localSectionData := make([]byte, len(aSection))
4553
mpagenko15ff4a52021-03-02 10:09:20 +00004554 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004555 request := &omci.DownloadSectionRequest{
4556 MeBasePacket: omci.MeBasePacket{
4557 EntityClass: me.SoftwareImageClassID,
4558 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004559 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004560 },
4561 SectionNumber: aDownloadSectionNo,
4562 SectionData: localSectionData,
4563 }
4564
4565 var options gopacket.SerializeOptions
4566 options.FixLengths = true
4567 buffer := gopacket.NewSerializeBuffer()
4568 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4569 if err != nil {
4570 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4571 "device-id": oo.deviceID})
4572 return err
4573 }
4574 outgoingPacket := buffer.Bytes()
4575
mpagenko15ff4a52021-03-02 10:09:20 +00004576 //for initial debug purpose overrule the requested print state for some frames
4577 printFrame := aPrint
4578 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4579 printFrame = true
4580 }
4581
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004582 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004583 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4584 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004585 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004586 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004587 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004588 if err != nil {
4589 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4590 "device-id": oo.deviceID})
4591 return err
4592 }
4593 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004594 return nil
4595}
4596
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05304597// SendEndSoftwareDownload sends EndSoftwareDownloadRequest
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004598func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004599 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004600 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004601 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4602 "SequNo": strconv.FormatInt(int64(tid), 16),
4603 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4604
mpagenko15ff4a52021-03-02 10:09:20 +00004605 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004606 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004607 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004608 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4609 // Length: 0x28, // Optional, defaults to 40 octets
4610 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004611 if aIsExtendedOmci {
4612 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4613 }
mpagenko15ff4a52021-03-02 10:09:20 +00004614 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004615 MeBasePacket: omci.MeBasePacket{
4616 EntityClass: me.SoftwareImageClassID,
4617 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004618 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004619 },
mpagenko15ff4a52021-03-02 10:09:20 +00004620 CRC32: aImageCrc,
4621 ImageSize: aFileLen,
4622 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4623 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004624 }
mpagenko15ff4a52021-03-02 10:09:20 +00004625
4626 var options gopacket.SerializeOptions
4627 options.FixLengths = true
4628 buffer := gopacket.NewSerializeBuffer()
4629 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4630 if err != nil {
4631 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004632 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004633 return err
mpagenko80622a52021-02-09 16:53:23 +00004634 }
mpagenko15ff4a52021-03-02 10:09:20 +00004635 outgoingPacket := buffer.Bytes()
4636
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004637 omciRxCallbackPair := CallbackPair{CbKey: tid,
4638 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004639 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004640 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004641 if err != nil {
4642 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4643 "device-id": oo.deviceID})
4644 return err
4645 }
4646 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004647 return nil
4648}
4649
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004650// SendActivateSoftware sends ActivateSoftwareRequest
4651func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004652 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004653 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004654 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4655 "SequNo": strconv.FormatInt(int64(tid), 16),
4656 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4657
4658 omciLayer := &omci.OMCI{
4659 TransactionID: tid,
4660 MessageType: omci.ActivateSoftwareRequestType,
4661 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4662 // Length: 0x28, // Optional, defaults to 40 octets
4663 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004664 if aIsExtendedOmci {
4665 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4666 }
mpagenko80622a52021-02-09 16:53:23 +00004667 request := &omci.ActivateSoftwareRequest{
4668 MeBasePacket: omci.MeBasePacket{
4669 EntityClass: me.SoftwareImageClassID,
4670 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004671 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004672 },
4673 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4674 }
4675
4676 var options gopacket.SerializeOptions
4677 options.FixLengths = true
4678 buffer := gopacket.NewSerializeBuffer()
4679 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4680 if err != nil {
4681 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4682 "device-id": oo.deviceID})
4683 return err
4684 }
4685 outgoingPacket := buffer.Bytes()
4686
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004687 omciRxCallbackPair := CallbackPair{CbKey: tid,
4688 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004689 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004690 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004691 if err != nil {
4692 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4693 "device-id": oo.deviceID})
4694 return err
4695 }
4696 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004697 return nil
4698}
mpagenko80622a52021-02-09 16:53:23 +00004699
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004700// SendCommitSoftware sends CommitSoftwareRequest
4701func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004702 rxChan chan Message, aImageMeID uint16, aIsExtendedOmci bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004703 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004704 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4705 "SequNo": strconv.FormatInt(int64(tid), 16),
4706 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4707
4708 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004709 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004710 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004711 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4712 // Length: 0x28, // Optional, defaults to 40 octets
4713 }
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004714 if aIsExtendedOmci {
4715 omciLayer.DeviceIdentifier = omci.ExtendedIdent
4716 }
mpagenko15ff4a52021-03-02 10:09:20 +00004717 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004718 MeBasePacket: omci.MeBasePacket{
4719 EntityClass: me.SoftwareImageClassID,
4720 EntityInstance: aImageMeID, //inactive image
Holger Hildebrandt5458d892022-05-31 09:52:06 +00004721 Extended: aIsExtendedOmci,
mpagenko80622a52021-02-09 16:53:23 +00004722 },
mpagenko80622a52021-02-09 16:53:23 +00004723 }
mpagenko15ff4a52021-03-02 10:09:20 +00004724
4725 var options gopacket.SerializeOptions
4726 options.FixLengths = true
4727 buffer := gopacket.NewSerializeBuffer()
4728 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4729 if err != nil {
4730 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004731 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004732 return err
mpagenko80622a52021-02-09 16:53:23 +00004733 }
mpagenko15ff4a52021-03-02 10:09:20 +00004734 outgoingPacket := buffer.Bytes()
4735
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004736 omciRxCallbackPair := CallbackPair{CbKey: tid,
4737 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004738 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004739 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004740 if err != nil {
4741 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4742 "device-id": oo.deviceID})
4743 return err
4744 }
4745 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004746 return nil
4747}
4748
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05304749// SendSelfTestReq sends TestRequest
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004750func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4751 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004752 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4753 "SequNo": strconv.FormatInt(int64(tid), 16),
4754 "InstId": strconv.FormatInt(int64(instdID), 16)})
4755 omciLayer := &omci.OMCI{
4756 TransactionID: tid,
4757 MessageType: omci.TestRequestType,
4758 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4759 // Length: 0x28, // Optional, defaults to 40 octets
4760 }
4761
4762 var request *omci.OpticalLineSupervisionTestRequest
4763 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004764 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004765 request = &omci.OpticalLineSupervisionTestRequest{
4766 MeBasePacket: omci.MeBasePacket{
4767 EntityClass: classID,
4768 EntityInstance: instdID,
4769 },
4770 SelectTest: uint8(7), // self test
4771 GeneralPurposeBuffer: uint16(0),
4772 VendorSpecificParameters: uint16(0),
4773 }
4774 default:
4775 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4776 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4777 }
4778 // Test serialization back to former string
4779 var options gopacket.SerializeOptions
4780 options.FixLengths = true
4781
4782 buffer := gopacket.NewSerializeBuffer()
4783 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4784 if err != nil {
4785 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4786 "device-id": oo.deviceID})
4787 return err
4788 }
4789 outgoingPacket := buffer.Bytes()
4790
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004791 omciRxCallbackPair := CallbackPair{CbKey: tid,
4792 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004793 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004794 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004795 if err != nil {
4796 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4797 "device-id": oo.deviceID})
4798 return err
4799 }
4800 logger.Debug(ctx, "send self test request done")
4801 return nil
4802}
4803
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05304804// nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004805func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4806
4807 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4808 if err != nil {
4809 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4810 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4811 }
4812 msgLayer := (*packet).Layer(nextLayer)
4813 if msgLayer != nil {
4814 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4815 if failure := (*packet).ErrorLayer(); failure != nil {
4816 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4817 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4818 // can examine for UnkonwnMEs and UnknownAttributes
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05304819 logger.Debug(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004820 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4821 return false, nil
4822 } else if nextLayer == omci.LayerTypeGetResponse {
4823 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4824 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4825 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4826 if unknownAttrLayer != nil {
4827 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4828 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4829 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4830 }
4831 }
4832 }
4833 }
4834 // Try to decode any further error information
4835 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4836 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4837 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4838 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4839 }
4840 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4841 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4842 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4843 }
4844 } else if failure := (*packet).ErrorLayer(); failure != nil {
4845 // message layer could not be decoded, but at least check if additional failure information is available
4846 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004847 errMsg := decodeFailure.String()
4848 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4849 if strings.Contains(strings.ToLower(errMsg), "table decode") {
4850 // In the case of MibUploadNextResponse with non-standard table attributes, we let the packet pass
4851 // so that later processing can deal with it
4852 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with table attributes - let it pass",
4853 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4854 return false, nil
4855 }
4856 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004857 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
Holger Hildebrandt93d183f2022-04-22 15:50:26 +00004858 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": errMsg})
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004859 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4860 }
4861 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4862 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4863 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4864 } else {
4865 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4866 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4867 }
4868
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004869 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004870 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004871 switch nextLayer {
4872 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004873 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4874 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004875 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004876 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004877 }
4878 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004879 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4880 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004881 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004882 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004883 }
4884 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004885 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4886 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004887 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004888 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004889 }
4890 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004891 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4892 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004893 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004894 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004895 }
4896 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004897 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4898 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004899 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004900 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004901 }
4902 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004903 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4904 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004905 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004906 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004907 }
4908 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004909 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4910 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004911 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004912 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004913 }
4914 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004915 }
4916 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004917 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004918}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004919
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004920func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004921 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004922 if timeout == 0 {
4923 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004924 // enqueue
4925 if aOmciTxRequest.highPrio {
4926 oo.mutexHighPrioTxQueue.Lock()
4927 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4928 oo.mutexHighPrioTxQueue.Unlock()
4929 } else {
4930 oo.mutexLowPrioTxQueue.Lock()
4931 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4932 oo.mutexLowPrioTxQueue.Unlock()
4933 }
4934 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004935 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004936 //the supervised sending with waiting on the response (based on TID) is called in background
4937 // to avoid blocking of the sender for the complete OMCI handshake procedure
4938 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4939 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4940 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004941 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004942}
4943
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004944func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004945 chSuccess := make(chan bool)
4946 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004947 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004948 oo.mutexMonReq.Lock()
4949 oo.monitoredRequests[tid] = aOmciTxRequest
4950 oo.mutexMonReq.Unlock()
4951
4952 retries := aOmciTxRequest.retries
4953 retryCounter := 0
4954loop:
4955 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004956 // enqueue
4957 if aOmciTxRequest.highPrio {
4958 oo.mutexHighPrioTxQueue.Lock()
4959 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4960 oo.mutexHighPrioTxQueue.Unlock()
4961 } else {
4962 oo.mutexLowPrioTxQueue.Lock()
4963 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4964 oo.mutexLowPrioTxQueue.Unlock()
4965 }
4966 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004967
4968 select {
4969 case success := <-chSuccess:
4970 if success {
4971 logger.Debugw(ctx, "reqMon: response received in time",
4972 log.Fields{"tid": tid, "device-id": oo.deviceID})
4973 } else {
4974 logger.Debugw(ctx, "reqMon: wait for response aborted",
4975 log.Fields{"tid": tid, "device-id": oo.deviceID})
4976 }
4977 break loop
4978 case <-time.After(time.Duration(aTimeout) * time.Second):
4979 if retryCounter == retries {
Holger Hildebrandt2b107642022-12-09 07:56:23 +00004980 if oo.pBaseDeviceHandler.IsOltAvailable() {
4981 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
4982 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4983 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
4984 } else {
4985 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - skip ONU device event: OLT unavailable!",
4986 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4987 }
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004988 oo.incrementTxTimesouts()
mpagenko7455fd42021-06-10 16:25:55 +00004989 break loop
4990 } else {
4991 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4992 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00004993 oo.incrementTxRetries()
mpagenko7455fd42021-06-10 16:25:55 +00004994 }
4995 }
4996 retryCounter++
4997 }
4998 oo.mutexMonReq.Lock()
4999 delete(oo.monitoredRequests, tid)
5000 oo.mutexMonReq.Unlock()
5001}
5002
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05305003// CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005004func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt12609a12022-03-25 13:23:25 +00005005 logger.Debugw(ctx, "CancelRequestMonitoring entered", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005006 oo.mutexMonReq.RLock()
5007 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00005008 //implement non-blocking channel send to avoid blocking on mutexMonReq later
5009 select {
5010 case oo.monitoredRequests[k].chSuccess <- false:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00005011 logger.Debugw(ctx, "send cancellation on omciRespChannel",
5012 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00005013 default:
Holger Hildebrandt12609a12022-03-25 13:23:25 +00005014 logger.Debugw(ctx, "cancellation could not be send on omciRespChannel (no receiver)",
5015 log.Fields{"index": k, "device-id": oo.deviceID})
mpagenko8cd1bf72021-06-22 10:11:19 +00005016 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005017 }
5018 oo.mutexMonReq.RUnlock()
5019}
5020
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05305021// GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
5022// time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005023func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
5024 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00005025}
Himani Chawla43f95ff2021-06-03 00:24:12 +05305026
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005027// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
5028func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05305029 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005030 tid := oo.GetNextTid(highPrio)
nikesh.krishnan1ffb8132023-05-23 03:44:13 +05305031 logger.Info(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
Himani Chawla43f95ff2021-06-03 00:24:12 +05305032 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
5033
5034 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005035 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305036 }
5037 var meInstance *me.ManagedEntity
5038 var omciErr me.OmciErrors
5039 if classID == me.EthernetFrameExtendedPmClassID {
5040 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
5041 } else {
5042 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
5043 }
5044
5045 if omciErr.GetError() == nil {
5046 var omciLayer *omci.OMCI
5047 var msgLayer gopacket.SerializableLayer
5048 var err error
5049 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00005050 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
5051 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05305052 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00005053 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
5054 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05305055 }
5056 if err != nil {
5057 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5058 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5059 return nil, err
5060 }
5061
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005062 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305063 if err != nil {
5064 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
5065 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5066 return nil, err
5067 }
5068
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005069 omciRxCallbackPair := CallbackPair{CbKey: tid,
5070 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05305071 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005072 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05305073 if err != nil {
5074 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5075 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5076 return nil, err
5077 }
5078 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
5079 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5080 return meInstance, nil
5081 }
5082 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5083 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5084 return nil, omciErr.GetError()
5085}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00005086
5087// RLockMutexMonReq lock read access to monitoredRequests
5088func (oo *OmciCC) RLockMutexMonReq() {
5089 oo.mutexMonReq.RLock()
5090}
5091
5092// RUnlockMutexMonReq unlock read access to monitoredRequests
5093func (oo *OmciCC) RUnlockMutexMonReq() {
5094 oo.mutexMonReq.RUnlock()
5095}
5096
5097// GetMonitoredRequest get OmciTransferStructure for an omciTransID
5098func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
5099 value, exist = oo.monitoredRequests[omciTransID]
5100 return value, exist
5101}
5102
5103// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
5104func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
5105 oo.monitoredRequests[omciTransID].chSuccess <- chVal
5106}
Himani Chawlaee10b542021-09-20 16:46:40 +05305107
5108// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
5109func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
5110 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
5111 tid := oo.GetNextTid(highPrio)
5112 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
5113 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
5114
5115 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00005116 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05305117 }
5118 var meInstance *me.ManagedEntity
5119 var omciErr me.OmciErrors
5120 if classID == me.EthernetFrameExtendedPmClassID {
5121 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
5122 } else {
5123 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
5124 }
5125
5126 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00005127 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05305128 if err != nil {
5129 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
5130 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5131 return nil, err
5132 }
Holger Hildebrandta6ef0e82022-04-06 13:11:32 +00005133 pkt, err := SerializeOmciLayer(ctx, omciLayer, msgLayer)
Himani Chawlaee10b542021-09-20 16:46:40 +05305134 if err != nil {
5135 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
5136 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5137 return nil, err
5138 }
5139 omciRxCallbackPair := CallbackPair{
5140 CbKey: tid,
5141 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
5142 }
5143 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
5144 if err != nil {
5145 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
5146 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5147 return nil, err
5148 }
5149 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
5150 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5151 return meInstance, nil
5152 }
5153 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
5154 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
5155 return nil, omciErr.GetError()
5156}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00005157
5158// PrepareForGarbageCollection - remove references to prepare for garbage collection
5159func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
5160 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
5161 oo.pBaseDeviceHandler = nil
5162 oo.pOnuDeviceEntry = nil
5163 oo.pOnuAlarmManager = nil
5164}
Holger Hildebrandt66af5ce2022-09-07 13:38:02 +00005165
5166// GetOmciCounters - TODO: add comment
5167func (oo *OmciCC) GetOmciCounters() *extension.SingleGetValueResponse {
5168 oo.mutexCounters.RLock()
5169 defer oo.mutexCounters.RUnlock()
5170 resp := extension.SingleGetValueResponse{
5171 Response: &extension.GetValueResponse{
5172 Status: extension.GetValueResponse_OK,
5173 Response: &extension.GetValueResponse_OnuOmciStats{
5174 OnuOmciStats: &extension.GetOnuOmciTxRxStatsResponse{},
5175 },
5176 },
5177 }
5178 resp.Response.GetOnuOmciStats().BaseTxArFrames = oo.countersBase.txArFrames
5179 resp.Response.GetOnuOmciStats().BaseTxNoArFrames = oo.countersBase.txNoArFrames
5180 resp.Response.GetOnuOmciStats().BaseRxAkFrames = oo.countersBase.rxAkFrames
5181 resp.Response.GetOnuOmciStats().BaseRxNoAkFrames = oo.countersBase.rxNoAkFrames
5182 resp.Response.GetOnuOmciStats().ExtTxArFrames = oo.countersExt.txArFrames
5183 resp.Response.GetOnuOmciStats().ExtTxNoArFrames = oo.countersExt.txNoArFrames
5184 resp.Response.GetOnuOmciStats().ExtRxAkFrames = oo.countersExt.rxAkFrames
5185 resp.Response.GetOnuOmciStats().ExtRxNoAkFrames = oo.countersExt.rxNoAkFrames
5186 resp.Response.GetOnuOmciStats().TxOmciCounterRetries = oo.txRetries
5187 resp.Response.GetOnuOmciStats().TxOmciCounterTimeouts = oo.txTimeouts
5188 return &resp
5189}
5190
5191// For more speed, separate functions for each counter
5192
5193func (oo *OmciCC) incrementBaseTxArFrames() {
5194 oo.mutexCounters.Lock()
5195 defer oo.mutexCounters.Unlock()
5196 oo.countersBase.txArFrames++
5197}
5198
5199func (oo *OmciCC) incrementExtTxArFrames() {
5200 oo.mutexCounters.Lock()
5201 defer oo.mutexCounters.Unlock()
5202 oo.countersExt.txArFrames++
5203}
5204
5205func (oo *OmciCC) incrementBaseRxAkFrames() {
5206 oo.mutexCounters.Lock()
5207 defer oo.mutexCounters.Unlock()
5208 oo.countersBase.rxAkFrames++
5209}
5210
5211func (oo *OmciCC) incrementExtRxAkFrames() {
5212 oo.mutexCounters.Lock()
5213 defer oo.mutexCounters.Unlock()
5214 oo.countersExt.rxAkFrames++
5215}
5216
5217func (oo *OmciCC) increaseBaseTxNoArFramesBy(ctx context.Context, value uint32) {
5218 oo.mutexCounters.Lock()
5219 defer oo.mutexCounters.Unlock()
5220 oo.countersBase.txNoArFrames += value
5221}
5222
5223func (oo *OmciCC) increaseExtTxNoArFramesBy(ctx context.Context, value uint32) {
5224 oo.mutexCounters.Lock()
5225 defer oo.mutexCounters.Unlock()
5226 oo.countersExt.txNoArFrames += value
5227}
5228
5229func (oo *OmciCC) incrementBaseRxNoAkFrames() {
5230 oo.mutexCounters.Lock()
5231 defer oo.mutexCounters.Unlock()
5232 oo.countersBase.rxNoAkFrames++
5233}
5234
5235func (oo *OmciCC) incrementExtRxNoAkFrames() {
5236 oo.mutexCounters.Lock()
5237 defer oo.mutexCounters.Unlock()
5238 oo.countersExt.rxNoAkFrames++
5239}
5240
5241func (oo *OmciCC) incrementTxRetries() {
5242 oo.mutexCounters.Lock()
5243 defer oo.mutexCounters.Unlock()
5244 oo.txRetries++
5245}
5246
5247func (oo *OmciCC) incrementTxTimesouts() {
5248 oo.mutexCounters.Lock()
5249 defer oo.mutexCounters.Unlock()
5250 oo.txTimeouts++
5251}
Holger Hildebrandt7e138462023-03-29 12:12:14 +00005252
5253// NotifyAboutOnuConfigFailure - trigger ONU DeviceEvent to notify about ONU config failure
5254func (oo *OmciCC) NotifyAboutOnuConfigFailure(ctx context.Context, errID string, meClassID me.ClassID, meEntityID uint16,
5255 meName string, meResult me.Results) {
5256 var description string
5257 if !oo.confFailMeAlreadyHandled(meClassID) {
5258 switch errID {
5259 case OnuConfigFailureResponseErr:
5260 description = OnuConfigFailureResponseErrDesc + meResult.String() +
5261 ", OMCI ME: " + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) + " (only first instance reported)"
5262 case OnuConfigFailureTimeout:
5263 description = OnuConfigFailureTimeoutDesc + meName + " / instance: " + fmt.Sprintf("%d", meEntityID) +
5264 " (only first instance reported)"
5265 default:
5266 logger.Warnw(ctx, "method called with undefined errID", log.Fields{"errID": errID, "device-id": oo.deviceID})
5267 return
5268 }
5269 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, errID, description)
5270 oo.appendConfFailMe(meClassID)
5271 }
5272}
5273
5274func (oo *OmciCC) confFailMeAlreadyHandled(meClassID me.ClassID) bool {
5275 oo.mutexConfFailMEs.RLock()
5276 defer oo.mutexConfFailMEs.RUnlock()
5277 for _, v := range oo.confFailMEs {
5278 if v == meClassID {
5279 return true
5280 }
5281 }
5282 return false
5283}
5284
5285func (oo *OmciCC) appendConfFailMe(meClassID me.ClassID) {
5286 oo.mutexConfFailMEs.Lock()
5287 defer oo.mutexConfFailMEs.Unlock()
5288 oo.confFailMEs = append(oo.confFailMEs, meClassID)
5289}
5290
5291// ResetConfFailMEs - reset list of stored config failure MEs
5292func (oo *OmciCC) ResetConfFailMEs() {
5293 oo.mutexConfFailMEs.Lock()
5294 defer oo.mutexConfFailMEs.Unlock()
5295 oo.confFailMEs = nil
5296}