blob: 6c0169463c76c8065e232619c3e3d5e2d8ccf545 [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000017//Package common provides global definitions
18package common
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
Andrea Campanella6515c582020-10-05 11:25:00 +020025 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000027 "sync"
mpagenko80622a52021-02-09 16:53:23 +000028 "time" //by now for testing
Holger Hildebrandtfa074992020-03-27 15:42:06 +000029
30 "github.com/google/gopacket"
31 // TODO!!! Some references could be resolved auto, but some need specific context ....
32 gp "github.com/google/gopacket"
33
mpagenko836a1fd2021-11-01 16:12:42 +000034 "github.com/opencord/omci-lib-go/v2"
35 me "github.com/opencord/omci-lib-go/v2/generated"
36 oframe "github.com/opencord/omci-lib-go/v2/meframe"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
khenaidoo7d3c5582021-08-11 18:09:44 -040038 vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
39
khenaidoo7d3c5582021-08-11 18:09:44 -040040 "github.com/opencord/voltha-lib-go/v7/pkg/log"
khenaidoo42dcdfd2021-10-19 17:34:12 -040041 "github.com/opencord/voltha-protos/v5/go/common"
42 ia "github.com/opencord/voltha-protos/v5/go/inter_adapter"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000043)
44
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000045// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053046
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047const maxGemPayloadSize = uint16(48)
48const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053049
50//const defaultTPID = uint16(0x8100)
51//const broadComDefaultVID = uint16(4091)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000052
53// UnusedTcontAllocID - TODO: add comment
54const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
mpagenko8b07c1b2020-11-26 10:36:31 +000055
mpagenkoc8bba412021-01-15 15:38:44 +000056const cOmciBaseMessageTrailerLen = 40
57
58// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
59type tOmciReceiveError uint8
60
61const (
62 // cOmciMessageReceiveNoError - default start state
63 cOmciMessageReceiveNoError tOmciReceiveError = iota
64 // Error indication wrong trailer length within the message
65 cOmciMessageReceiveErrorTrailerLen
66 // Error indication missing trailer within the message
67 cOmciMessageReceiveErrorMissTrailer
68)
69
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000070// CDefaultRetries - TODO: add comment
71const CDefaultRetries = 2
Holger Hildebrandt366ef192021-05-05 11:07:44 +000072
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000073// ### OMCI related definitions - end
74
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000075//CallbackPairEntry to be used for OMCI send/receive correlation
76type CallbackPairEntry struct {
77 CbRespChannel chan Message
78 CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
79 FramePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000080}
81
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000082//CallbackPair to be used for ReceiveCallback init
83type CallbackPair struct {
84 CbKey uint16
85 CbEntry CallbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000086}
87
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000088// OmciTransferStructure - TODO: add comment
89type OmciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000090 txFrame []byte
91 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000092 retries int
mpagenko80622a52021-02-09 16:53:23 +000093 highPrio bool
94 withFramePrint bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000095 cbPair CallbackPair
Holger Hildebrandt366ef192021-05-05 11:07:44 +000096 chSuccess chan bool
kesavand011d5162021-11-25 19:21:06 +053097 OnuSwWindow *ia.OmciMessages
Holger Hildebrandtfa074992020-03-27 15:42:06 +000098}
99
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000100//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
101type OmciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000102 enabled bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000103 pBaseDeviceHandler IdeviceHandler
104 pOnuDeviceEntry IonuDeviceEntry
105 pOnuAlarmManager IonuAlarmManager
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000106 deviceID string
khenaidoo7d3c5582021-08-11 18:09:44 -0400107 coreClient *vgrpc.Client
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000108 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000109 rxOmciFrameError tOmciReceiveError
110
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000111 txFrames, txOnuFrames uint32
112 rxFrames, rxOnuFrames, rxOnuDiscards uint32
113
114 // OMCI params
115 mutexTid sync.Mutex
116 tid uint16
117 mutexHpTid sync.Mutex
118 hpTid uint16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000119 UploadSequNo uint16
120 UploadNoOfCmds uint16
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000121
Holger Hildebrandt34555512021-10-01 16:26:59 +0000122 mutexSendQueuedRequests sync.Mutex
123 mutexLowPrioTxQueue sync.Mutex
124 lowPrioTxQueue *list.List
125 mutexHighPrioTxQueue sync.Mutex
126 highPrioTxQueue *list.List
127 mutexRxSchedMap sync.Mutex
128 rxSchedulerMap map[uint16]CallbackPairEntry
129 mutexMonReq sync.RWMutex
130 monitoredRequests map[uint16]OmciTransferStructure
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000131}
132
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000133var responsesWithMibDataSync = []omci.MessageType{
134 omci.CreateResponseType,
135 omci.DeleteResponseType,
136 omci.SetResponseType,
137 omci.StartSoftwareDownloadResponseType,
138 omci.EndSoftwareDownloadResponseType,
139 omci.ActivateSoftwareResponseType,
140 omci.CommitSoftwareResponseType,
141}
142
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000143//NewOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000144//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000145func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
146 onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
147 coreClient *vgrpc.Client) *OmciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000148 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000149 var omciCC OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000150 omciCC.enabled = false
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000151 omciCC.pBaseDeviceHandler = deviceHandler
152 omciCC.pOnuAlarmManager = onuAlarmManager
Himani Chawla4d908332020-08-31 12:30:20 +0530153 omciCC.pOnuDeviceEntry = onuDeviceEntry
154 omciCC.deviceID = deviceID
khenaidoo7d3c5582021-08-11 18:09:44 -0400155 omciCC.coreClient = coreClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000156 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000157 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000158 omciCC.txFrames = 0
159 omciCC.txOnuFrames = 0
160 omciCC.rxFrames = 0
161 omciCC.rxOnuFrames = 0
162 omciCC.rxOnuDiscards = 0
163 omciCC.tid = 0x1
164 omciCC.hpTid = 0x8000
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000165 omciCC.UploadSequNo = 0
166 omciCC.UploadNoOfCmds = 0
Holger Hildebrandt34555512021-10-01 16:26:59 +0000167 omciCC.lowPrioTxQueue = list.New()
168 omciCC.highPrioTxQueue = list.New()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000169 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
170 omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000171
172 return &omciCC
173}
174
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000175//Stop stops/resets the omciCC
176func (oo *OmciCC) Stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000177 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000178 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
mpagenko8cd1bf72021-06-22 10:11:19 +0000179 oo.CancelRequestMonitoring(ctx)
Holger Hildebrandt34555512021-10-01 16:26:59 +0000180 // clear the tx queues
181 oo.mutexHighPrioTxQueue.Lock()
182 oo.highPrioTxQueue.Init()
183 oo.mutexHighPrioTxQueue.Unlock()
184 oo.mutexLowPrioTxQueue.Lock()
185 oo.lowPrioTxQueue.Init()
186 oo.mutexLowPrioTxQueue.Unlock()
187 //clear the scheduler map
mpagenko900ee4b2020-10-12 11:56:34 +0000188 oo.mutexRxSchedMap.Lock()
189 for k := range oo.rxSchedulerMap {
Holger Hildebrandt34555512021-10-01 16:26:59 +0000190 delete(oo.rxSchedulerMap, k)
mpagenko900ee4b2020-10-12 11:56:34 +0000191 }
192 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000193 //reset the high prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000194 oo.mutexHpTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000195 oo.hpTid = 0x8000
mpagenko900ee4b2020-10-12 11:56:34 +0000196 oo.mutexHpTid.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000197 //reset the low prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000198 oo.mutexTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000199 oo.tid = 1
mpagenko900ee4b2020-10-12 11:56:34 +0000200 oo.mutexTid.Unlock()
201 //reset control values
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000202 oo.UploadSequNo = 0
203 oo.UploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000204 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000205 //reset the stats counter - which might be topic of discussion ...
206 oo.txFrames = 0
207 oo.txOnuFrames = 0
208 oo.rxFrames = 0
209 oo.rxOnuFrames = 0
210 oo.rxOnuDiscards = 0
211
212 return nil
213}
214
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000215// Rx handler for omci messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000216func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000217 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000218 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530219 switch omciMsg.MessageType {
220 case omci.AlarmNotificationType:
221 data := OmciMessage{
222 OmciMsg: omciMsg,
223 OmciPacket: packet,
224 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000225 go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530226 return nil
227 default:
228 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
229 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000230 /*
231 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
232 rxOnuFrames++
233
234 switch msgType {
235 case AlarmNotification:
236 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000237 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000238 // python code was:
239 //if msg_type == EntityOperations.AlarmNotification.value:
240 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
241 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
242 //
243 return errors.New("RxAlarmNotification unimplemented")
244 }
245 case AttributeValueChange:
246 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000247 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000248 // python code was:
249 //elif msg_type == EntityOperations.AttributeValueChange.value:
250 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
251 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
252 //
253 return errors.New("RxAttributeValueChange unimplemented")
254 }
255 case TestResult:
256 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000257 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000258 // python code was:
259 //elif msg_type == EntityOperations.TestResult.value:
260 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
261 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
262 //
263 return errors.New("RxTestResult unimplemented")
264 }
265 default:
266 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000267 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000268 rxOnuDiscards++
269 return errors.New("RxOnuMsgType unimplemented")
270 }
271 }
272 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000273}
274
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000275func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
mpagenko80622a52021-02-09 16:53:23 +0000276 //assuming omci message content is hex coded!
277 // with restricted output of 16bytes would be ...rxMsg[:16]
278 logger.Debugw(ctx, "omci-message-received:", log.Fields{
279 "RxOmciMessage": hex.EncodeToString(rxMsg),
280 "device-id": oo.deviceID})
281}
282
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000283// ReceiveMessage - Rx handler for onu messages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000284// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000285func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000286 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000287 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
288 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000289 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000290 trailerLenData := rxMsg[42:44]
291 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000292 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000293 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
294 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
295 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
296 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
297 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
298 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
299 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
300 }
301 }
302 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
303 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
304 // (an extendedFormat message could be destroyed this way!)
305 // extend/overwrite with trailer
306 trailer := make([]byte, 8)
307 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
308 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
309 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
310 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
311 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
312 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
313 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000314 }
315 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000316 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
317 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000318 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200319 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000320 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000321 decodeOptions := gopacket.DecodeOptions{
322 Lazy: true,
323 NoCopy: true,
324 }
325 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, decodeOptions)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000326 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000327 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000328 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200329 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000330 }
331 omciLayer := packet.Layer(omci.LayerTypeOMCI)
332 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000333 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000334 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200335 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000336 }
mpagenko836a1fd2021-11-01 16:12:42 +0000337 // insert some check on detected OMCI decoding issues and log them
338 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
339 // even though allowed from omci-lib due to set relaxed decoding
340 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
341 // (compare mib_sync.go unknownAttrLayer)
342 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
343 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
344 errMsg := failure.Error()
345 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
346 "device-id": oo.deviceID, "issue": errMsg})
347 }
348 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000349 omciMsg, ok := omciLayer.(*omci.OMCI)
350 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000351 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000352 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200353 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000354 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000355 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000356 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
357 "DeviceIdent": omciMsg.DeviceIdentifier, "device-id": oo.deviceID})
mpagenko836a1fd2021-11-01 16:12:42 +0000358
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700359 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
360 // We expect to find the TID in the oo.rxSchedulerMap
361 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000362 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000363 oo.printRxMessage(ctx, rxMsg)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000364 logger.Debugw(ctx, "RxMsg is no Omci Response Message", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000365 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530366 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000367 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000368 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200369 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000370 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200371 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530372 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000373 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530374 oo.mutexRxSchedMap.Lock()
375 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000376 if ok && rxCallbackEntry.CbFunction != nil {
377 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000378 oo.printRxMessage(ctx, rxMsg)
379 }
Himani Chawla4d908332020-08-31 12:30:20 +0530380 //disadvantage of decoupling: error verification made difficult, but anyway the question is
381 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000382 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000383 isSuccessfulResponse, err := oo.isSuccessfulResponseWithMibDataSync(ctx, omciMsg, &packet)
384 if err != nil {
385 // qualified error logging already done in function above
386 if !rxCallbackEntry.FramePrint {
387 oo.printRxMessage(ctx, rxMsg)
388 }
389 return fmt.Errorf("could not decode further layers %s", oo.deviceID)
390 }
391 if isSuccessfulResponse {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000392 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt36747fd2022-03-14 09:47:17 +0000393 } else {
394 logger.Debugw(ctx, "mibDataSync counter not to be updated for this message type",
395 log.Fields{"omciMsg.MessageType": omciMsg.MessageType, "device-id": oo.deviceID})
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000396 }
mpagenkoc8bba412021-01-15 15:38:44 +0000397
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700398 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
399 // so do not clean up the TransactionID in that case.
400 if omciMsg.MessageType != omci.TestResponseType {
401 // having posted the response the request is regarded as 'done'
402 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
403 }
Himani Chawla4d908332020-08-31 12:30:20 +0530404 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000405 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000406 }
mpagenko80622a52021-02-09 16:53:23 +0000407 oo.mutexRxSchedMap.Unlock()
408 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
409 oo.printRxMessage(ctx, rxMsg)
410 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000411
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000412 /* py code was:
413 Receive and OMCI message from the proxy channel to the OLT.
414
415 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
416 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
417 """
418 if not self.enabled:
419 return
420
421 try:
422 now = arrow.utcnow()
423 d = None
424
425 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
426 # save the current value of the entity_id_to_class_map, then
427 # replace it with our custom one before decode, and then finally
428 # restore it later. Tried other ways but really made the code messy.
429 saved_me_map = omci_entities.entity_id_to_class_map
430 omci_entities.entity_id_to_class_map = self._me_map
431
432 try:
433 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000434 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000435 except KeyError as e:
436 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000437 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000438 rx_frame = self._decode_unknown_me(msg)
439 self._rx_unknown_me += 1
440
441 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000442 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000443 return
444
445 finally:
446 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
447
448 rx_tid = rx_frame.fields['transaction_id']
449 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000450 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000451 # Filter the Test Result frame and route through receive onu
452 # message method.
453 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000454 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000455 return self._receive_onu_message(rx_frame)
456
457 # Previously unreachable if this is the very first round-trip Rx or we
458 # have been running consecutive errors
459 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000460 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000461 self.reactor.callLater(0, self._publish_connectivity_event, True)
462
463 self._rx_frames += 1
464 self._consecutive_errors = 0
465
466 try:
467 high_priority = self._tid_is_high_priority(rx_tid)
468 index = self._get_priority_index(high_priority)
469
470 # (timestamp, defer, frame, timeout, retry, delayedCall)
471 last_tx_tuple = self._tx_request[index]
472
473 if last_tx_tuple is None or \
474 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
475 # Possible late Rx on a message that timed-out
476 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000477 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000478 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
479 self._rx_unknown_tid += 1
480 self._rx_late += 1
481 return
482
483 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
484 if dc is not None and not dc.cancelled and not dc.called:
485 dc.cancel()
486
487 _secs = self._update_rx_tx_stats(now, ts)
488
489 # Late arrival already serviced by a timeout?
490 if d.called:
491 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000492 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000493 return
494
495 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000496 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000497 if d is not None:
498 return d.errback(failure.Failure(e))
499 return
500
501 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000502 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000503 tx_tid = tx_frame.fields['transaction_id'])
504 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
505
506 # begin success callback chain (will cancel timeout and queue next Tx message)
507 self._rx_response[index] = rx_frame
508 d.callback(rx_frame)
509
510 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000511 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000512 */
513}
514
Himani Chawla6d2ae152020-09-02 13:11:20 +0530515/*
516func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530517 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530518 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000519}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530520*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000521
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700522// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000523func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700524 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
525 delete(oo.rxSchedulerMap, tid)
526}
527
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000528// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
529func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
530 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000531
mpagenkoc26d4c02021-05-06 14:27:57 +0000532 if timeout != 0 {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000533 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000534 oo.mutexRxSchedMap.Lock()
535 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000536 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000537 oo.mutexRxSchedMap.Unlock()
538 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000539
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000540 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000541 //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 +0000542 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000543 txFrame,
544 timeout,
545 retry,
546 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000547 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000548 receiveCallbackPair,
549 nil,
kesavand011d5162021-11-25 19:21:06 +0530550 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000551 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000552 oo.mutexMonReq.Lock()
553 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000554 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000555 // do not call processRequestMonitoring in background here to ensure correct sequencing
556 // of requested messages into txQueue (especially for non-response-supervised messages)
557 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000558 return nil
559 }
560 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000561 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000562 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000563}
564
Holger Hildebrandt34555512021-10-01 16:26:59 +0000565func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
566 // Avoid accessing the txQueues from parallel send routines to block
567 // parallel omci send requests at least until SendIAP is 'committed'.
568 // To guarantee window size 1 for one ONU it would be necessary to wait
569 // for the corresponding response too (t.b.d.).
570 oo.mutexSendQueuedRequests.Lock()
571 defer oo.mutexSendQueuedRequests.Unlock()
572 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
573 logger.Errorw(ctx, "Error during sending high prio requests!",
574 log.Fields{"err": err, "device-id": oo.deviceID})
575 return
576 }
577 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
578 logger.Errorw(ctx, "Error during sending low prio requests!",
579 log.Fields{"err": err, "device-id": oo.deviceID})
580 return
581 }
582}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000583
Holger Hildebrandt34555512021-10-01 16:26:59 +0000584func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
585 oo.mutexHighPrioTxQueue.Lock()
586 defer oo.mutexHighPrioTxQueue.Unlock()
587 for oo.highPrioTxQueue.Len() > 0 {
588 queueElement := oo.highPrioTxQueue.Front() // First element
589 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
590 return err
mpagenko80622a52021-02-09 16:53:23 +0000591 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000592 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
593 }
594 return nil
595}
596
597func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
598 oo.mutexLowPrioTxQueue.Lock()
599 for oo.lowPrioTxQueue.Len() > 0 {
600 queueElement := oo.lowPrioTxQueue.Front() // First element
kesavand011d5162021-11-25 19:21:06 +0530601 // check if the element is for onu sw section
602 aOmciTxReq := queueElement.Value.(OmciTransferStructure)
603 if aOmciTxReq.OnuSwWindow != nil {
604 if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil {
605 oo.mutexLowPrioTxQueue.Unlock()
606 return err
607 }
608 } else {
609 err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure))
610 if err != nil {
611 oo.mutexLowPrioTxQueue.Unlock()
612 return err
613 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200614 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000615 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
616 // Interrupt the sending of low priority requests to process any high priority requests
617 // that may have arrived in the meantime
618 oo.mutexLowPrioTxQueue.Unlock()
619 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
620 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000621 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000622 oo.mutexLowPrioTxQueue.Lock()
623 }
624
625 oo.mutexLowPrioTxQueue.Unlock()
626 return nil
627}
628
629func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
630 if omciTxRequest.withFramePrint {
631 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
632 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
633 "device-id": oo.deviceID,
634 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
635 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
636 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
637 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400638 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000639 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
640 ChildDeviceId: oo.deviceID,
641 Message: omciTxRequest.txFrame,
642 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
643 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
644 }
645 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
646 if sendErr != nil {
Holger Hildebrandtabfef032022-02-25 12:40:20 +0000647 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 +0000648 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000649 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000650 return nil
651}
652
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000653// GetNextTid - TODO: add comment
654func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000655 var next uint16
656 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000657 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000658 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530659 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000660 if oo.hpTid < 0x8000 {
661 oo.hpTid = 0x8000
662 }
mpagenko900ee4b2020-10-12 11:56:34 +0000663 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000664 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000665 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000666 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530667 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000668 if oo.tid >= 0x8000 {
669 oo.tid = 1
670 }
mpagenko900ee4b2020-10-12 11:56:34 +0000671 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000672 }
673 return next
674}
675
kesavand011d5162021-11-25 19:21:06 +0530676//GetOnuSwSecNextTid get the next low prio tid for the onu sw sections
677//onu sw sections uses only low priority tids
678//The mutexTid lock should be taken prior to using this function
679func (oo *OmciCC) GetOnuSwSecNextTid() uint16 {
680 next := oo.tid
681 oo.tid++
682 if oo.tid >= 0x8000 {
683 oo.tid = 1
684 }
685 return next
686}
687
688//GetOnuSwSecLastTid gets the last allocated tid
689//The mutexTid lock should be taken prior to using this function
690func (oo *OmciCC) GetOnuSwSecLastTid() uint16 {
691 next := oo.tid
692 lastAllocatedTid := next - 1
693 return lastAllocatedTid
694}
695
696//LockMutexTID locks mutexTid
697func (oo *OmciCC) LockMutexTID() {
698 oo.mutexTid.Lock()
699}
700
701//UnLockMutexTID unlocks mutexTid
702func (oo *OmciCC) UnLockMutexTID() {
703 oo.mutexTid.Unlock()
704}
705
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000706// ###################################################################################
707// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000708
709// Serialize - TODO: add comment
710func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000711 omciLayer := &omci.OMCI{
712 TransactionID: tid,
713 MessageType: msgType,
714 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000715 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000716}
717
dbainbri4d3a0dc2020-12-02 00:33:42 +0000718func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000719 var options gopacket.SerializeOptions
720 options.FixLengths = true
721
722 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530723 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000724 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000725 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000726 return nil, err
727 }
728 return buffer.Bytes(), nil
729}
730
Himani Chawla4d908332020-08-31 12:30:20 +0530731/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000732func hexEncode(omciPkt []byte) ([]byte, error) {
733 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
734 hex.Encode(dst, omciPkt)
735 return dst, nil
736}
Himani Chawla4d908332020-08-31 12:30:20 +0530737*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000738
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000739//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000740func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000741
dbainbri4d3a0dc2020-12-02 00:33:42 +0000742 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000743 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000744
745 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000746 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000747 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200748 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000749 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000750 oo.mutexMonReq.RLock()
751 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000752 //implement non-blocking channel send to avoid blocking on mutexMonReq later
753 select {
754 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
755 default:
756 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
757 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
758 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000759 } else {
760 logger.Infow(ctx, "reqMon: map entry does not exist!",
761 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
762 }
763 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000764
765 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
766 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000767 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000768 Type: OMCI,
769 Data: OmciMessage{
770 OmciMsg: omciMsg,
771 OmciPacket: packet,
772 },
773 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000774 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000775 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000776
777 return nil
778}
779
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000780// SendMibReset sends MibResetRequest
781func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000782
dbainbri4d3a0dc2020-12-02 00:33:42 +0000783 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000784 request := &omci.MibResetRequest{
785 MeBasePacket: omci.MeBasePacket{
786 EntityClass: me.OnuDataClassID,
787 },
788 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000789 tid := oo.GetNextTid(highPrio)
790 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000791 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000792 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000793 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000794 return err
795 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000796 omciRxCallbackPair := CallbackPair{
797 CbKey: tid,
798 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000799 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000800 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000801}
802
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000803// SendReboot sends RebootRequest
804func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
805 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300806 request := &omci.RebootRequest{
807 MeBasePacket: omci.MeBasePacket{
808 EntityClass: me.OnuGClassID,
809 },
810 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000811 tid := oo.GetNextTid(highPrio)
812 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300813 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000814 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000815 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300816 return err
817 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000818 omciRxCallbackPair := CallbackPair{
819 CbKey: tid,
820 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300821 }
822
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000823 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300824 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000825 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000826 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300827 return err
828 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000829 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300830 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000831 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200832 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300833 return err
834 }
835 return nil
836}
837
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000838// SendMibUpload sends MibUploadRequest
839func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000840 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000841 request := &omci.MibUploadRequest{
842 MeBasePacket: omci.MeBasePacket{
843 EntityClass: me.OnuDataClassID,
844 },
845 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000846 tid := oo.GetNextTid(highPrio)
847 pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000848 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000849 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000850 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000851 return err
852 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000853 oo.UploadSequNo = 0
854 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000855
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000856 omciRxCallbackPair := CallbackPair{
857 CbKey: tid,
858 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000859 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000860 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000861}
862
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000863// SendMibUploadNext sends MibUploadNextRequest
864func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
865 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000866 request := &omci.MibUploadNextRequest{
867 MeBasePacket: omci.MeBasePacket{
868 EntityClass: me.OnuDataClassID,
869 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000870 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000871 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000872 tid := oo.GetNextTid(highPrio)
873 pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000874 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000875 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000876 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000877 return err
878 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000879 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000880
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000881 omciRxCallbackPair := CallbackPair{
882 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000883 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
884 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
885 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000886 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000887 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000888 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000889}
890
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000891// SendGetAllAlarm gets all alarm ME instances
892func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530893 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
894 request := &omci.GetAllAlarmsRequest{
895 MeBasePacket: omci.MeBasePacket{
896 EntityClass: me.OnuDataClassID,
897 },
898 AlarmRetrievalMode: byte(alarmRetreivalMode),
899 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000900 tid := oo.GetNextTid(highPrio)
901 pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530902 if err != nil {
903 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
904 "Err": err, "device-id": oo.deviceID})
905 return err
906 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000907 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530908
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000909 omciRxCallbackPair := CallbackPair{
910 CbKey: tid,
911 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530912 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000913 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530914}
915
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000916// SendGetAllAlarmNext gets next alarm ME instance
917func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
918 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
919 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +0530920 "alarmUploadSeqNo": alarmUploadSeqNo})
921 request := &omci.GetAllAlarmsNextRequest{
922 MeBasePacket: omci.MeBasePacket{
923 EntityClass: me.OnuDataClassID,
924 },
925 CommandSequenceNumber: alarmUploadSeqNo,
926 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000927 tid := oo.GetNextTid(highPrio)
928 pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530929 if err != nil {
930 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
931 "Err": err, "device-id": oo.deviceID})
932 return err
933 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000934 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530935
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000936 omciRxCallbackPair := CallbackPair{
937 CbKey: tid,
938 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530939 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000940 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530941}
942
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000943// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
944func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
945 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000946 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000947 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000948
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000950 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +0000951 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000952 }
953 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
954 if omciErr.GetError() == nil {
955 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +0000956 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000957 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000958 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000959 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300960 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000961 }
962
dbainbri4d3a0dc2020-12-02 00:33:42 +0000963 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000964 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000965 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000966 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300967 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000968 }
969
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000970 omciRxCallbackPair := CallbackPair{
971 CbKey: tid,
972 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000973 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000974 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000975 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000976 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000977 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300978 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000979 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000980 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300981 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000982 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000983 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000984 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300985 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000986}
987
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000988// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000989// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000990func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
991 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000992 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000993 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000994
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000995 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
996 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000997 // By now we just use fix values to fire - this is anyway what the python adapter does
998 // read ONU-2G from DB ???? //TODO!!!
999 meParams := me.ParamData{
1000 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001001 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001002 }
1003 meInstance, omciErr := me.NewOnu2G(meParams)
1004 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001005 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001006 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001007 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001008 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001009 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001010 }
1011
dbainbri4d3a0dc2020-12-02 00:33:42 +00001012 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001013 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001014 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001015 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001016 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001017 }
1018
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001019 omciRxCallbackPair := CallbackPair{
1020 CbKey: tid,
1021 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001022 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001023 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001024 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001025 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001026 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001027 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001028 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001029 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001030 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001031 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001032 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001033 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001034 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001035}
1036
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001037// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1038func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1039 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1040 tid := oo.GetNextTid(highPrio)
1041 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001042 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001043 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001044
1045 meParams := me.ParamData{
1046 EntityID: instID,
1047 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001048 me.MacBridgeServiceProfile_Priority: 0x8000,
1049 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1050 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1051 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1052 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001053 },
1054 }
1055
1056 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1057 if omciErr.GetError() == nil {
1058 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001059 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1060 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001061 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001062 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001063 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001064 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001065 }
1066
dbainbri4d3a0dc2020-12-02 00:33:42 +00001067 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001068 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001069 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001070 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001071 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001072 }
1073
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001074 omciRxCallbackPair := CallbackPair{
1075 CbKey: tid,
1076 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001077 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001078 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001079 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001080 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001081 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001082 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001083 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001084 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001085 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001086 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001087 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001088 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001089 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001090}
1091
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001092// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1093func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1094 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1095 tid := oo.GetNextTid(highPrio)
1096 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001097 if idErr != nil {
1098 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1099 "Err": idErr, "device-id": oo.deviceID})
1100 return nil, idErr
1101 }
1102 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001103 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001104
1105 meParams := me.ParamData{
1106 EntityID: instID,
1107 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001108 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1109 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1110 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1111 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001112 },
1113 }
1114 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1115 if omciErr.GetError() == nil {
1116 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001117 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1118 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001119 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001120 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001121 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001122 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001123 }
1124
dbainbri4d3a0dc2020-12-02 00:33:42 +00001125 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001126 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001127 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001128 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001129 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001130 }
1131
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001132 omciRxCallbackPair := CallbackPair{
1133 CbKey: tid,
1134 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001135 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001136 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001137 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001138 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001139 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001140 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001141 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001142 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001143 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001144 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001145 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001146 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001147 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001148}
1149
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001150// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1151func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1152 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1153 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001154 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001155 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001156 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001157 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001158
1159 // compare python adapter code WA VOL-1311: this is not done here!
1160 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1161 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1162 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001163 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001164 assType = uint8(10) // for VEIP
1165 }
1166 meParams := me.ParamData{
1167 EntityID: instID,
1168 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001169 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1170 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001171 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001172 },
1173 }
1174 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1175 if omciErr.GetError() == nil {
1176 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001177 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1178 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001179 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001180 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001181 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001182 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001183 }
1184
dbainbri4d3a0dc2020-12-02 00:33:42 +00001185 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001187 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001188 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001189 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001190 }
1191
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001192 omciRxCallbackPair := CallbackPair{
1193 CbKey: tid,
1194 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001195 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001196 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001197 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001199 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001200 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001201 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001202 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001203 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001204 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001205 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001206 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001207 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001208}
1209
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001210// SendSetOnuGLS sets OnuG ME instance
1211func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001212 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001213 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001214 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001215 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001216
1217 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1218 meParams := me.ParamData{
1219 EntityID: 0,
1220 Attributes: requestedAttributes,
1221 }
1222 meInstance, omciErr := me.NewOnuG(meParams)
1223 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001224 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001225 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001226 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", 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 Hildebrandtccd390c2020-05-29 13:49:04 +00001229 }
1230
dbainbri4d3a0dc2020-12-02 00:33:42 +00001231 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001232 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001233 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001234 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001235 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001236 }
1237
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001238 omciRxCallbackPair := CallbackPair{
1239 CbKey: tid,
1240 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001241 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001242 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001243 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001245 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001246 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001247 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001248 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001249 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001251 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001252 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001253 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001254}
1255
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001256// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1257func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001258 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001259 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001260 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001261 "SequNo": strconv.FormatInt(int64(tid), 16)})
1262
1263 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1264 meParams := me.ParamData{
1265 EntityID: aInstNo,
1266 Attributes: requestedAttributes,
1267 }
1268 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1269 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001270 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001271 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001272 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001273 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001274 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001275 }
1276
dbainbri4d3a0dc2020-12-02 00:33:42 +00001277 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001278 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001279 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001280 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001281 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001282 }
1283
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001284 omciRxCallbackPair := CallbackPair{
1285 CbKey: tid,
1286 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001287 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001288 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001289 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001291 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001292 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001293 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001294 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001295 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001296 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001297 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001298 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001299 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001300}
1301
1302/* UniG obsolete by now, left here in case it should be needed once again
1303 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301304func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001305 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001306 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001307 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001308 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001309
1310 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1311 meParams := me.ParamData{
1312 EntityID: aInstNo,
1313 Attributes: requestedAttributes,
1314 }
1315 meInstance, omciErr := me.NewUniG(meParams)
1316 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001317 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001318 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001319 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001320 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001321 return nil
1322 }
1323
1324 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1325 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001326 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001327 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001328 return nil
1329 }
1330
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001331 omciRxCallbackPair := CallbackPair{
1332 CbKey: tid,
1333 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001334 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001335 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001336 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001337 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001338 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001339 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001340 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001341 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001342 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001343 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001344 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001345 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001346 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001347}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001348*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001349
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001350// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1351func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001352 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001353 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001354 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001355 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001356
1357 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1358 meParams := me.ParamData{
1359 EntityID: aInstNo,
1360 Attributes: requestedAttributes,
1361 }
1362 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1363 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001364 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001365 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001366 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001367 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001368 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001369 }
1370
dbainbri4d3a0dc2020-12-02 00:33:42 +00001371 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001372 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001373 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001374 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001375 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001376 }
1377
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001378 omciRxCallbackPair := CallbackPair{
1379 CbKey: tid,
1380 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001381 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001382 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001383 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001384 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001385 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001386 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001387 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001388 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001389 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001390 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001391 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001392 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001393 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001394}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001395
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001396// SendGetMe gets ME instance
1397func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001398 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001399
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001400 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001401 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001402 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001403
1404 meParams := me.ParamData{
1405 EntityID: entityID,
1406 Attributes: requestedAttributes,
1407 }
1408 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1409 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301410 meClassIDName := meInstance.GetName()
mpagenko836a1fd2021-11-01 16:12:42 +00001411 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001412 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001413 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 +03001414 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001415 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001416 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001417 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001418 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001419 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001420 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001421 omciRxCallbackPair := CallbackPair{
1422 CbKey: tid,
1423 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001424 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001425 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001426 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001427 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001428 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001429 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001431 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001432 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001434 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001435}
1436
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001437// SendGetMeWithAttributeMask gets ME instance with attribute mask
1438func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301439 timeout int, highPrio bool, rxChan chan Message) error {
1440
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001441 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301442 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1443 "SequNo": strconv.FormatInt(int64(tid), 16)})
1444
1445 request := &omci.GetRequest{
1446 MeBasePacket: omci.MeBasePacket{
1447 EntityInstance: entityID,
1448 EntityClass: classID,
1449 },
1450 AttributeMask: requestedAttributesMask,
1451 }
1452
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001453 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301454 if err != nil {
1455 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1456 return err
1457 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001458 omciRxCallbackPair := CallbackPair{
1459 CbKey: tid,
1460 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301461 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001462 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301463 if err != nil {
1464 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1465 return err
1466 }
1467 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1468 return nil
1469}
1470
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001471// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1472func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001473 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001474 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001475 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001476 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1477
1478 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001479 EntityID: aInstID,
1480 Attributes: me.AttributeValueMap{
1481 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001482 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1483 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1484 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1485 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1486 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1487 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1488 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1489 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1490 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001491 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001492 }
1493 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1494 if omciErr.GetError() == nil {
1495 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001496 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1497 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001498 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001499 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001500 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001501 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001502 }
1503
dbainbri4d3a0dc2020-12-02 00:33:42 +00001504 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001505 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001506 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001507 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001508 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001509 }
1510
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001511 omciRxCallbackPair := CallbackPair{
1512 CbKey: tid,
1513 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001514 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001515 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001519 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001520 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001521 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001522 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001523 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001524 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001525 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001526 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001527}
1528
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001529// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1530func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001531 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001532 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001533 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001534 "SequNo": strconv.FormatInt(int64(tid), 16),
1535 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1536
1537 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1538 if omciErr.GetError() == nil {
1539 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001540 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1541 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001542 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001543 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001544 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001545 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001546 }
1547
dbainbri4d3a0dc2020-12-02 00:33:42 +00001548 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001549 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001550 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001551 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001552 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001553 }
1554
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001555 omciRxCallbackPair := CallbackPair{
1556 CbKey: tid,
1557 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001558 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001559 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001560 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001561 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001562 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001563 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001564 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001565 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001566 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001567 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001568 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001569 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001570 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001571}
1572
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001573// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1574func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001575 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001576 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001577 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001578 "SequNo": strconv.FormatInt(int64(tid), 16),
1579 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1580
1581 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1582 if omciErr.GetError() == nil {
1583 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001584 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1585 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001586 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001587 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001588 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001589 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001590 }
1591
dbainbri4d3a0dc2020-12-02 00:33:42 +00001592 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001593 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001594 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001595 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001596 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001597 }
1598
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001599 omciRxCallbackPair := CallbackPair{
1600 CbKey: tid,
1601 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001602 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001603 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001604 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001605 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001606 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001607 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001608 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001609 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001610 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001611 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001612 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001613 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001614 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001615}
1616
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001617// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1618func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1619 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001620 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1621 "SequNo": strconv.FormatInt(int64(tid), 16),
1622 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1623
1624 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1625 if omciErr.GetError() == nil {
1626 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001627 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1628 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001629 if err != nil {
1630 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1631 "Err": err, "device-id": oo.deviceID})
1632 return nil, err
1633 }
1634
1635 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1636 if err != nil {
1637 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1638 "Err": err, "device-id": oo.deviceID})
1639 return nil, err
1640 }
1641
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001642 omciRxCallbackPair := CallbackPair{
1643 CbKey: tid,
1644 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001645 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001646 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001647 if err != nil {
1648 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1649 "Err": err, "device-id": oo.deviceID})
1650 return nil, err
1651 }
1652 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1653 return meInstance, nil
1654 }
1655 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1656 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1657 return nil, omciErr.GetError()
1658}
1659
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001660// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1661func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001662 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001663 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001664 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001665 "SequNo": strconv.FormatInt(int64(tid), 16),
1666 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1667
1668 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1669 if omciErr.GetError() == nil {
1670 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001671 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1672 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001673 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001674 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001675 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001676 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001677 }
1678
dbainbri4d3a0dc2020-12-02 00:33:42 +00001679 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001680 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001681 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001682 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001683 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001684 }
1685
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001686 omciRxCallbackPair := CallbackPair{
1687 CbKey: tid,
1688 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001689 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001690 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001691 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001692 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001693 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001694 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001695 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001696 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001697 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001698 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001699 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001700 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001701 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001702}
1703
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001704// SendSetTcontVar sets TCont ME instance
1705func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001706 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001707 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001708 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001709 "SequNo": strconv.FormatInt(int64(tid), 16),
1710 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1711
1712 meInstance, omciErr := me.NewTCont(params[0])
1713 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001714 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001715 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001716 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001717 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001718 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001719 }
1720
dbainbri4d3a0dc2020-12-02 00:33:42 +00001721 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001722 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001723 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001724 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001725 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001726 }
1727
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001728 omciRxCallbackPair := CallbackPair{
1729 CbKey: tid,
1730 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001731 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001732 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001733 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001734 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001735 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001736 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001737 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001738 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001739 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001740 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001741 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001742 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001743 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001744}
1745
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001746// SendSetPrioQueueVar sets PriorityQueue ME instance
1747func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001748 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001749 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001750 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001751 "SequNo": strconv.FormatInt(int64(tid), 16),
1752 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1753
1754 meInstance, omciErr := me.NewPriorityQueue(params[0])
1755 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001756 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001757 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001758 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001759 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001760 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001761 }
1762
dbainbri4d3a0dc2020-12-02 00:33:42 +00001763 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001764 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001765 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001766 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001767 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001768 }
1769
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001770 omciRxCallbackPair := CallbackPair{
1771 CbKey: tid,
1772 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001773 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001774 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001775 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001776 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001777 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001778 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001779 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001780 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001781 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001782 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001783 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001784 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001785 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001786}
1787
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001788// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1789func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001790 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001791 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001792 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001793 "SequNo": strconv.FormatInt(int64(tid), 16),
1794 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1795
1796 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1797 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001798 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001799 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001800 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001801 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001802 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001803 }
1804
dbainbri4d3a0dc2020-12-02 00:33:42 +00001805 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001806 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001807 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001808 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001809 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001810 }
1811
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001812 omciRxCallbackPair := CallbackPair{
1813 CbKey: tid,
1814 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001815 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001816 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001817 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001818 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001819 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001820 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001821 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001822 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001823 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001824 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001825 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001826 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001827 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001828}
mpagenkodff5dda2020-08-28 11:52:01 +00001829
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001830// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1831func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001832 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001833 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001834 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001835 "SequNo": strconv.FormatInt(int64(tid), 16),
1836 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1837
1838 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1839 if omciErr.GetError() == nil {
1840 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001841 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1842 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001843 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001844 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001845 "Err": err, "device-id": oo.deviceID})
1846 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1847 // return (dual format) error code that can be used at caller for immediate error treatment
1848 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001849 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001850 }
1851
dbainbri4d3a0dc2020-12-02 00:33:42 +00001852 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001853 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001854 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001855 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001856 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001857 }
1858
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001859 omciRxCallbackPair := CallbackPair{
1860 CbKey: tid,
1861 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001862 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001863 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001864 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001865 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001866 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001867 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001868 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001869 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001870 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001871 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001872 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001873 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001874 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001875}
1876
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001877// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001878func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001879 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001880 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001881 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001882 "SequNo": strconv.FormatInt(int64(tid), 16),
1883 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1884
1885 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1886 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001887 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1888 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001889 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001890 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001891 "Err": err, "device-id": oo.deviceID})
1892 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1893 // return (dual format) error code that can be used at caller for immediate error treatment
1894 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001895 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001896 }
1897
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001899 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001900 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001901 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001902 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001903 }
1904
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001905 omciRxCallbackPair := CallbackPair{
1906 CbKey: tid,
1907 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001908 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001909 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001910 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001911 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001912 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001913 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001914 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001915 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001916 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001917 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001918 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001919 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001920 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001921}
1922
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001923// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
1924func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001925 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001926 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001927 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001928 "SequNo": strconv.FormatInt(int64(tid), 16),
1929 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1930
1931 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1932 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001933 //EnhancedMode not yet supported, used with default options
1934 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1935 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001936 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001937 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001938 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001939 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001940 }
1941
dbainbri4d3a0dc2020-12-02 00:33:42 +00001942 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001943 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001944 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001945 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001946 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001947 }
1948
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001949 omciRxCallbackPair := CallbackPair{
1950 CbKey: tid,
1951 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001952 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001953 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001954 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001955 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001956 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001957 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001958 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001959 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001960 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001961 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001962 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001963 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001964 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001965}
1966
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001967// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
1968func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001969 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001970 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001971 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001972 "SequNo": strconv.FormatInt(int64(tid), 16),
1973 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1974
1975 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1976 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001977 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001978 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001979 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001980 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001981 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001982 }
1983
dbainbri4d3a0dc2020-12-02 00:33:42 +00001984 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001985 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001986 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001987 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001988 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001989 }
1990
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001991 omciRxCallbackPair := CallbackPair{
1992 CbKey: tid,
1993 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001994 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001995 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001996 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001997 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001998 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001999 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00002000 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002001 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002002 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00002003 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002004 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00002005 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002006 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00002007}
mpagenko01e726e2020-10-23 09:45:29 +00002008
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002009// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
2010func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002011 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002012 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002013 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002014 "SequNo": strconv.FormatInt(int64(tid), 16),
2015 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2016
2017 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2018 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002019 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002020 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002021 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002022 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002023 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002024 }
2025
dbainbri4d3a0dc2020-12-02 00:33:42 +00002026 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002027 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002028 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002029 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002030 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002031 }
2032
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002033 omciRxCallbackPair := CallbackPair{
2034 CbKey: tid,
2035 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002036 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002037 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002038 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002039 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002040 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002041 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002042 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002043 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002044 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002045 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002046 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002047 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002048 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002049}
2050
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002051// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2052func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002053 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002054 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002055 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002056 "SequNo": strconv.FormatInt(int64(tid), 16),
2057 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2058
2059 meParams := me.ParamData{EntityID: aInstID}
2060 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2061 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002062 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2063 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002064 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002065 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002066 "Err": err, "device-id": oo.deviceID})
2067 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2068 // return (dual format) error code that can be used at caller for immediate error treatment
2069 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002070 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002071 }
2072
dbainbri4d3a0dc2020-12-02 00:33:42 +00002073 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002074 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002075 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002076 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002077 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002078 }
2079
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002080 omciRxCallbackPair := CallbackPair{
2081 CbKey: tid,
2082 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002083 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002084 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002085 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002086 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002087 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002088 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002089 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002090 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002091 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002092 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002093 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002094 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002095 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002096}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002097
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002098// SendCreateTDVar creates TrafficDescriptor ME instance
2099func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2100 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002101 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2102 "SequNo": strconv.FormatInt(int64(tid), 16),
2103 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2104 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2105 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002106 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002107 if err != nil {
2108 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002109 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002110 }
2111 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2112 if err != nil {
2113 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002114 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002115 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002116 omciRxCallbackPair := CallbackPair{
2117 CbKey: tid,
2118 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002119 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002120 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002121 if err != nil {
2122 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002123 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002124 }
2125 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002126 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002127 }
2128 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002129 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002130}
2131
2132// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002133func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002134 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002135 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002136 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2137 "SequNo": strconv.FormatInt(int64(tid), 16),
2138 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2139
2140 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2141 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002142 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002143 if err != nil {
2144 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002145 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002146 }
2147 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2148 if err != nil {
2149 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002150 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002151 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002152 omciRxCallbackPair := CallbackPair{
2153 CbKey: tid,
2154 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002155 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002156 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002157 if err != nil {
2158 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002159 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002160 }
2161 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002162 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002163 }
2164 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002165 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002166
2167}
2168
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002169// SendDeleteTD - TODO: add comment
2170func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002171 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002172 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002173 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2174 "SequNo": strconv.FormatInt(int64(tid), 16),
2175 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2176
2177 meParams := me.ParamData{EntityID: aInstID}
2178 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2179 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002180 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002181 if err != nil {
2182 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002183 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002184 }
2185 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2186 if err != nil {
2187 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002188 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002189 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002190 omciRxCallbackPair := CallbackPair{
2191 CbKey: tid,
2192 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002193 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002194 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002195 if err != nil {
2196 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002197 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002198 }
2199 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002200 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002201 }
2202 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002203 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002204
2205}
2206
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002207// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2208func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002209 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002210 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002211 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002212 "SequNo": strconv.FormatInt(int64(tid), 16),
2213 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2214
2215 meParams := me.ParamData{EntityID: aInstID}
2216 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2217 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002218 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2219 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002220 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002221 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002222 "Err": err, "device-id": oo.deviceID})
2223 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2224 // return (dual format) error code that can be used at caller for immediate error treatment
2225 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002226 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002227 }
2228
dbainbri4d3a0dc2020-12-02 00:33:42 +00002229 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002230 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002231 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002232 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002233 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002234 }
2235
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002236 omciRxCallbackPair := CallbackPair{
2237 CbKey: tid,
2238 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002239 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002240 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002241 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002242 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002243 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002244 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002245 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002246 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002247 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002248 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002249 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002250 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002251 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002252}
2253
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002254// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2255func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002256 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002257 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002258 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002259 "SequNo": strconv.FormatInt(int64(tid), 16),
2260 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2261
2262 meParams := me.ParamData{EntityID: aInstID}
2263 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2264 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002265 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2266 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002267 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002268 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002269 "Err": err, "device-id": oo.deviceID})
2270 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2271 // return (dual format) error code that can be used at caller for immediate error treatment
2272 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002273 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002274 }
2275
dbainbri4d3a0dc2020-12-02 00:33:42 +00002276 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002277 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002278 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002279 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002280 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002281 }
2282
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002283 omciRxCallbackPair := CallbackPair{
2284 CbKey: tid,
2285 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002286 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002287 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002288 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002289 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002290 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002291 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002292 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002293 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002294 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002295 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002296 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002297 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002298 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002299}
2300
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002301// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2302func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002303 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002304 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002305 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002306 "SequNo": strconv.FormatInt(int64(tid), 16),
2307 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2308
2309 meParams := me.ParamData{EntityID: aInstID}
2310 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2311 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002312 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2313 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002314 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002315 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002316 "Err": err, "device-id": oo.deviceID})
2317 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2318 // return (dual format) error code that can be used at caller for immediate error treatment
2319 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002320 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002321 }
2322
dbainbri4d3a0dc2020-12-02 00:33:42 +00002323 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002324 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002325 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002326 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002327 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002328 }
2329
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002330 omciRxCallbackPair := CallbackPair{
2331 CbKey: tid,
2332 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002333 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002334 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002335 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002337 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002338 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002339 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002340 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002341 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002342 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002343 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002344 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002345 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002346}
2347
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002348// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2349func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002350 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002351 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002352 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002353 "SequNo": strconv.FormatInt(int64(tid), 16),
2354 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2355
2356 meParams := me.ParamData{EntityID: aInstID}
2357 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2358 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002359 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2360 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002361 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002362 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002363 "Err": err, "device-id": oo.deviceID})
2364 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2365 // return (dual format) error code that can be used at caller for immediate error treatment
2366 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002367 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002368 }
2369
dbainbri4d3a0dc2020-12-02 00:33:42 +00002370 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002371 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002372 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002373 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002374 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002375 }
2376
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002377 omciRxCallbackPair := CallbackPair{
2378 CbKey: tid,
2379 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002380 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002381 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002382 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002383 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002384 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002385 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002386 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002387 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002388 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002389 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002390 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002391 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002392 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002393}
2394
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002395// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2396func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002397 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002398 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002399 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002400 "SequNo": strconv.FormatInt(int64(tid), 16),
2401 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2402
2403 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2404 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002405 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2406 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002407 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002408 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002409 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002410 }
2411
dbainbri4d3a0dc2020-12-02 00:33:42 +00002412 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002413 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002414 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002415 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002416 }
2417
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002418 omciRxCallbackPair := CallbackPair{CbKey: tid,
2419 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002420 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002421 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002422 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002423 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002424 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002425 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002426 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002427 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002428 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002429 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002430 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002431 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002432}
2433
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002434// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2435func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002436 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002437 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002438 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002439 "SequNo": strconv.FormatInt(int64(tid), 16),
2440 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2441
2442 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2443 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002444 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2445 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002446 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002447 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002448 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002449 }
2450
dbainbri4d3a0dc2020-12-02 00:33:42 +00002451 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002452 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002453 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002454 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002455 }
2456
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002457 omciRxCallbackPair := CallbackPair{CbKey: tid,
2458 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002459 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002460 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002461 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002462 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002463 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002464 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002465 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002466 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002467 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002468 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002469 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002470 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002471}
2472
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002473// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2474func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002475 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002476 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002477 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002478 "SequNo": strconv.FormatInt(int64(tid), 16),
2479 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2480
2481 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2482 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002483 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2484 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002485 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002486 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002487 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002488 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002489 }
2490
dbainbri4d3a0dc2020-12-02 00:33:42 +00002491 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002492 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002493 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002494 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002495 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002496 }
2497
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002498 omciRxCallbackPair := CallbackPair{CbKey: tid,
2499 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002500 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002501 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002502 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002503 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002504 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002505 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002506 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002507 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002508 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002509 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002510 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002511 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002512 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002513}
2514
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002515// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2516func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002517 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002518 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002519 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002520 "SequNo": strconv.FormatInt(int64(tid), 16),
2521 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2522
2523 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2524 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002525 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2526 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002527 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002528 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002529 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002530 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002531 }
2532
dbainbri4d3a0dc2020-12-02 00:33:42 +00002533 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002534 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002535 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002536 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002537 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002538 }
2539
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002540 omciRxCallbackPair := CallbackPair{CbKey: tid,
2541 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002542 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002543 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002544 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002545 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002546 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002547 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002548 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002549 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002550 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002551 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002552 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002553 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002554 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002555}
2556
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002557// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2558func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002559 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002560 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002561 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002562 "SequNo": strconv.FormatInt(int64(tid), 16),
2563 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2564
2565 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2566 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002567 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2568 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002569 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002570 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002571 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002572 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002573 }
2574
dbainbri4d3a0dc2020-12-02 00:33:42 +00002575 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002576 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002577 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002578 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002579 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002580 }
2581
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002582 omciRxCallbackPair := CallbackPair{CbKey: tid,
2583 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002584 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002585 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002586 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002587 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002588 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002589 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002590 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002591 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002592 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002593 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002594 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002595 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002596 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002597}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002598
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002599// SendCreateVoipVoiceCTP nolint: unused
2600func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2601 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2602 tid := oo.GetNextTid(highPrio)
2603 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2604 "SequNo": strconv.FormatInt(int64(tid), 16),
2605 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2606
2607 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2608 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002609 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2610 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002611 if err != nil {
2612 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2613 "device-id": oo.deviceID})
2614 return nil, err
2615 }
2616
2617 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2618 if err != nil {
2619 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2620 "device-id": oo.deviceID})
2621 return nil, err
2622 }
2623
2624 omciRxCallbackPair := CallbackPair{CbKey: tid,
2625 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2626 }
2627 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2628 if err != nil {
2629 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2630 "device-id": oo.deviceID})
2631 return nil, err
2632 }
2633 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2634 return meInstance, nil
2635 }
2636 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2637 "device-id": oo.deviceID})
2638 return nil, omciErr.GetError()
2639}
2640
2641// SendSetVoipVoiceCTP nolint: unused
2642func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2643 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2644 tid := oo.GetNextTid(highPrio)
2645 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2646 "SequNo": strconv.FormatInt(int64(tid), 16),
2647 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2648
2649 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2650 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002651 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2652 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002653 if err != nil {
2654 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2655 "device-id": oo.deviceID})
2656 return nil, err
2657 }
2658
2659 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2660 if err != nil {
2661 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2662 "device-id": oo.deviceID})
2663 return nil, err
2664 }
2665
2666 omciRxCallbackPair := CallbackPair{CbKey: tid,
2667 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2668 }
2669 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2670 if err != nil {
2671 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2672 "device-id": oo.deviceID})
2673 return nil, err
2674 }
2675 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2676 return meInstance, nil
2677 }
2678 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2679 "device-id": oo.deviceID})
2680 return nil, omciErr.GetError()
2681}
2682
2683// SendDeleteVoipVoiceCTP nolint: unused
2684func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2685 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2686 tid := oo.GetNextTid(highPrio)
2687 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2688 "SequNo": strconv.FormatInt(int64(tid), 16),
2689 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2690
2691 meParams := me.ParamData{EntityID: aInstID}
2692 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2693 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002694 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2695 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002696 if err != nil {
2697 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2698 "Err": err, "device-id": oo.deviceID})
2699 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2700 // return (dual format) error code that can be used at caller for immediate error treatment
2701 // (relevant to all used sendXX() methods and their error conditions)
2702 return nil, err
2703 }
2704
2705 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2706 if err != nil {
2707 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2708 "Err": err, "device-id": oo.deviceID})
2709 return nil, err
2710 }
2711
2712 omciRxCallbackPair := CallbackPair{
2713 CbKey: tid,
2714 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2715 }
2716 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2717 if err != nil {
2718 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2719 "Err": err, "device-id": oo.deviceID})
2720 return nil, err
2721 }
2722 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2723 return meInstance, nil
2724 }
2725 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2726 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2727 return nil, omciErr.GetError()
2728}
2729
2730// SendCreateVoipMediaProfile nolint: unused
2731func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2732 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2733 tid := oo.GetNextTid(highPrio)
2734 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2735 "SequNo": strconv.FormatInt(int64(tid), 16),
2736 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2737
2738 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2739 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002740 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2741 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002742 if err != nil {
2743 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2744 "device-id": oo.deviceID})
2745 return nil, err
2746 }
2747
2748 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2749 if err != nil {
2750 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2751 "device-id": oo.deviceID})
2752 return nil, err
2753 }
2754
2755 omciRxCallbackPair := CallbackPair{CbKey: tid,
2756 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2757 }
2758 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2759 if err != nil {
2760 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2761 "device-id": oo.deviceID})
2762 return nil, err
2763 }
2764 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2765 return meInstance, nil
2766 }
2767 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2768 "device-id": oo.deviceID})
2769 return nil, omciErr.GetError()
2770}
2771
2772// SendSetVoipMediaProfile nolint: unused
2773func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2774 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2775 tid := oo.GetNextTid(highPrio)
2776 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2777 "SequNo": strconv.FormatInt(int64(tid), 16),
2778 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2779
2780 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2781 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002782 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2783 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002784 if err != nil {
2785 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2786 "device-id": oo.deviceID})
2787 return nil, err
2788 }
2789
2790 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2791 if err != nil {
2792 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2793 "device-id": oo.deviceID})
2794 return nil, err
2795 }
2796
2797 omciRxCallbackPair := CallbackPair{CbKey: tid,
2798 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2799 }
2800 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2801 if err != nil {
2802 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2803 "device-id": oo.deviceID})
2804 return nil, err
2805 }
2806 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2807 return meInstance, nil
2808 }
2809 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2810 "device-id": oo.deviceID})
2811 return nil, omciErr.GetError()
2812}
2813
2814// SendDeleteVoipMediaProfile nolint: unused
2815func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2816 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2817 tid := oo.GetNextTid(highPrio)
2818 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2819 "SequNo": strconv.FormatInt(int64(tid), 16),
2820 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2821
2822 meParams := me.ParamData{EntityID: aInstID}
2823 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2824 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002825 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2826 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002827 if err != nil {
2828 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2829 "Err": err, "device-id": oo.deviceID})
2830 return nil, err
2831 }
2832
2833 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2834 if err != nil {
2835 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2836 "Err": err, "device-id": oo.deviceID})
2837 return nil, err
2838 }
2839
2840 omciRxCallbackPair := CallbackPair{
2841 CbKey: tid,
2842 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2843 }
2844 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2845 if err != nil {
2846 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2847 "Err": err, "device-id": oo.deviceID})
2848 return nil, err
2849 }
2850 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2851 return meInstance, nil
2852 }
2853 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2854 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2855 return nil, omciErr.GetError()
2856}
2857
2858// SendCreateVoiceServiceProfile nolint: unused
2859func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2860 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2861 tid := oo.GetNextTid(highPrio)
2862 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2863 "SequNo": strconv.FormatInt(int64(tid), 16),
2864 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2865
2866 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2867 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002868 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2869 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002870 if err != nil {
2871 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2872 "device-id": oo.deviceID})
2873 return nil, err
2874 }
2875
2876 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2877 if err != nil {
2878 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2879 "device-id": oo.deviceID})
2880 return nil, err
2881 }
2882
2883 omciRxCallbackPair := CallbackPair{CbKey: tid,
2884 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2885 }
2886 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2887 if err != nil {
2888 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
2889 "device-id": oo.deviceID})
2890 return nil, err
2891 }
2892 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
2893 return meInstance, nil
2894 }
2895 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2896 "device-id": oo.deviceID})
2897 return nil, omciErr.GetError()
2898}
2899
2900// SendSetVoiceServiceProfile nolint: unused
2901func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2902 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2903 tid := oo.GetNextTid(highPrio)
2904 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2905 "SequNo": strconv.FormatInt(int64(tid), 16),
2906 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2907
2908 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2909 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002910 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2911 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002912 if err != nil {
2913 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
2914 "device-id": oo.deviceID})
2915 return nil, err
2916 }
2917
2918 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2919 if err != nil {
2920 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
2921 "device-id": oo.deviceID})
2922 return nil, err
2923 }
2924
2925 omciRxCallbackPair := CallbackPair{CbKey: tid,
2926 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2927 }
2928 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2929 if err != nil {
2930 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
2931 "device-id": oo.deviceID})
2932 return nil, err
2933 }
2934 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
2935 return meInstance, nil
2936 }
2937 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2938 "device-id": oo.deviceID})
2939 return nil, omciErr.GetError()
2940}
2941
2942// SendDeleteVoiceServiceProfile nolint: unused
2943func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2944 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2945 tid := oo.GetNextTid(highPrio)
2946 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2947 "SequNo": strconv.FormatInt(int64(tid), 16),
2948 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2949
2950 meParams := me.ParamData{EntityID: aInstID}
2951 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
2952 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002953 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2954 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002955 if err != nil {
2956 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
2957 "Err": err, "device-id": oo.deviceID})
2958 return nil, err
2959 }
2960
2961 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2962 if err != nil {
2963 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
2964 "Err": err, "device-id": oo.deviceID})
2965 return nil, err
2966 }
2967
2968 omciRxCallbackPair := CallbackPair{
2969 CbKey: tid,
2970 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2971 }
2972 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2973 if err != nil {
2974 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
2975 "Err": err, "device-id": oo.deviceID})
2976 return nil, err
2977 }
2978 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
2979 return meInstance, nil
2980 }
2981 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
2982 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2983 return nil, omciErr.GetError()
2984}
2985
2986// SendCreateSIPUserData nolint: unused
2987func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
2988 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2989 tid := oo.GetNextTid(highPrio)
2990 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
2991 "SequNo": strconv.FormatInt(int64(tid), 16),
2992 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2993
2994 meInstance, omciErr := me.NewSipUserData(params[0])
2995 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002996 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2997 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002998 if err != nil {
2999 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
3000 "device-id": oo.deviceID})
3001 return nil, err
3002 }
3003
3004 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3005 if err != nil {
3006 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
3007 "device-id": oo.deviceID})
3008 return nil, err
3009 }
3010
3011 omciRxCallbackPair := CallbackPair{CbKey: tid,
3012 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3013 }
3014 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3015 if err != nil {
3016 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3017 "device-id": oo.deviceID})
3018 return nil, err
3019 }
3020 logger.Debug(ctx, "send SIPUserData-create-msg done")
3021 return meInstance, nil
3022 }
3023 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3024 "device-id": oo.deviceID})
3025 return nil, omciErr.GetError()
3026}
3027
3028// SendSetSIPUserData nolint: unused
3029func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3030 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3031 tid := oo.GetNextTid(highPrio)
3032 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3033 "SequNo": strconv.FormatInt(int64(tid), 16),
3034 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3035
3036 meInstance, omciErr := me.NewSipUserData(params[0])
3037 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003038 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3039 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003040 if err != nil {
3041 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3042 "device-id": oo.deviceID})
3043 return nil, err
3044 }
3045
3046 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3047 if err != nil {
3048 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3049 "device-id": oo.deviceID})
3050 return nil, err
3051 }
3052
3053 omciRxCallbackPair := CallbackPair{CbKey: tid,
3054 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3055 }
3056 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3057 if err != nil {
3058 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3059 "device-id": oo.deviceID})
3060 return nil, err
3061 }
3062 logger.Debug(ctx, "send SIPUserData-set-msg done")
3063 return meInstance, nil
3064 }
3065 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3066 "device-id": oo.deviceID})
3067 return nil, omciErr.GetError()
3068}
3069
3070// SendDeleteSIPUserData nolint: unused
3071func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3072 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3073 tid := oo.GetNextTid(highPrio)
3074 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3075 "SequNo": strconv.FormatInt(int64(tid), 16),
3076 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3077
3078 meParams := me.ParamData{EntityID: aInstID}
3079 meInstance, omciErr := me.NewSipUserData(meParams)
3080 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003081 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3082 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003083 if err != nil {
3084 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3085 "Err": err, "device-id": oo.deviceID})
3086 return nil, err
3087 }
3088
3089 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3090 if err != nil {
3091 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3092 "Err": err, "device-id": oo.deviceID})
3093 return nil, err
3094 }
3095
3096 omciRxCallbackPair := CallbackPair{
3097 CbKey: tid,
3098 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3099 }
3100 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3101 if err != nil {
3102 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3103 "Err": err, "device-id": oo.deviceID})
3104 return nil, err
3105 }
3106 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3107 return meInstance, nil
3108 }
3109 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3110 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3111 return nil, omciErr.GetError()
3112}
3113
3114// SendCreateVoipApplicationServiceProfile nolint: unused
3115func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3116 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3117 tid := oo.GetNextTid(highPrio)
3118 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3119 "SequNo": strconv.FormatInt(int64(tid), 16),
3120 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3121
3122 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3123 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003124 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3125 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003126 if err != nil {
3127 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3128 "device-id": oo.deviceID})
3129 return nil, err
3130 }
3131
3132 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3133 if err != nil {
3134 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3135 "device-id": oo.deviceID})
3136 return nil, err
3137 }
3138
3139 omciRxCallbackPair := CallbackPair{CbKey: tid,
3140 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3141 }
3142 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3143 if err != nil {
3144 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3145 "device-id": oo.deviceID})
3146 return nil, err
3147 }
3148 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3149 return meInstance, nil
3150 }
3151 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3152 "device-id": oo.deviceID})
3153 return nil, omciErr.GetError()
3154}
3155
3156// SendSetVoipApplicationServiceProfile nolint: unused
3157func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3158 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3159 tid := oo.GetNextTid(highPrio)
3160 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3161 "SequNo": strconv.FormatInt(int64(tid), 16),
3162 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3163
3164 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3165 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003166 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3167 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003168 if err != nil {
3169 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3170 "device-id": oo.deviceID})
3171 return nil, err
3172 }
3173
3174 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3175 if err != nil {
3176 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3177 "device-id": oo.deviceID})
3178 return nil, err
3179 }
3180
3181 omciRxCallbackPair := CallbackPair{CbKey: tid,
3182 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3183 }
3184 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3185 if err != nil {
3186 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3187 "device-id": oo.deviceID})
3188 return nil, err
3189 }
3190 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3191 return meInstance, nil
3192 }
3193 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3194 "device-id": oo.deviceID})
3195 return nil, omciErr.GetError()
3196}
3197
3198// SendDeleteVoipApplicationServiceProfile nolint: unused
3199func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3200 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3201 tid := oo.GetNextTid(highPrio)
3202 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3203 "SequNo": strconv.FormatInt(int64(tid), 16),
3204 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3205
3206 meParams := me.ParamData{EntityID: aInstID}
3207 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3208 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003209 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3210 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003211 if err != nil {
3212 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3213 "Err": err, "device-id": oo.deviceID})
3214 return nil, err
3215 }
3216
3217 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3218 if err != nil {
3219 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3220 "Err": err, "device-id": oo.deviceID})
3221 return nil, err
3222 }
3223
3224 omciRxCallbackPair := CallbackPair{
3225 CbKey: tid,
3226 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3227 }
3228 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3229 if err != nil {
3230 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3231 "Err": err, "device-id": oo.deviceID})
3232 return nil, err
3233 }
3234 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3235 return meInstance, nil
3236 }
3237 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3238 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3239 return nil, omciErr.GetError()
3240}
3241
3242// SendCreateSIPAgentConfigData nolint: unused
3243func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3244 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3245 tid := oo.GetNextTid(highPrio)
3246 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3247 "SequNo": strconv.FormatInt(int64(tid), 16),
3248 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3249
3250 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3251 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003252 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3253 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003254 if err != nil {
3255 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3256 "device-id": oo.deviceID})
3257 return nil, err
3258 }
3259
3260 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3261 if err != nil {
3262 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3263 "device-id": oo.deviceID})
3264 return nil, err
3265 }
3266
3267 omciRxCallbackPair := CallbackPair{CbKey: tid,
3268 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3269 }
3270 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3271 if err != nil {
3272 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3273 "device-id": oo.deviceID})
3274 return nil, err
3275 }
3276 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3277 return meInstance, nil
3278 }
3279 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3280 "device-id": oo.deviceID})
3281 return nil, omciErr.GetError()
3282}
3283
3284// SendSetSIPAgentConfigData nolint: unused
3285func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3286 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3287 tid := oo.GetNextTid(highPrio)
3288 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3289 "SequNo": strconv.FormatInt(int64(tid), 16),
3290 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3291
3292 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3293 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003294 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3295 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003296 if err != nil {
3297 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3298 "device-id": oo.deviceID})
3299 return nil, err
3300 }
3301
3302 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3303 if err != nil {
3304 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3305 "device-id": oo.deviceID})
3306 return nil, err
3307 }
3308
3309 omciRxCallbackPair := CallbackPair{CbKey: tid,
3310 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3311 }
3312 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3313 if err != nil {
3314 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3315 "device-id": oo.deviceID})
3316 return nil, err
3317 }
3318 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3319 return meInstance, nil
3320 }
3321 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3322 "device-id": oo.deviceID})
3323 return nil, omciErr.GetError()
3324}
3325
3326// SendDeleteSIPAgentConfigData nolint: unused
3327func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3328 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3329 tid := oo.GetNextTid(highPrio)
3330 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3331 "SequNo": strconv.FormatInt(int64(tid), 16),
3332 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3333
3334 meParams := me.ParamData{EntityID: aInstID}
3335 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3336 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003337 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3338 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003339 if err != nil {
3340 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3341 "Err": err, "device-id": oo.deviceID})
3342 return nil, err
3343 }
3344
3345 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3346 if err != nil {
3347 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3348 "Err": err, "device-id": oo.deviceID})
3349 return nil, err
3350 }
3351
3352 omciRxCallbackPair := CallbackPair{
3353 CbKey: tid,
3354 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3355 }
3356 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3357 if err != nil {
3358 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3359 "Err": err, "device-id": oo.deviceID})
3360 return nil, err
3361 }
3362 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3363 return meInstance, nil
3364 }
3365 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3366 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3367 return nil, omciErr.GetError()
3368}
3369
3370// SendCreateTCPUDPConfigData nolint: unused
3371func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3372 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3373 tid := oo.GetNextTid(highPrio)
3374 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3375 "SequNo": strconv.FormatInt(int64(tid), 16),
3376 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3377
3378 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3379 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003380 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3381 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003382 if err != nil {
3383 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3384 "device-id": oo.deviceID})
3385 return nil, err
3386 }
3387
3388 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3389 if err != nil {
3390 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3391 "device-id": oo.deviceID})
3392 return nil, err
3393 }
3394
3395 omciRxCallbackPair := CallbackPair{CbKey: tid,
3396 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3397 }
3398 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3399 if err != nil {
3400 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3401 "device-id": oo.deviceID})
3402 return nil, err
3403 }
3404 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3405 return meInstance, nil
3406 }
3407 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3408 "device-id": oo.deviceID})
3409 return nil, omciErr.GetError()
3410}
3411
3412// SendSetTCPUDPConfigData nolint: unused
3413func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3414 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3415 tid := oo.GetNextTid(highPrio)
3416 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3417 "SequNo": strconv.FormatInt(int64(tid), 16),
3418 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3419
3420 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3421 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003422 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3423 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003424 if err != nil {
3425 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3426 "device-id": oo.deviceID})
3427 return nil, err
3428 }
3429
3430 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3431 if err != nil {
3432 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3433 "device-id": oo.deviceID})
3434 return nil, err
3435 }
3436
3437 omciRxCallbackPair := CallbackPair{CbKey: tid,
3438 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3439 }
3440 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3441 if err != nil {
3442 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3443 "device-id": oo.deviceID})
3444 return nil, err
3445 }
3446 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3447 return meInstance, nil
3448 }
3449 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3450 "device-id": oo.deviceID})
3451 return nil, omciErr.GetError()
3452}
3453
3454// SendDeleteTCPUDPConfigData nolint: unused
3455func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3456 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3457 tid := oo.GetNextTid(highPrio)
3458 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3459 "SequNo": strconv.FormatInt(int64(tid), 16),
3460 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3461
3462 meParams := me.ParamData{EntityID: aInstID}
3463 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3464 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003465 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3466 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003467 if err != nil {
3468 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3469 "Err": err, "device-id": oo.deviceID})
3470 return nil, err
3471 }
3472
3473 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3474 if err != nil {
3475 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3476 "Err": err, "device-id": oo.deviceID})
3477 return nil, err
3478 }
3479
3480 omciRxCallbackPair := CallbackPair{
3481 CbKey: tid,
3482 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3483 }
3484 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3485 if err != nil {
3486 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3487 "Err": err, "device-id": oo.deviceID})
3488 return nil, err
3489 }
3490 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3491 return meInstance, nil
3492 }
3493 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3494 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3495 return nil, omciErr.GetError()
3496}
3497
3498// SendCreateIPHostConfigData nolint: unused
3499func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3500 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3501 tid := oo.GetNextTid(highPrio)
3502 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3503 "SequNo": strconv.FormatInt(int64(tid), 16),
3504 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3505
3506 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3507 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003508 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3509 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003510 if err != nil {
3511 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3512 "device-id": oo.deviceID})
3513 return nil, err
3514 }
3515
3516 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3517 if err != nil {
3518 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3519 "device-id": oo.deviceID})
3520 return nil, err
3521 }
3522
3523 omciRxCallbackPair := CallbackPair{CbKey: tid,
3524 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3525 }
3526 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3527 if err != nil {
3528 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3529 "device-id": oo.deviceID})
3530 return nil, err
3531 }
3532 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3533 return meInstance, nil
3534 }
3535 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3536 "device-id": oo.deviceID})
3537 return nil, omciErr.GetError()
3538}
3539
3540// SendSetIPHostConfigData nolint: unused
3541func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3542 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3543 tid := oo.GetNextTid(highPrio)
3544 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3545 "SequNo": strconv.FormatInt(int64(tid), 16),
3546 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3547
3548 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3549 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003550 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3551 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003552 if err != nil {
3553 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3554 "device-id": oo.deviceID})
3555 return nil, err
3556 }
3557
3558 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3559 if err != nil {
3560 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3561 "device-id": oo.deviceID})
3562 return nil, err
3563 }
3564
3565 omciRxCallbackPair := CallbackPair{CbKey: tid,
3566 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3567 }
3568 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3569 if err != nil {
3570 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3571 "device-id": oo.deviceID})
3572 return nil, err
3573 }
3574 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3575 return meInstance, nil
3576 }
3577 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3578 "device-id": oo.deviceID})
3579 return nil, omciErr.GetError()
3580}
3581
3582// SendDeleteIPHostConfigData nolint: unused
3583func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3584 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3585 tid := oo.GetNextTid(highPrio)
3586 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3587 "SequNo": strconv.FormatInt(int64(tid), 16),
3588 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3589
3590 meParams := me.ParamData{EntityID: aInstID}
3591 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3592 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003593 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3594 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003595 if err != nil {
3596 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3597 "Err": err, "device-id": oo.deviceID})
3598 return nil, err
3599 }
3600
3601 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3602 if err != nil {
3603 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3604 "Err": err, "device-id": oo.deviceID})
3605 return nil, err
3606 }
3607
3608 omciRxCallbackPair := CallbackPair{
3609 CbKey: tid,
3610 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3611 }
3612 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3613 if err != nil {
3614 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3615 "Err": err, "device-id": oo.deviceID})
3616 return nil, err
3617 }
3618 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3619 return meInstance, nil
3620 }
3621 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3622 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3623 return nil, omciErr.GetError()
3624}
3625
3626// SendCreateRTPProfileData nolint: unused
3627func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3628 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3629 tid := oo.GetNextTid(highPrio)
3630 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3631 "SequNo": strconv.FormatInt(int64(tid), 16),
3632 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3633
3634 meInstance, omciErr := me.NewRtpProfileData(params[0])
3635 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003636 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3637 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003638 if err != nil {
3639 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3640 "device-id": oo.deviceID})
3641 return nil, err
3642 }
3643
3644 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3645 if err != nil {
3646 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3647 "device-id": oo.deviceID})
3648 return nil, err
3649 }
3650
3651 omciRxCallbackPair := CallbackPair{CbKey: tid,
3652 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3653 }
3654 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3655 if err != nil {
3656 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3657 "device-id": oo.deviceID})
3658 return nil, err
3659 }
3660 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3661 return meInstance, nil
3662 }
3663 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3664 "device-id": oo.deviceID})
3665 return nil, omciErr.GetError()
3666}
3667
3668// SendSetRTPProfileData nolint: unused
3669func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3670 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3671 tid := oo.GetNextTid(highPrio)
3672 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3673 "SequNo": strconv.FormatInt(int64(tid), 16),
3674 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3675
3676 meInstance, omciErr := me.NewRtpProfileData(params[0])
3677 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003678 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3679 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003680 if err != nil {
3681 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3682 "device-id": oo.deviceID})
3683 return nil, err
3684 }
3685
3686 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3687 if err != nil {
3688 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3689 "device-id": oo.deviceID})
3690 return nil, err
3691 }
3692
3693 omciRxCallbackPair := CallbackPair{CbKey: tid,
3694 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3695 }
3696 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3697 if err != nil {
3698 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3699 "device-id": oo.deviceID})
3700 return nil, err
3701 }
3702 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3703 return meInstance, nil
3704 }
3705 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3706 "device-id": oo.deviceID})
3707 return nil, omciErr.GetError()
3708}
3709
3710// SendDeleteRTPProfileData nolint: unused
3711func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3712 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3713 tid := oo.GetNextTid(highPrio)
3714 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3715 "SequNo": strconv.FormatInt(int64(tid), 16),
3716 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3717
3718 meParams := me.ParamData{EntityID: aInstID}
3719 meInstance, omciErr := me.NewRtpProfileData(meParams)
3720 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003721 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3722 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003723 if err != nil {
3724 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3725 "Err": err, "device-id": oo.deviceID})
3726 return nil, err
3727 }
3728
3729 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3730 if err != nil {
3731 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3732 "Err": err, "device-id": oo.deviceID})
3733 return nil, err
3734 }
3735
3736 omciRxCallbackPair := CallbackPair{
3737 CbKey: tid,
3738 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3739 }
3740 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3741 if err != nil {
3742 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3743 "Err": err, "device-id": oo.deviceID})
3744 return nil, err
3745 }
3746 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3747 return meInstance, nil
3748 }
3749 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3750 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3751 return nil, omciErr.GetError()
3752}
3753
3754// SendCreateNetworkDialPlanTable nolint: unused
3755func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3756 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3757 tid := oo.GetNextTid(highPrio)
3758 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3759 "SequNo": strconv.FormatInt(int64(tid), 16),
3760 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3761
3762 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3763 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003764 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3765 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003766 if err != nil {
3767 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3768 "device-id": oo.deviceID})
3769 return nil, err
3770 }
3771
3772 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3773 if err != nil {
3774 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3775 "device-id": oo.deviceID})
3776 return nil, err
3777 }
3778
3779 omciRxCallbackPair := CallbackPair{CbKey: tid,
3780 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3781 }
3782 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3783 if err != nil {
3784 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3785 "device-id": oo.deviceID})
3786 return nil, err
3787 }
3788 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3789 return meInstance, nil
3790 }
3791 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3792 "device-id": oo.deviceID})
3793 return nil, omciErr.GetError()
3794}
3795
3796// SendSetNetworkDialPlanTable nolint: unused
3797func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3798 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3799 tid := oo.GetNextTid(highPrio)
3800 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3801 "SequNo": strconv.FormatInt(int64(tid), 16),
3802 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3803
3804 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3805 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003806 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3807 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003808 if err != nil {
3809 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3810 "device-id": oo.deviceID})
3811 return nil, err
3812 }
3813
3814 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3815 if err != nil {
3816 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3817 "device-id": oo.deviceID})
3818 return nil, err
3819 }
3820
3821 omciRxCallbackPair := CallbackPair{CbKey: tid,
3822 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3823 }
3824 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3825 if err != nil {
3826 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3827 "device-id": oo.deviceID})
3828 return nil, err
3829 }
3830 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3831 return meInstance, nil
3832 }
3833 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3834 "device-id": oo.deviceID})
3835 return nil, omciErr.GetError()
3836}
3837
3838// SendDeleteNetworkDialPlanTable nolint: unused
3839func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3840 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3841 tid := oo.GetNextTid(highPrio)
3842 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3843 "SequNo": strconv.FormatInt(int64(tid), 16),
3844 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3845
3846 meParams := me.ParamData{EntityID: aInstID}
3847 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3848 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003849 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3850 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003851 if err != nil {
3852 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3853 "Err": err, "device-id": oo.deviceID})
3854 return nil, err
3855 }
3856
3857 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3858 if err != nil {
3859 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3860 "Err": err, "device-id": oo.deviceID})
3861 return nil, err
3862 }
3863
3864 omciRxCallbackPair := CallbackPair{
3865 CbKey: tid,
3866 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3867 }
3868 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3869 if err != nil {
3870 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3871 "Err": err, "device-id": oo.deviceID})
3872 return nil, err
3873 }
3874 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3875 return meInstance, nil
3876 }
3877 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3878 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3879 return nil, omciErr.GetError()
3880}
3881
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003882// SendSyncTime sends SynchronizeTimeRequest
3883func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
3884 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003885 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
3886 "SequNo": strconv.FormatInt(int64(tid), 16)})
3887
3888 omciLayer := &omci.OMCI{
3889 TransactionID: tid,
3890 MessageType: omci.SynchronizeTimeRequestType,
3891 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3892 // Length: 0x28, // Optional, defaults to 40 octets
3893 }
3894 utcTime := time.Now().UTC()
3895 request := &omci.SynchronizeTimeRequest{
3896 MeBasePacket: omci.MeBasePacket{
3897 EntityClass: me.OnuGClassID,
3898 // Default Instance ID is 0
3899 },
3900 Year: uint16(utcTime.Year()),
3901 Month: uint8(utcTime.Month()),
3902 Day: uint8(utcTime.Day()),
3903 Hour: uint8(utcTime.Hour()),
3904 Minute: uint8(utcTime.Minute()),
3905 Second: uint8(utcTime.Second()),
3906 }
3907
3908 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
3909 if err != nil {
3910 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
3911 "device-id": oo.deviceID})
3912 return err
3913 }
3914
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003915 omciRxCallbackPair := CallbackPair{CbKey: tid,
3916 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003917 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003918 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003919 if err != nil {
3920 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
3921 "device-id": oo.deviceID})
3922 return err
3923 }
3924 logger.Debug(ctx, "send synchronize time request done")
3925 return nil
3926}
3927
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003928// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
3929func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003930 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003931 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003932 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3933 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3934 meParam := me.ParamData{EntityID: entityID}
3935 var meInstance *me.ManagedEntity
3936 var omciErr me.OmciErrors
3937 if upstream {
3938 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
3939 } else {
3940 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
3941 }
3942 if omciErr.GetError() == nil {
3943 var omciLayer *omci.OMCI
3944 var msgLayer gopacket.SerializableLayer
3945 var err error
3946 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003947 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3948 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003949 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003950 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
3951 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003952 }
3953 if err != nil {
3954 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
3955 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003956 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003957 }
3958
3959 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3960 if err != nil {
3961 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
3962 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003963 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003964 }
3965
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003966 omciRxCallbackPair := CallbackPair{CbKey: tid,
3967 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003968 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003969 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003970 if err != nil {
3971 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
3972 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003973 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003974 }
3975 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
3976 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003977 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08003978 }
3979 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
3980 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 +03003981 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08003982}
3983
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003984// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
3985func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003986 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003987 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003988 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3989 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
3990 meParam := me.ParamData{EntityID: entityID}
3991 var meInstance *me.ManagedEntity
3992 var omciErr me.OmciErrors
3993 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
3994
3995 if omciErr.GetError() == nil {
3996 var omciLayer *omci.OMCI
3997 var msgLayer gopacket.SerializableLayer
3998 var err error
3999 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004000 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4001 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004002 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004003 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4004 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08004005 }
4006 if err != nil {
4007 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
4008 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004009 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004010 }
4011
4012 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4013 if err != nil {
4014 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4015 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004016 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004017 }
4018
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004019 omciRxCallbackPair := CallbackPair{CbKey: tid,
4020 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004021 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004022 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004023 if err != nil {
4024 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4025 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004026 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004027 }
4028 logger.Debugw(ctx, "send ethernet uni history data ME done",
4029 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004030 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004031 }
4032 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4033 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004034 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004035}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004036
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004037// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4038func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004039 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004040 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004041 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4042 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4043 meParam := me.ParamData{EntityID: entityID}
4044 var meInstance *me.ManagedEntity
4045 var omciErr me.OmciErrors
4046 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4047
4048 if omciErr.GetError() == nil {
4049 var omciLayer *omci.OMCI
4050 var msgLayer gopacket.SerializableLayer
4051 var err error
4052 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004053 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4054 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004055 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004056 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4057 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004058 }
4059 if err != nil {
4060 logger.Errorw(ctx, "Cannot encode fec history data ME",
4061 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004062 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004063 }
4064
4065 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4066 if err != nil {
4067 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4068 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004069 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004070 }
4071
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004072 omciRxCallbackPair := CallbackPair{CbKey: tid,
4073 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004074 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004075 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004076 if err != nil {
4077 logger.Errorw(ctx, "Cannot send fec history data ME",
4078 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004079 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004080 }
4081 logger.Debugw(ctx, "send fec history data ME done",
4082 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004083 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004084 }
4085 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4086 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004087 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004088}
4089
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004090// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4091func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004092 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004093 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004094 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4095 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4096 meParam := me.ParamData{EntityID: entityID}
4097 var meInstance *me.ManagedEntity
4098 var omciErr me.OmciErrors
4099 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4100
4101 if omciErr.GetError() == nil {
4102 var omciLayer *omci.OMCI
4103 var msgLayer gopacket.SerializableLayer
4104 var err error
4105 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004106 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4107 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004108 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004109 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4110 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004111 }
4112 if err != nil {
4113 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4114 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004115 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004116 }
4117
4118 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4119 if err != nil {
4120 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4121 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004122 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004123 }
4124
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004125 omciRxCallbackPair := CallbackPair{CbKey: tid,
4126 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004127 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004128 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004129 if err != nil {
4130 logger.Errorw(ctx, "Cannot send gemport history data ME",
4131 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004132 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004133 }
4134 logger.Debugw(ctx, "send gemport history data ME done",
4135 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004136 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004137 }
4138 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4139 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004140 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004141}
4142
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004143// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4144func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004145 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004146 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004147 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4148 "SequNo": strconv.FormatInt(int64(tid), 16),
4149 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4150
4151 omciLayer := &omci.OMCI{
4152 TransactionID: tid,
4153 MessageType: omci.StartSoftwareDownloadRequestType,
4154 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4155 // Length: 0x28, // Optional, defaults to 40 octets
4156 }
4157 request := &omci.StartSoftwareDownloadRequest{
4158 MeBasePacket: omci.MeBasePacket{
4159 EntityClass: me.SoftwareImageClassID,
4160 EntityInstance: aImageMeID, //inactive image
4161 },
4162 WindowSize: aDownloadWindowSize,
4163 ImageSize: aFileLen,
4164 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4165 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4166 }
4167
4168 var options gopacket.SerializeOptions
4169 options.FixLengths = true
4170 buffer := gopacket.NewSerializeBuffer()
4171 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4172 if err != nil {
4173 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4174 "device-id": oo.deviceID})
4175 return err
4176 }
4177 outgoingPacket := buffer.Bytes()
4178
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004179 omciRxCallbackPair := CallbackPair{CbKey: tid,
4180 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004181 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004182 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004183 if err != nil {
4184 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4185 "device-id": oo.deviceID})
4186 return err
4187 }
4188 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004189 return nil
4190}
4191
kesavand011d5162021-11-25 19:21:06 +05304192// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4193//Before invoking this function the oo.mutexTid needs to be be locked so that
4194//GetOnuSwSecNextTid can be invoked without further locking
4195func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4196 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
4197 omciMsgsPerWindow *ia.OmciMessages) (OmciTransferStructure, error) {
4198 //onuswsections uses only low prioirity tids
4199 tid := oo.GetOnuSwSecNextTid()
4200 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4201 "SequNo": strconv.FormatInt(int64(tid), 16),
4202 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4203
4204 var omciTxReq OmciTransferStructure
4205 msgType := omci.DownloadSectionRequestType
4206
4207 if aAckRequest > 0 {
4208 msgType = omci.DownloadSectionRequestWithResponseType
4209
4210 }
4211 omciLayer := &omci.OMCI{
4212 TransactionID: tid,
4213 MessageType: msgType,
4214 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4215 // Length: 0x28, // Optional, defaults to 40 octets
4216 }
4217 localSectionData := make([]byte, len(aSection))
4218
4219 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4220 request := &omci.DownloadSectionRequest{
4221 MeBasePacket: omci.MeBasePacket{
4222 EntityClass: me.SoftwareImageClassID,
4223 EntityInstance: aImageMeID, //inactive image
4224 },
4225 SectionNumber: aDownloadSectionNo,
4226 SectionData: localSectionData,
4227 }
4228
4229 var options gopacket.SerializeOptions
4230 options.FixLengths = true
4231 buffer := gopacket.NewSerializeBuffer()
4232 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4233 if err != nil {
4234 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4235 "device-id": oo.deviceID})
4236 return omciTxReq, err
4237 }
4238 outgoingPacket := buffer.Bytes()
4239
4240 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4241
4242 if aAckRequest > 0 {
4243 // only the last section should have a timeout as an ack is required only for the last section of the window
4244 omciTxReq = OmciTransferStructure{
4245 withFramePrint: true,
4246 OnuSwWindow: omciMsgsPerWindow,
4247 }
4248 return omciTxReq, nil
4249 }
4250
4251 return omciTxReq, nil
4252}
4253
4254//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4255func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4256 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4257 if aOmciTxRequest.OnuSwWindow == nil {
4258 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4259 log.Fields{"device-id": oo.deviceID})
4260 return
4261
4262 }
4263
4264 tid := oo.GetOnuSwSecLastTid()
4265 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4266 omciRxCallbackPair := CallbackPair{CbKey: tid,
4267 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4268 }
4269
4270 aOmciTxRequest.cbPair = omciRxCallbackPair
4271 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4272 oo.mutexRxSchedMap.Lock()
4273 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4274 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4275 oo.mutexRxSchedMap.Unlock()
4276
4277 chSuccess := make(chan bool)
4278 aOmciTxRequest.chSuccess = chSuccess
4279 aOmciTxRequest.timeout = aTimeout
4280 aOmciTxRequest.retries = CDefaultRetries
4281
4282 //tid := aOmciTxRequest.cbPair.CbKey
4283 oo.mutexMonReq.Lock()
4284 oo.monitoredRequests[tid] = aOmciTxRequest
4285 oo.mutexMonReq.Unlock()
4286
4287 retries := aOmciTxRequest.retries
4288 retryCounter := 0
4289 if aTimeout == 0 {
4290 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4291 return
4292 }
4293loop:
4294 for retryCounter <= retries {
4295 // the onu sw sections are enqueued only to the low priority queue
4296 oo.mutexLowPrioTxQueue.Lock()
4297 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4298 oo.mutexLowPrioTxQueue.Unlock()
4299
4300 go oo.sendQueuedRequests(ctx)
4301
4302 select {
4303 case success := <-chSuccess:
4304 if success {
4305 logger.Debugw(ctx, "reqMon: response received in time",
4306 log.Fields{"tid": tid, "device-id": oo.deviceID})
4307 } else {
4308 logger.Debugw(ctx, "reqMon: wait for response aborted",
4309 log.Fields{"tid": tid, "device-id": oo.deviceID})
4310 }
4311 break loop
4312 case <-time.After(time.Duration(aTimeout) * time.Second):
4313 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004314 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
kesavand011d5162021-11-25 19:21:06 +05304315 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004316 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc)
kesavand011d5162021-11-25 19:21:06 +05304317 break loop
4318 } else {
4319 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4320 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4321 }
4322 }
4323 retryCounter++
4324 }
4325 oo.mutexMonReq.Lock()
4326 delete(oo.monitoredRequests, tid)
4327 oo.mutexMonReq.Unlock()
4328}
4329
4330func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
4331 if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil {
4332 lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4333 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
4334 "TxOmciMessage": hex.EncodeToString(lastSection),
4335 "device-id": oo.deviceID,
4336 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4337 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4338 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4339 }
4340 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4341 if sendErr != nil {
4342 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
4343 return sendErr
4344 }
4345 return nil
4346}
4347
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004348// SendDownloadSection sends DownloadSectionRequestWithResponse
4349func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004350 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004351 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004352 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4353 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004354 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004355
4356 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4357 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004358 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004359 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004360 if aAckRequest > 0 {
4361 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004362 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004363 }
mpagenko80622a52021-02-09 16:53:23 +00004364 omciLayer := &omci.OMCI{
4365 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004366 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004367 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4368 // Length: 0x28, // Optional, defaults to 40 octets
4369 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304370 localSectionData := make([]byte, len(aSection))
4371
mpagenko15ff4a52021-03-02 10:09:20 +00004372 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004373 request := &omci.DownloadSectionRequest{
4374 MeBasePacket: omci.MeBasePacket{
4375 EntityClass: me.SoftwareImageClassID,
4376 EntityInstance: aImageMeID, //inactive image
4377 },
4378 SectionNumber: aDownloadSectionNo,
4379 SectionData: localSectionData,
4380 }
4381
4382 var options gopacket.SerializeOptions
4383 options.FixLengths = true
4384 buffer := gopacket.NewSerializeBuffer()
4385 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4386 if err != nil {
4387 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4388 "device-id": oo.deviceID})
4389 return err
4390 }
4391 outgoingPacket := buffer.Bytes()
4392
mpagenko15ff4a52021-03-02 10:09:20 +00004393 //for initial debug purpose overrule the requested print state for some frames
4394 printFrame := aPrint
4395 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4396 printFrame = true
4397 }
4398
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004399 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004400 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4401 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004402 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004403 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004404 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004405 if err != nil {
4406 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4407 "device-id": oo.deviceID})
4408 return err
4409 }
4410 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004411 return nil
4412}
4413
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004414//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4415func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004416 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004417 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004418 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4419 "SequNo": strconv.FormatInt(int64(tid), 16),
4420 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4421
mpagenko15ff4a52021-03-02 10:09:20 +00004422 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004423 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004424 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004425 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4426 // Length: 0x28, // Optional, defaults to 40 octets
4427 }
mpagenko15ff4a52021-03-02 10:09:20 +00004428 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004429 MeBasePacket: omci.MeBasePacket{
4430 EntityClass: me.SoftwareImageClassID,
4431 EntityInstance: aImageMeID, //inactive image
4432 },
mpagenko15ff4a52021-03-02 10:09:20 +00004433 CRC32: aImageCrc,
4434 ImageSize: aFileLen,
4435 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4436 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004437 }
mpagenko15ff4a52021-03-02 10:09:20 +00004438
4439 var options gopacket.SerializeOptions
4440 options.FixLengths = true
4441 buffer := gopacket.NewSerializeBuffer()
4442 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4443 if err != nil {
4444 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004445 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004446 return err
mpagenko80622a52021-02-09 16:53:23 +00004447 }
mpagenko15ff4a52021-03-02 10:09:20 +00004448 outgoingPacket := buffer.Bytes()
4449
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004450 omciRxCallbackPair := CallbackPair{CbKey: tid,
4451 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004452 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004453 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004454 if err != nil {
4455 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4456 "device-id": oo.deviceID})
4457 return err
4458 }
4459 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004460 return nil
4461}
4462
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004463// SendActivateSoftware sends ActivateSoftwareRequest
4464func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004465 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004466 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004467 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4468 "SequNo": strconv.FormatInt(int64(tid), 16),
4469 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4470
4471 omciLayer := &omci.OMCI{
4472 TransactionID: tid,
4473 MessageType: omci.ActivateSoftwareRequestType,
4474 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4475 // Length: 0x28, // Optional, defaults to 40 octets
4476 }
4477 request := &omci.ActivateSoftwareRequest{
4478 MeBasePacket: omci.MeBasePacket{
4479 EntityClass: me.SoftwareImageClassID,
4480 EntityInstance: aImageMeID, //inactive image
4481 },
4482 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4483 }
4484
4485 var options gopacket.SerializeOptions
4486 options.FixLengths = true
4487 buffer := gopacket.NewSerializeBuffer()
4488 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4489 if err != nil {
4490 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4491 "device-id": oo.deviceID})
4492 return err
4493 }
4494 outgoingPacket := buffer.Bytes()
4495
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004496 omciRxCallbackPair := CallbackPair{CbKey: tid,
4497 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004498 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004499 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004500 if err != nil {
4501 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4502 "device-id": oo.deviceID})
4503 return err
4504 }
4505 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004506 return nil
4507}
mpagenko80622a52021-02-09 16:53:23 +00004508
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004509// SendCommitSoftware sends CommitSoftwareRequest
4510func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko15ff4a52021-03-02 10:09:20 +00004511 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004512 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004513 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4514 "SequNo": strconv.FormatInt(int64(tid), 16),
4515 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4516
4517 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004518 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004519 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004520 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4521 // Length: 0x28, // Optional, defaults to 40 octets
4522 }
mpagenko15ff4a52021-03-02 10:09:20 +00004523 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004524 MeBasePacket: omci.MeBasePacket{
4525 EntityClass: me.SoftwareImageClassID,
4526 EntityInstance: aImageMeID, //inactive image
4527 },
mpagenko80622a52021-02-09 16:53:23 +00004528 }
mpagenko15ff4a52021-03-02 10:09:20 +00004529
4530 var options gopacket.SerializeOptions
4531 options.FixLengths = true
4532 buffer := gopacket.NewSerializeBuffer()
4533 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4534 if err != nil {
4535 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004536 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004537 return err
mpagenko80622a52021-02-09 16:53:23 +00004538 }
mpagenko15ff4a52021-03-02 10:09:20 +00004539 outgoingPacket := buffer.Bytes()
4540
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004541 omciRxCallbackPair := CallbackPair{CbKey: tid,
4542 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004543 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004544 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004545 if err != nil {
4546 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4547 "device-id": oo.deviceID})
4548 return err
4549 }
4550 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004551 return nil
4552}
4553
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004554//SendSelfTestReq sends TestRequest
4555func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4556 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004557 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4558 "SequNo": strconv.FormatInt(int64(tid), 16),
4559 "InstId": strconv.FormatInt(int64(instdID), 16)})
4560 omciLayer := &omci.OMCI{
4561 TransactionID: tid,
4562 MessageType: omci.TestRequestType,
4563 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4564 // Length: 0x28, // Optional, defaults to 40 octets
4565 }
4566
4567 var request *omci.OpticalLineSupervisionTestRequest
4568 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004569 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004570 request = &omci.OpticalLineSupervisionTestRequest{
4571 MeBasePacket: omci.MeBasePacket{
4572 EntityClass: classID,
4573 EntityInstance: instdID,
4574 },
4575 SelectTest: uint8(7), // self test
4576 GeneralPurposeBuffer: uint16(0),
4577 VendorSpecificParameters: uint16(0),
4578 }
4579 default:
4580 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4581 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4582 }
4583 // Test serialization back to former string
4584 var options gopacket.SerializeOptions
4585 options.FixLengths = true
4586
4587 buffer := gopacket.NewSerializeBuffer()
4588 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4589 if err != nil {
4590 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4591 "device-id": oo.deviceID})
4592 return err
4593 }
4594 outgoingPacket := buffer.Bytes()
4595
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004596 omciRxCallbackPair := CallbackPair{CbKey: tid,
4597 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004598 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004599 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004600 if err != nil {
4601 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4602 "device-id": oo.deviceID})
4603 return err
4604 }
4605 logger.Debug(ctx, "send self test request done")
4606 return nil
4607}
4608
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004609//nolint: gocyclo
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004610func (oo *OmciCC) isSuccessfulResponseWithMibDataSync(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) (bool, error) {
4611
4612 nextLayer, err := omci.MsgTypeToNextLayer(omciMsg.MessageType, false)
4613 if err != nil {
4614 logger.Errorw(ctx, "omci-message: could not map msgType to nextLayer", log.Fields{"device-id": oo.deviceID})
4615 return false, fmt.Errorf("could not map msgType to nextLayer - %s", oo.deviceID)
4616 }
4617 msgLayer := (*packet).Layer(nextLayer)
4618 if msgLayer != nil {
4619 // Note: Due to relaxed decoding, you may now still have a decoding error attached to the layers
4620 if failure := (*packet).ErrorLayer(); failure != nil {
4621 if nextLayer == omci.LayerTypeMibUploadNextResponse {
4622 // In the case of MibUploadNextResponse, we let the packet pass so that later processing
4623 // can examine for UnkonwnMEs and UnknownAttributes
4624 logger.Infow(ctx, "omci-message: MibUploadNextResponse packet with ErrorLayer - let it pass",
4625 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4626 return false, nil
4627 } else if nextLayer == omci.LayerTypeGetResponse {
4628 if resp := msgLayer.(*omci.GetResponse); resp != nil {
4629 if resp.NextLayerType() == omci.LayerTypeUnknownAttributes {
4630 unknownAttrLayer := (*packet).Layer(omci.LayerTypeUnknownAttributes)
4631 if unknownAttrLayer != nil {
4632 logger.Errorw(ctx, "omci-message: GetResponse packet contains unknownAttrLayer - skip it!",
4633 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "unknownAttrLayer": unknownAttrLayer})
4634 return false, fmt.Errorf("packet contains unknownAttrLayer - %s", oo.deviceID)
4635 }
4636 }
4637 }
4638 }
4639 // Try to decode any further error information
4640 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4641 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer with further info - skip it!",
4642 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4643 return false, fmt.Errorf("packet contains ErrorLayer with further info - %s", oo.deviceID)
4644 }
4645 logger.Errorw(ctx, "omci-message: packet contains ErrorLayer - skip it!",
4646 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4647 return false, fmt.Errorf("packet contains ErrorLayer - %s", oo.deviceID)
4648 }
4649 } else if failure := (*packet).ErrorLayer(); failure != nil {
4650 // message layer could not be decoded, but at least check if additional failure information is available
4651 if decodeFailure, ok := failure.(*gopacket.DecodeFailure); ok && decodeFailure != nil {
4652 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, further info available - skip it!",
4653 log.Fields{"device-id": oo.deviceID, "error": failure.Error(), "decodeFailure": decodeFailure.String()})
4654 return false, fmt.Errorf("could not decode msgLayer of packet, further info available - %s", oo.deviceID)
4655 }
4656 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet, ErrorLayer available",
4657 log.Fields{"device-id": oo.deviceID, "error": failure.Error()})
4658 return false, fmt.Errorf("could not decode msgLayer of packet, ErrorLayer available - %s", oo.deviceID)
4659 } else {
4660 logger.Errorw(ctx, "omci-message: could not decode msgLayer of packet", log.Fields{"device-id": oo.deviceID})
4661 return false, fmt.Errorf("could not decode msgLayer of packet - %s", oo.deviceID)
4662 }
4663
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004664 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004665 if v == omciMsg.MessageType {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004666 switch nextLayer {
4667 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004668 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4669 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004670 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004671 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004672 }
4673 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004674 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4675 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004676 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004677 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004678 }
4679 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004680 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4681 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004682 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004683 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004684 }
4685 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004686 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4687 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004688 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004689 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004690 }
4691 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004692 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4693 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004694 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004695 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004696 }
4697 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004698 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4699 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004700 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004701 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004702 }
4703 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004704 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4705 if resp.Result == me.Success {
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004706 return true, nil
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004707 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004708 }
4709 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004710 }
4711 }
Holger Hildebrandt36747fd2022-03-14 09:47:17 +00004712 return false, nil
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004713}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004714
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004715func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004716 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004717 if timeout == 0 {
4718 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004719 // enqueue
4720 if aOmciTxRequest.highPrio {
4721 oo.mutexHighPrioTxQueue.Lock()
4722 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4723 oo.mutexHighPrioTxQueue.Unlock()
4724 } else {
4725 oo.mutexLowPrioTxQueue.Lock()
4726 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4727 oo.mutexLowPrioTxQueue.Unlock()
4728 }
4729 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004730 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004731 //the supervised sending with waiting on the response (based on TID) is called in background
4732 // to avoid blocking of the sender for the complete OMCI handshake procedure
4733 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4734 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4735 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004736 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004737}
4738
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004739func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004740 chSuccess := make(chan bool)
4741 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004742 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004743 oo.mutexMonReq.Lock()
4744 oo.monitoredRequests[tid] = aOmciTxRequest
4745 oo.mutexMonReq.Unlock()
4746
4747 retries := aOmciTxRequest.retries
4748 retryCounter := 0
4749loop:
4750 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004751 // enqueue
4752 if aOmciTxRequest.highPrio {
4753 oo.mutexHighPrioTxQueue.Lock()
4754 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4755 oo.mutexHighPrioTxQueue.Unlock()
4756 } else {
4757 oo.mutexLowPrioTxQueue.Lock()
4758 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4759 oo.mutexLowPrioTxQueue.Unlock()
4760 }
4761 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004762
4763 select {
4764 case success := <-chSuccess:
4765 if success {
4766 logger.Debugw(ctx, "reqMon: response received in time",
4767 log.Fields{"tid": tid, "device-id": oo.deviceID})
4768 } else {
4769 logger.Debugw(ctx, "reqMon: wait for response aborted",
4770 log.Fields{"tid": tid, "device-id": oo.deviceID})
4771 }
4772 break loop
4773 case <-time.After(time.Duration(aTimeout) * time.Second):
4774 if retryCounter == retries {
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004775 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!",
mpagenko7455fd42021-06-10 16:25:55 +00004776 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
Holger Hildebrandtc56febd2022-02-09 13:23:30 +00004777 oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc)
mpagenko7455fd42021-06-10 16:25:55 +00004778 break loop
4779 } else {
4780 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4781 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4782 }
4783 }
4784 retryCounter++
4785 }
4786 oo.mutexMonReq.Lock()
4787 delete(oo.monitoredRequests, tid)
4788 oo.mutexMonReq.Unlock()
4789}
4790
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004791//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004792func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004793 oo.mutexMonReq.RLock()
4794 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004795 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4796 select {
4797 case oo.monitoredRequests[k].chSuccess <- false:
4798 default:
4799 logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
4800 "index": k, "device-id": oo.deviceID})
4801 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004802 }
4803 oo.mutexMonReq.RUnlock()
4804}
4805
4806//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4807//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004808func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4809 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004810}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304811
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004812// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4813func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304814 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004815 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304816 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4817 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4818
4819 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004820 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304821 }
4822 var meInstance *me.ManagedEntity
4823 var omciErr me.OmciErrors
4824 if classID == me.EthernetFrameExtendedPmClassID {
4825 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4826 } else {
4827 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4828 }
4829
4830 if omciErr.GetError() == nil {
4831 var omciLayer *omci.OMCI
4832 var msgLayer gopacket.SerializableLayer
4833 var err error
4834 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004835 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4836 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304837 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004838 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4839 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304840 }
4841 if err != nil {
4842 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4843 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4844 return nil, err
4845 }
4846
4847 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4848 if err != nil {
4849 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
4850 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4851 return nil, err
4852 }
4853
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004854 omciRxCallbackPair := CallbackPair{CbKey: tid,
4855 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304856 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004857 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304858 if err != nil {
4859 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4860 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4861 return nil, err
4862 }
4863 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
4864 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4865 return meInstance, nil
4866 }
4867 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4868 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4869 return nil, omciErr.GetError()
4870}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004871
4872// RLockMutexMonReq lock read access to monitoredRequests
4873func (oo *OmciCC) RLockMutexMonReq() {
4874 oo.mutexMonReq.RLock()
4875}
4876
4877// RUnlockMutexMonReq unlock read access to monitoredRequests
4878func (oo *OmciCC) RUnlockMutexMonReq() {
4879 oo.mutexMonReq.RUnlock()
4880}
4881
4882// GetMonitoredRequest get OmciTransferStructure for an omciTransID
4883func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
4884 value, exist = oo.monitoredRequests[omciTransID]
4885 return value, exist
4886}
4887
4888// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
4889func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
4890 oo.monitoredRequests[omciTransID].chSuccess <- chVal
4891}
Himani Chawlaee10b542021-09-20 16:46:40 +05304892
4893// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
4894func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
4895 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
4896 tid := oo.GetNextTid(highPrio)
4897 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
4898 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
4899
4900 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004901 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05304902 }
4903 var meInstance *me.ManagedEntity
4904 var omciErr me.OmciErrors
4905 if classID == me.EthernetFrameExtendedPmClassID {
4906 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
4907 } else {
4908 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
4909 }
4910
4911 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00004912 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05304913 if err != nil {
4914 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4915 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4916 return nil, err
4917 }
4918 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4919 if err != nil {
4920 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
4921 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4922 return nil, err
4923 }
4924 omciRxCallbackPair := CallbackPair{
4925 CbKey: tid,
4926 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4927 }
4928 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4929 if err != nil {
4930 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4931 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4932 return nil, err
4933 }
4934 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
4935 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4936 return meInstance, nil
4937 }
4938 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4939 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4940 return nil, omciErr.GetError()
4941}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00004942
4943// PrepareForGarbageCollection - remove references to prepare for garbage collection
4944func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
4945 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
4946 oo.pBaseDeviceHandler = nil
4947 oo.pOnuDeviceEntry = nil
4948 oo.pOnuAlarmManager = nil
4949}