blob: a3df18ac51457545bcc3536172a04c9b4d614f1f [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 }
321
322 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
323 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000324 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000325 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200326 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000327 }
328 omciLayer := packet.Layer(omci.LayerTypeOMCI)
329 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000330 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000331 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200332 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000333 }
mpagenko836a1fd2021-11-01 16:12:42 +0000334 // insert some check on detected OMCI decoding issues and log them
335 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
336 // even though allowed from omci-lib due to set relaxed decoding
337 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
338 // (compare mib_sync.go unknownAttrLayer)
339 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
340 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
341 errMsg := failure.Error()
342 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
343 "device-id": oo.deviceID, "issue": errMsg})
344 }
345 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000346 omciMsg, ok := omciLayer.(*omci.OMCI)
347 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000348 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000349 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200350 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000351 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000352 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000353 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
mpagenko836a1fd2021-11-01 16:12:42 +0000354
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700355 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
356 // We expect to find the TID in the oo.rxSchedulerMap
357 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000358 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000359 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000360 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000361 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530362 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000363 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000364 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200365 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000366 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200367 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530368 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000369 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530370 oo.mutexRxSchedMap.Lock()
371 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000372 if ok && rxCallbackEntry.CbFunction != nil {
373 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000374 oo.printRxMessage(ctx, rxMsg)
375 }
Himani Chawla4d908332020-08-31 12:30:20 +0530376 //disadvantage of decoupling: error verification made difficult, but anyway the question is
377 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000378 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000379 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000380 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000381 }
mpagenkoc8bba412021-01-15 15:38:44 +0000382
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700383 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
384 // so do not clean up the TransactionID in that case.
385 if omciMsg.MessageType != omci.TestResponseType {
386 // having posted the response the request is regarded as 'done'
387 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
388 }
Himani Chawla4d908332020-08-31 12:30:20 +0530389 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000390 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000391 }
mpagenko80622a52021-02-09 16:53:23 +0000392 oo.mutexRxSchedMap.Unlock()
393 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
394 oo.printRxMessage(ctx, rxMsg)
395 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000396
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000397 /* py code was:
398 Receive and OMCI message from the proxy channel to the OLT.
399
400 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
401 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
402 """
403 if not self.enabled:
404 return
405
406 try:
407 now = arrow.utcnow()
408 d = None
409
410 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
411 # save the current value of the entity_id_to_class_map, then
412 # replace it with our custom one before decode, and then finally
413 # restore it later. Tried other ways but really made the code messy.
414 saved_me_map = omci_entities.entity_id_to_class_map
415 omci_entities.entity_id_to_class_map = self._me_map
416
417 try:
418 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000419 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000420 except KeyError as e:
421 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000422 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000423 rx_frame = self._decode_unknown_me(msg)
424 self._rx_unknown_me += 1
425
426 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000427 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000428 return
429
430 finally:
431 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
432
433 rx_tid = rx_frame.fields['transaction_id']
434 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000435 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000436 # Filter the Test Result frame and route through receive onu
437 # message method.
438 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000439 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000440 return self._receive_onu_message(rx_frame)
441
442 # Previously unreachable if this is the very first round-trip Rx or we
443 # have been running consecutive errors
444 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000445 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000446 self.reactor.callLater(0, self._publish_connectivity_event, True)
447
448 self._rx_frames += 1
449 self._consecutive_errors = 0
450
451 try:
452 high_priority = self._tid_is_high_priority(rx_tid)
453 index = self._get_priority_index(high_priority)
454
455 # (timestamp, defer, frame, timeout, retry, delayedCall)
456 last_tx_tuple = self._tx_request[index]
457
458 if last_tx_tuple is None or \
459 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
460 # Possible late Rx on a message that timed-out
461 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000462 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000463 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
464 self._rx_unknown_tid += 1
465 self._rx_late += 1
466 return
467
468 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
469 if dc is not None and not dc.cancelled and not dc.called:
470 dc.cancel()
471
472 _secs = self._update_rx_tx_stats(now, ts)
473
474 # Late arrival already serviced by a timeout?
475 if d.called:
476 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000477 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000478 return
479
480 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000481 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000482 if d is not None:
483 return d.errback(failure.Failure(e))
484 return
485
486 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000487 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000488 tx_tid = tx_frame.fields['transaction_id'])
489 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
490
491 # begin success callback chain (will cancel timeout and queue next Tx message)
492 self._rx_response[index] = rx_frame
493 d.callback(rx_frame)
494
495 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000496 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000497 */
498}
499
Himani Chawla6d2ae152020-09-02 13:11:20 +0530500/*
501func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530502 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530503 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000504}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530505*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000506
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700507// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000508func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700509 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
510 delete(oo.rxSchedulerMap, tid)
511}
512
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000513// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
514func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
515 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000516
mpagenkoc26d4c02021-05-06 14:27:57 +0000517 if timeout != 0 {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000518 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000519 oo.mutexRxSchedMap.Lock()
520 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000521 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000522 oo.mutexRxSchedMap.Unlock()
523 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000524
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000525 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000526 //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 +0000527 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000528 txFrame,
529 timeout,
530 retry,
531 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000532 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000533 receiveCallbackPair,
534 nil,
kesavand011d5162021-11-25 19:21:06 +0530535 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000536 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000537 oo.mutexMonReq.Lock()
538 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000539 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000540 // do not call processRequestMonitoring in background here to ensure correct sequencing
541 // of requested messages into txQueue (especially for non-response-supervised messages)
542 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000543 return nil
544 }
545 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000546 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000547 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000548}
549
Holger Hildebrandt34555512021-10-01 16:26:59 +0000550func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
551 // Avoid accessing the txQueues from parallel send routines to block
552 // parallel omci send requests at least until SendIAP is 'committed'.
553 // To guarantee window size 1 for one ONU it would be necessary to wait
554 // for the corresponding response too (t.b.d.).
555 oo.mutexSendQueuedRequests.Lock()
556 defer oo.mutexSendQueuedRequests.Unlock()
557 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
558 logger.Errorw(ctx, "Error during sending high prio requests!",
559 log.Fields{"err": err, "device-id": oo.deviceID})
560 return
561 }
562 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
563 logger.Errorw(ctx, "Error during sending low prio requests!",
564 log.Fields{"err": err, "device-id": oo.deviceID})
565 return
566 }
567}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000568
Holger Hildebrandt34555512021-10-01 16:26:59 +0000569func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
570 oo.mutexHighPrioTxQueue.Lock()
571 defer oo.mutexHighPrioTxQueue.Unlock()
572 for oo.highPrioTxQueue.Len() > 0 {
573 queueElement := oo.highPrioTxQueue.Front() // First element
574 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
575 return err
mpagenko80622a52021-02-09 16:53:23 +0000576 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000577 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
578 }
579 return nil
580}
581
582func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
583 oo.mutexLowPrioTxQueue.Lock()
584 for oo.lowPrioTxQueue.Len() > 0 {
585 queueElement := oo.lowPrioTxQueue.Front() // First element
kesavand011d5162021-11-25 19:21:06 +0530586 // check if the element is for onu sw section
587 aOmciTxReq := queueElement.Value.(OmciTransferStructure)
588 if aOmciTxReq.OnuSwWindow != nil {
589 if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil {
590 oo.mutexLowPrioTxQueue.Unlock()
591 return err
592 }
593 } else {
594 err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure))
595 if err != nil {
596 oo.mutexLowPrioTxQueue.Unlock()
597 return err
598 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200599 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000600 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
601 // Interrupt the sending of low priority requests to process any high priority requests
602 // that may have arrived in the meantime
603 oo.mutexLowPrioTxQueue.Unlock()
604 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
605 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000606 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000607 oo.mutexLowPrioTxQueue.Lock()
608 }
609
610 oo.mutexLowPrioTxQueue.Unlock()
611 return nil
612}
613
614func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
615 if omciTxRequest.withFramePrint {
616 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
617 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
618 "device-id": oo.deviceID,
619 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
620 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
621 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
622 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400623 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000624 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
625 ChildDeviceId: oo.deviceID,
626 Message: omciTxRequest.txFrame,
627 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
628 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
629 }
630 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
631 if sendErr != nil {
632 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
633 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000634 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000635 return nil
636}
637
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000638// GetNextTid - TODO: add comment
639func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000640 var next uint16
641 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000642 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000643 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530644 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000645 if oo.hpTid < 0x8000 {
646 oo.hpTid = 0x8000
647 }
mpagenko900ee4b2020-10-12 11:56:34 +0000648 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000649 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000650 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000651 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530652 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000653 if oo.tid >= 0x8000 {
654 oo.tid = 1
655 }
mpagenko900ee4b2020-10-12 11:56:34 +0000656 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000657 }
658 return next
659}
660
kesavand011d5162021-11-25 19:21:06 +0530661//GetOnuSwSecNextTid get the next low prio tid for the onu sw sections
662//onu sw sections uses only low priority tids
663//The mutexTid lock should be taken prior to using this function
664func (oo *OmciCC) GetOnuSwSecNextTid() uint16 {
665 next := oo.tid
666 oo.tid++
667 if oo.tid >= 0x8000 {
668 oo.tid = 1
669 }
670 return next
671}
672
673//GetOnuSwSecLastTid gets the last allocated tid
674//The mutexTid lock should be taken prior to using this function
675func (oo *OmciCC) GetOnuSwSecLastTid() uint16 {
676 next := oo.tid
677 lastAllocatedTid := next - 1
678 return lastAllocatedTid
679}
680
681//LockMutexTID locks mutexTid
682func (oo *OmciCC) LockMutexTID() {
683 oo.mutexTid.Lock()
684}
685
686//UnLockMutexTID unlocks mutexTid
687func (oo *OmciCC) UnLockMutexTID() {
688 oo.mutexTid.Unlock()
689}
690
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000691// ###################################################################################
692// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000693
694// Serialize - TODO: add comment
695func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000696 omciLayer := &omci.OMCI{
697 TransactionID: tid,
698 MessageType: msgType,
699 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000700 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000701}
702
dbainbri4d3a0dc2020-12-02 00:33:42 +0000703func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000704 var options gopacket.SerializeOptions
705 options.FixLengths = true
706
707 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530708 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000709 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000710 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000711 return nil, err
712 }
713 return buffer.Bytes(), nil
714}
715
Himani Chawla4d908332020-08-31 12:30:20 +0530716/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717func hexEncode(omciPkt []byte) ([]byte, error) {
718 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
719 hex.Encode(dst, omciPkt)
720 return dst, nil
721}
Himani Chawla4d908332020-08-31 12:30:20 +0530722*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000723
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000724//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000725func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000726
dbainbri4d3a0dc2020-12-02 00:33:42 +0000727 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000728 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000729
730 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000731 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000732 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200733 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000734 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000735 oo.mutexMonReq.RLock()
736 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000737 //implement non-blocking channel send to avoid blocking on mutexMonReq later
738 select {
739 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
740 default:
741 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
742 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
743 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000744 } else {
745 logger.Infow(ctx, "reqMon: map entry does not exist!",
746 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
747 }
748 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000749
750 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
751 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000752 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000753 Type: OMCI,
754 Data: OmciMessage{
755 OmciMsg: omciMsg,
756 OmciPacket: packet,
757 },
758 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000759 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000760 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000761
762 return nil
763}
764
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000765// SendMibReset sends MibResetRequest
766func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000767
dbainbri4d3a0dc2020-12-02 00:33:42 +0000768 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000769 request := &omci.MibResetRequest{
770 MeBasePacket: omci.MeBasePacket{
771 EntityClass: me.OnuDataClassID,
772 },
773 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000774 tid := oo.GetNextTid(highPrio)
775 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000776 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000777 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000778 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000779 return err
780 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000781 omciRxCallbackPair := CallbackPair{
782 CbKey: tid,
783 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000784 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000785 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000786}
787
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000788// SendReboot sends RebootRequest
789func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
790 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300791 request := &omci.RebootRequest{
792 MeBasePacket: omci.MeBasePacket{
793 EntityClass: me.OnuGClassID,
794 },
795 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000796 tid := oo.GetNextTid(highPrio)
797 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300798 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000799 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000800 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300801 return err
802 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000803 omciRxCallbackPair := CallbackPair{
804 CbKey: tid,
805 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300806 }
807
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000808 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300809 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000810 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000811 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300812 return err
813 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000814 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300815 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000816 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200817 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300818 return err
819 }
820 return nil
821}
822
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000823// SendMibUpload sends MibUploadRequest
824func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000825 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000826 request := &omci.MibUploadRequest{
827 MeBasePacket: omci.MeBasePacket{
828 EntityClass: me.OnuDataClassID,
829 },
830 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000831 tid := oo.GetNextTid(highPrio)
832 pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000833 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000834 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000835 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000836 return err
837 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000838 oo.UploadSequNo = 0
839 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000840
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000841 omciRxCallbackPair := CallbackPair{
842 CbKey: tid,
843 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000844 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000845 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000846}
847
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000848// SendMibUploadNext sends MibUploadNextRequest
849func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
850 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000851 request := &omci.MibUploadNextRequest{
852 MeBasePacket: omci.MeBasePacket{
853 EntityClass: me.OnuDataClassID,
854 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000855 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000856 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000857 tid := oo.GetNextTid(highPrio)
858 pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000859 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000860 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000861 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000862 return err
863 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000864 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000865
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000866 omciRxCallbackPair := CallbackPair{
867 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000868 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
869 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
870 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000871 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000872 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000873 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000874}
875
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000876// SendGetAllAlarm gets all alarm ME instances
877func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530878 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
879 request := &omci.GetAllAlarmsRequest{
880 MeBasePacket: omci.MeBasePacket{
881 EntityClass: me.OnuDataClassID,
882 },
883 AlarmRetrievalMode: byte(alarmRetreivalMode),
884 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000885 tid := oo.GetNextTid(highPrio)
886 pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530887 if err != nil {
888 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
889 "Err": err, "device-id": oo.deviceID})
890 return err
891 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000892 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530893
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000894 omciRxCallbackPair := CallbackPair{
895 CbKey: tid,
896 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530897 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000898 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530899}
900
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000901// SendGetAllAlarmNext gets next alarm ME instance
902func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
903 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
904 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +0530905 "alarmUploadSeqNo": alarmUploadSeqNo})
906 request := &omci.GetAllAlarmsNextRequest{
907 MeBasePacket: omci.MeBasePacket{
908 EntityClass: me.OnuDataClassID,
909 },
910 CommandSequenceNumber: alarmUploadSeqNo,
911 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000912 tid := oo.GetNextTid(highPrio)
913 pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530914 if err != nil {
915 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
916 "Err": err, "device-id": oo.deviceID})
917 return err
918 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000919 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530920
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000921 omciRxCallbackPair := CallbackPair{
922 CbKey: tid,
923 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530924 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000925 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530926}
927
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000928// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
929func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
930 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000931 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000932 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000933
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000934 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000935 EntityID: GalEthernetEID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +0000936 Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000937 }
938 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
939 if omciErr.GetError() == nil {
940 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +0000941 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000942 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000943 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000944 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300945 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000946 }
947
dbainbri4d3a0dc2020-12-02 00:33:42 +0000948 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000950 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000951 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300952 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000953 }
954
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000955 omciRxCallbackPair := CallbackPair{
956 CbKey: tid,
957 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000958 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000959 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000960 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000961 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000962 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300963 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000964 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000965 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300966 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000967 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000968 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000969 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300970 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000971}
972
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000973// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000974// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000975func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
976 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000977 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000978 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000979
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000980 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
981 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000982 // By now we just use fix values to fire - this is anyway what the python adapter does
983 // read ONU-2G from DB ???? //TODO!!!
984 meParams := me.ParamData{
985 EntityID: 0,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +0000986 Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue},
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000987 }
988 meInstance, omciErr := me.NewOnu2G(meParams)
989 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +0000990 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000991 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000992 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000993 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300994 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000995 }
996
dbainbri4d3a0dc2020-12-02 00:33:42 +0000997 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000998 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000999 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001000 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001001 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001002 }
1003
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001004 omciRxCallbackPair := CallbackPair{
1005 CbKey: tid,
1006 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001007 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001008 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001009 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001010 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001011 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001012 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001013 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001014 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001015 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001016 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001017 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001018 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001019 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001020}
1021
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001022// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
1023func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
1024 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1025 tid := oo.GetNextTid(highPrio)
1026 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001027 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001028 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001029
1030 meParams := me.ParamData{
1031 EntityID: instID,
1032 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001033 me.MacBridgeServiceProfile_Priority: 0x8000,
1034 me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s
1035 me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s
1036 me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s
1037 me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001038 },
1039 }
1040
1041 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1042 if omciErr.GetError() == nil {
1043 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001044 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1045 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001046 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001047 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001048 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001049 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001050 }
1051
dbainbri4d3a0dc2020-12-02 00:33:42 +00001052 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001053 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001054 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001055 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001056 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001057 }
1058
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001059 omciRxCallbackPair := CallbackPair{
1060 CbKey: tid,
1061 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001062 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001063 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001064 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001065 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001066 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001067 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001068 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001069 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001070 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001071 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001072 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001073 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001074 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001075}
1076
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001077// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1078func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1079 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1080 tid := oo.GetNextTid(highPrio)
1081 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001082 if idErr != nil {
1083 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1084 "Err": idErr, "device-id": oo.deviceID})
1085 return nil, idErr
1086 }
1087 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001088 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001089
1090 meParams := me.ParamData{
1091 EntityID: instID,
1092 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001093 me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1094 me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo,
1095 me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType),
1096 me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001097 },
1098 }
1099 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1100 if omciErr.GetError() == nil {
1101 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001102 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1103 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001104 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001105 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001106 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001107 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001108 }
1109
dbainbri4d3a0dc2020-12-02 00:33:42 +00001110 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001111 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001112 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001113 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001114 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001115 }
1116
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001117 omciRxCallbackPair := CallbackPair{
1118 CbKey: tid,
1119 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001120 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001121 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001122 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001123 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001124 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001125 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001126 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001127 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001128 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001129 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001130 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001131 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001132 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001133}
1134
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001135// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1136func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1137 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1138 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001139 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001140 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001141 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001142 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001143
1144 // compare python adapter code WA VOL-1311: this is not done here!
1145 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1146 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1147 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001148 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001149 assType = uint8(10) // for VEIP
1150 }
1151 meParams := me.ParamData{
1152 EntityID: instID,
1153 Attributes: me.AttributeValueMap{
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001154 me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType,
1155 me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001156 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001157 },
1158 }
1159 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1160 if omciErr.GetError() == nil {
1161 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001162 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1163 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001164 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001165 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001166 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001167 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001168 }
1169
dbainbri4d3a0dc2020-12-02 00:33:42 +00001170 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001171 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001172 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001173 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001174 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001175 }
1176
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001177 omciRxCallbackPair := CallbackPair{
1178 CbKey: tid,
1179 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001180 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001181 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001182 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001183 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001184 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001185 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001186 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001187 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001188 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001189 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001190 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001191 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001192 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001193}
1194
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001195// SendSetOnuGLS sets OnuG ME instance
1196func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001197 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001198 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001199 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001200 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001201
1202 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1203 meParams := me.ParamData{
1204 EntityID: 0,
1205 Attributes: requestedAttributes,
1206 }
1207 meInstance, omciErr := me.NewOnuG(meParams)
1208 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001209 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001210 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001211 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001212 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001213 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001214 }
1215
dbainbri4d3a0dc2020-12-02 00:33:42 +00001216 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001217 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001218 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001219 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001220 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001221 }
1222
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001223 omciRxCallbackPair := CallbackPair{
1224 CbKey: tid,
1225 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001226 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001227 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001228 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001229 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001230 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001231 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001232 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001233 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001234 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001235 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001236 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001237 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001238 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001239}
1240
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001241// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1242func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001243 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001244 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001245 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001246 "SequNo": strconv.FormatInt(int64(tid), 16)})
1247
1248 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1249 meParams := me.ParamData{
1250 EntityID: aInstNo,
1251 Attributes: requestedAttributes,
1252 }
1253 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1254 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001255 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001256 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001257 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001258 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001259 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001260 }
1261
dbainbri4d3a0dc2020-12-02 00:33:42 +00001262 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001263 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001264 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001265 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001266 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001267 }
1268
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001269 omciRxCallbackPair := CallbackPair{
1270 CbKey: tid,
1271 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001272 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001273 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001274 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001276 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001277 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001278 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001279 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001280 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001281 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001282 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001283 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001284 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001285}
1286
1287/* UniG obsolete by now, left here in case it should be needed once again
1288 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301289func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001290 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001291 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001292 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001293 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001294
1295 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1296 meParams := me.ParamData{
1297 EntityID: aInstNo,
1298 Attributes: requestedAttributes,
1299 }
1300 meInstance, omciErr := me.NewUniG(meParams)
1301 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001302 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001303 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001304 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001305 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001306 return nil
1307 }
1308
1309 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1310 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001311 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001312 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001313 return nil
1314 }
1315
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001316 omciRxCallbackPair := CallbackPair{
1317 CbKey: tid,
1318 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001319 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001320 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001321 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001322 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001323 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001324 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001325 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001326 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001327 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001328 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001329 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001330 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001331 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001332}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001333*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001334
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001335// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1336func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001337 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001338 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001339 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001340 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001341
1342 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1343 meParams := me.ParamData{
1344 EntityID: aInstNo,
1345 Attributes: requestedAttributes,
1346 }
1347 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1348 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001349 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001350 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001351 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001352 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001353 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001354 }
1355
dbainbri4d3a0dc2020-12-02 00:33:42 +00001356 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001357 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001358 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001359 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001360 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001361 }
1362
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001363 omciRxCallbackPair := CallbackPair{
1364 CbKey: tid,
1365 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001366 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001367 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001368 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001369 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001370 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001371 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001372 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001373 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001374 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001375 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001376 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001377 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001378 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001379}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001380
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001381// SendGetMe gets ME instance
1382func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001383 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001384
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001385 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001386 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001387 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001388
1389 meParams := me.ParamData{
1390 EntityID: entityID,
1391 Attributes: requestedAttributes,
1392 }
1393 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1394 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301395 meClassIDName := meInstance.GetName()
mpagenko836a1fd2021-11-01 16:12:42 +00001396 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001397 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001398 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 +03001399 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001400 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001401 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001402 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001403 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001404 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001405 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001406 omciRxCallbackPair := CallbackPair{
1407 CbKey: tid,
1408 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001409 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001410 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001411 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001412 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001413 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001414 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001416 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001417 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001418 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001419 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001420}
1421
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001422// SendGetMeWithAttributeMask gets ME instance with attribute mask
1423func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301424 timeout int, highPrio bool, rxChan chan Message) error {
1425
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001426 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301427 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1428 "SequNo": strconv.FormatInt(int64(tid), 16)})
1429
1430 request := &omci.GetRequest{
1431 MeBasePacket: omci.MeBasePacket{
1432 EntityInstance: entityID,
1433 EntityClass: classID,
1434 },
1435 AttributeMask: requestedAttributesMask,
1436 }
1437
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001438 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301439 if err != nil {
1440 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1441 return err
1442 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001443 omciRxCallbackPair := CallbackPair{
1444 CbKey: tid,
1445 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301446 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001447 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301448 if err != nil {
1449 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1450 return err
1451 }
1452 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1453 return nil
1454}
1455
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001456// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1457func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001458 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001459 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001461 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1462
1463 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001464 EntityID: aInstID,
1465 Attributes: me.AttributeValueMap{
1466 //workaround for unsuitable omci-lib default values, cmp VOL-3729
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00001467 me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF,
1468 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF,
1469 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF,
1470 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF,
1471 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF,
1472 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF,
1473 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF,
1474 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF,
1475 me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF,
mpagenko8b5fdd22020-12-17 17:58:32 +00001476 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001477 }
1478 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1479 if omciErr.GetError() == nil {
1480 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001481 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1482 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001483 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001484 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001485 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001486 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001487 }
1488
dbainbri4d3a0dc2020-12-02 00:33:42 +00001489 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001490 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001491 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001492 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001493 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001494 }
1495
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001496 omciRxCallbackPair := CallbackPair{
1497 CbKey: tid,
1498 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001499 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001500 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001502 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001503 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001504 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001505 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001506 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001507 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001508 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001509 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001510 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001511 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001512}
1513
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001514// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1515func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001516 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001517 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001518 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001519 "SequNo": strconv.FormatInt(int64(tid), 16),
1520 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1521
1522 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1523 if omciErr.GetError() == nil {
1524 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001525 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1526 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001527 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001528 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001529 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001530 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001531 }
1532
dbainbri4d3a0dc2020-12-02 00:33:42 +00001533 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001534 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001535 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001536 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001537 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001538 }
1539
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001540 omciRxCallbackPair := CallbackPair{
1541 CbKey: tid,
1542 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001543 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001544 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001545 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001546 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001547 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001548 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001549 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001550 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001551 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001552 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001553 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001554 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001555 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001556}
1557
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001558// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1559func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001560 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001561 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001562 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001563 "SequNo": strconv.FormatInt(int64(tid), 16),
1564 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1565
1566 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1567 if omciErr.GetError() == nil {
1568 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001569 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1570 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001571 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001572 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001573 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001574 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001575 }
1576
dbainbri4d3a0dc2020-12-02 00:33:42 +00001577 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001578 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001579 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001580 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001581 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001582 }
1583
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001584 omciRxCallbackPair := CallbackPair{
1585 CbKey: tid,
1586 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001587 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001588 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001589 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001590 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001591 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001592 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001593 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001594 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001595 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001596 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001597 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001598 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001599 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001600}
1601
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001602// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1603func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1604 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001605 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1606 "SequNo": strconv.FormatInt(int64(tid), 16),
1607 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1608
1609 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1610 if omciErr.GetError() == nil {
1611 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001612 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1613 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001614 if err != nil {
1615 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1616 "Err": err, "device-id": oo.deviceID})
1617 return nil, err
1618 }
1619
1620 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1621 if err != nil {
1622 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1623 "Err": err, "device-id": oo.deviceID})
1624 return nil, err
1625 }
1626
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001627 omciRxCallbackPair := CallbackPair{
1628 CbKey: tid,
1629 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001630 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001631 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001632 if err != nil {
1633 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1634 "Err": err, "device-id": oo.deviceID})
1635 return nil, err
1636 }
1637 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1638 return meInstance, nil
1639 }
1640 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1641 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1642 return nil, omciErr.GetError()
1643}
1644
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001645// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1646func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001647 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001648 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001649 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001650 "SequNo": strconv.FormatInt(int64(tid), 16),
1651 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1652
1653 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1654 if omciErr.GetError() == nil {
1655 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001656 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1657 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001658 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001659 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001660 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001661 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001662 }
1663
dbainbri4d3a0dc2020-12-02 00:33:42 +00001664 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001665 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001666 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001667 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001668 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001669 }
1670
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001671 omciRxCallbackPair := CallbackPair{
1672 CbKey: tid,
1673 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001674 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001675 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001676 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001677 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001678 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001679 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001680 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001681 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001682 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001683 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001684 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001685 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001686 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001687}
1688
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001689// SendSetTcontVar sets TCont ME instance
1690func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001691 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001692 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001693 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001694 "SequNo": strconv.FormatInt(int64(tid), 16),
1695 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1696
1697 meInstance, omciErr := me.NewTCont(params[0])
1698 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001699 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001700 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001701 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001702 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001703 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001704 }
1705
dbainbri4d3a0dc2020-12-02 00:33:42 +00001706 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001707 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001708 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001709 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001710 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001711 }
1712
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001713 omciRxCallbackPair := CallbackPair{
1714 CbKey: tid,
1715 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001716 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001717 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001718 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001719 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001720 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001721 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001722 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001723 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001724 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001725 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001726 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001727 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001728 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001729}
1730
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001731// SendSetPrioQueueVar sets PriorityQueue ME instance
1732func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001733 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001734 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001735 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001736 "SequNo": strconv.FormatInt(int64(tid), 16),
1737 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1738
1739 meInstance, omciErr := me.NewPriorityQueue(params[0])
1740 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001741 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001742 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001743 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001744 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001745 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001746 }
1747
dbainbri4d3a0dc2020-12-02 00:33:42 +00001748 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001749 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001750 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001751 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001752 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001753 }
1754
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001755 omciRxCallbackPair := CallbackPair{
1756 CbKey: tid,
1757 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001758 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001759 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001760 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001761 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001762 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001763 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001764 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001765 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001766 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001767 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001768 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001769 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001770 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001771}
1772
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001773// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1774func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001775 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001776 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001777 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001778 "SequNo": strconv.FormatInt(int64(tid), 16),
1779 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1780
1781 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1782 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001783 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001784 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001785 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001786 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001787 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001788 }
1789
dbainbri4d3a0dc2020-12-02 00:33:42 +00001790 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001791 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001792 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001793 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001794 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001795 }
1796
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001797 omciRxCallbackPair := CallbackPair{
1798 CbKey: tid,
1799 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001800 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001801 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001802 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001803 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001804 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001805 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001806 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001807 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001808 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001809 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001810 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001811 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001812 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001813}
mpagenkodff5dda2020-08-28 11:52:01 +00001814
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001815// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1816func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001817 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001818 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001819 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001820 "SequNo": strconv.FormatInt(int64(tid), 16),
1821 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1822
1823 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1824 if omciErr.GetError() == nil {
1825 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001826 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1827 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001828 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001829 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001830 "Err": err, "device-id": oo.deviceID})
1831 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1832 // return (dual format) error code that can be used at caller for immediate error treatment
1833 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001834 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001835 }
1836
dbainbri4d3a0dc2020-12-02 00:33:42 +00001837 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001838 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001839 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001840 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001841 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001842 }
1843
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001844 omciRxCallbackPair := CallbackPair{
1845 CbKey: tid,
1846 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001847 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001848 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001849 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001850 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001851 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001852 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001853 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001854 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001855 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001856 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001857 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001858 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001859 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001860}
1861
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001862// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001863func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001864 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001865 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001866 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001867 "SequNo": strconv.FormatInt(int64(tid), 16),
1868 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1869
1870 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1871 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001872 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1873 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001874 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001875 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001876 "Err": err, "device-id": oo.deviceID})
1877 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1878 // return (dual format) error code that can be used at caller for immediate error treatment
1879 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001880 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001881 }
1882
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001884 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001885 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001886 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001887 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001888 }
1889
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001890 omciRxCallbackPair := CallbackPair{
1891 CbKey: tid,
1892 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001893 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001894 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001895 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001896 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001897 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001898 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001899 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001900 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001901 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001902 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001903 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001904 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001905 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001906}
1907
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001908// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
1909func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001910 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001911 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001912 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001913 "SequNo": strconv.FormatInt(int64(tid), 16),
1914 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1915
1916 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1917 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001918 //EnhancedMode not yet supported, used with default options
1919 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1920 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001921 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001922 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001923 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001924 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001925 }
1926
dbainbri4d3a0dc2020-12-02 00:33:42 +00001927 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001928 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001929 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001930 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001931 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001932 }
1933
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001934 omciRxCallbackPair := CallbackPair{
1935 CbKey: tid,
1936 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001937 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001938 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001939 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001940 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001941 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001942 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001943 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001944 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001945 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001946 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001947 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001948 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001949 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001950}
1951
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001952// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
1953func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001954 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001955 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001956 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001957 "SequNo": strconv.FormatInt(int64(tid), 16),
1958 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1959
1960 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1961 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001962 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001963 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001964 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001965 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001966 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001967 }
1968
dbainbri4d3a0dc2020-12-02 00:33:42 +00001969 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001970 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001971 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001972 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001973 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001974 }
1975
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001976 omciRxCallbackPair := CallbackPair{
1977 CbKey: tid,
1978 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001979 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001980 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001981 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001982 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001983 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001984 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001985 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001986 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001987 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001988 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001989 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001990 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001991 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001992}
mpagenko01e726e2020-10-23 09:45:29 +00001993
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001994// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
1995func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001996 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001997 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001998 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001999 "SequNo": strconv.FormatInt(int64(tid), 16),
2000 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2001
2002 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
2003 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002004 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002005 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002006 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002007 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002008 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002009 }
2010
dbainbri4d3a0dc2020-12-02 00:33:42 +00002011 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002012 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002013 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002014 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002015 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002016 }
2017
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002018 omciRxCallbackPair := CallbackPair{
2019 CbKey: tid,
2020 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002021 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002022 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002023 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002024 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002025 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002026 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002027 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002028 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002029 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002030 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002031 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002032 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002033 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002034}
2035
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002036// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
2037func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002038 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002039 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002040 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00002041 "SequNo": strconv.FormatInt(int64(tid), 16),
2042 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2043
2044 meParams := me.ParamData{EntityID: aInstID}
2045 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2046 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002047 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2048 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002049 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002050 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002051 "Err": err, "device-id": oo.deviceID})
2052 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2053 // return (dual format) error code that can be used at caller for immediate error treatment
2054 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002055 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002056 }
2057
dbainbri4d3a0dc2020-12-02 00:33:42 +00002058 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002059 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002060 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002061 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002062 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002063 }
2064
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002065 omciRxCallbackPair := CallbackPair{
2066 CbKey: tid,
2067 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002068 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002069 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002070 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002071 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002072 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002073 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002074 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002075 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002076 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002077 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002078 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002079 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002080 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002081}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002082
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002083// SendCreateTDVar creates TrafficDescriptor ME instance
2084func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2085 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002086 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2087 "SequNo": strconv.FormatInt(int64(tid), 16),
2088 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2089 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2090 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002091 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002092 if err != nil {
2093 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002094 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002095 }
2096 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2097 if err != nil {
2098 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002099 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002100 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002101 omciRxCallbackPair := CallbackPair{
2102 CbKey: tid,
2103 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002104 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002105 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002106 if err != nil {
2107 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002108 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002109 }
2110 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002111 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002112 }
2113 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002114 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002115}
2116
2117// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002118func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002119 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002120 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002121 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2122 "SequNo": strconv.FormatInt(int64(tid), 16),
2123 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2124
2125 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2126 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002127 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002128 if err != nil {
2129 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002130 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002131 }
2132 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2133 if err != nil {
2134 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002135 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002136 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002137 omciRxCallbackPair := CallbackPair{
2138 CbKey: tid,
2139 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002140 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002141 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002142 if err != nil {
2143 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002144 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002145 }
2146 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002147 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002148 }
2149 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002150 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002151
2152}
2153
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002154// SendDeleteTD - TODO: add comment
2155func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002156 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002157 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002158 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2159 "SequNo": strconv.FormatInt(int64(tid), 16),
2160 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2161
2162 meParams := me.ParamData{EntityID: aInstID}
2163 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2164 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002165 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002166 if err != nil {
2167 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002168 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002169 }
2170 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2171 if err != nil {
2172 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002173 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002174 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002175 omciRxCallbackPair := CallbackPair{
2176 CbKey: tid,
2177 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002178 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002179 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002180 if err != nil {
2181 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002182 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002183 }
2184 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002185 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002186 }
2187 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002188 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002189
2190}
2191
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002192// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2193func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002194 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002195 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002196 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002197 "SequNo": strconv.FormatInt(int64(tid), 16),
2198 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2199
2200 meParams := me.ParamData{EntityID: aInstID}
2201 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2202 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002203 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2204 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002205 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002206 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002207 "Err": err, "device-id": oo.deviceID})
2208 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2209 // return (dual format) error code that can be used at caller for immediate error treatment
2210 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002211 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002212 }
2213
dbainbri4d3a0dc2020-12-02 00:33:42 +00002214 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002215 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002216 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002217 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002218 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002219 }
2220
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002221 omciRxCallbackPair := CallbackPair{
2222 CbKey: tid,
2223 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002224 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002225 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002226 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002227 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002228 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002229 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002230 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002231 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002232 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002233 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002235 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002236 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002237}
2238
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002239// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2240func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002242 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002243 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002244 "SequNo": strconv.FormatInt(int64(tid), 16),
2245 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2246
2247 meParams := me.ParamData{EntityID: aInstID}
2248 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2249 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002250 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2251 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002252 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002253 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002254 "Err": err, "device-id": oo.deviceID})
2255 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2256 // return (dual format) error code that can be used at caller for immediate error treatment
2257 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002258 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002259 }
2260
dbainbri4d3a0dc2020-12-02 00:33:42 +00002261 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002262 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002263 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002264 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002265 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002266 }
2267
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002268 omciRxCallbackPair := CallbackPair{
2269 CbKey: tid,
2270 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002271 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002272 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002273 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002274 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002275 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002276 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002277 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002278 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002279 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002280 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002281 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002282 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002283 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002284}
2285
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002286// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2287func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002288 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002289 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002290 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002291 "SequNo": strconv.FormatInt(int64(tid), 16),
2292 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2293
2294 meParams := me.ParamData{EntityID: aInstID}
2295 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2296 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002297 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2298 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002299 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002300 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002301 "Err": err, "device-id": oo.deviceID})
2302 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2303 // return (dual format) error code that can be used at caller for immediate error treatment
2304 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002305 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002306 }
2307
dbainbri4d3a0dc2020-12-02 00:33:42 +00002308 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002309 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002310 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002311 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002312 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002313 }
2314
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002315 omciRxCallbackPair := CallbackPair{
2316 CbKey: tid,
2317 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002318 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002319 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002320 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002321 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002322 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002323 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002324 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002325 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002326 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002327 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002328 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002329 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002330 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002331}
2332
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002333// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2334func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002335 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002336 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002337 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002338 "SequNo": strconv.FormatInt(int64(tid), 16),
2339 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2340
2341 meParams := me.ParamData{EntityID: aInstID}
2342 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2343 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002344 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2345 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002346 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002347 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002348 "Err": err, "device-id": oo.deviceID})
2349 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2350 // return (dual format) error code that can be used at caller for immediate error treatment
2351 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002352 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002353 }
2354
dbainbri4d3a0dc2020-12-02 00:33:42 +00002355 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002356 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002357 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002358 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002359 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002360 }
2361
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002362 omciRxCallbackPair := CallbackPair{
2363 CbKey: tid,
2364 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002365 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002366 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002367 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002368 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002369 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002370 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002371 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002372 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002373 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002374 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002375 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002376 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002377 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002378}
2379
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002380// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2381func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002382 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002383 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002384 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002385 "SequNo": strconv.FormatInt(int64(tid), 16),
2386 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2387
2388 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2389 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002390 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2391 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002392 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002393 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002394 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002395 }
2396
dbainbri4d3a0dc2020-12-02 00:33:42 +00002397 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002398 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002399 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002400 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002401 }
2402
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002403 omciRxCallbackPair := CallbackPair{CbKey: tid,
2404 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002405 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002406 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002407 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002408 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002411 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002412 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002413 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002414 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002415 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002416 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002417}
2418
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002419// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2420func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002421 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002422 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002423 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002424 "SequNo": strconv.FormatInt(int64(tid), 16),
2425 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2426
2427 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2428 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002429 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2430 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002431 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002432 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002433 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002434 }
2435
dbainbri4d3a0dc2020-12-02 00:33:42 +00002436 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002437 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002438 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002439 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002440 }
2441
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002442 omciRxCallbackPair := CallbackPair{CbKey: tid,
2443 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002444 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002445 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002446 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002447 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002450 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002451 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002452 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002453 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002454 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002455 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002456}
2457
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002458// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2459func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002460 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002461 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002462 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002463 "SequNo": strconv.FormatInt(int64(tid), 16),
2464 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2465
2466 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2467 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002468 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2469 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002470 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002471 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002472 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002473 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002474 }
2475
dbainbri4d3a0dc2020-12-02 00:33:42 +00002476 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002477 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002478 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002479 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002480 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002481 }
2482
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002483 omciRxCallbackPair := CallbackPair{CbKey: tid,
2484 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002485 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002486 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002487 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002488 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002489 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002490 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002491 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002492 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002493 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002494 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002495 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002496 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002497 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002498}
2499
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002500// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2501func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002502 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002503 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002504 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002505 "SequNo": strconv.FormatInt(int64(tid), 16),
2506 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2507
2508 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2509 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002510 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2511 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002512 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002513 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002514 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002515 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002516 }
2517
dbainbri4d3a0dc2020-12-02 00:33:42 +00002518 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002519 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002520 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002521 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002522 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002523 }
2524
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002525 omciRxCallbackPair := CallbackPair{CbKey: tid,
2526 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002527 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002528 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002529 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002530 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002531 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002532 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002533 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002534 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002535 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002536 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002537 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002538 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002539 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002540}
2541
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002542// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2543func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002544 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002545 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002546 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002547 "SequNo": strconv.FormatInt(int64(tid), 16),
2548 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2549
2550 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2551 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002552 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2553 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002554 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002555 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002556 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002557 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002558 }
2559
dbainbri4d3a0dc2020-12-02 00:33:42 +00002560 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002561 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002562 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002563 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002564 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002565 }
2566
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002567 omciRxCallbackPair := CallbackPair{CbKey: tid,
2568 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002569 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002570 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002571 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002572 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002573 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002574 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002575 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002576 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002577 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002578 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002579 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002580 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002581 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002582}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002583
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002584// SendCreateVoipVoiceCTP nolint: unused
2585func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2586 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2587 tid := oo.GetNextTid(highPrio)
2588 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2589 "SequNo": strconv.FormatInt(int64(tid), 16),
2590 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2591
2592 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2593 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002594 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2595 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002596 if err != nil {
2597 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2598 "device-id": oo.deviceID})
2599 return nil, err
2600 }
2601
2602 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2603 if err != nil {
2604 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2605 "device-id": oo.deviceID})
2606 return nil, err
2607 }
2608
2609 omciRxCallbackPair := CallbackPair{CbKey: tid,
2610 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2611 }
2612 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2613 if err != nil {
2614 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2615 "device-id": oo.deviceID})
2616 return nil, err
2617 }
2618 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2619 return meInstance, nil
2620 }
2621 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2622 "device-id": oo.deviceID})
2623 return nil, omciErr.GetError()
2624}
2625
2626// SendSetVoipVoiceCTP nolint: unused
2627func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2628 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2629 tid := oo.GetNextTid(highPrio)
2630 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2631 "SequNo": strconv.FormatInt(int64(tid), 16),
2632 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2633
2634 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2635 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002636 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2637 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002638 if err != nil {
2639 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2640 "device-id": oo.deviceID})
2641 return nil, err
2642 }
2643
2644 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2645 if err != nil {
2646 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2647 "device-id": oo.deviceID})
2648 return nil, err
2649 }
2650
2651 omciRxCallbackPair := CallbackPair{CbKey: tid,
2652 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2653 }
2654 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2655 if err != nil {
2656 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2657 "device-id": oo.deviceID})
2658 return nil, err
2659 }
2660 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2661 return meInstance, nil
2662 }
2663 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2664 "device-id": oo.deviceID})
2665 return nil, omciErr.GetError()
2666}
2667
2668// SendDeleteVoipVoiceCTP nolint: unused
2669func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2670 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2671 tid := oo.GetNextTid(highPrio)
2672 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2673 "SequNo": strconv.FormatInt(int64(tid), 16),
2674 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2675
2676 meParams := me.ParamData{EntityID: aInstID}
2677 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2678 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002679 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2680 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002681 if err != nil {
2682 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2683 "Err": err, "device-id": oo.deviceID})
2684 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2685 // return (dual format) error code that can be used at caller for immediate error treatment
2686 // (relevant to all used sendXX() methods and their error conditions)
2687 return nil, err
2688 }
2689
2690 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2691 if err != nil {
2692 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2693 "Err": err, "device-id": oo.deviceID})
2694 return nil, err
2695 }
2696
2697 omciRxCallbackPair := CallbackPair{
2698 CbKey: tid,
2699 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2700 }
2701 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2702 if err != nil {
2703 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2704 "Err": err, "device-id": oo.deviceID})
2705 return nil, err
2706 }
2707 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2708 return meInstance, nil
2709 }
2710 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2711 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2712 return nil, omciErr.GetError()
2713}
2714
2715// SendCreateVoipMediaProfile nolint: unused
2716func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2717 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2718 tid := oo.GetNextTid(highPrio)
2719 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2720 "SequNo": strconv.FormatInt(int64(tid), 16),
2721 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2722
2723 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2724 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002725 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2726 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002727 if err != nil {
2728 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2729 "device-id": oo.deviceID})
2730 return nil, err
2731 }
2732
2733 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2734 if err != nil {
2735 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2736 "device-id": oo.deviceID})
2737 return nil, err
2738 }
2739
2740 omciRxCallbackPair := CallbackPair{CbKey: tid,
2741 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2742 }
2743 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2744 if err != nil {
2745 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2746 "device-id": oo.deviceID})
2747 return nil, err
2748 }
2749 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2750 return meInstance, nil
2751 }
2752 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2753 "device-id": oo.deviceID})
2754 return nil, omciErr.GetError()
2755}
2756
2757// SendSetVoipMediaProfile nolint: unused
2758func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2759 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2760 tid := oo.GetNextTid(highPrio)
2761 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2762 "SequNo": strconv.FormatInt(int64(tid), 16),
2763 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2764
2765 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2766 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002767 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2768 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002769 if err != nil {
2770 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2771 "device-id": oo.deviceID})
2772 return nil, err
2773 }
2774
2775 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2776 if err != nil {
2777 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2778 "device-id": oo.deviceID})
2779 return nil, err
2780 }
2781
2782 omciRxCallbackPair := CallbackPair{CbKey: tid,
2783 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2784 }
2785 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2786 if err != nil {
2787 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2788 "device-id": oo.deviceID})
2789 return nil, err
2790 }
2791 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2792 return meInstance, nil
2793 }
2794 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2795 "device-id": oo.deviceID})
2796 return nil, omciErr.GetError()
2797}
2798
2799// SendDeleteVoipMediaProfile nolint: unused
2800func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2801 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2802 tid := oo.GetNextTid(highPrio)
2803 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2804 "SequNo": strconv.FormatInt(int64(tid), 16),
2805 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2806
2807 meParams := me.ParamData{EntityID: aInstID}
2808 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2809 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002810 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2811 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002812 if err != nil {
2813 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2814 "Err": err, "device-id": oo.deviceID})
2815 return nil, err
2816 }
2817
2818 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2819 if err != nil {
2820 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2821 "Err": err, "device-id": oo.deviceID})
2822 return nil, err
2823 }
2824
2825 omciRxCallbackPair := CallbackPair{
2826 CbKey: tid,
2827 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2828 }
2829 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2830 if err != nil {
2831 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2832 "Err": err, "device-id": oo.deviceID})
2833 return nil, err
2834 }
2835 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2836 return meInstance, nil
2837 }
2838 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2839 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2840 return nil, omciErr.GetError()
2841}
2842
2843// SendCreateVoiceServiceProfile nolint: unused
2844func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2845 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2846 tid := oo.GetNextTid(highPrio)
2847 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2848 "SequNo": strconv.FormatInt(int64(tid), 16),
2849 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2850
2851 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2852 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002853 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2854 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002855 if err != nil {
2856 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2857 "device-id": oo.deviceID})
2858 return nil, err
2859 }
2860
2861 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2862 if err != nil {
2863 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2864 "device-id": oo.deviceID})
2865 return nil, err
2866 }
2867
2868 omciRxCallbackPair := CallbackPair{CbKey: tid,
2869 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2870 }
2871 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2872 if err != nil {
2873 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
2874 "device-id": oo.deviceID})
2875 return nil, err
2876 }
2877 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
2878 return meInstance, nil
2879 }
2880 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2881 "device-id": oo.deviceID})
2882 return nil, omciErr.GetError()
2883}
2884
2885// SendSetVoiceServiceProfile nolint: unused
2886func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2887 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2888 tid := oo.GetNextTid(highPrio)
2889 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2890 "SequNo": strconv.FormatInt(int64(tid), 16),
2891 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2892
2893 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2894 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002895 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2896 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002897 if err != nil {
2898 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
2899 "device-id": oo.deviceID})
2900 return nil, err
2901 }
2902
2903 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2904 if err != nil {
2905 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
2906 "device-id": oo.deviceID})
2907 return nil, err
2908 }
2909
2910 omciRxCallbackPair := CallbackPair{CbKey: tid,
2911 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2912 }
2913 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2914 if err != nil {
2915 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
2916 "device-id": oo.deviceID})
2917 return nil, err
2918 }
2919 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
2920 return meInstance, nil
2921 }
2922 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2923 "device-id": oo.deviceID})
2924 return nil, omciErr.GetError()
2925}
2926
2927// SendDeleteVoiceServiceProfile nolint: unused
2928func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2929 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2930 tid := oo.GetNextTid(highPrio)
2931 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2932 "SequNo": strconv.FormatInt(int64(tid), 16),
2933 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2934
2935 meParams := me.ParamData{EntityID: aInstID}
2936 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
2937 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002938 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2939 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002940 if err != nil {
2941 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
2942 "Err": err, "device-id": oo.deviceID})
2943 return nil, err
2944 }
2945
2946 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2947 if err != nil {
2948 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
2949 "Err": err, "device-id": oo.deviceID})
2950 return nil, err
2951 }
2952
2953 omciRxCallbackPair := CallbackPair{
2954 CbKey: tid,
2955 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2956 }
2957 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2958 if err != nil {
2959 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
2960 "Err": err, "device-id": oo.deviceID})
2961 return nil, err
2962 }
2963 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
2964 return meInstance, nil
2965 }
2966 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
2967 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2968 return nil, omciErr.GetError()
2969}
2970
2971// SendCreateSIPUserData nolint: unused
2972func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
2973 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2974 tid := oo.GetNextTid(highPrio)
2975 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
2976 "SequNo": strconv.FormatInt(int64(tid), 16),
2977 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2978
2979 meInstance, omciErr := me.NewSipUserData(params[0])
2980 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002981 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2982 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002983 if err != nil {
2984 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
2985 "device-id": oo.deviceID})
2986 return nil, err
2987 }
2988
2989 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2990 if err != nil {
2991 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
2992 "device-id": oo.deviceID})
2993 return nil, err
2994 }
2995
2996 omciRxCallbackPair := CallbackPair{CbKey: tid,
2997 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2998 }
2999 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3000 if err != nil {
3001 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
3002 "device-id": oo.deviceID})
3003 return nil, err
3004 }
3005 logger.Debug(ctx, "send SIPUserData-create-msg done")
3006 return meInstance, nil
3007 }
3008 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3009 "device-id": oo.deviceID})
3010 return nil, omciErr.GetError()
3011}
3012
3013// SendSetSIPUserData nolint: unused
3014func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
3015 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3016 tid := oo.GetNextTid(highPrio)
3017 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
3018 "SequNo": strconv.FormatInt(int64(tid), 16),
3019 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3020
3021 meInstance, omciErr := me.NewSipUserData(params[0])
3022 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003023 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3024 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003025 if err != nil {
3026 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
3027 "device-id": oo.deviceID})
3028 return nil, err
3029 }
3030
3031 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3032 if err != nil {
3033 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
3034 "device-id": oo.deviceID})
3035 return nil, err
3036 }
3037
3038 omciRxCallbackPair := CallbackPair{CbKey: tid,
3039 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3040 }
3041 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3042 if err != nil {
3043 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
3044 "device-id": oo.deviceID})
3045 return nil, err
3046 }
3047 logger.Debug(ctx, "send SIPUserData-set-msg done")
3048 return meInstance, nil
3049 }
3050 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
3051 "device-id": oo.deviceID})
3052 return nil, omciErr.GetError()
3053}
3054
3055// SendDeleteSIPUserData nolint: unused
3056func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3057 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3058 tid := oo.GetNextTid(highPrio)
3059 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3060 "SequNo": strconv.FormatInt(int64(tid), 16),
3061 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3062
3063 meParams := me.ParamData{EntityID: aInstID}
3064 meInstance, omciErr := me.NewSipUserData(meParams)
3065 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003066 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3067 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003068 if err != nil {
3069 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3070 "Err": err, "device-id": oo.deviceID})
3071 return nil, err
3072 }
3073
3074 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3075 if err != nil {
3076 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3077 "Err": err, "device-id": oo.deviceID})
3078 return nil, err
3079 }
3080
3081 omciRxCallbackPair := CallbackPair{
3082 CbKey: tid,
3083 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3084 }
3085 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3086 if err != nil {
3087 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3088 "Err": err, "device-id": oo.deviceID})
3089 return nil, err
3090 }
3091 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3092 return meInstance, nil
3093 }
3094 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3095 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3096 return nil, omciErr.GetError()
3097}
3098
3099// SendCreateVoipApplicationServiceProfile nolint: unused
3100func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3101 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3102 tid := oo.GetNextTid(highPrio)
3103 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3104 "SequNo": strconv.FormatInt(int64(tid), 16),
3105 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3106
3107 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3108 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003109 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3110 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003111 if err != nil {
3112 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3113 "device-id": oo.deviceID})
3114 return nil, err
3115 }
3116
3117 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3118 if err != nil {
3119 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3120 "device-id": oo.deviceID})
3121 return nil, err
3122 }
3123
3124 omciRxCallbackPair := CallbackPair{CbKey: tid,
3125 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3126 }
3127 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3128 if err != nil {
3129 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3130 "device-id": oo.deviceID})
3131 return nil, err
3132 }
3133 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3134 return meInstance, nil
3135 }
3136 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3137 "device-id": oo.deviceID})
3138 return nil, omciErr.GetError()
3139}
3140
3141// SendSetVoipApplicationServiceProfile nolint: unused
3142func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3143 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3144 tid := oo.GetNextTid(highPrio)
3145 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3146 "SequNo": strconv.FormatInt(int64(tid), 16),
3147 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3148
3149 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3150 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003151 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3152 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003153 if err != nil {
3154 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3155 "device-id": oo.deviceID})
3156 return nil, err
3157 }
3158
3159 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3160 if err != nil {
3161 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3162 "device-id": oo.deviceID})
3163 return nil, err
3164 }
3165
3166 omciRxCallbackPair := CallbackPair{CbKey: tid,
3167 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3168 }
3169 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3170 if err != nil {
3171 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3172 "device-id": oo.deviceID})
3173 return nil, err
3174 }
3175 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3176 return meInstance, nil
3177 }
3178 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3179 "device-id": oo.deviceID})
3180 return nil, omciErr.GetError()
3181}
3182
3183// SendDeleteVoipApplicationServiceProfile nolint: unused
3184func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3185 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3186 tid := oo.GetNextTid(highPrio)
3187 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3188 "SequNo": strconv.FormatInt(int64(tid), 16),
3189 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3190
3191 meParams := me.ParamData{EntityID: aInstID}
3192 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3193 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003194 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3195 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003196 if err != nil {
3197 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3198 "Err": err, "device-id": oo.deviceID})
3199 return nil, err
3200 }
3201
3202 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3203 if err != nil {
3204 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3205 "Err": err, "device-id": oo.deviceID})
3206 return nil, err
3207 }
3208
3209 omciRxCallbackPair := CallbackPair{
3210 CbKey: tid,
3211 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3212 }
3213 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3214 if err != nil {
3215 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3216 "Err": err, "device-id": oo.deviceID})
3217 return nil, err
3218 }
3219 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3220 return meInstance, nil
3221 }
3222 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3223 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3224 return nil, omciErr.GetError()
3225}
3226
3227// SendCreateSIPAgentConfigData nolint: unused
3228func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3229 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3230 tid := oo.GetNextTid(highPrio)
3231 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3232 "SequNo": strconv.FormatInt(int64(tid), 16),
3233 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3234
3235 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3236 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003237 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3238 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003239 if err != nil {
3240 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3241 "device-id": oo.deviceID})
3242 return nil, err
3243 }
3244
3245 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3246 if err != nil {
3247 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3248 "device-id": oo.deviceID})
3249 return nil, err
3250 }
3251
3252 omciRxCallbackPair := CallbackPair{CbKey: tid,
3253 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3254 }
3255 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3256 if err != nil {
3257 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3258 "device-id": oo.deviceID})
3259 return nil, err
3260 }
3261 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3262 return meInstance, nil
3263 }
3264 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3265 "device-id": oo.deviceID})
3266 return nil, omciErr.GetError()
3267}
3268
3269// SendSetSIPAgentConfigData nolint: unused
3270func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3271 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3272 tid := oo.GetNextTid(highPrio)
3273 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3274 "SequNo": strconv.FormatInt(int64(tid), 16),
3275 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3276
3277 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3278 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003279 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3280 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003281 if err != nil {
3282 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3283 "device-id": oo.deviceID})
3284 return nil, err
3285 }
3286
3287 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3288 if err != nil {
3289 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3290 "device-id": oo.deviceID})
3291 return nil, err
3292 }
3293
3294 omciRxCallbackPair := CallbackPair{CbKey: tid,
3295 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3296 }
3297 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3298 if err != nil {
3299 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3300 "device-id": oo.deviceID})
3301 return nil, err
3302 }
3303 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3304 return meInstance, nil
3305 }
3306 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3307 "device-id": oo.deviceID})
3308 return nil, omciErr.GetError()
3309}
3310
3311// SendDeleteSIPAgentConfigData nolint: unused
3312func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3313 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3314 tid := oo.GetNextTid(highPrio)
3315 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3316 "SequNo": strconv.FormatInt(int64(tid), 16),
3317 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3318
3319 meParams := me.ParamData{EntityID: aInstID}
3320 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3321 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003322 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3323 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003324 if err != nil {
3325 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3326 "Err": err, "device-id": oo.deviceID})
3327 return nil, err
3328 }
3329
3330 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3331 if err != nil {
3332 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3333 "Err": err, "device-id": oo.deviceID})
3334 return nil, err
3335 }
3336
3337 omciRxCallbackPair := CallbackPair{
3338 CbKey: tid,
3339 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3340 }
3341 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3342 if err != nil {
3343 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3344 "Err": err, "device-id": oo.deviceID})
3345 return nil, err
3346 }
3347 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3348 return meInstance, nil
3349 }
3350 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3351 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3352 return nil, omciErr.GetError()
3353}
3354
3355// SendCreateTCPUDPConfigData nolint: unused
3356func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3357 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3358 tid := oo.GetNextTid(highPrio)
3359 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3360 "SequNo": strconv.FormatInt(int64(tid), 16),
3361 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3362
3363 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3364 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003365 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3366 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003367 if err != nil {
3368 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3369 "device-id": oo.deviceID})
3370 return nil, err
3371 }
3372
3373 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3374 if err != nil {
3375 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3376 "device-id": oo.deviceID})
3377 return nil, err
3378 }
3379
3380 omciRxCallbackPair := CallbackPair{CbKey: tid,
3381 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3382 }
3383 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3384 if err != nil {
3385 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3386 "device-id": oo.deviceID})
3387 return nil, err
3388 }
3389 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3390 return meInstance, nil
3391 }
3392 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3393 "device-id": oo.deviceID})
3394 return nil, omciErr.GetError()
3395}
3396
3397// SendSetTCPUDPConfigData nolint: unused
3398func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3399 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3400 tid := oo.GetNextTid(highPrio)
3401 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3402 "SequNo": strconv.FormatInt(int64(tid), 16),
3403 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3404
3405 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3406 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003407 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3408 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003409 if err != nil {
3410 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3411 "device-id": oo.deviceID})
3412 return nil, err
3413 }
3414
3415 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3416 if err != nil {
3417 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3418 "device-id": oo.deviceID})
3419 return nil, err
3420 }
3421
3422 omciRxCallbackPair := CallbackPair{CbKey: tid,
3423 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3424 }
3425 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3426 if err != nil {
3427 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3428 "device-id": oo.deviceID})
3429 return nil, err
3430 }
3431 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3432 return meInstance, nil
3433 }
3434 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3435 "device-id": oo.deviceID})
3436 return nil, omciErr.GetError()
3437}
3438
3439// SendDeleteTCPUDPConfigData nolint: unused
3440func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3441 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3442 tid := oo.GetNextTid(highPrio)
3443 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3444 "SequNo": strconv.FormatInt(int64(tid), 16),
3445 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3446
3447 meParams := me.ParamData{EntityID: aInstID}
3448 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3449 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003450 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3451 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003452 if err != nil {
3453 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3454 "Err": err, "device-id": oo.deviceID})
3455 return nil, err
3456 }
3457
3458 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3459 if err != nil {
3460 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3461 "Err": err, "device-id": oo.deviceID})
3462 return nil, err
3463 }
3464
3465 omciRxCallbackPair := CallbackPair{
3466 CbKey: tid,
3467 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3468 }
3469 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3470 if err != nil {
3471 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3472 "Err": err, "device-id": oo.deviceID})
3473 return nil, err
3474 }
3475 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3476 return meInstance, nil
3477 }
3478 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3479 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3480 return nil, omciErr.GetError()
3481}
3482
3483// SendCreateIPHostConfigData nolint: unused
3484func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3485 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3486 tid := oo.GetNextTid(highPrio)
3487 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3488 "SequNo": strconv.FormatInt(int64(tid), 16),
3489 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3490
3491 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3492 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003493 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3494 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003495 if err != nil {
3496 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3497 "device-id": oo.deviceID})
3498 return nil, err
3499 }
3500
3501 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3502 if err != nil {
3503 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3504 "device-id": oo.deviceID})
3505 return nil, err
3506 }
3507
3508 omciRxCallbackPair := CallbackPair{CbKey: tid,
3509 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3510 }
3511 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3512 if err != nil {
3513 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3514 "device-id": oo.deviceID})
3515 return nil, err
3516 }
3517 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3518 return meInstance, nil
3519 }
3520 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3521 "device-id": oo.deviceID})
3522 return nil, omciErr.GetError()
3523}
3524
3525// SendSetIPHostConfigData nolint: unused
3526func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3527 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3528 tid := oo.GetNextTid(highPrio)
3529 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3530 "SequNo": strconv.FormatInt(int64(tid), 16),
3531 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3532
3533 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3534 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003535 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3536 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003537 if err != nil {
3538 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3539 "device-id": oo.deviceID})
3540 return nil, err
3541 }
3542
3543 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3544 if err != nil {
3545 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3546 "device-id": oo.deviceID})
3547 return nil, err
3548 }
3549
3550 omciRxCallbackPair := CallbackPair{CbKey: tid,
3551 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3552 }
3553 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3554 if err != nil {
3555 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3556 "device-id": oo.deviceID})
3557 return nil, err
3558 }
3559 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3560 return meInstance, nil
3561 }
3562 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3563 "device-id": oo.deviceID})
3564 return nil, omciErr.GetError()
3565}
3566
3567// SendDeleteIPHostConfigData nolint: unused
3568func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3569 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3570 tid := oo.GetNextTid(highPrio)
3571 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3572 "SequNo": strconv.FormatInt(int64(tid), 16),
3573 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3574
3575 meParams := me.ParamData{EntityID: aInstID}
3576 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3577 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003578 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3579 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003580 if err != nil {
3581 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3582 "Err": err, "device-id": oo.deviceID})
3583 return nil, err
3584 }
3585
3586 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3587 if err != nil {
3588 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3589 "Err": err, "device-id": oo.deviceID})
3590 return nil, err
3591 }
3592
3593 omciRxCallbackPair := CallbackPair{
3594 CbKey: tid,
3595 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3596 }
3597 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3598 if err != nil {
3599 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3600 "Err": err, "device-id": oo.deviceID})
3601 return nil, err
3602 }
3603 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3604 return meInstance, nil
3605 }
3606 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3607 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3608 return nil, omciErr.GetError()
3609}
3610
3611// SendCreateRTPProfileData nolint: unused
3612func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3613 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3614 tid := oo.GetNextTid(highPrio)
3615 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3616 "SequNo": strconv.FormatInt(int64(tid), 16),
3617 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3618
3619 meInstance, omciErr := me.NewRtpProfileData(params[0])
3620 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003621 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3622 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003623 if err != nil {
3624 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3625 "device-id": oo.deviceID})
3626 return nil, err
3627 }
3628
3629 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3630 if err != nil {
3631 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3632 "device-id": oo.deviceID})
3633 return nil, err
3634 }
3635
3636 omciRxCallbackPair := CallbackPair{CbKey: tid,
3637 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3638 }
3639 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3640 if err != nil {
3641 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3642 "device-id": oo.deviceID})
3643 return nil, err
3644 }
3645 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3646 return meInstance, nil
3647 }
3648 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3649 "device-id": oo.deviceID})
3650 return nil, omciErr.GetError()
3651}
3652
3653// SendSetRTPProfileData nolint: unused
3654func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3655 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3656 tid := oo.GetNextTid(highPrio)
3657 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3658 "SequNo": strconv.FormatInt(int64(tid), 16),
3659 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3660
3661 meInstance, omciErr := me.NewRtpProfileData(params[0])
3662 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003663 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3664 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003665 if err != nil {
3666 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3667 "device-id": oo.deviceID})
3668 return nil, err
3669 }
3670
3671 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3672 if err != nil {
3673 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3674 "device-id": oo.deviceID})
3675 return nil, err
3676 }
3677
3678 omciRxCallbackPair := CallbackPair{CbKey: tid,
3679 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3680 }
3681 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3682 if err != nil {
3683 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3684 "device-id": oo.deviceID})
3685 return nil, err
3686 }
3687 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3688 return meInstance, nil
3689 }
3690 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3691 "device-id": oo.deviceID})
3692 return nil, omciErr.GetError()
3693}
3694
3695// SendDeleteRTPProfileData nolint: unused
3696func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3697 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3698 tid := oo.GetNextTid(highPrio)
3699 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3700 "SequNo": strconv.FormatInt(int64(tid), 16),
3701 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3702
3703 meParams := me.ParamData{EntityID: aInstID}
3704 meInstance, omciErr := me.NewRtpProfileData(meParams)
3705 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003706 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3707 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003708 if err != nil {
3709 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3710 "Err": err, "device-id": oo.deviceID})
3711 return nil, err
3712 }
3713
3714 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3715 if err != nil {
3716 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3717 "Err": err, "device-id": oo.deviceID})
3718 return nil, err
3719 }
3720
3721 omciRxCallbackPair := CallbackPair{
3722 CbKey: tid,
3723 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3724 }
3725 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3726 if err != nil {
3727 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3728 "Err": err, "device-id": oo.deviceID})
3729 return nil, err
3730 }
3731 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3732 return meInstance, nil
3733 }
3734 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3735 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3736 return nil, omciErr.GetError()
3737}
3738
3739// SendCreateNetworkDialPlanTable nolint: unused
3740func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3741 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3742 tid := oo.GetNextTid(highPrio)
3743 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3744 "SequNo": strconv.FormatInt(int64(tid), 16),
3745 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3746
3747 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3748 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003749 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3750 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003751 if err != nil {
3752 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3753 "device-id": oo.deviceID})
3754 return nil, err
3755 }
3756
3757 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3758 if err != nil {
3759 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3760 "device-id": oo.deviceID})
3761 return nil, err
3762 }
3763
3764 omciRxCallbackPair := CallbackPair{CbKey: tid,
3765 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3766 }
3767 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3768 if err != nil {
3769 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3770 "device-id": oo.deviceID})
3771 return nil, err
3772 }
3773 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3774 return meInstance, nil
3775 }
3776 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3777 "device-id": oo.deviceID})
3778 return nil, omciErr.GetError()
3779}
3780
3781// SendSetNetworkDialPlanTable nolint: unused
3782func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3783 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3784 tid := oo.GetNextTid(highPrio)
3785 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3786 "SequNo": strconv.FormatInt(int64(tid), 16),
3787 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3788
3789 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3790 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003791 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
3792 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003793 if err != nil {
3794 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3795 "device-id": oo.deviceID})
3796 return nil, err
3797 }
3798
3799 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3800 if err != nil {
3801 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3802 "device-id": oo.deviceID})
3803 return nil, err
3804 }
3805
3806 omciRxCallbackPair := CallbackPair{CbKey: tid,
3807 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3808 }
3809 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3810 if err != nil {
3811 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3812 "device-id": oo.deviceID})
3813 return nil, err
3814 }
3815 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3816 return meInstance, nil
3817 }
3818 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3819 "device-id": oo.deviceID})
3820 return nil, omciErr.GetError()
3821}
3822
3823// SendDeleteNetworkDialPlanTable nolint: unused
3824func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3825 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3826 tid := oo.GetNextTid(highPrio)
3827 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3828 "SequNo": strconv.FormatInt(int64(tid), 16),
3829 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3830
3831 meParams := me.ParamData{EntityID: aInstID}
3832 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3833 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003834 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3835 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003836 if err != nil {
3837 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3838 "Err": err, "device-id": oo.deviceID})
3839 return nil, err
3840 }
3841
3842 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3843 if err != nil {
3844 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3845 "Err": err, "device-id": oo.deviceID})
3846 return nil, err
3847 }
3848
3849 omciRxCallbackPair := CallbackPair{
3850 CbKey: tid,
3851 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3852 }
3853 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3854 if err != nil {
3855 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3856 "Err": err, "device-id": oo.deviceID})
3857 return nil, err
3858 }
3859 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3860 return meInstance, nil
3861 }
3862 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3863 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3864 return nil, omciErr.GetError()
3865}
3866
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003867// SendSyncTime sends SynchronizeTimeRequest
3868func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
3869 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003870 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
3871 "SequNo": strconv.FormatInt(int64(tid), 16)})
3872
3873 omciLayer := &omci.OMCI{
3874 TransactionID: tid,
3875 MessageType: omci.SynchronizeTimeRequestType,
3876 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3877 // Length: 0x28, // Optional, defaults to 40 octets
3878 }
3879 utcTime := time.Now().UTC()
3880 request := &omci.SynchronizeTimeRequest{
3881 MeBasePacket: omci.MeBasePacket{
3882 EntityClass: me.OnuGClassID,
3883 // Default Instance ID is 0
3884 },
3885 Year: uint16(utcTime.Year()),
3886 Month: uint8(utcTime.Month()),
3887 Day: uint8(utcTime.Day()),
3888 Hour: uint8(utcTime.Hour()),
3889 Minute: uint8(utcTime.Minute()),
3890 Second: uint8(utcTime.Second()),
3891 }
3892
3893 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
3894 if err != nil {
3895 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
3896 "device-id": oo.deviceID})
3897 return err
3898 }
3899
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003900 omciRxCallbackPair := CallbackPair{CbKey: tid,
3901 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003902 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003903 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003904 if err != nil {
3905 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
3906 "device-id": oo.deviceID})
3907 return err
3908 }
3909 logger.Debug(ctx, "send synchronize time request done")
3910 return nil
3911}
3912
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003913// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
3914func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003915 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003916 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003917 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3918 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3919 meParam := me.ParamData{EntityID: entityID}
3920 var meInstance *me.ManagedEntity
3921 var omciErr me.OmciErrors
3922 if upstream {
3923 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
3924 } else {
3925 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
3926 }
3927 if omciErr.GetError() == nil {
3928 var omciLayer *omci.OMCI
3929 var msgLayer gopacket.SerializableLayer
3930 var err error
3931 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003932 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3933 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003934 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003935 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
3936 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003937 }
3938 if err != nil {
3939 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
3940 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003941 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003942 }
3943
3944 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3945 if err != nil {
3946 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
3947 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003948 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003949 }
3950
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003951 omciRxCallbackPair := CallbackPair{CbKey: tid,
3952 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003953 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003954 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003955 if err != nil {
3956 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
3957 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003958 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003959 }
3960 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
3961 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003962 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08003963 }
3964 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
3965 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 +03003966 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08003967}
3968
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003969// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
3970func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003971 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003972 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003973 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3974 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
3975 meParam := me.ParamData{EntityID: entityID}
3976 var meInstance *me.ManagedEntity
3977 var omciErr me.OmciErrors
3978 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
3979
3980 if omciErr.GetError() == nil {
3981 var omciLayer *omci.OMCI
3982 var msgLayer gopacket.SerializableLayer
3983 var err error
3984 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003985 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3986 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003987 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003988 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
3989 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003990 }
3991 if err != nil {
3992 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
3993 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003994 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003995 }
3996
3997 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3998 if err != nil {
3999 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
4000 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004001 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004002 }
4003
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004004 omciRxCallbackPair := CallbackPair{CbKey: tid,
4005 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08004006 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004007 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08004008 if err != nil {
4009 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
4010 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004011 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08004012 }
4013 logger.Debugw(ctx, "send ethernet uni history data ME done",
4014 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004015 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08004016 }
4017 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
4018 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004019 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08004020}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004021
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004022// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
4023func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004024 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004025 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004026 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4027 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4028 meParam := me.ParamData{EntityID: entityID}
4029 var meInstance *me.ManagedEntity
4030 var omciErr me.OmciErrors
4031 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
4032
4033 if omciErr.GetError() == nil {
4034 var omciLayer *omci.OMCI
4035 var msgLayer gopacket.SerializableLayer
4036 var err error
4037 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004038 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4039 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004040 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004041 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4042 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004043 }
4044 if err != nil {
4045 logger.Errorw(ctx, "Cannot encode fec history data ME",
4046 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004047 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004048 }
4049
4050 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4051 if err != nil {
4052 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4053 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004054 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004055 }
4056
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004057 omciRxCallbackPair := CallbackPair{CbKey: tid,
4058 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004059 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004060 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004061 if err != nil {
4062 logger.Errorw(ctx, "Cannot send fec history data ME",
4063 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004064 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004065 }
4066 logger.Debugw(ctx, "send fec history data ME done",
4067 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004068 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004069 }
4070 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4071 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004072 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004073}
4074
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004075// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4076func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004077 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004078 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004079 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4080 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4081 meParam := me.ParamData{EntityID: entityID}
4082 var meInstance *me.ManagedEntity
4083 var omciErr me.OmciErrors
4084 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4085
4086 if omciErr.GetError() == nil {
4087 var omciLayer *omci.OMCI
4088 var msgLayer gopacket.SerializableLayer
4089 var err error
4090 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004091 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4092 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004093 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004094 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4095 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004096 }
4097 if err != nil {
4098 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4099 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004100 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004101 }
4102
4103 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4104 if err != nil {
4105 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4106 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004107 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004108 }
4109
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004110 omciRxCallbackPair := CallbackPair{CbKey: tid,
4111 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004112 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004113 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004114 if err != nil {
4115 logger.Errorw(ctx, "Cannot send gemport history data ME",
4116 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004117 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004118 }
4119 logger.Debugw(ctx, "send gemport history data ME done",
4120 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004121 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004122 }
4123 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4124 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004125 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004126}
4127
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004128// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4129func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004130 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004131 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004132 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4133 "SequNo": strconv.FormatInt(int64(tid), 16),
4134 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4135
4136 omciLayer := &omci.OMCI{
4137 TransactionID: tid,
4138 MessageType: omci.StartSoftwareDownloadRequestType,
4139 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4140 // Length: 0x28, // Optional, defaults to 40 octets
4141 }
4142 request := &omci.StartSoftwareDownloadRequest{
4143 MeBasePacket: omci.MeBasePacket{
4144 EntityClass: me.SoftwareImageClassID,
4145 EntityInstance: aImageMeID, //inactive image
4146 },
4147 WindowSize: aDownloadWindowSize,
4148 ImageSize: aFileLen,
4149 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4150 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4151 }
4152
4153 var options gopacket.SerializeOptions
4154 options.FixLengths = true
4155 buffer := gopacket.NewSerializeBuffer()
4156 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4157 if err != nil {
4158 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4159 "device-id": oo.deviceID})
4160 return err
4161 }
4162 outgoingPacket := buffer.Bytes()
4163
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004164 omciRxCallbackPair := CallbackPair{CbKey: tid,
4165 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004166 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004167 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004168 if err != nil {
4169 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4170 "device-id": oo.deviceID})
4171 return err
4172 }
4173 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004174 return nil
4175}
4176
kesavand011d5162021-11-25 19:21:06 +05304177// PrepareOnuSectionsOfWindow prepares a list of sections for each window
4178//Before invoking this function the oo.mutexTid needs to be be locked so that
4179//GetOnuSwSecNextTid can be invoked without further locking
4180func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context,
4181 aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte,
4182 omciMsgsPerWindow *ia.OmciMessages) (OmciTransferStructure, error) {
4183 //onuswsections uses only low prioirity tids
4184 tid := oo.GetOnuSwSecNextTid()
4185 logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4186 "SequNo": strconv.FormatInt(int64(tid), 16),
4187 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection})
4188
4189 var omciTxReq OmciTransferStructure
4190 msgType := omci.DownloadSectionRequestType
4191
4192 if aAckRequest > 0 {
4193 msgType = omci.DownloadSectionRequestWithResponseType
4194
4195 }
4196 omciLayer := &omci.OMCI{
4197 TransactionID: tid,
4198 MessageType: msgType,
4199 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4200 // Length: 0x28, // Optional, defaults to 40 octets
4201 }
4202 localSectionData := make([]byte, len(aSection))
4203
4204 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
4205 request := &omci.DownloadSectionRequest{
4206 MeBasePacket: omci.MeBasePacket{
4207 EntityClass: me.SoftwareImageClassID,
4208 EntityInstance: aImageMeID, //inactive image
4209 },
4210 SectionNumber: aDownloadSectionNo,
4211 SectionData: localSectionData,
4212 }
4213
4214 var options gopacket.SerializeOptions
4215 options.FixLengths = true
4216 buffer := gopacket.NewSerializeBuffer()
4217 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4218 if err != nil {
4219 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4220 "device-id": oo.deviceID})
4221 return omciTxReq, err
4222 }
4223 outgoingPacket := buffer.Bytes()
4224
4225 omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket)
4226
4227 if aAckRequest > 0 {
4228 // only the last section should have a timeout as an ack is required only for the last section of the window
4229 omciTxReq = OmciTransferStructure{
4230 withFramePrint: true,
4231 OnuSwWindow: omciMsgsPerWindow,
4232 }
4233 return omciTxReq, nil
4234 }
4235
4236 return omciTxReq, nil
4237}
4238
4239//SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections
4240func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context,
4241 aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) {
4242 if aOmciTxRequest.OnuSwWindow == nil {
4243 logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil",
4244 log.Fields{"device-id": oo.deviceID})
4245 return
4246
4247 }
4248
4249 tid := oo.GetOnuSwSecLastTid()
4250 logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid})
4251 omciRxCallbackPair := CallbackPair{CbKey: tid,
4252 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4253 }
4254
4255 aOmciTxRequest.cbPair = omciRxCallbackPair
4256 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey})
4257 oo.mutexRxSchedMap.Lock()
4258 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
4259 oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry
4260 oo.mutexRxSchedMap.Unlock()
4261
4262 chSuccess := make(chan bool)
4263 aOmciTxRequest.chSuccess = chSuccess
4264 aOmciTxRequest.timeout = aTimeout
4265 aOmciTxRequest.retries = CDefaultRetries
4266
4267 //tid := aOmciTxRequest.cbPair.CbKey
4268 oo.mutexMonReq.Lock()
4269 oo.monitoredRequests[tid] = aOmciTxRequest
4270 oo.mutexMonReq.Unlock()
4271
4272 retries := aOmciTxRequest.retries
4273 retryCounter := 0
4274 if aTimeout == 0 {
4275 logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID})
4276 return
4277 }
4278loop:
4279 for retryCounter <= retries {
4280 // the onu sw sections are enqueued only to the low priority queue
4281 oo.mutexLowPrioTxQueue.Lock()
4282 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4283 oo.mutexLowPrioTxQueue.Unlock()
4284
4285 go oo.sendQueuedRequests(ctx)
4286
4287 select {
4288 case success := <-chSuccess:
4289 if success {
4290 logger.Debugw(ctx, "reqMon: response received in time",
4291 log.Fields{"tid": tid, "device-id": oo.deviceID})
4292 } else {
4293 logger.Debugw(ctx, "reqMon: wait for response aborted",
4294 log.Fields{"tid": tid, "device-id": oo.deviceID})
4295 }
4296 break loop
4297 case <-time.After(time.Duration(aTimeout) * time.Second):
4298 if retryCounter == retries {
4299 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
4300 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4301 break loop
4302 } else {
4303 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4304 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4305 }
4306 }
4307 retryCounter++
4308 }
4309 oo.mutexMonReq.Lock()
4310 delete(oo.monitoredRequests, tid)
4311 oo.mutexMonReq.Unlock()
4312}
4313
4314func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error {
4315 if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil {
4316 lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1]
4317 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
4318 "TxOmciMessage": hex.EncodeToString(lastSection),
4319 "device-id": oo.deviceID,
4320 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
4321 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
4322 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
4323 }
4324 sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow)
4325 if sendErr != nil {
4326 logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
4327 return sendErr
4328 }
4329 return nil
4330}
4331
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004332// SendDownloadSection sends DownloadSectionRequestWithResponse
4333func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004334 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004335 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004336 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4337 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004338 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004339
4340 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4341 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004342 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004343 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004344 if aAckRequest > 0 {
4345 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004346 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004347 }
mpagenko80622a52021-02-09 16:53:23 +00004348 omciLayer := &omci.OMCI{
4349 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004350 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004351 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4352 // Length: 0x28, // Optional, defaults to 40 octets
4353 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304354 localSectionData := make([]byte, len(aSection))
4355
mpagenko15ff4a52021-03-02 10:09:20 +00004356 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004357 request := &omci.DownloadSectionRequest{
4358 MeBasePacket: omci.MeBasePacket{
4359 EntityClass: me.SoftwareImageClassID,
4360 EntityInstance: aImageMeID, //inactive image
4361 },
4362 SectionNumber: aDownloadSectionNo,
4363 SectionData: localSectionData,
4364 }
4365
4366 var options gopacket.SerializeOptions
4367 options.FixLengths = true
4368 buffer := gopacket.NewSerializeBuffer()
4369 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4370 if err != nil {
4371 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4372 "device-id": oo.deviceID})
4373 return err
4374 }
4375 outgoingPacket := buffer.Bytes()
4376
mpagenko15ff4a52021-03-02 10:09:20 +00004377 //for initial debug purpose overrule the requested print state for some frames
4378 printFrame := aPrint
4379 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4380 printFrame = true
4381 }
4382
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004383 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004384 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4385 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004386 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004387 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004388 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004389 if err != nil {
4390 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4391 "device-id": oo.deviceID})
4392 return err
4393 }
4394 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004395 return nil
4396}
4397
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004398//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4399func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004400 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004401 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004402 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4403 "SequNo": strconv.FormatInt(int64(tid), 16),
4404 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4405
mpagenko15ff4a52021-03-02 10:09:20 +00004406 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004407 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004408 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004409 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4410 // Length: 0x28, // Optional, defaults to 40 octets
4411 }
mpagenko15ff4a52021-03-02 10:09:20 +00004412 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004413 MeBasePacket: omci.MeBasePacket{
4414 EntityClass: me.SoftwareImageClassID,
4415 EntityInstance: aImageMeID, //inactive image
4416 },
mpagenko15ff4a52021-03-02 10:09:20 +00004417 CRC32: aImageCrc,
4418 ImageSize: aFileLen,
4419 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4420 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004421 }
mpagenko15ff4a52021-03-02 10:09:20 +00004422
4423 var options gopacket.SerializeOptions
4424 options.FixLengths = true
4425 buffer := gopacket.NewSerializeBuffer()
4426 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4427 if err != nil {
4428 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004429 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004430 return err
mpagenko80622a52021-02-09 16:53:23 +00004431 }
mpagenko15ff4a52021-03-02 10:09:20 +00004432 outgoingPacket := buffer.Bytes()
4433
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004434 omciRxCallbackPair := CallbackPair{CbKey: tid,
4435 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004436 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004437 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004438 if err != nil {
4439 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4440 "device-id": oo.deviceID})
4441 return err
4442 }
4443 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004444 return nil
4445}
4446
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004447// SendActivateSoftware sends ActivateSoftwareRequest
4448func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004449 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004450 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004451 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4452 "SequNo": strconv.FormatInt(int64(tid), 16),
4453 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4454
4455 omciLayer := &omci.OMCI{
4456 TransactionID: tid,
4457 MessageType: omci.ActivateSoftwareRequestType,
4458 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4459 // Length: 0x28, // Optional, defaults to 40 octets
4460 }
4461 request := &omci.ActivateSoftwareRequest{
4462 MeBasePacket: omci.MeBasePacket{
4463 EntityClass: me.SoftwareImageClassID,
4464 EntityInstance: aImageMeID, //inactive image
4465 },
4466 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4467 }
4468
4469 var options gopacket.SerializeOptions
4470 options.FixLengths = true
4471 buffer := gopacket.NewSerializeBuffer()
4472 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4473 if err != nil {
4474 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4475 "device-id": oo.deviceID})
4476 return err
4477 }
4478 outgoingPacket := buffer.Bytes()
4479
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004480 omciRxCallbackPair := CallbackPair{CbKey: tid,
4481 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004482 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004483 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004484 if err != nil {
4485 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4486 "device-id": oo.deviceID})
4487 return err
4488 }
4489 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004490 return nil
4491}
mpagenko80622a52021-02-09 16:53:23 +00004492
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004493// SendCommitSoftware sends CommitSoftwareRequest
4494func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko15ff4a52021-03-02 10:09:20 +00004495 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004496 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004497 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4498 "SequNo": strconv.FormatInt(int64(tid), 16),
4499 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4500
4501 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004502 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004503 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004504 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4505 // Length: 0x28, // Optional, defaults to 40 octets
4506 }
mpagenko15ff4a52021-03-02 10:09:20 +00004507 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004508 MeBasePacket: omci.MeBasePacket{
4509 EntityClass: me.SoftwareImageClassID,
4510 EntityInstance: aImageMeID, //inactive image
4511 },
mpagenko80622a52021-02-09 16:53:23 +00004512 }
mpagenko15ff4a52021-03-02 10:09:20 +00004513
4514 var options gopacket.SerializeOptions
4515 options.FixLengths = true
4516 buffer := gopacket.NewSerializeBuffer()
4517 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4518 if err != nil {
4519 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004520 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004521 return err
mpagenko80622a52021-02-09 16:53:23 +00004522 }
mpagenko15ff4a52021-03-02 10:09:20 +00004523 outgoingPacket := buffer.Bytes()
4524
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004525 omciRxCallbackPair := CallbackPair{CbKey: tid,
4526 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004527 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004528 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004529 if err != nil {
4530 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4531 "device-id": oo.deviceID})
4532 return err
4533 }
4534 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004535 return nil
4536}
4537
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004538//SendSelfTestReq sends TestRequest
4539func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4540 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004541 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4542 "SequNo": strconv.FormatInt(int64(tid), 16),
4543 "InstId": strconv.FormatInt(int64(instdID), 16)})
4544 omciLayer := &omci.OMCI{
4545 TransactionID: tid,
4546 MessageType: omci.TestRequestType,
4547 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4548 // Length: 0x28, // Optional, defaults to 40 octets
4549 }
4550
4551 var request *omci.OpticalLineSupervisionTestRequest
4552 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004553 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004554 request = &omci.OpticalLineSupervisionTestRequest{
4555 MeBasePacket: omci.MeBasePacket{
4556 EntityClass: classID,
4557 EntityInstance: instdID,
4558 },
4559 SelectTest: uint8(7), // self test
4560 GeneralPurposeBuffer: uint16(0),
4561 VendorSpecificParameters: uint16(0),
4562 }
4563 default:
4564 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4565 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4566 }
4567 // Test serialization back to former string
4568 var options gopacket.SerializeOptions
4569 options.FixLengths = true
4570
4571 buffer := gopacket.NewSerializeBuffer()
4572 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4573 if err != nil {
4574 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4575 "device-id": oo.deviceID})
4576 return err
4577 }
4578 outgoingPacket := buffer.Bytes()
4579
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004580 omciRxCallbackPair := CallbackPair{CbKey: tid,
4581 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004582 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004583 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004584 if err != nil {
4585 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4586 "device-id": oo.deviceID})
4587 return err
4588 }
4589 logger.Debug(ctx, "send self test request done")
4590 return nil
4591}
4592
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004593//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004594func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004595 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004596 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004597 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004598 msgLayer := (*packet).Layer(nextLayer)
4599 switch nextLayer {
4600 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004601 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4602 if resp.Result == me.Success {
4603 return true
4604 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004605 }
4606 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004607 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4608 if resp.Result == me.Success {
4609 return true
4610 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004611 }
4612 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004613 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4614 if resp.Result == me.Success {
4615 return true
4616 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004617 }
4618 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004619 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4620 if resp.Result == me.Success {
4621 return true
4622 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004623 }
4624 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004625 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4626 if resp.Result == me.Success {
4627 return true
4628 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004629 }
4630 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004631 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4632 if resp.Result == me.Success {
4633 return true
4634 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004635 }
4636 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004637 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4638 if resp.Result == me.Success {
4639 return true
4640 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004641 }
4642 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004643 }
4644 }
4645 return false
4646}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004647
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004648func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004649 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004650 if timeout == 0 {
4651 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004652 // enqueue
4653 if aOmciTxRequest.highPrio {
4654 oo.mutexHighPrioTxQueue.Lock()
4655 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4656 oo.mutexHighPrioTxQueue.Unlock()
4657 } else {
4658 oo.mutexLowPrioTxQueue.Lock()
4659 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4660 oo.mutexLowPrioTxQueue.Unlock()
4661 }
4662 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004663 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004664 //the supervised sending with waiting on the response (based on TID) is called in background
4665 // to avoid blocking of the sender for the complete OMCI handshake procedure
4666 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4667 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4668 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004669 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004670}
4671
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004672func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004673 chSuccess := make(chan bool)
4674 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004675 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004676 oo.mutexMonReq.Lock()
4677 oo.monitoredRequests[tid] = aOmciTxRequest
4678 oo.mutexMonReq.Unlock()
4679
4680 retries := aOmciTxRequest.retries
4681 retryCounter := 0
4682loop:
4683 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004684 // enqueue
4685 if aOmciTxRequest.highPrio {
4686 oo.mutexHighPrioTxQueue.Lock()
4687 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4688 oo.mutexHighPrioTxQueue.Unlock()
4689 } else {
4690 oo.mutexLowPrioTxQueue.Lock()
4691 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4692 oo.mutexLowPrioTxQueue.Unlock()
4693 }
4694 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004695
4696 select {
4697 case success := <-chSuccess:
4698 if success {
4699 logger.Debugw(ctx, "reqMon: response received in time",
4700 log.Fields{"tid": tid, "device-id": oo.deviceID})
4701 } else {
4702 logger.Debugw(ctx, "reqMon: wait for response aborted",
4703 log.Fields{"tid": tid, "device-id": oo.deviceID})
4704 }
4705 break loop
4706 case <-time.After(time.Duration(aTimeout) * time.Second):
4707 if retryCounter == retries {
4708 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
4709 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4710 break loop
4711 } else {
4712 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4713 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4714 }
4715 }
4716 retryCounter++
4717 }
4718 oo.mutexMonReq.Lock()
4719 delete(oo.monitoredRequests, tid)
4720 oo.mutexMonReq.Unlock()
4721}
4722
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004723//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004724func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004725 oo.mutexMonReq.RLock()
4726 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004727 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4728 select {
4729 case oo.monitoredRequests[k].chSuccess <- false:
4730 default:
4731 logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
4732 "index": k, "device-id": oo.deviceID})
4733 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004734 }
4735 oo.mutexMonReq.RUnlock()
4736}
4737
4738//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4739//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004740func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4741 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004742}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304743
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004744// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4745func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304746 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004747 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304748 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4749 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4750
4751 meParam := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004752 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304753 }
4754 var meInstance *me.ManagedEntity
4755 var omciErr me.OmciErrors
4756 if classID == me.EthernetFrameExtendedPmClassID {
4757 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4758 } else {
4759 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4760 }
4761
4762 if omciErr.GetError() == nil {
4763 var omciLayer *omci.OMCI
4764 var msgLayer gopacket.SerializableLayer
4765 var err error
4766 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004767 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4768 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304769 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004770 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4771 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304772 }
4773 if err != nil {
4774 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4775 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4776 return nil, err
4777 }
4778
4779 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4780 if err != nil {
4781 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
4782 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4783 return nil, err
4784 }
4785
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004786 omciRxCallbackPair := CallbackPair{CbKey: tid,
4787 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304788 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004789 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304790 if err != nil {
4791 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4792 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4793 return nil, err
4794 }
4795 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
4796 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4797 return meInstance, nil
4798 }
4799 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4800 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4801 return nil, omciErr.GetError()
4802}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004803
4804// RLockMutexMonReq lock read access to monitoredRequests
4805func (oo *OmciCC) RLockMutexMonReq() {
4806 oo.mutexMonReq.RLock()
4807}
4808
4809// RUnlockMutexMonReq unlock read access to monitoredRequests
4810func (oo *OmciCC) RUnlockMutexMonReq() {
4811 oo.mutexMonReq.RUnlock()
4812}
4813
4814// GetMonitoredRequest get OmciTransferStructure for an omciTransID
4815func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
4816 value, exist = oo.monitoredRequests[omciTransID]
4817 return value, exist
4818}
4819
4820// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
4821func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
4822 oo.monitoredRequests[omciTransID].chSuccess <- chVal
4823}
Himani Chawlaee10b542021-09-20 16:46:40 +05304824
4825// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
4826func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
4827 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
4828 tid := oo.GetNextTid(highPrio)
4829 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
4830 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
4831
4832 meParams := me.ParamData{EntityID: entityID,
Holger Hildebrandt3ac49bd2022-02-07 17:46:43 +00004833 Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock},
Himani Chawlaee10b542021-09-20 16:46:40 +05304834 }
4835 var meInstance *me.ManagedEntity
4836 var omciErr me.OmciErrors
4837 if classID == me.EthernetFrameExtendedPmClassID {
4838 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
4839 } else {
4840 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
4841 }
4842
4843 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00004844 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05304845 if err != nil {
4846 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4847 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4848 return nil, err
4849 }
4850 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4851 if err != nil {
4852 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
4853 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4854 return nil, err
4855 }
4856 omciRxCallbackPair := CallbackPair{
4857 CbKey: tid,
4858 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4859 }
4860 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4861 if err != nil {
4862 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4863 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4864 return nil, err
4865 }
4866 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
4867 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4868 return meInstance, nil
4869 }
4870 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4871 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4872 return nil, omciErr.GetError()
4873}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00004874
4875// PrepareForGarbageCollection - remove references to prepare for garbage collection
4876func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
4877 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
4878 oo.pBaseDeviceHandler = nil
4879 oo.pOnuDeviceEntry = nil
4880 oo.pOnuAlarmManager = nil
4881}