blob: 57bc0ce5958852c0616e13c8765ff781c8065ed7 [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
Holger Hildebrandtfa074992020-03-27 15:42:06 +000097}
98
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000099//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
100type OmciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000101 enabled bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000102 pBaseDeviceHandler IdeviceHandler
103 pOnuDeviceEntry IonuDeviceEntry
104 pOnuAlarmManager IonuAlarmManager
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000105 deviceID string
khenaidoo7d3c5582021-08-11 18:09:44 -0400106 coreClient *vgrpc.Client
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000107 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000108 rxOmciFrameError tOmciReceiveError
109
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000110 txFrames, txOnuFrames uint32
111 rxFrames, rxOnuFrames, rxOnuDiscards uint32
112
113 // OMCI params
114 mutexTid sync.Mutex
115 tid uint16
116 mutexHpTid sync.Mutex
117 hpTid uint16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000118 UploadSequNo uint16
119 UploadNoOfCmds uint16
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000120
Holger Hildebrandt34555512021-10-01 16:26:59 +0000121 mutexSendQueuedRequests sync.Mutex
122 mutexLowPrioTxQueue sync.Mutex
123 lowPrioTxQueue *list.List
124 mutexHighPrioTxQueue sync.Mutex
125 highPrioTxQueue *list.List
126 mutexRxSchedMap sync.Mutex
127 rxSchedulerMap map[uint16]CallbackPairEntry
128 mutexMonReq sync.RWMutex
129 monitoredRequests map[uint16]OmciTransferStructure
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000130}
131
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000132var responsesWithMibDataSync = []omci.MessageType{
133 omci.CreateResponseType,
134 omci.DeleteResponseType,
135 omci.SetResponseType,
136 omci.StartSoftwareDownloadResponseType,
137 omci.EndSoftwareDownloadResponseType,
138 omci.ActivateSoftwareResponseType,
139 omci.CommitSoftwareResponseType,
140}
141
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000142//NewOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000143//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000144func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
145 onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
146 coreClient *vgrpc.Client) *OmciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000147 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000148 var omciCC OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000149 omciCC.enabled = false
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000150 omciCC.pBaseDeviceHandler = deviceHandler
151 omciCC.pOnuAlarmManager = onuAlarmManager
Himani Chawla4d908332020-08-31 12:30:20 +0530152 omciCC.pOnuDeviceEntry = onuDeviceEntry
153 omciCC.deviceID = deviceID
khenaidoo7d3c5582021-08-11 18:09:44 -0400154 omciCC.coreClient = coreClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000155 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000156 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000157 omciCC.txFrames = 0
158 omciCC.txOnuFrames = 0
159 omciCC.rxFrames = 0
160 omciCC.rxOnuFrames = 0
161 omciCC.rxOnuDiscards = 0
162 omciCC.tid = 0x1
163 omciCC.hpTid = 0x8000
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000164 omciCC.UploadSequNo = 0
165 omciCC.UploadNoOfCmds = 0
Holger Hildebrandt34555512021-10-01 16:26:59 +0000166 omciCC.lowPrioTxQueue = list.New()
167 omciCC.highPrioTxQueue = list.New()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000168 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
169 omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000170
171 return &omciCC
172}
173
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000174//Stop stops/resets the omciCC
175func (oo *OmciCC) Stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000176 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000177 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
mpagenko8cd1bf72021-06-22 10:11:19 +0000178 oo.CancelRequestMonitoring(ctx)
Holger Hildebrandt34555512021-10-01 16:26:59 +0000179 // clear the tx queues
180 oo.mutexHighPrioTxQueue.Lock()
181 oo.highPrioTxQueue.Init()
182 oo.mutexHighPrioTxQueue.Unlock()
183 oo.mutexLowPrioTxQueue.Lock()
184 oo.lowPrioTxQueue.Init()
185 oo.mutexLowPrioTxQueue.Unlock()
186 //clear the scheduler map
mpagenko900ee4b2020-10-12 11:56:34 +0000187 oo.mutexRxSchedMap.Lock()
188 for k := range oo.rxSchedulerMap {
Holger Hildebrandt34555512021-10-01 16:26:59 +0000189 delete(oo.rxSchedulerMap, k)
mpagenko900ee4b2020-10-12 11:56:34 +0000190 }
191 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000192 //reset the high prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000193 oo.mutexHpTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000194 oo.hpTid = 0x8000
mpagenko900ee4b2020-10-12 11:56:34 +0000195 oo.mutexHpTid.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000196 //reset the low prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000197 oo.mutexTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000198 oo.tid = 1
mpagenko900ee4b2020-10-12 11:56:34 +0000199 oo.mutexTid.Unlock()
200 //reset control values
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000201 oo.UploadSequNo = 0
202 oo.UploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000203 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000204 //reset the stats counter - which might be topic of discussion ...
205 oo.txFrames = 0
206 oo.txOnuFrames = 0
207 oo.rxFrames = 0
208 oo.rxOnuFrames = 0
209 oo.rxOnuDiscards = 0
210
211 return nil
212}
213
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000214// Rx handler for omci messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000215func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000216 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000217 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530218 switch omciMsg.MessageType {
219 case omci.AlarmNotificationType:
220 data := OmciMessage{
221 OmciMsg: omciMsg,
222 OmciPacket: packet,
223 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000224 go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530225 return nil
226 default:
227 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
228 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000229 /*
230 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
231 rxOnuFrames++
232
233 switch msgType {
234 case AlarmNotification:
235 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000236 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000237 // python code was:
238 //if msg_type == EntityOperations.AlarmNotification.value:
239 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
240 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
241 //
242 return errors.New("RxAlarmNotification unimplemented")
243 }
244 case AttributeValueChange:
245 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000246 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000247 // python code was:
248 //elif msg_type == EntityOperations.AttributeValueChange.value:
249 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
250 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
251 //
252 return errors.New("RxAttributeValueChange unimplemented")
253 }
254 case TestResult:
255 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000256 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000257 // python code was:
258 //elif msg_type == EntityOperations.TestResult.value:
259 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
260 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
261 //
262 return errors.New("RxTestResult unimplemented")
263 }
264 default:
265 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000266 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000267 rxOnuDiscards++
268 return errors.New("RxOnuMsgType unimplemented")
269 }
270 }
271 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000272}
273
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000274func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
mpagenko80622a52021-02-09 16:53:23 +0000275 //assuming omci message content is hex coded!
276 // with restricted output of 16bytes would be ...rxMsg[:16]
277 logger.Debugw(ctx, "omci-message-received:", log.Fields{
278 "RxOmciMessage": hex.EncodeToString(rxMsg),
279 "device-id": oo.deviceID})
280}
281
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000282// ReceiveMessage - Rx handler for onu messages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000283// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000284func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000285 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000286 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
287 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000288 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000289 trailerLenData := rxMsg[42:44]
290 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000291 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000292 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
293 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
294 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
295 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
296 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
297 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
298 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
299 }
300 }
301 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
302 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
303 // (an extendedFormat message could be destroyed this way!)
304 // extend/overwrite with trailer
305 trailer := make([]byte, 8)
306 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
307 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
308 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
309 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
310 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
311 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
312 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000313 }
314 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000315 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
316 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000317 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200318 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000319 }
320
321 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
322 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000323 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000324 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200325 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000326 }
327 omciLayer := packet.Layer(omci.LayerTypeOMCI)
328 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000329 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000330 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200331 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000332 }
mpagenko836a1fd2021-11-01 16:12:42 +0000333 // insert some check on detected OMCI decoding issues and log them
334 // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type)
335 // even though allowed from omci-lib due to set relaxed decoding
336 // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far]
337 // (compare mib_sync.go unknownAttrLayer)
338 errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure)
339 if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk {
340 errMsg := failure.Error()
341 logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{
342 "device-id": oo.deviceID, "issue": errMsg})
343 }
344 //anyway try continue OMCI decoding further on message type layer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000345 omciMsg, ok := omciLayer.(*omci.OMCI)
346 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000347 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000348 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200349 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000350 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000351 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000352 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
mpagenko836a1fd2021-11-01 16:12:42 +0000353
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700354 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
355 // We expect to find the TID in the oo.rxSchedulerMap
356 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000357 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000358 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000359 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000360 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530361 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000362 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000363 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200364 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000365 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200366 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530367 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000368 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530369 oo.mutexRxSchedMap.Lock()
370 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000371 if ok && rxCallbackEntry.CbFunction != nil {
372 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000373 oo.printRxMessage(ctx, rxMsg)
374 }
Himani Chawla4d908332020-08-31 12:30:20 +0530375 //disadvantage of decoupling: error verification made difficult, but anyway the question is
376 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000377 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000378 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000379 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000380 }
mpagenkoc8bba412021-01-15 15:38:44 +0000381
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700382 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
383 // so do not clean up the TransactionID in that case.
384 if omciMsg.MessageType != omci.TestResponseType {
385 // having posted the response the request is regarded as 'done'
386 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
387 }
Himani Chawla4d908332020-08-31 12:30:20 +0530388 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000389 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000390 }
mpagenko80622a52021-02-09 16:53:23 +0000391 oo.mutexRxSchedMap.Unlock()
392 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
393 oo.printRxMessage(ctx, rxMsg)
394 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000395
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000396 /* py code was:
397 Receive and OMCI message from the proxy channel to the OLT.
398
399 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
400 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
401 """
402 if not self.enabled:
403 return
404
405 try:
406 now = arrow.utcnow()
407 d = None
408
409 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
410 # save the current value of the entity_id_to_class_map, then
411 # replace it with our custom one before decode, and then finally
412 # restore it later. Tried other ways but really made the code messy.
413 saved_me_map = omci_entities.entity_id_to_class_map
414 omci_entities.entity_id_to_class_map = self._me_map
415
416 try:
417 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000418 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000419 except KeyError as e:
420 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000421 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000422 rx_frame = self._decode_unknown_me(msg)
423 self._rx_unknown_me += 1
424
425 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000426 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000427 return
428
429 finally:
430 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
431
432 rx_tid = rx_frame.fields['transaction_id']
433 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000434 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000435 # Filter the Test Result frame and route through receive onu
436 # message method.
437 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000438 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000439 return self._receive_onu_message(rx_frame)
440
441 # Previously unreachable if this is the very first round-trip Rx or we
442 # have been running consecutive errors
443 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000444 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000445 self.reactor.callLater(0, self._publish_connectivity_event, True)
446
447 self._rx_frames += 1
448 self._consecutive_errors = 0
449
450 try:
451 high_priority = self._tid_is_high_priority(rx_tid)
452 index = self._get_priority_index(high_priority)
453
454 # (timestamp, defer, frame, timeout, retry, delayedCall)
455 last_tx_tuple = self._tx_request[index]
456
457 if last_tx_tuple is None or \
458 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
459 # Possible late Rx on a message that timed-out
460 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000461 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000462 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
463 self._rx_unknown_tid += 1
464 self._rx_late += 1
465 return
466
467 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
468 if dc is not None and not dc.cancelled and not dc.called:
469 dc.cancel()
470
471 _secs = self._update_rx_tx_stats(now, ts)
472
473 # Late arrival already serviced by a timeout?
474 if d.called:
475 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000476 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000477 return
478
479 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000480 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000481 if d is not None:
482 return d.errback(failure.Failure(e))
483 return
484
485 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000486 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000487 tx_tid = tx_frame.fields['transaction_id'])
488 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
489
490 # begin success callback chain (will cancel timeout and queue next Tx message)
491 self._rx_response[index] = rx_frame
492 d.callback(rx_frame)
493
494 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000495 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000496 */
497}
498
Himani Chawla6d2ae152020-09-02 13:11:20 +0530499/*
500func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530501 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530502 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000503}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530504*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000505
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700506// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000507func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700508 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
509 delete(oo.rxSchedulerMap, tid)
510}
511
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000512// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
513func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
514 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000515
mpagenkoc26d4c02021-05-06 14:27:57 +0000516 if timeout != 0 {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000517 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000518 oo.mutexRxSchedMap.Lock()
519 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000520 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000521 oo.mutexRxSchedMap.Unlock()
522 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000523
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000524 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000525 //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 +0000526 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000527 txFrame,
528 timeout,
529 retry,
530 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000531 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000532 receiveCallbackPair,
533 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000534 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000535 oo.mutexMonReq.Lock()
536 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000537 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000538 // do not call processRequestMonitoring in background here to ensure correct sequencing
539 // of requested messages into txQueue (especially for non-response-supervised messages)
540 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000541 return nil
542 }
543 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000544 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000545 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000546}
547
Holger Hildebrandt34555512021-10-01 16:26:59 +0000548func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
549 // Avoid accessing the txQueues from parallel send routines to block
550 // parallel omci send requests at least until SendIAP is 'committed'.
551 // To guarantee window size 1 for one ONU it would be necessary to wait
552 // for the corresponding response too (t.b.d.).
553 oo.mutexSendQueuedRequests.Lock()
554 defer oo.mutexSendQueuedRequests.Unlock()
555 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
556 logger.Errorw(ctx, "Error during sending high prio requests!",
557 log.Fields{"err": err, "device-id": oo.deviceID})
558 return
559 }
560 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
561 logger.Errorw(ctx, "Error during sending low prio requests!",
562 log.Fields{"err": err, "device-id": oo.deviceID})
563 return
564 }
565}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566
Holger Hildebrandt34555512021-10-01 16:26:59 +0000567func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
568 oo.mutexHighPrioTxQueue.Lock()
569 defer oo.mutexHighPrioTxQueue.Unlock()
570 for oo.highPrioTxQueue.Len() > 0 {
571 queueElement := oo.highPrioTxQueue.Front() // First element
572 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
573 return err
mpagenko80622a52021-02-09 16:53:23 +0000574 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000575 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
576 }
577 return nil
578}
579
580func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
581 oo.mutexLowPrioTxQueue.Lock()
582 for oo.lowPrioTxQueue.Len() > 0 {
583 queueElement := oo.lowPrioTxQueue.Front() // First element
584 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
585 oo.mutexLowPrioTxQueue.Unlock()
586 return err
amit.ghosh58b704b2021-06-18 03:45:52 +0200587 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000588 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
589 // Interrupt the sending of low priority requests to process any high priority requests
590 // that may have arrived in the meantime
591 oo.mutexLowPrioTxQueue.Unlock()
592 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
593 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000594 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000595 oo.mutexLowPrioTxQueue.Lock()
596 }
597
598 oo.mutexLowPrioTxQueue.Unlock()
599 return nil
600}
601
602func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
603 if omciTxRequest.withFramePrint {
604 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
605 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
606 "device-id": oo.deviceID,
607 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
608 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
609 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
610 }
khenaidoo42dcdfd2021-10-19 17:34:12 -0400611 omciMsg := &ia.OmciMessage{
Holger Hildebrandt34555512021-10-01 16:26:59 +0000612 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
613 ChildDeviceId: oo.deviceID,
614 Message: omciTxRequest.txFrame,
615 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
616 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
617 }
618 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
619 if sendErr != nil {
620 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
621 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000622 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000623 return nil
624}
625
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000626// GetNextTid - TODO: add comment
627func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000628 var next uint16
629 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000630 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000631 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530632 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000633 if oo.hpTid < 0x8000 {
634 oo.hpTid = 0x8000
635 }
mpagenko900ee4b2020-10-12 11:56:34 +0000636 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000637 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000638 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000639 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530640 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000641 if oo.tid >= 0x8000 {
642 oo.tid = 1
643 }
mpagenko900ee4b2020-10-12 11:56:34 +0000644 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000645 }
646 return next
647}
648
649// ###################################################################################
650// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000651
652// Serialize - TODO: add comment
653func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000654 omciLayer := &omci.OMCI{
655 TransactionID: tid,
656 MessageType: msgType,
657 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000658 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000659}
660
dbainbri4d3a0dc2020-12-02 00:33:42 +0000661func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662 var options gopacket.SerializeOptions
663 options.FixLengths = true
664
665 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530666 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000667 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000668 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000669 return nil, err
670 }
671 return buffer.Bytes(), nil
672}
673
Himani Chawla4d908332020-08-31 12:30:20 +0530674/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000675func hexEncode(omciPkt []byte) ([]byte, error) {
676 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
677 hex.Encode(dst, omciPkt)
678 return dst, nil
679}
Himani Chawla4d908332020-08-31 12:30:20 +0530680*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000681
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000682//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000683func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000684
dbainbri4d3a0dc2020-12-02 00:33:42 +0000685 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000686 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000687
688 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000689 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000690 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200691 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000692 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000693 oo.mutexMonReq.RLock()
694 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000695 //implement non-blocking channel send to avoid blocking on mutexMonReq later
696 select {
697 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
698 default:
699 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
700 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
701 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000702 } else {
703 logger.Infow(ctx, "reqMon: map entry does not exist!",
704 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
705 }
706 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000707
708 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
709 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000710 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000711 Type: OMCI,
712 Data: OmciMessage{
713 OmciMsg: omciMsg,
714 OmciPacket: packet,
715 },
716 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000717 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000718 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000719
720 return nil
721}
722
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000723// SendMibReset sends MibResetRequest
724func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000725
dbainbri4d3a0dc2020-12-02 00:33:42 +0000726 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000727 request := &omci.MibResetRequest{
728 MeBasePacket: omci.MeBasePacket{
729 EntityClass: me.OnuDataClassID,
730 },
731 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000732 tid := oo.GetNextTid(highPrio)
733 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000734 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000735 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000736 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000737 return err
738 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000739 omciRxCallbackPair := CallbackPair{
740 CbKey: tid,
741 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000742 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000743 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000744}
745
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000746// SendReboot sends RebootRequest
747func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
748 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300749 request := &omci.RebootRequest{
750 MeBasePacket: omci.MeBasePacket{
751 EntityClass: me.OnuGClassID,
752 },
753 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000754 tid := oo.GetNextTid(highPrio)
755 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300756 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000757 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000758 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300759 return err
760 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000761 omciRxCallbackPair := CallbackPair{
762 CbKey: tid,
763 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300764 }
765
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000766 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300767 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000768 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000769 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300770 return err
771 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000772 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300773 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000774 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200775 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300776 return err
777 }
778 return nil
779}
780
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000781// SendMibUpload sends MibUploadRequest
782func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000783 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000784 request := &omci.MibUploadRequest{
785 MeBasePacket: omci.MeBasePacket{
786 EntityClass: me.OnuDataClassID,
787 },
788 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000789 tid := oo.GetNextTid(highPrio)
790 pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000791 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000792 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000793 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000794 return err
795 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000796 oo.UploadSequNo = 0
797 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000798
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000799 omciRxCallbackPair := CallbackPair{
800 CbKey: tid,
801 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000802 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000803 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000804}
805
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000806// SendMibUploadNext sends MibUploadNextRequest
807func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
808 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000809 request := &omci.MibUploadNextRequest{
810 MeBasePacket: omci.MeBasePacket{
811 EntityClass: me.OnuDataClassID,
812 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000813 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000814 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000815 tid := oo.GetNextTid(highPrio)
816 pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000817 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000818 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000819 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000820 return err
821 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000822 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000823
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000824 omciRxCallbackPair := CallbackPair{
825 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000826 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
827 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
828 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000829 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000830 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000831 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000832}
833
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000834// SendGetAllAlarm gets all alarm ME instances
835func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530836 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
837 request := &omci.GetAllAlarmsRequest{
838 MeBasePacket: omci.MeBasePacket{
839 EntityClass: me.OnuDataClassID,
840 },
841 AlarmRetrievalMode: byte(alarmRetreivalMode),
842 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000843 tid := oo.GetNextTid(highPrio)
844 pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530845 if err != nil {
846 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
847 "Err": err, "device-id": oo.deviceID})
848 return err
849 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000850 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530851
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000852 omciRxCallbackPair := CallbackPair{
853 CbKey: tid,
854 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530855 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000856 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530857}
858
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000859// SendGetAllAlarmNext gets next alarm ME instance
860func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
861 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
862 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +0530863 "alarmUploadSeqNo": alarmUploadSeqNo})
864 request := &omci.GetAllAlarmsNextRequest{
865 MeBasePacket: omci.MeBasePacket{
866 EntityClass: me.OnuDataClassID,
867 },
868 CommandSequenceNumber: alarmUploadSeqNo,
869 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000870 tid := oo.GetNextTid(highPrio)
871 pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530872 if err != nil {
873 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
874 "Err": err, "device-id": oo.deviceID})
875 return err
876 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000877 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530878
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000879 omciRxCallbackPair := CallbackPair{
880 CbKey: tid,
881 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530882 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000883 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530884}
885
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000886// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
887func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
888 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000889 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000890 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000891
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000892 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000893 EntityID: GalEthernetEID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000894 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
895 }
896 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
897 if omciErr.GetError() == nil {
898 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +0000899 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000900 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000901 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000902 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300903 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000904 }
905
dbainbri4d3a0dc2020-12-02 00:33:42 +0000906 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000908 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000909 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300910 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000911 }
912
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000913 omciRxCallbackPair := CallbackPair{
914 CbKey: tid,
915 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000916 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000917 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000918 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000919 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000920 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300921 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000922 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000923 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300924 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000925 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000926 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000927 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300928 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000929}
930
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000931// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000932// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000933func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
934 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000935 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000936 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000937
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000938 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
939 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000940 // By now we just use fix values to fire - this is anyway what the python adapter does
941 // read ONU-2G from DB ???? //TODO!!!
942 meParams := me.ParamData{
943 EntityID: 0,
944 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
945 }
946 meInstance, omciErr := me.NewOnu2G(meParams)
947 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +0000948 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000950 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", 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
dbainbri4d3a0dc2020-12-02 00:33:42 +0000955 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000956 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000957 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000958 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300959 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000960 }
961
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000962 omciRxCallbackPair := CallbackPair{
963 CbKey: tid,
964 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000965 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000966 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000967 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000968 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000969 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300970 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000971 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000972 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300973 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000974 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000975 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000976 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300977 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000978}
979
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000980// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
981func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
982 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
983 tid := oo.GetNextTid(highPrio)
984 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000985 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000986 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000987
988 meParams := me.ParamData{
989 EntityID: instID,
990 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300991 "Priority": 0x8000,
992 "MaxAge": 20 * 256, //20s
993 "HelloTime": 2 * 256, //2s
994 "ForwardDelay": 15 * 256, //15s
995 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000996 },
997 }
998
999 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
1000 if omciErr.GetError() == nil {
1001 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001002 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1003 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001004 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001005 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001006 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001007 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001008 }
1009
dbainbri4d3a0dc2020-12-02 00:33:42 +00001010 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001011 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001012 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001013 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001014 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001015 }
1016
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001017 omciRxCallbackPair := CallbackPair{
1018 CbKey: tid,
1019 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001020 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001021 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001022 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001023 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001024 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001025 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001026 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001027 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001028 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001029 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001030 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001031 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001032 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001033}
1034
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001035// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1036func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1037 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1038 tid := oo.GetNextTid(highPrio)
1039 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001040 if idErr != nil {
1041 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1042 "Err": idErr, "device-id": oo.deviceID})
1043 return nil, idErr
1044 }
1045 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001046 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001047
1048 meParams := me.ParamData{
1049 EntityID: instID,
1050 Attributes: me.AttributeValueMap{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001051 "BridgeIdPointer": MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1052 "PortNum": aPUniPort.MacBpNo,
1053 "TpType": uint8(aPUniPort.PortType),
1054 "TpPointer": aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001055 },
1056 }
1057 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1058 if omciErr.GetError() == nil {
1059 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001060 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1061 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001062 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001063 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001064 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001065 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001066 }
1067
dbainbri4d3a0dc2020-12-02 00:33:42 +00001068 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001069 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001070 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001071 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001072 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001073 }
1074
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001075 omciRxCallbackPair := CallbackPair{
1076 CbKey: tid,
1077 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001078 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001079 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001080 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001081 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001082 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001083 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001084 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001085 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001086 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001087 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001088 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001089 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001090 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001091}
1092
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001093// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1094func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1095 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1096 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001097 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001098 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001099 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001100 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001101
1102 // compare python adapter code WA VOL-1311: this is not done here!
1103 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1104 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1105 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001106 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001107 assType = uint8(10) // for VEIP
1108 }
1109 meParams := me.ParamData{
1110 EntityID: instID,
1111 Attributes: me.AttributeValueMap{
1112 "AssociationType": assType,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001113 "AssociatedMePointer": aPUniPort.EntityID,
mpagenko836a1fd2021-11-01 16:12:42 +00001114 //EnhancedMode not yet supported, used with default options
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001115 },
1116 }
1117 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1118 if omciErr.GetError() == nil {
1119 //all setByCreate parameters already set, no default option required ...
mpagenko836a1fd2021-11-01 16:12:42 +00001120 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1121 oframe.TransactionID(tid), oframe.AddDefaults(true))
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001122 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001123 logger.Errorw(ctx, "Cannot encode EVTOCD for 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 }
1127
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001129 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001130 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001131 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001132 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001133 }
1134
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001135 omciRxCallbackPair := CallbackPair{
1136 CbKey: tid,
1137 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001138 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001139 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001140 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001141 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001142 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001143 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001144 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001145 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001146 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001147 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001148 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001149 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001150 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001151}
1152
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001153// SendSetOnuGLS sets OnuG ME instance
1154func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001155 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001156 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001157 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001158 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001159
1160 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1161 meParams := me.ParamData{
1162 EntityID: 0,
1163 Attributes: requestedAttributes,
1164 }
1165 meInstance, omciErr := me.NewOnuG(meParams)
1166 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001167 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001168 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001169 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001170 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001171 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001172 }
1173
dbainbri4d3a0dc2020-12-02 00:33:42 +00001174 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001175 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001176 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001177 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001178 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001179 }
1180
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001181 omciRxCallbackPair := CallbackPair{
1182 CbKey: tid,
1183 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001184 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001185 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001187 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001188 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001189 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001190 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001191 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001192 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001193 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001194 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001195 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001196 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001197}
1198
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001199// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1200func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001201 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001202 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001203 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001204 "SequNo": strconv.FormatInt(int64(tid), 16)})
1205
1206 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1207 meParams := me.ParamData{
1208 EntityID: aInstNo,
1209 Attributes: requestedAttributes,
1210 }
1211 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1212 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001213 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001214 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001215 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001216 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001217 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001218 }
1219
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001221 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001222 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001223 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001224 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001225 }
1226
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001227 omciRxCallbackPair := CallbackPair{
1228 CbKey: tid,
1229 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001230 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001231 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001232 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001233 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001234 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001235 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001236 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001237 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001238 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001239 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001240 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001241 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001242 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001243}
1244
1245/* UniG obsolete by now, left here in case it should be needed once again
1246 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301247func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001248 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001249 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001250 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001251 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001252
1253 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1254 meParams := me.ParamData{
1255 EntityID: aInstNo,
1256 Attributes: requestedAttributes,
1257 }
1258 meInstance, omciErr := me.NewUniG(meParams)
1259 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001260 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001261 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001262 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001263 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001264 return nil
1265 }
1266
1267 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1268 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001269 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001270 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001271 return nil
1272 }
1273
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001274 omciRxCallbackPair := CallbackPair{
1275 CbKey: tid,
1276 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001277 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001278 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001279 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001280 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001281 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001282 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001283 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001284 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001285 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001286 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001287 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001288 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001289 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001290}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001291*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001292
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001293// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1294func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001295 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001296 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001297 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001298 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001299
1300 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1301 meParams := me.ParamData{
1302 EntityID: aInstNo,
1303 Attributes: requestedAttributes,
1304 }
1305 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1306 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001307 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001308 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001309 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001310 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001311 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001312 }
1313
dbainbri4d3a0dc2020-12-02 00:33:42 +00001314 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001315 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001316 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001317 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001318 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001319 }
1320
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001321 omciRxCallbackPair := CallbackPair{
1322 CbKey: tid,
1323 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001324 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001325 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001326 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001327 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001328 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001329 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001330 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001331 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001332 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001333 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001334 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001335 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001336 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001337}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001338
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001339// SendGetMe gets ME instance
1340func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001341 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001342
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001343 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001344 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001345 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001346
1347 meParams := me.ParamData{
1348 EntityID: entityID,
1349 Attributes: requestedAttributes,
1350 }
1351 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1352 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301353 meClassIDName := meInstance.GetName()
mpagenko836a1fd2021-11-01 16:12:42 +00001354 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid))
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001355 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001356 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 +03001357 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001358 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001359 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001360 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001361 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001362 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001363 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001364 omciRxCallbackPair := CallbackPair{
1365 CbKey: tid,
1366 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001367 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001368 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001369 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001370 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001371 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001372 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001373 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001374 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001375 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001376 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001377 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001378}
1379
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001380// SendGetMeWithAttributeMask gets ME instance with attribute mask
1381func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301382 timeout int, highPrio bool, rxChan chan Message) error {
1383
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001384 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301385 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1386 "SequNo": strconv.FormatInt(int64(tid), 16)})
1387
1388 request := &omci.GetRequest{
1389 MeBasePacket: omci.MeBasePacket{
1390 EntityInstance: entityID,
1391 EntityClass: classID,
1392 },
1393 AttributeMask: requestedAttributesMask,
1394 }
1395
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001396 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301397 if err != nil {
1398 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1399 return err
1400 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001401 omciRxCallbackPair := CallbackPair{
1402 CbKey: tid,
1403 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301404 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001405 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301406 if err != nil {
1407 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1408 return err
1409 }
1410 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1411 return nil
1412}
1413
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001414// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1415func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001416 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001417 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001418 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001419 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1420
1421 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001422 EntityID: aInstID,
1423 Attributes: me.AttributeValueMap{
1424 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1425 "TpPointer": 0xFFFF,
1426 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1427 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1428 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1429 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1430 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1431 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1432 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1433 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1434 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001435 }
1436 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1437 if omciErr.GetError() == nil {
1438 //we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001439 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1440 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001441 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001442 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001443 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001444 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001445 }
1446
dbainbri4d3a0dc2020-12-02 00:33:42 +00001447 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001448 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001449 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001450 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001451 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001452 }
1453
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001454 omciRxCallbackPair := CallbackPair{
1455 CbKey: tid,
1456 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001457 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001458 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001459 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001461 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001462 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001463 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001464 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001465 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001467 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001468 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001469 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001470}
1471
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001472// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1473func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001474 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001475 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001476 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001477 "SequNo": strconv.FormatInt(int64(tid), 16),
1478 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1479
1480 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1481 if omciErr.GetError() == nil {
1482 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001483 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1484 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001485 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001486 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001487 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001488 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001489 }
1490
dbainbri4d3a0dc2020-12-02 00:33:42 +00001491 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001492 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001493 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001494 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001495 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001496 }
1497
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001498 omciRxCallbackPair := CallbackPair{
1499 CbKey: tid,
1500 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001502 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001503 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001504 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001505 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001506 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001507 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001508 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001509 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001510 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001511 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001512 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001513 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001514}
1515
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001516// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1517func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001518 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001519 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001520 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001521 "SequNo": strconv.FormatInt(int64(tid), 16),
1522 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1523
1524 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1525 if omciErr.GetError() == nil {
1526 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001527 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1528 oframe.TransactionID(tid), oframe.AddDefaults(true))
mpagenko3dbcdd22020-07-22 07:38:45 +00001529 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001530 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001531 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001532 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001533 }
1534
dbainbri4d3a0dc2020-12-02 00:33:42 +00001535 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001536 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001537 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001538 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001539 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001540 }
1541
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001542 omciRxCallbackPair := CallbackPair{
1543 CbKey: tid,
1544 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001545 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001546 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001547 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001548 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001549 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001550 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001551 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001552 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001553 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001554 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001555 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001556 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001557 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001558}
1559
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001560// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1561func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1562 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001563 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1564 "SequNo": strconv.FormatInt(int64(tid), 16),
1565 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1566
1567 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1568 if omciErr.GetError() == nil {
1569 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
mpagenko836a1fd2021-11-01 16:12:42 +00001570 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1571 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsia82b91a62021-05-21 18:54:49 +03001572 if err != nil {
1573 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1574 "Err": err, "device-id": oo.deviceID})
1575 return nil, err
1576 }
1577
1578 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1579 if err != nil {
1580 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1581 "Err": err, "device-id": oo.deviceID})
1582 return nil, err
1583 }
1584
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001585 omciRxCallbackPair := CallbackPair{
1586 CbKey: tid,
1587 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001588 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001589 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001590 if err != nil {
1591 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1592 "Err": err, "device-id": oo.deviceID})
1593 return nil, err
1594 }
1595 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1596 return meInstance, nil
1597 }
1598 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1599 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1600 return nil, omciErr.GetError()
1601}
1602
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001603// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1604func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001605 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001606 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001607 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001608 "SequNo": strconv.FormatInt(int64(tid), 16),
1609 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1610
1611 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1612 if omciErr.GetError() == nil {
1613 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001614 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1615 oframe.TransactionID(tid))
mpagenko3dbcdd22020-07-22 07:38:45 +00001616 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001617 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001618 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001619 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001620 }
1621
dbainbri4d3a0dc2020-12-02 00:33:42 +00001622 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001623 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001624 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001625 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001626 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001627 }
1628
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001629 omciRxCallbackPair := CallbackPair{
1630 CbKey: tid,
1631 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001632 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001633 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001634 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001635 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001636 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001637 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001638 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001639 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001640 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001641 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001642 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001643 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001644 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001645}
1646
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001647// SendSetTcontVar sets TCont ME instance
1648func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001649 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001650 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001651 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001652 "SequNo": strconv.FormatInt(int64(tid), 16),
1653 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1654
1655 meInstance, omciErr := me.NewTCont(params[0])
1656 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001657 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, 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 TCont for set", 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 TCont set", 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 TCont set", 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 TCont-set 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 TCont 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// SendSetPrioQueueVar sets PriorityQueue ME instance
1690func (oo *OmciCC) SendSetPrioQueueVar(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 PrioQueue-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.NewPriorityQueue(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 PrioQueue 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 PrioQueue 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 PrioQueue 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 PrioQueue-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 PrioQueue 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// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1732func (oo *OmciCC) SendSetDot1PMapperVar(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 1PMapper-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.NewIeee8021PMapperServiceProfile(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 1PMapper 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 1PMapper 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 1PMapper 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 1PMapper-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 1PMapper 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()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001771}
mpagenkodff5dda2020-08-28 11:52:01 +00001772
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001773// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1774func (oo *OmciCC) SendCreateVtfdVar(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 VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001778 "SequNo": strconv.FormatInt(int64(tid), 16),
1779 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1780
1781 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1782 if omciErr.GetError() == nil {
1783 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
mpagenko836a1fd2021-11-01 16:12:42 +00001784 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1785 oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001786 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001787 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001788 "Err": err, "device-id": oo.deviceID})
1789 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1790 // return (dual format) error code that can be used at caller for immediate error treatment
1791 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001792 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001793 }
1794
dbainbri4d3a0dc2020-12-02 00:33:42 +00001795 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001796 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001797 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001798 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001799 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001800 }
1801
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001802 omciRxCallbackPair := CallbackPair{
1803 CbKey: tid,
1804 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001805 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001806 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001807 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001808 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001809 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001810 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001811 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001812 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001813 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001814 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001815 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001816 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001817 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001818}
1819
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001820// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001821func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001822 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001823 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001824 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001825 "SequNo": strconv.FormatInt(int64(tid), 16),
1826 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1827
1828 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1829 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001830 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType,
1831 oframe.TransactionID(tid))
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001832 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001833 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001834 "Err": err, "device-id": oo.deviceID})
1835 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1836 // return (dual format) error code that can be used at caller for immediate error treatment
1837 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001838 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001839 }
1840
dbainbri4d3a0dc2020-12-02 00:33:42 +00001841 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001842 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001843 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001844 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001845 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001846 }
1847
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001848 omciRxCallbackPair := CallbackPair{
1849 CbKey: tid,
1850 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001851 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001852 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001853 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001854 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001855 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001856 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001857 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001858 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001859 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001860 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001861 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001862 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001863 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001864}
1865
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001866// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
1867func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001868 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001869 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001870 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001871 "SequNo": strconv.FormatInt(int64(tid), 16),
1872 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1873
1874 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1875 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001876 //EnhancedMode not yet supported, used with default options
1877 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType,
1878 oframe.TransactionID(tid), oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001879 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001880 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001881 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001882 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001883 }
1884
dbainbri4d3a0dc2020-12-02 00:33:42 +00001885 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001886 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001887 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001888 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001889 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001890 }
1891
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001892 omciRxCallbackPair := CallbackPair{
1893 CbKey: tid,
1894 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001895 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001896 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001897 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001899 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001900 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001901 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001902 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001903 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001904 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001905 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001906 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001907 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001908}
1909
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001910// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
1911func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001912 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001913 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001914 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001915 "SequNo": strconv.FormatInt(int64(tid), 16),
1916 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1917
1918 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1919 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00001920 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
mpagenkodff5dda2020-08-28 11:52:01 +00001921 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001922 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001923 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001924 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001925 }
1926
dbainbri4d3a0dc2020-12-02 00:33:42 +00001927 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001928 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001929 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001930 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001931 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001932 }
1933
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001934 omciRxCallbackPair := CallbackPair{
1935 CbKey: tid,
1936 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001937 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001938 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001939 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001940 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001941 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001942 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001943 }
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
mpagenkodff5dda2020-08-28 11:52:01 +00001946 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001947 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001948 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001949 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001950}
mpagenko01e726e2020-10-23 09:45:29 +00001951
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001952// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
1953func (oo *OmciCC) SendDeleteEvtocd(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-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001957 "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.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001963 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001964 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001965 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001966 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001967 }
1968
dbainbri4d3a0dc2020-12-02 00:33:42 +00001969 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001970 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001971 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001972 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001973 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001974 }
1975
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001976 omciRxCallbackPair := CallbackPair{
1977 CbKey: tid,
1978 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001979 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001980 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001981 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001982 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001983 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001984 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001985 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001986 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001987 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001988 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001989 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001990 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001991 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001992}
1993
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001994// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
1995func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001996 rxChan chan Message, aInstID uint16) (*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 VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001999 "SequNo": strconv.FormatInt(int64(tid), 16),
2000 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2001
2002 meParams := me.ParamData{EntityID: aInstID}
2003 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
2004 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002005 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2006 oframe.TransactionID(tid))
mpagenko01e726e2020-10-23 09:45:29 +00002007 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002008 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002009 "Err": err, "device-id": oo.deviceID})
2010 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2011 // return (dual format) error code that can be used at caller for immediate error treatment
2012 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002013 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002014 }
2015
dbainbri4d3a0dc2020-12-02 00:33:42 +00002016 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002017 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002018 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002019 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002020 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002021 }
2022
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002023 omciRxCallbackPair := CallbackPair{
2024 CbKey: tid,
2025 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002026 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002027 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002028 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002030 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002031 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002032 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002033 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002034 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002035 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002036 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002037 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002038 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002039}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002040
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002041// SendCreateTDVar creates TrafficDescriptor ME instance
2042func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2043 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002044 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2045 "SequNo": strconv.FormatInt(int64(tid), 16),
2046 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2047 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2048 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002049 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002050 if err != nil {
2051 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002052 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002053 }
2054 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2055 if err != nil {
2056 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002057 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002058 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002059 omciRxCallbackPair := CallbackPair{
2060 CbKey: tid,
2061 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002062 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002063 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002064 if err != nil {
2065 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002066 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002067 }
2068 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002069 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002070 }
2071 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002072 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002073}
2074
2075// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002076func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002077 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002078 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002079 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2080 "SequNo": strconv.FormatInt(int64(tid), 16),
2081 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2082
2083 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2084 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002085 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002086 if err != nil {
2087 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002088 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002089 }
2090 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2091 if err != nil {
2092 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002093 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002094 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002095 omciRxCallbackPair := CallbackPair{
2096 CbKey: tid,
2097 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002098 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002099 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002100 if err != nil {
2101 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002102 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002103 }
2104 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002105 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002106 }
2107 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002108 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002109
2110}
2111
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002112// SendDeleteTD - TODO: add comment
2113func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002114 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002115 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002116 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2117 "SequNo": strconv.FormatInt(int64(tid), 16),
2118 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2119
2120 meParams := me.ParamData{EntityID: aInstID}
2121 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2122 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002123 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid))
ozgecanetsiab6441962021-03-10 10:58:48 +03002124 if err != nil {
2125 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002126 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002127 }
2128 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2129 if err != nil {
2130 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002131 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002132 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002133 omciRxCallbackPair := CallbackPair{
2134 CbKey: tid,
2135 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002136 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002137 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002138 if err != nil {
2139 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002140 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002141 }
2142 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002143 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002144 }
2145 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002146 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002147
2148}
2149
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002150// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2151func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002152 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002153 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002154 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002155 "SequNo": strconv.FormatInt(int64(tid), 16),
2156 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2157
2158 meParams := me.ParamData{EntityID: aInstID}
2159 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2160 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002161 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2162 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002163 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002164 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002165 "Err": err, "device-id": oo.deviceID})
2166 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2167 // return (dual format) error code that can be used at caller for immediate error treatment
2168 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002169 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002170 }
2171
dbainbri4d3a0dc2020-12-02 00:33:42 +00002172 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002173 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002174 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002175 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002176 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002177 }
2178
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002179 omciRxCallbackPair := CallbackPair{
2180 CbKey: tid,
2181 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002182 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002183 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002184 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002185 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002186 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002187 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002188 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002189 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002190 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002191 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002192 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002193 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002194 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002195}
2196
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002197// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2198func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002199 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002200 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002201 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002202 "SequNo": strconv.FormatInt(int64(tid), 16),
2203 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2204
2205 meParams := me.ParamData{EntityID: aInstID}
2206 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2207 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002208 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2209 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002210 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002211 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002212 "Err": err, "device-id": oo.deviceID})
2213 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2214 // return (dual format) error code that can be used at caller for immediate error treatment
2215 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002216 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002217 }
2218
dbainbri4d3a0dc2020-12-02 00:33:42 +00002219 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002220 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002221 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002222 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002223 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002224 }
2225
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002226 omciRxCallbackPair := CallbackPair{
2227 CbKey: tid,
2228 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002229 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002230 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002231 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002232 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002233 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002234 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002235 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002236 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002237 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002238 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002239 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002240 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002242}
2243
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002244// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2245func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002246 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002247 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002248 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002249 "SequNo": strconv.FormatInt(int64(tid), 16),
2250 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2251
2252 meParams := me.ParamData{EntityID: aInstID}
2253 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2254 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002255 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2256 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002257 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002258 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002259 "Err": err, "device-id": oo.deviceID})
2260 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2261 // return (dual format) error code that can be used at caller for immediate error treatment
2262 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002263 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002264 }
2265
dbainbri4d3a0dc2020-12-02 00:33:42 +00002266 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002267 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002268 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002269 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002270 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002271 }
2272
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002273 omciRxCallbackPair := CallbackPair{
2274 CbKey: tid,
2275 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002276 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002277 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002278 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002279 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002280 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002281 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002282 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002283 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002284 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002285 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002286 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002287 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002288 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002289}
2290
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002291// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2292func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002293 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002294 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002295 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002296 "SequNo": strconv.FormatInt(int64(tid), 16),
2297 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2298
2299 meParams := me.ParamData{EntityID: aInstID}
2300 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2301 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002302 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2303 oframe.TransactionID(tid))
mpagenko8b07c1b2020-11-26 10:36:31 +00002304 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002305 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002306 "Err": err, "device-id": oo.deviceID})
2307 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2308 // return (dual format) error code that can be used at caller for immediate error treatment
2309 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002310 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002311 }
2312
dbainbri4d3a0dc2020-12-02 00:33:42 +00002313 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002314 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002315 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002316 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002317 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002318 }
2319
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002320 omciRxCallbackPair := CallbackPair{
2321 CbKey: tid,
2322 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002323 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002324 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002325 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002326 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002327 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002328 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002329 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002330 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002331 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002332 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002333 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002334 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002335 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002336}
2337
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002338// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2339func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002340 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002341 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002342 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002343 "SequNo": strconv.FormatInt(int64(tid), 16),
2344 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2345
2346 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2347 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002348 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2349 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002350 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002351 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002352 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002353 }
2354
dbainbri4d3a0dc2020-12-02 00:33:42 +00002355 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002356 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002357 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002358 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002359 }
2360
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002361 omciRxCallbackPair := CallbackPair{CbKey: tid,
2362 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002363 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002364 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002365 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002366 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002367 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002368 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002369 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002370 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002371 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002372 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002373 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002374 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002375}
2376
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002377// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2378func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002379 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002380 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002381 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002382 "SequNo": strconv.FormatInt(int64(tid), 16),
2383 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2384
2385 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2386 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002387 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid),
2388 oframe.AddDefaults(true))
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002389 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002390 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002391 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002392 }
2393
dbainbri4d3a0dc2020-12-02 00:33:42 +00002394 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002395 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002396 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002397 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002398 }
2399
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002400 omciRxCallbackPair := CallbackPair{CbKey: tid,
2401 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002402 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002403 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002404 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002405 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002406 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002407 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002408 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002409 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002410 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002411 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002412 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002413 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002414}
2415
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002416// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2417func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002418 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002419 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002420 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002421 "SequNo": strconv.FormatInt(int64(tid), 16),
2422 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2423
2424 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2425 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002426 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2427 oframe.AddDefaults(true))
ozgecanetsia422dbf32020-10-28 14:07:19 +03002428 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002429 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002430 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002431 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002432 }
2433
dbainbri4d3a0dc2020-12-02 00:33:42 +00002434 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002435 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002436 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002437 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002438 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002439 }
2440
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002441 omciRxCallbackPair := CallbackPair{CbKey: tid,
2442 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002443 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002444 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002445 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002446 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002447 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002448 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002449 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002450 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002451 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002452 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002453 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002454 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002455 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002456}
2457
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002458// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2459func (oo *OmciCC) SendSetMulticastOperationProfileVar(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)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002462 logger.Debugw(ctx, "send MulticastOperationProfile-set-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.SetRequestType, 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// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2501func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(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)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002504 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-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.NewMulticastSubscriberConfigInfo(params[0])
2509 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002510 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, 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 MulticastSubConfigInfo 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 MulticastSubConfigInfo 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 MulticastSubConfigInfo 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 MulticastSubConfigInfo-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 MulticastSubConfigInfo 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}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002541
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002542// SendCreateVoipVoiceCTP nolint: unused
2543func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2544 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2545 tid := oo.GetNextTid(highPrio)
2546 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2547 "SequNo": strconv.FormatInt(int64(tid), 16),
2548 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2549
2550 meInstance, omciErr := me.NewVoipVoiceCtp(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))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002554 if err != nil {
2555 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2556 "device-id": oo.deviceID})
2557 return nil, err
2558 }
2559
2560 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2561 if err != nil {
2562 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2563 "device-id": oo.deviceID})
2564 return nil, err
2565 }
2566
2567 omciRxCallbackPair := CallbackPair{CbKey: tid,
2568 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2569 }
2570 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2571 if err != nil {
2572 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2573 "device-id": oo.deviceID})
2574 return nil, err
2575 }
2576 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2577 return meInstance, nil
2578 }
2579 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2580 "device-id": oo.deviceID})
2581 return nil, omciErr.GetError()
2582}
2583
2584// SendSetVoipVoiceCTP nolint: unused
2585func (oo *OmciCC) SendSetVoipVoiceCTP(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
2615 "device-id": oo.deviceID})
2616 return nil, err
2617 }
2618 logger.Debug(ctx, "send VoipVoiceCTP-set-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// SendDeleteVoipVoiceCTP nolint: unused
2627func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2628 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2629 tid := oo.GetNextTid(highPrio)
2630 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2631 "SequNo": strconv.FormatInt(int64(tid), 16),
2632 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2633
2634 meParams := me.ParamData{EntityID: aInstID}
2635 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2636 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002637 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2638 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002639 if err != nil {
2640 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2641 "Err": err, "device-id": oo.deviceID})
2642 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2643 // return (dual format) error code that can be used at caller for immediate error treatment
2644 // (relevant to all used sendXX() methods and their error conditions)
2645 return nil, err
2646 }
2647
2648 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2649 if err != nil {
2650 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2651 "Err": err, "device-id": oo.deviceID})
2652 return nil, err
2653 }
2654
2655 omciRxCallbackPair := CallbackPair{
2656 CbKey: tid,
2657 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2658 }
2659 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2660 if err != nil {
2661 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2662 "Err": err, "device-id": oo.deviceID})
2663 return nil, err
2664 }
2665 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2666 return meInstance, nil
2667 }
2668 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2669 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2670 return nil, omciErr.GetError()
2671}
2672
2673// SendCreateVoipMediaProfile nolint: unused
2674func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2675 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2676 tid := oo.GetNextTid(highPrio)
2677 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2678 "SequNo": strconv.FormatInt(int64(tid), 16),
2679 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2680
2681 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2682 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002683 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2684 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002685 if err != nil {
2686 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2687 "device-id": oo.deviceID})
2688 return nil, err
2689 }
2690
2691 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2692 if err != nil {
2693 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2694 "device-id": oo.deviceID})
2695 return nil, err
2696 }
2697
2698 omciRxCallbackPair := CallbackPair{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 VoipMediaProfile create", log.Fields{"Err": err,
2704 "device-id": oo.deviceID})
2705 return nil, err
2706 }
2707 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2708 return meInstance, nil
2709 }
2710 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2711 "device-id": oo.deviceID})
2712 return nil, omciErr.GetError()
2713}
2714
2715// SendSetVoipMediaProfile nolint: unused
2716func (oo *OmciCC) SendSetVoipMediaProfile(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
2746 "device-id": oo.deviceID})
2747 return nil, err
2748 }
2749 logger.Debug(ctx, "send VoipMediaProfile-set-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// SendDeleteVoipMediaProfile nolint: unused
2758func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2759 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2760 tid := oo.GetNextTid(highPrio)
2761 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2762 "SequNo": strconv.FormatInt(int64(tid), 16),
2763 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2764
2765 meParams := me.ParamData{EntityID: aInstID}
2766 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2767 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002768 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2769 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002770 if err != nil {
2771 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2772 "Err": err, "device-id": oo.deviceID})
2773 return nil, err
2774 }
2775
2776 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2777 if err != nil {
2778 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2779 "Err": err, "device-id": oo.deviceID})
2780 return nil, err
2781 }
2782
2783 omciRxCallbackPair := CallbackPair{
2784 CbKey: tid,
2785 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2786 }
2787 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2788 if err != nil {
2789 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2790 "Err": err, "device-id": oo.deviceID})
2791 return nil, err
2792 }
2793 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2794 return meInstance, nil
2795 }
2796 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2797 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2798 return nil, omciErr.GetError()
2799}
2800
2801// SendCreateVoiceServiceProfile nolint: unused
2802func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2803 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2804 tid := oo.GetNextTid(highPrio)
2805 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2806 "SequNo": strconv.FormatInt(int64(tid), 16),
2807 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2808
2809 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2810 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002811 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2812 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002813 if err != nil {
2814 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2815 "device-id": oo.deviceID})
2816 return nil, err
2817 }
2818
2819 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2820 if err != nil {
2821 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2822 "device-id": oo.deviceID})
2823 return nil, err
2824 }
2825
2826 omciRxCallbackPair := CallbackPair{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 VoiceServiceProfile create", log.Fields{"Err": err,
2832 "device-id": oo.deviceID})
2833 return nil, err
2834 }
2835 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
2836 return meInstance, nil
2837 }
2838 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2839 "device-id": oo.deviceID})
2840 return nil, omciErr.GetError()
2841}
2842
2843// SendSetVoiceServiceProfile nolint: unused
2844func (oo *OmciCC) SendSetVoiceServiceProfile(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
2874 "device-id": oo.deviceID})
2875 return nil, err
2876 }
2877 logger.Debug(ctx, "send VoiceServiceProfile-set-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// SendDeleteVoiceServiceProfile nolint: unused
2886func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2887 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2888 tid := oo.GetNextTid(highPrio)
2889 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2890 "SequNo": strconv.FormatInt(int64(tid), 16),
2891 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2892
2893 meParams := me.ParamData{EntityID: aInstID}
2894 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
2895 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002896 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
2897 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002898 if err != nil {
2899 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
2900 "Err": err, "device-id": oo.deviceID})
2901 return nil, err
2902 }
2903
2904 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2905 if err != nil {
2906 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
2907 "Err": err, "device-id": oo.deviceID})
2908 return nil, err
2909 }
2910
2911 omciRxCallbackPair := CallbackPair{
2912 CbKey: tid,
2913 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2914 }
2915 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2916 if err != nil {
2917 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
2918 "Err": err, "device-id": oo.deviceID})
2919 return nil, err
2920 }
2921 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
2922 return meInstance, nil
2923 }
2924 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
2925 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2926 return nil, omciErr.GetError()
2927}
2928
2929// SendCreateSIPUserData nolint: unused
2930func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
2931 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2932 tid := oo.GetNextTid(highPrio)
2933 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
2934 "SequNo": strconv.FormatInt(int64(tid), 16),
2935 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2936
2937 meInstance, omciErr := me.NewSipUserData(params[0])
2938 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00002939 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
2940 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002941 if err != nil {
2942 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
2943 "device-id": oo.deviceID})
2944 return nil, err
2945 }
2946
2947 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2948 if err != nil {
2949 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
2950 "device-id": oo.deviceID})
2951 return nil, err
2952 }
2953
2954 omciRxCallbackPair := CallbackPair{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 SIPUserData create", log.Fields{"Err": err,
2960 "device-id": oo.deviceID})
2961 return nil, err
2962 }
2963 logger.Debug(ctx, "send SIPUserData-create-msg done")
2964 return meInstance, nil
2965 }
2966 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
2967 "device-id": oo.deviceID})
2968 return nil, omciErr.GetError()
2969}
2970
2971// SendSetSIPUserData nolint: unused
2972func (oo *OmciCC) SendSetSIPUserData(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3002 "device-id": oo.deviceID})
3003 return nil, err
3004 }
3005 logger.Debug(ctx, "send SIPUserData-set-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// SendDeleteSIPUserData nolint: unused
3014func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3015 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3016 tid := oo.GetNextTid(highPrio)
3017 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3018 "SequNo": strconv.FormatInt(int64(tid), 16),
3019 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3020
3021 meParams := me.ParamData{EntityID: aInstID}
3022 meInstance, omciErr := me.NewSipUserData(meParams)
3023 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003024 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3025 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003026 if err != nil {
3027 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3028 "Err": err, "device-id": oo.deviceID})
3029 return nil, err
3030 }
3031
3032 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3033 if err != nil {
3034 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3035 "Err": err, "device-id": oo.deviceID})
3036 return nil, err
3037 }
3038
3039 omciRxCallbackPair := CallbackPair{
3040 CbKey: tid,
3041 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3042 }
3043 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3044 if err != nil {
3045 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3046 "Err": err, "device-id": oo.deviceID})
3047 return nil, err
3048 }
3049 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3050 return meInstance, nil
3051 }
3052 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3053 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3054 return nil, omciErr.GetError()
3055}
3056
3057// SendCreateVoipApplicationServiceProfile nolint: unused
3058func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3059 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3060 tid := oo.GetNextTid(highPrio)
3061 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3062 "SequNo": strconv.FormatInt(int64(tid), 16),
3063 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3064
3065 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3066 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003067 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3068 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003069 if err != nil {
3070 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3071 "device-id": oo.deviceID})
3072 return nil, err
3073 }
3074
3075 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3076 if err != nil {
3077 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3078 "device-id": oo.deviceID})
3079 return nil, err
3080 }
3081
3082 omciRxCallbackPair := CallbackPair{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 VoipApplicationServiceProfile create", log.Fields{"Err": err,
3088 "device-id": oo.deviceID})
3089 return nil, err
3090 }
3091 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3092 return meInstance, nil
3093 }
3094 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3095 "device-id": oo.deviceID})
3096 return nil, omciErr.GetError()
3097}
3098
3099// SendSetVoipApplicationServiceProfile nolint: unused
3100func (oo *OmciCC) SendSetVoipApplicationServiceProfile(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3130 "device-id": oo.deviceID})
3131 return nil, err
3132 }
3133 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-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// SendDeleteVoipApplicationServiceProfile nolint: unused
3142func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3143 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3144 tid := oo.GetNextTid(highPrio)
3145 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3146 "SequNo": strconv.FormatInt(int64(tid), 16),
3147 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3148
3149 meParams := me.ParamData{EntityID: aInstID}
3150 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3151 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003152 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3153 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003154 if err != nil {
3155 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3156 "Err": err, "device-id": oo.deviceID})
3157 return nil, err
3158 }
3159
3160 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3161 if err != nil {
3162 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3163 "Err": err, "device-id": oo.deviceID})
3164 return nil, err
3165 }
3166
3167 omciRxCallbackPair := CallbackPair{
3168 CbKey: tid,
3169 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3170 }
3171 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3172 if err != nil {
3173 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3174 "Err": err, "device-id": oo.deviceID})
3175 return nil, err
3176 }
3177 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3178 return meInstance, nil
3179 }
3180 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3181 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3182 return nil, omciErr.GetError()
3183}
3184
3185// SendCreateSIPAgentConfigData nolint: unused
3186func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3187 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3188 tid := oo.GetNextTid(highPrio)
3189 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3190 "SequNo": strconv.FormatInt(int64(tid), 16),
3191 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3192
3193 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3194 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003195 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3196 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003197 if err != nil {
3198 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3199 "device-id": oo.deviceID})
3200 return nil, err
3201 }
3202
3203 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3204 if err != nil {
3205 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3206 "device-id": oo.deviceID})
3207 return nil, err
3208 }
3209
3210 omciRxCallbackPair := CallbackPair{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 SIPAgentConfigData create", log.Fields{"Err": err,
3216 "device-id": oo.deviceID})
3217 return nil, err
3218 }
3219 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3220 return meInstance, nil
3221 }
3222 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3223 "device-id": oo.deviceID})
3224 return nil, omciErr.GetError()
3225}
3226
3227// SendSetSIPAgentConfigData nolint: unused
3228func (oo *OmciCC) SendSetSIPAgentConfigData(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3258 "device-id": oo.deviceID})
3259 return nil, err
3260 }
3261 logger.Debug(ctx, "send SIPAgentConfigData-set-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// SendDeleteSIPAgentConfigData nolint: unused
3270func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3271 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3272 tid := oo.GetNextTid(highPrio)
3273 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3274 "SequNo": strconv.FormatInt(int64(tid), 16),
3275 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3276
3277 meParams := me.ParamData{EntityID: aInstID}
3278 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3279 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003280 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3281 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003282 if err != nil {
3283 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3284 "Err": err, "device-id": oo.deviceID})
3285 return nil, err
3286 }
3287
3288 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3289 if err != nil {
3290 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3291 "Err": err, "device-id": oo.deviceID})
3292 return nil, err
3293 }
3294
3295 omciRxCallbackPair := CallbackPair{
3296 CbKey: tid,
3297 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3298 }
3299 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3300 if err != nil {
3301 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3302 "Err": err, "device-id": oo.deviceID})
3303 return nil, err
3304 }
3305 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3306 return meInstance, nil
3307 }
3308 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3309 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3310 return nil, omciErr.GetError()
3311}
3312
3313// SendCreateTCPUDPConfigData nolint: unused
3314func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3315 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3316 tid := oo.GetNextTid(highPrio)
3317 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3318 "SequNo": strconv.FormatInt(int64(tid), 16),
3319 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3320
3321 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3322 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003323 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3324 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003325 if err != nil {
3326 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3327 "device-id": oo.deviceID})
3328 return nil, err
3329 }
3330
3331 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3332 if err != nil {
3333 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3334 "device-id": oo.deviceID})
3335 return nil, err
3336 }
3337
3338 omciRxCallbackPair := CallbackPair{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 TCPUDPConfigData create", log.Fields{"Err": err,
3344 "device-id": oo.deviceID})
3345 return nil, err
3346 }
3347 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3348 return meInstance, nil
3349 }
3350 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3351 "device-id": oo.deviceID})
3352 return nil, omciErr.GetError()
3353}
3354
3355// SendSetTCPUDPConfigData nolint: unused
3356func (oo *OmciCC) SendSetTCPUDPConfigData(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3386 "device-id": oo.deviceID})
3387 return nil, err
3388 }
3389 logger.Debug(ctx, "send TCPUDPConfigData-set-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// SendDeleteTCPUDPConfigData nolint: unused
3398func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3399 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3400 tid := oo.GetNextTid(highPrio)
3401 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3402 "SequNo": strconv.FormatInt(int64(tid), 16),
3403 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3404
3405 meParams := me.ParamData{EntityID: aInstID}
3406 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3407 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003408 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3409 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003410 if err != nil {
3411 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3412 "Err": err, "device-id": oo.deviceID})
3413 return nil, err
3414 }
3415
3416 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3417 if err != nil {
3418 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3419 "Err": err, "device-id": oo.deviceID})
3420 return nil, err
3421 }
3422
3423 omciRxCallbackPair := CallbackPair{
3424 CbKey: tid,
3425 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3426 }
3427 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3428 if err != nil {
3429 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3430 "Err": err, "device-id": oo.deviceID})
3431 return nil, err
3432 }
3433 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3434 return meInstance, nil
3435 }
3436 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3437 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3438 return nil, omciErr.GetError()
3439}
3440
3441// SendCreateIPHostConfigData nolint: unused
3442func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3443 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3444 tid := oo.GetNextTid(highPrio)
3445 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3446 "SequNo": strconv.FormatInt(int64(tid), 16),
3447 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3448
3449 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3450 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003451 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3452 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003453 if err != nil {
3454 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3455 "device-id": oo.deviceID})
3456 return nil, err
3457 }
3458
3459 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3460 if err != nil {
3461 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3462 "device-id": oo.deviceID})
3463 return nil, err
3464 }
3465
3466 omciRxCallbackPair := CallbackPair{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 IPHostConfigData create", log.Fields{"Err": err,
3472 "device-id": oo.deviceID})
3473 return nil, err
3474 }
3475 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3476 return meInstance, nil
3477 }
3478 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3479 "device-id": oo.deviceID})
3480 return nil, omciErr.GetError()
3481}
3482
3483// SendSetIPHostConfigData nolint: unused
3484func (oo *OmciCC) SendSetIPHostConfigData(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3514 "device-id": oo.deviceID})
3515 return nil, err
3516 }
3517 logger.Debug(ctx, "send IPHostConfigData-set-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// SendDeleteIPHostConfigData nolint: unused
3526func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3527 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3528 tid := oo.GetNextTid(highPrio)
3529 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3530 "SequNo": strconv.FormatInt(int64(tid), 16),
3531 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3532
3533 meParams := me.ParamData{EntityID: aInstID}
3534 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3535 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003536 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3537 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003538 if err != nil {
3539 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3540 "Err": err, "device-id": oo.deviceID})
3541 return nil, err
3542 }
3543
3544 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3545 if err != nil {
3546 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3547 "Err": err, "device-id": oo.deviceID})
3548 return nil, err
3549 }
3550
3551 omciRxCallbackPair := CallbackPair{
3552 CbKey: tid,
3553 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3554 }
3555 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3556 if err != nil {
3557 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3558 "Err": err, "device-id": oo.deviceID})
3559 return nil, err
3560 }
3561 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3562 return meInstance, nil
3563 }
3564 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3565 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3566 return nil, omciErr.GetError()
3567}
3568
3569// SendCreateRTPProfileData nolint: unused
3570func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3571 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3572 tid := oo.GetNextTid(highPrio)
3573 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3574 "SequNo": strconv.FormatInt(int64(tid), 16),
3575 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3576
3577 meInstance, omciErr := me.NewRtpProfileData(params[0])
3578 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003579 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3580 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003581 if err != nil {
3582 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3583 "device-id": oo.deviceID})
3584 return nil, err
3585 }
3586
3587 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3588 if err != nil {
3589 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3590 "device-id": oo.deviceID})
3591 return nil, err
3592 }
3593
3594 omciRxCallbackPair := CallbackPair{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 RTPProfileData create", log.Fields{"Err": err,
3600 "device-id": oo.deviceID})
3601 return nil, err
3602 }
3603 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3604 return meInstance, nil
3605 }
3606 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3607 "device-id": oo.deviceID})
3608 return nil, omciErr.GetError()
3609}
3610
3611// SendSetRTPProfileData nolint: unused
3612func (oo *OmciCC) SendSetRTPProfileData(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3642 "device-id": oo.deviceID})
3643 return nil, err
3644 }
3645 logger.Debug(ctx, "send RTPProfileData-set-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// SendDeleteRTPProfileData nolint: unused
3654func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3655 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3656 tid := oo.GetNextTid(highPrio)
3657 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3658 "SequNo": strconv.FormatInt(int64(tid), 16),
3659 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3660
3661 meParams := me.ParamData{EntityID: aInstID}
3662 meInstance, omciErr := me.NewRtpProfileData(meParams)
3663 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003664 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3665 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003666 if err != nil {
3667 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3668 "Err": err, "device-id": oo.deviceID})
3669 return nil, err
3670 }
3671
3672 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3673 if err != nil {
3674 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3675 "Err": err, "device-id": oo.deviceID})
3676 return nil, err
3677 }
3678
3679 omciRxCallbackPair := CallbackPair{
3680 CbKey: tid,
3681 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3682 }
3683 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3684 if err != nil {
3685 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3686 "Err": err, "device-id": oo.deviceID})
3687 return nil, err
3688 }
3689 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3690 return meInstance, nil
3691 }
3692 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3693 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3694 return nil, omciErr.GetError()
3695}
3696
3697// SendCreateNetworkDialPlanTable nolint: unused
3698func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3699 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3700 tid := oo.GetNextTid(highPrio)
3701 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3702 "SequNo": strconv.FormatInt(int64(tid), 16),
3703 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3704
3705 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3706 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003707 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3708 oframe.AddDefaults(true))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003709 if err != nil {
3710 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3711 "device-id": oo.deviceID})
3712 return nil, err
3713 }
3714
3715 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3716 if err != nil {
3717 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3718 "device-id": oo.deviceID})
3719 return nil, err
3720 }
3721
3722 omciRxCallbackPair := CallbackPair{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 NetworkDialPlanTable create", log.Fields{"Err": err,
3728 "device-id": oo.deviceID})
3729 return nil, err
3730 }
3731 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3732 return meInstance, nil
3733 }
3734 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3735 "device-id": oo.deviceID})
3736 return nil, omciErr.GetError()
3737}
3738
3739// SendSetNetworkDialPlanTable nolint: unused
3740func (oo *OmciCC) SendSetNetworkDialPlanTable(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-set-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.SetRequestType, 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 set", 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 set", 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 set", log.Fields{"Err": err,
3770 "device-id": oo.deviceID})
3771 return nil, err
3772 }
3773 logger.Debug(ctx, "send NetworkDialPlanTable-set-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// SendDeleteNetworkDialPlanTable nolint: unused
3782func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3783 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3784 tid := oo.GetNextTid(highPrio)
3785 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3786 "SequNo": strconv.FormatInt(int64(tid), 16),
3787 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3788
3789 meParams := me.ParamData{EntityID: aInstID}
3790 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3791 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00003792 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType,
3793 oframe.TransactionID(tid))
ozgecanetsia0e3111f2021-10-19 18:04:15 +03003794 if err != nil {
3795 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3796 "Err": err, "device-id": oo.deviceID})
3797 return nil, err
3798 }
3799
3800 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3801 if err != nil {
3802 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3803 "Err": err, "device-id": oo.deviceID})
3804 return nil, err
3805 }
3806
3807 omciRxCallbackPair := CallbackPair{
3808 CbKey: tid,
3809 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3810 }
3811 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3812 if err != nil {
3813 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3814 "Err": err, "device-id": oo.deviceID})
3815 return nil, err
3816 }
3817 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3818 return meInstance, nil
3819 }
3820 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3821 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3822 return nil, omciErr.GetError()
3823}
3824
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003825// SendSyncTime sends SynchronizeTimeRequest
3826func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
3827 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003828 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
3829 "SequNo": strconv.FormatInt(int64(tid), 16)})
3830
3831 omciLayer := &omci.OMCI{
3832 TransactionID: tid,
3833 MessageType: omci.SynchronizeTimeRequestType,
3834 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3835 // Length: 0x28, // Optional, defaults to 40 octets
3836 }
3837 utcTime := time.Now().UTC()
3838 request := &omci.SynchronizeTimeRequest{
3839 MeBasePacket: omci.MeBasePacket{
3840 EntityClass: me.OnuGClassID,
3841 // Default Instance ID is 0
3842 },
3843 Year: uint16(utcTime.Year()),
3844 Month: uint8(utcTime.Month()),
3845 Day: uint8(utcTime.Day()),
3846 Hour: uint8(utcTime.Hour()),
3847 Minute: uint8(utcTime.Minute()),
3848 Second: uint8(utcTime.Second()),
3849 }
3850
3851 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
3852 if err != nil {
3853 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
3854 "device-id": oo.deviceID})
3855 return err
3856 }
3857
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003858 omciRxCallbackPair := CallbackPair{CbKey: tid,
3859 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003860 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003861 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003862 if err != nil {
3863 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
3864 "device-id": oo.deviceID})
3865 return err
3866 }
3867 logger.Debug(ctx, "send synchronize time request done")
3868 return nil
3869}
3870
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003871// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
3872func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003873 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003874 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003875 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3876 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3877 meParam := me.ParamData{EntityID: entityID}
3878 var meInstance *me.ManagedEntity
3879 var omciErr me.OmciErrors
3880 if upstream {
3881 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
3882 } else {
3883 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
3884 }
3885 if omciErr.GetError() == nil {
3886 var omciLayer *omci.OMCI
3887 var msgLayer gopacket.SerializableLayer
3888 var err error
3889 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003890 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3891 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003892 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003893 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
3894 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003895 }
3896 if err != nil {
3897 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
3898 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003899 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003900 }
3901
3902 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3903 if err != nil {
3904 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
3905 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003906 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003907 }
3908
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003909 omciRxCallbackPair := CallbackPair{CbKey: tid,
3910 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003911 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003912 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003913 if err != nil {
3914 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
3915 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003916 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003917 }
3918 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
3919 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003920 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08003921 }
3922 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
3923 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 +03003924 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08003925}
3926
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003927// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
3928func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003929 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003930 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003931 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3932 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
3933 meParam := me.ParamData{EntityID: entityID}
3934 var meInstance *me.ManagedEntity
3935 var omciErr me.OmciErrors
3936 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
3937
3938 if omciErr.GetError() == nil {
3939 var omciLayer *omci.OMCI
3940 var msgLayer gopacket.SerializableLayer
3941 var err error
3942 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003943 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3944 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003945 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003946 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
3947 oframe.AddDefaults(true))
Girish Gowdrae0140f02021-02-02 16:55:09 -08003948 }
3949 if err != nil {
3950 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
3951 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003952 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003953 }
3954
3955 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3956 if err != nil {
3957 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
3958 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003959 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003960 }
3961
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003962 omciRxCallbackPair := CallbackPair{CbKey: tid,
3963 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003964 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003965 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003966 if err != nil {
3967 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
3968 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003969 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003970 }
3971 logger.Debugw(ctx, "send ethernet uni history data ME done",
3972 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003973 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08003974 }
3975 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
3976 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003977 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08003978}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003979
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003980// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
3981func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003982 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003983 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003984 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3985 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
3986 meParam := me.ParamData{EntityID: entityID}
3987 var meInstance *me.ManagedEntity
3988 var omciErr me.OmciErrors
3989 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
3990
3991 if omciErr.GetError() == nil {
3992 var omciLayer *omci.OMCI
3993 var msgLayer gopacket.SerializableLayer
3994 var err error
3995 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00003996 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
3997 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003998 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00003999 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4000 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004001 }
4002 if err != nil {
4003 logger.Errorw(ctx, "Cannot encode fec history data ME",
4004 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004005 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004006 }
4007
4008 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4009 if err != nil {
4010 logger.Errorw(ctx, "Cannot serialize fec history data ME",
4011 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004012 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004013 }
4014
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004015 omciRxCallbackPair := CallbackPair{CbKey: tid,
4016 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004017 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004018 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004019 if err != nil {
4020 logger.Errorw(ctx, "Cannot send fec history data ME",
4021 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004022 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004023 }
4024 logger.Debugw(ctx, "send fec history data ME done",
4025 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004026 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004027 }
4028 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4029 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004030 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004031}
4032
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004033// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4034func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004035 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004036 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004037 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4038 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4039 meParam := me.ParamData{EntityID: entityID}
4040 var meInstance *me.ManagedEntity
4041 var omciErr me.OmciErrors
4042 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4043
4044 if omciErr.GetError() == nil {
4045 var omciLayer *omci.OMCI
4046 var msgLayer gopacket.SerializableLayer
4047 var err error
4048 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004049 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4050 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004051 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004052 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4053 oframe.AddDefaults(true))
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004054 }
4055 if err != nil {
4056 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4057 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004058 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004059 }
4060
4061 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4062 if err != nil {
4063 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4064 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004065 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004066 }
4067
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004068 omciRxCallbackPair := CallbackPair{CbKey: tid,
4069 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004070 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004071 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004072 if err != nil {
4073 logger.Errorw(ctx, "Cannot send gemport history data ME",
4074 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004075 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004076 }
4077 logger.Debugw(ctx, "send gemport history data ME done",
4078 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004079 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004080 }
4081 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4082 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004083 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004084}
4085
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004086// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4087func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004088 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004089 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004090 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4091 "SequNo": strconv.FormatInt(int64(tid), 16),
4092 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4093
4094 omciLayer := &omci.OMCI{
4095 TransactionID: tid,
4096 MessageType: omci.StartSoftwareDownloadRequestType,
4097 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4098 // Length: 0x28, // Optional, defaults to 40 octets
4099 }
4100 request := &omci.StartSoftwareDownloadRequest{
4101 MeBasePacket: omci.MeBasePacket{
4102 EntityClass: me.SoftwareImageClassID,
4103 EntityInstance: aImageMeID, //inactive image
4104 },
4105 WindowSize: aDownloadWindowSize,
4106 ImageSize: aFileLen,
4107 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4108 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4109 }
4110
4111 var options gopacket.SerializeOptions
4112 options.FixLengths = true
4113 buffer := gopacket.NewSerializeBuffer()
4114 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4115 if err != nil {
4116 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4117 "device-id": oo.deviceID})
4118 return err
4119 }
4120 outgoingPacket := buffer.Bytes()
4121
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004122 omciRxCallbackPair := CallbackPair{CbKey: tid,
4123 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004124 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004125 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004126 if err != nil {
4127 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4128 "device-id": oo.deviceID})
4129 return err
4130 }
4131 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004132 return nil
4133}
4134
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004135// SendDownloadSection sends DownloadSectionRequestWithResponse
4136func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004137 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004138 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004139 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4140 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004141 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004142
4143 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4144 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004145 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004146 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004147 if aAckRequest > 0 {
4148 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004149 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004150 }
mpagenko80622a52021-02-09 16:53:23 +00004151 omciLayer := &omci.OMCI{
4152 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004153 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004154 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4155 // Length: 0x28, // Optional, defaults to 40 octets
4156 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304157 localSectionData := make([]byte, len(aSection))
4158
mpagenko15ff4a52021-03-02 10:09:20 +00004159 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004160 request := &omci.DownloadSectionRequest{
4161 MeBasePacket: omci.MeBasePacket{
4162 EntityClass: me.SoftwareImageClassID,
4163 EntityInstance: aImageMeID, //inactive image
4164 },
4165 SectionNumber: aDownloadSectionNo,
4166 SectionData: localSectionData,
4167 }
4168
4169 var options gopacket.SerializeOptions
4170 options.FixLengths = true
4171 buffer := gopacket.NewSerializeBuffer()
4172 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4173 if err != nil {
4174 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4175 "device-id": oo.deviceID})
4176 return err
4177 }
4178 outgoingPacket := buffer.Bytes()
4179
mpagenko15ff4a52021-03-02 10:09:20 +00004180 //for initial debug purpose overrule the requested print state for some frames
4181 printFrame := aPrint
4182 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4183 printFrame = true
4184 }
4185
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004186 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004187 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4188 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004189 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004190 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004191 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004192 if err != nil {
4193 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4194 "device-id": oo.deviceID})
4195 return err
4196 }
4197 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004198 return nil
4199}
4200
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004201//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4202func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004203 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004204 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004205 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4206 "SequNo": strconv.FormatInt(int64(tid), 16),
4207 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4208
mpagenko15ff4a52021-03-02 10:09:20 +00004209 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004210 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004211 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004212 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4213 // Length: 0x28, // Optional, defaults to 40 octets
4214 }
mpagenko15ff4a52021-03-02 10:09:20 +00004215 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004216 MeBasePacket: omci.MeBasePacket{
4217 EntityClass: me.SoftwareImageClassID,
4218 EntityInstance: aImageMeID, //inactive image
4219 },
mpagenko15ff4a52021-03-02 10:09:20 +00004220 CRC32: aImageCrc,
4221 ImageSize: aFileLen,
4222 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4223 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004224 }
mpagenko15ff4a52021-03-02 10:09:20 +00004225
4226 var options gopacket.SerializeOptions
4227 options.FixLengths = true
4228 buffer := gopacket.NewSerializeBuffer()
4229 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4230 if err != nil {
4231 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004232 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004233 return err
mpagenko80622a52021-02-09 16:53:23 +00004234 }
mpagenko15ff4a52021-03-02 10:09:20 +00004235 outgoingPacket := buffer.Bytes()
4236
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004237 omciRxCallbackPair := CallbackPair{CbKey: tid,
4238 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004239 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004240 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004241 if err != nil {
4242 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4243 "device-id": oo.deviceID})
4244 return err
4245 }
4246 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004247 return nil
4248}
4249
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004250// SendActivateSoftware sends ActivateSoftwareRequest
4251func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004252 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004253 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004254 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4255 "SequNo": strconv.FormatInt(int64(tid), 16),
4256 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4257
4258 omciLayer := &omci.OMCI{
4259 TransactionID: tid,
4260 MessageType: omci.ActivateSoftwareRequestType,
4261 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4262 // Length: 0x28, // Optional, defaults to 40 octets
4263 }
4264 request := &omci.ActivateSoftwareRequest{
4265 MeBasePacket: omci.MeBasePacket{
4266 EntityClass: me.SoftwareImageClassID,
4267 EntityInstance: aImageMeID, //inactive image
4268 },
4269 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4270 }
4271
4272 var options gopacket.SerializeOptions
4273 options.FixLengths = true
4274 buffer := gopacket.NewSerializeBuffer()
4275 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4276 if err != nil {
4277 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4278 "device-id": oo.deviceID})
4279 return err
4280 }
4281 outgoingPacket := buffer.Bytes()
4282
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004283 omciRxCallbackPair := CallbackPair{CbKey: tid,
4284 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004285 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004286 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004287 if err != nil {
4288 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4289 "device-id": oo.deviceID})
4290 return err
4291 }
4292 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004293 return nil
4294}
mpagenko80622a52021-02-09 16:53:23 +00004295
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004296// SendCommitSoftware sends CommitSoftwareRequest
4297func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko15ff4a52021-03-02 10:09:20 +00004298 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004299 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004300 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4301 "SequNo": strconv.FormatInt(int64(tid), 16),
4302 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4303
4304 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004305 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004306 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004307 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4308 // Length: 0x28, // Optional, defaults to 40 octets
4309 }
mpagenko15ff4a52021-03-02 10:09:20 +00004310 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004311 MeBasePacket: omci.MeBasePacket{
4312 EntityClass: me.SoftwareImageClassID,
4313 EntityInstance: aImageMeID, //inactive image
4314 },
mpagenko80622a52021-02-09 16:53:23 +00004315 }
mpagenko15ff4a52021-03-02 10:09:20 +00004316
4317 var options gopacket.SerializeOptions
4318 options.FixLengths = true
4319 buffer := gopacket.NewSerializeBuffer()
4320 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4321 if err != nil {
4322 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004323 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004324 return err
mpagenko80622a52021-02-09 16:53:23 +00004325 }
mpagenko15ff4a52021-03-02 10:09:20 +00004326 outgoingPacket := buffer.Bytes()
4327
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004328 omciRxCallbackPair := CallbackPair{CbKey: tid,
4329 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004330 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004331 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004332 if err != nil {
4333 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4334 "device-id": oo.deviceID})
4335 return err
4336 }
4337 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004338 return nil
4339}
4340
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004341//SendSelfTestReq sends TestRequest
4342func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4343 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004344 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4345 "SequNo": strconv.FormatInt(int64(tid), 16),
4346 "InstId": strconv.FormatInt(int64(instdID), 16)})
4347 omciLayer := &omci.OMCI{
4348 TransactionID: tid,
4349 MessageType: omci.TestRequestType,
4350 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4351 // Length: 0x28, // Optional, defaults to 40 octets
4352 }
4353
4354 var request *omci.OpticalLineSupervisionTestRequest
4355 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004356 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004357 request = &omci.OpticalLineSupervisionTestRequest{
4358 MeBasePacket: omci.MeBasePacket{
4359 EntityClass: classID,
4360 EntityInstance: instdID,
4361 },
4362 SelectTest: uint8(7), // self test
4363 GeneralPurposeBuffer: uint16(0),
4364 VendorSpecificParameters: uint16(0),
4365 }
4366 default:
4367 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4368 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4369 }
4370 // Test serialization back to former string
4371 var options gopacket.SerializeOptions
4372 options.FixLengths = true
4373
4374 buffer := gopacket.NewSerializeBuffer()
4375 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4376 if err != nil {
4377 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4378 "device-id": oo.deviceID})
4379 return err
4380 }
4381 outgoingPacket := buffer.Bytes()
4382
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004383 omciRxCallbackPair := CallbackPair{CbKey: tid,
4384 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004385 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004386 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004387 if err != nil {
4388 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4389 "device-id": oo.deviceID})
4390 return err
4391 }
4392 logger.Debug(ctx, "send self test request done")
4393 return nil
4394}
4395
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004396//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004397func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004398 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004399 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004400 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004401 msgLayer := (*packet).Layer(nextLayer)
4402 switch nextLayer {
4403 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004404 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4405 if resp.Result == me.Success {
4406 return true
4407 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004408 }
4409 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004410 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4411 if resp.Result == me.Success {
4412 return true
4413 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004414 }
4415 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004416 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4417 if resp.Result == me.Success {
4418 return true
4419 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004420 }
4421 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004422 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4423 if resp.Result == me.Success {
4424 return true
4425 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004426 }
4427 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004428 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4429 if resp.Result == me.Success {
4430 return true
4431 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004432 }
4433 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004434 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4435 if resp.Result == me.Success {
4436 return true
4437 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004438 }
4439 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004440 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4441 if resp.Result == me.Success {
4442 return true
4443 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004444 }
4445 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004446 }
4447 }
4448 return false
4449}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004450
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004451func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004452 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004453 if timeout == 0 {
4454 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004455 // enqueue
4456 if aOmciTxRequest.highPrio {
4457 oo.mutexHighPrioTxQueue.Lock()
4458 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4459 oo.mutexHighPrioTxQueue.Unlock()
4460 } else {
4461 oo.mutexLowPrioTxQueue.Lock()
4462 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4463 oo.mutexLowPrioTxQueue.Unlock()
4464 }
4465 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004466 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004467 //the supervised sending with waiting on the response (based on TID) is called in background
4468 // to avoid blocking of the sender for the complete OMCI handshake procedure
4469 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4470 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4471 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004472 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004473}
4474
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004475func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004476 chSuccess := make(chan bool)
4477 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004478 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004479 oo.mutexMonReq.Lock()
4480 oo.monitoredRequests[tid] = aOmciTxRequest
4481 oo.mutexMonReq.Unlock()
4482
4483 retries := aOmciTxRequest.retries
4484 retryCounter := 0
4485loop:
4486 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004487 // enqueue
4488 if aOmciTxRequest.highPrio {
4489 oo.mutexHighPrioTxQueue.Lock()
4490 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4491 oo.mutexHighPrioTxQueue.Unlock()
4492 } else {
4493 oo.mutexLowPrioTxQueue.Lock()
4494 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4495 oo.mutexLowPrioTxQueue.Unlock()
4496 }
4497 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004498
4499 select {
4500 case success := <-chSuccess:
4501 if success {
4502 logger.Debugw(ctx, "reqMon: response received in time",
4503 log.Fields{"tid": tid, "device-id": oo.deviceID})
4504 } else {
4505 logger.Debugw(ctx, "reqMon: wait for response aborted",
4506 log.Fields{"tid": tid, "device-id": oo.deviceID})
4507 }
4508 break loop
4509 case <-time.After(time.Duration(aTimeout) * time.Second):
4510 if retryCounter == retries {
4511 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
4512 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4513 break loop
4514 } else {
4515 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4516 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4517 }
4518 }
4519 retryCounter++
4520 }
4521 oo.mutexMonReq.Lock()
4522 delete(oo.monitoredRequests, tid)
4523 oo.mutexMonReq.Unlock()
4524}
4525
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004526//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004527func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004528 oo.mutexMonReq.RLock()
4529 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004530 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4531 select {
4532 case oo.monitoredRequests[k].chSuccess <- false:
4533 default:
4534 logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
4535 "index": k, "device-id": oo.deviceID})
4536 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004537 }
4538 oo.mutexMonReq.RUnlock()
4539}
4540
4541//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4542//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004543func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4544 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004545}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304546
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004547// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4548func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304549 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004550 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304551 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4552 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4553
4554 meParam := me.ParamData{EntityID: entityID,
4555 Attributes: me.AttributeValueMap{"ControlBlock": controlBlock},
4556 }
4557 var meInstance *me.ManagedEntity
4558 var omciErr me.OmciErrors
4559 if classID == me.EthernetFrameExtendedPmClassID {
4560 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4561 } else {
4562 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4563 }
4564
4565 if omciErr.GetError() == nil {
4566 var omciLayer *omci.OMCI
4567 var msgLayer gopacket.SerializableLayer
4568 var err error
4569 if create {
mpagenko836a1fd2021-11-01 16:12:42 +00004570 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid),
4571 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304572 } else {
mpagenko836a1fd2021-11-01 16:12:42 +00004573 omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid),
4574 oframe.AddDefaults(true))
Himani Chawla43f95ff2021-06-03 00:24:12 +05304575 }
4576 if err != nil {
4577 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4578 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4579 return nil, err
4580 }
4581
4582 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4583 if err != nil {
4584 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
4585 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4586 return nil, err
4587 }
4588
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004589 omciRxCallbackPair := CallbackPair{CbKey: tid,
4590 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304591 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004592 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304593 if err != nil {
4594 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4595 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4596 return nil, err
4597 }
4598 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
4599 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4600 return meInstance, nil
4601 }
4602 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4603 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4604 return nil, omciErr.GetError()
4605}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004606
4607// RLockMutexMonReq lock read access to monitoredRequests
4608func (oo *OmciCC) RLockMutexMonReq() {
4609 oo.mutexMonReq.RLock()
4610}
4611
4612// RUnlockMutexMonReq unlock read access to monitoredRequests
4613func (oo *OmciCC) RUnlockMutexMonReq() {
4614 oo.mutexMonReq.RUnlock()
4615}
4616
4617// GetMonitoredRequest get OmciTransferStructure for an omciTransID
4618func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
4619 value, exist = oo.monitoredRequests[omciTransID]
4620 return value, exist
4621}
4622
4623// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
4624func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
4625 oo.monitoredRequests[omciTransID].chSuccess <- chVal
4626}
Himani Chawlaee10b542021-09-20 16:46:40 +05304627
4628// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
4629func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
4630 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
4631 tid := oo.GetNextTid(highPrio)
4632 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
4633 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
4634
4635 meParams := me.ParamData{EntityID: entityID,
4636 Attributes: me.AttributeValueMap{"ControlBlock": controlBlock},
4637 }
4638 var meInstance *me.ManagedEntity
4639 var omciErr me.OmciErrors
4640 if classID == me.EthernetFrameExtendedPmClassID {
4641 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
4642 } else {
4643 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
4644 }
4645
4646 if omciErr.GetError() == nil {
mpagenko836a1fd2021-11-01 16:12:42 +00004647 omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid))
Himani Chawlaee10b542021-09-20 16:46:40 +05304648 if err != nil {
4649 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4650 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4651 return nil, err
4652 }
4653 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4654 if err != nil {
4655 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
4656 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4657 return nil, err
4658 }
4659 omciRxCallbackPair := CallbackPair{
4660 CbKey: tid,
4661 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4662 }
4663 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4664 if err != nil {
4665 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4666 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4667 return nil, err
4668 }
4669 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
4670 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4671 return meInstance, nil
4672 }
4673 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4674 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4675 return nil, omciErr.GetError()
4676}
Holger Hildebrandte7cc6092022-02-01 11:37:03 +00004677
4678// PrepareForGarbageCollection - remove references to prepare for garbage collection
4679func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
4680 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
4681 oo.pBaseDeviceHandler = nil
4682 oo.pOnuDeviceEntry = nil
4683 oo.pOnuAlarmManager = nil
4684}