blob: 9224d61765fd70e7e7b57bf2429378cfd708737c [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
34 "github.com/opencord/omci-lib-go"
35 me "github.com/opencord/omci-lib-go/generated"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000036
khenaidoo7d3c5582021-08-11 18:09:44 -040037 vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc"
38
39 "github.com/opencord/voltha-protos/v5/go/common"
40 //"github.com/opencord/voltha-lib-go/v7/pkg/kafka"
41 "github.com/opencord/voltha-lib-go/v7/pkg/log"
42 ic "github.com/opencord/voltha-protos/v5/go/inter_container"
43 //"github.com/opencord/voltha-protos/v5/go/openflow_13"
44 //"github.com/opencord/voltha-protos/v5/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000045)
46
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053048
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000049const maxGemPayloadSize = uint16(48)
50const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053051
52//const defaultTPID = uint16(0x8100)
53//const broadComDefaultVID = uint16(4091)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000054
55// UnusedTcontAllocID - TODO: add comment
56const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
mpagenko8b07c1b2020-11-26 10:36:31 +000057
mpagenkoc8bba412021-01-15 15:38:44 +000058const cOmciBaseMessageTrailerLen = 40
59
60// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
61type tOmciReceiveError uint8
62
63const (
64 // cOmciMessageReceiveNoError - default start state
65 cOmciMessageReceiveNoError tOmciReceiveError = iota
66 // Error indication wrong trailer length within the message
67 cOmciMessageReceiveErrorTrailerLen
68 // Error indication missing trailer within the message
69 cOmciMessageReceiveErrorMissTrailer
70)
71
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000072// CDefaultRetries - TODO: add comment
73const CDefaultRetries = 2
Holger Hildebrandt366ef192021-05-05 11:07:44 +000074
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000075// ### OMCI related definitions - end
76
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000077//CallbackPairEntry to be used for OMCI send/receive correlation
78type CallbackPairEntry struct {
79 CbRespChannel chan Message
80 CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
81 FramePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000082}
83
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000084//CallbackPair to be used for ReceiveCallback init
85type CallbackPair struct {
86 CbKey uint16
87 CbEntry CallbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000088}
89
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000090// OmciTransferStructure - TODO: add comment
91type OmciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000092 txFrame []byte
93 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000094 retries int
mpagenko80622a52021-02-09 16:53:23 +000095 highPrio bool
96 withFramePrint bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +000097 cbPair CallbackPair
Holger Hildebrandt366ef192021-05-05 11:07:44 +000098 chSuccess chan bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000099}
100
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000101//OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
102type OmciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000103 enabled bool
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000104 pBaseDeviceHandler IdeviceHandler
105 pOnuDeviceEntry IonuDeviceEntry
106 pOnuAlarmManager IonuAlarmManager
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000107 deviceID string
khenaidoo7d3c5582021-08-11 18:09:44 -0400108 coreClient *vgrpc.Client
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000109 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000110 rxOmciFrameError tOmciReceiveError
111
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000112 txFrames, txOnuFrames uint32
113 rxFrames, rxOnuFrames, rxOnuDiscards uint32
114
115 // OMCI params
116 mutexTid sync.Mutex
117 tid uint16
118 mutexHpTid sync.Mutex
119 hpTid uint16
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000120 UploadSequNo uint16
121 UploadNoOfCmds uint16
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000122
Holger Hildebrandt34555512021-10-01 16:26:59 +0000123 mutexSendQueuedRequests sync.Mutex
124 mutexLowPrioTxQueue sync.Mutex
125 lowPrioTxQueue *list.List
126 mutexHighPrioTxQueue sync.Mutex
127 highPrioTxQueue *list.List
128 mutexRxSchedMap sync.Mutex
129 rxSchedulerMap map[uint16]CallbackPairEntry
130 mutexMonReq sync.RWMutex
131 monitoredRequests map[uint16]OmciTransferStructure
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000132}
133
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000134var responsesWithMibDataSync = []omci.MessageType{
135 omci.CreateResponseType,
136 omci.DeleteResponseType,
137 omci.SetResponseType,
138 omci.StartSoftwareDownloadResponseType,
139 omci.EndSoftwareDownloadResponseType,
140 omci.ActivateSoftwareResponseType,
141 omci.CommitSoftwareResponseType,
142}
143
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000144//NewOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000145//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000146func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler,
147 onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager,
148 coreClient *vgrpc.Client) *OmciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000149 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000150 var omciCC OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000151 omciCC.enabled = false
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000152 omciCC.pBaseDeviceHandler = deviceHandler
153 omciCC.pOnuAlarmManager = onuAlarmManager
Himani Chawla4d908332020-08-31 12:30:20 +0530154 omciCC.pOnuDeviceEntry = onuDeviceEntry
155 omciCC.deviceID = deviceID
khenaidoo7d3c5582021-08-11 18:09:44 -0400156 omciCC.coreClient = coreClient
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000157 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000158 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000159 omciCC.txFrames = 0
160 omciCC.txOnuFrames = 0
161 omciCC.rxFrames = 0
162 omciCC.rxOnuFrames = 0
163 omciCC.rxOnuDiscards = 0
164 omciCC.tid = 0x1
165 omciCC.hpTid = 0x8000
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000166 omciCC.UploadSequNo = 0
167 omciCC.UploadNoOfCmds = 0
Holger Hildebrandt34555512021-10-01 16:26:59 +0000168 omciCC.lowPrioTxQueue = list.New()
169 omciCC.highPrioTxQueue = list.New()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000170 omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry)
171 omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000172
173 return &omciCC
174}
175
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000176//Stop stops/resets the omciCC
177func (oo *OmciCC) Stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000178 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000179 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
mpagenko8cd1bf72021-06-22 10:11:19 +0000180 oo.CancelRequestMonitoring(ctx)
Holger Hildebrandt34555512021-10-01 16:26:59 +0000181 // clear the tx queues
182 oo.mutexHighPrioTxQueue.Lock()
183 oo.highPrioTxQueue.Init()
184 oo.mutexHighPrioTxQueue.Unlock()
185 oo.mutexLowPrioTxQueue.Lock()
186 oo.lowPrioTxQueue.Init()
187 oo.mutexLowPrioTxQueue.Unlock()
188 //clear the scheduler map
mpagenko900ee4b2020-10-12 11:56:34 +0000189 oo.mutexRxSchedMap.Lock()
190 for k := range oo.rxSchedulerMap {
Holger Hildebrandt34555512021-10-01 16:26:59 +0000191 delete(oo.rxSchedulerMap, k)
mpagenko900ee4b2020-10-12 11:56:34 +0000192 }
193 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000194 //reset the high prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000195 oo.mutexHpTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000196 oo.hpTid = 0x8000
mpagenko900ee4b2020-10-12 11:56:34 +0000197 oo.mutexHpTid.Unlock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000198 //reset the low prio transactionId
mpagenko900ee4b2020-10-12 11:56:34 +0000199 oo.mutexTid.Lock()
Holger Hildebrandt34555512021-10-01 16:26:59 +0000200 oo.tid = 1
mpagenko900ee4b2020-10-12 11:56:34 +0000201 oo.mutexTid.Unlock()
202 //reset control values
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000203 oo.UploadSequNo = 0
204 oo.UploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000205 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000206 //reset the stats counter - which might be topic of discussion ...
207 oo.txFrames = 0
208 oo.txOnuFrames = 0
209 oo.rxFrames = 0
210 oo.rxOnuFrames = 0
211 oo.rxOnuDiscards = 0
212
213 return nil
214}
215
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000216// Rx handler for omci messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000217func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000218 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000219 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530220 switch omciMsg.MessageType {
221 case omci.AlarmNotificationType:
222 data := OmciMessage{
223 OmciMsg: omciMsg,
224 OmciPacket: packet,
225 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000226 go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data)
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530227 return nil
228 default:
229 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
230 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000231 /*
232 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
233 rxOnuFrames++
234
235 switch msgType {
236 case AlarmNotification:
237 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000238 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000239 // python code was:
240 //if msg_type == EntityOperations.AlarmNotification.value:
241 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
242 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
243 //
244 return errors.New("RxAlarmNotification unimplemented")
245 }
246 case AttributeValueChange:
247 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000248 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000249 // python code was:
250 //elif msg_type == EntityOperations.AttributeValueChange.value:
251 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
252 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
253 //
254 return errors.New("RxAttributeValueChange unimplemented")
255 }
256 case TestResult:
257 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000258 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000259 // python code was:
260 //elif msg_type == EntityOperations.TestResult.value:
261 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
262 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
263 //
264 return errors.New("RxTestResult unimplemented")
265 }
266 default:
267 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000268 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000269 rxOnuDiscards++
270 return errors.New("RxOnuMsgType unimplemented")
271 }
272 }
273 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000274}
275
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000276func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
mpagenko80622a52021-02-09 16:53:23 +0000277 //assuming omci message content is hex coded!
278 // with restricted output of 16bytes would be ...rxMsg[:16]
279 logger.Debugw(ctx, "omci-message-received:", log.Fields{
280 "RxOmciMessage": hex.EncodeToString(rxMsg),
281 "device-id": oo.deviceID})
282}
283
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000284// ReceiveMessage - Rx handler for onu messages
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000285// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000286func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000287 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000288 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
289 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000290 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000291 trailerLenData := rxMsg[42:44]
292 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000293 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000294 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
295 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
296 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
297 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
298 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
299 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
300 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
301 }
302 }
303 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
304 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
305 // (an extendedFormat message could be destroyed this way!)
306 // extend/overwrite with trailer
307 trailer := make([]byte, 8)
308 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
309 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
310 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
311 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
312 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
313 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
314 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000315 }
316 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000317 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
318 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000319 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200320 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000321 }
322
323 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
324 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000325 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000326 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200327 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000328 }
329 omciLayer := packet.Layer(omci.LayerTypeOMCI)
330 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000331 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000332 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200333 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000334 }
335 omciMsg, ok := omciLayer.(*omci.OMCI)
336 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000337 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000338 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200339 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000340 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000341 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000342 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700343 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
344 // We expect to find the TID in the oo.rxSchedulerMap
345 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000346 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000347 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000348 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000349 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530350 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000351 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000352 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200353 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000354 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200355 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530356 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000357 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530358 oo.mutexRxSchedMap.Lock()
359 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000360 if ok && rxCallbackEntry.CbFunction != nil {
361 if rxCallbackEntry.FramePrint {
mpagenko80622a52021-02-09 16:53:23 +0000362 oo.printRxMessage(ctx, rxMsg)
363 }
Himani Chawla4d908332020-08-31 12:30:20 +0530364 //disadvantage of decoupling: error verification made difficult, but anyway the question is
365 // how to react on erroneous frame reception, maybe can simply be ignored
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000366 go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000367 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000368 oo.pOnuDeviceEntry.IncrementMibDataSync(ctx)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000369 }
mpagenkoc8bba412021-01-15 15:38:44 +0000370
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700371 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
372 // so do not clean up the TransactionID in that case.
373 if omciMsg.MessageType != omci.TestResponseType {
374 // having posted the response the request is regarded as 'done'
375 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
376 }
Himani Chawla4d908332020-08-31 12:30:20 +0530377 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000378 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000379 }
mpagenko80622a52021-02-09 16:53:23 +0000380 oo.mutexRxSchedMap.Unlock()
381 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
382 oo.printRxMessage(ctx, rxMsg)
383 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000384
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000385 /* py code was:
386 Receive and OMCI message from the proxy channel to the OLT.
387
388 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
389 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
390 """
391 if not self.enabled:
392 return
393
394 try:
395 now = arrow.utcnow()
396 d = None
397
398 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
399 # save the current value of the entity_id_to_class_map, then
400 # replace it with our custom one before decode, and then finally
401 # restore it later. Tried other ways but really made the code messy.
402 saved_me_map = omci_entities.entity_id_to_class_map
403 omci_entities.entity_id_to_class_map = self._me_map
404
405 try:
406 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000407 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000408 except KeyError as e:
409 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000410 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000411 rx_frame = self._decode_unknown_me(msg)
412 self._rx_unknown_me += 1
413
414 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000415 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000416 return
417
418 finally:
419 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
420
421 rx_tid = rx_frame.fields['transaction_id']
422 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000423 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000424 # Filter the Test Result frame and route through receive onu
425 # message method.
426 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000427 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000428 return self._receive_onu_message(rx_frame)
429
430 # Previously unreachable if this is the very first round-trip Rx or we
431 # have been running consecutive errors
432 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000433 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000434 self.reactor.callLater(0, self._publish_connectivity_event, True)
435
436 self._rx_frames += 1
437 self._consecutive_errors = 0
438
439 try:
440 high_priority = self._tid_is_high_priority(rx_tid)
441 index = self._get_priority_index(high_priority)
442
443 # (timestamp, defer, frame, timeout, retry, delayedCall)
444 last_tx_tuple = self._tx_request[index]
445
446 if last_tx_tuple is None or \
447 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
448 # Possible late Rx on a message that timed-out
449 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000450 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000451 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
452 self._rx_unknown_tid += 1
453 self._rx_late += 1
454 return
455
456 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
457 if dc is not None and not dc.cancelled and not dc.called:
458 dc.cancel()
459
460 _secs = self._update_rx_tx_stats(now, ts)
461
462 # Late arrival already serviced by a timeout?
463 if d.called:
464 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000465 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000466 return
467
468 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000469 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000470 if d is not None:
471 return d.errback(failure.Failure(e))
472 return
473
474 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000475 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000476 tx_tid = tx_frame.fields['transaction_id'])
477 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
478
479 # begin success callback chain (will cancel timeout and queue next Tx message)
480 self._rx_response[index] = rx_frame
481 d.callback(rx_frame)
482
483 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000484 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000485 */
486}
487
Himani Chawla6d2ae152020-09-02 13:11:20 +0530488/*
489func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530490 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530491 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000492}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530493*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000494
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700495// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000496func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) {
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700497 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
498 delete(oo.rxSchedulerMap, tid)
499}
500
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000501// Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
502func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
503 receiveCallbackPair CallbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000504
mpagenkoc26d4c02021-05-06 14:27:57 +0000505 if timeout != 0 {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000506 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey})
mpagenkoc26d4c02021-05-06 14:27:57 +0000507 oo.mutexRxSchedMap.Lock()
508 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000509 oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry
mpagenkoc26d4c02021-05-06 14:27:57 +0000510 oo.mutexRxSchedMap.Unlock()
511 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000512
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000513 printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000514 //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 +0000515 omciTxRequest := OmciTransferStructure{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000516 txFrame,
517 timeout,
518 retry,
519 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000520 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000521 receiveCallbackPair,
522 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000523 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000524 oo.mutexMonReq.Lock()
525 defer oo.mutexMonReq.Unlock()
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000526 if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000527 // do not call processRequestMonitoring in background here to ensure correct sequencing
528 // of requested messages into txQueue (especially for non-response-supervised messages)
529 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000530 return nil
531 }
532 logger.Errorw(ctx, "A message with this tid is processed already!",
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000533 log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID})
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000534 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000535}
536
Holger Hildebrandt34555512021-10-01 16:26:59 +0000537func (oo *OmciCC) sendQueuedRequests(ctx context.Context) {
538 // Avoid accessing the txQueues from parallel send routines to block
539 // parallel omci send requests at least until SendIAP is 'committed'.
540 // To guarantee window size 1 for one ONU it would be necessary to wait
541 // for the corresponding response too (t.b.d.).
542 oo.mutexSendQueuedRequests.Lock()
543 defer oo.mutexSendQueuedRequests.Unlock()
544 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
545 logger.Errorw(ctx, "Error during sending high prio requests!",
546 log.Fields{"err": err, "device-id": oo.deviceID})
547 return
548 }
549 if err := oo.sendQueuedLowPrioRequests(ctx); err != nil {
550 logger.Errorw(ctx, "Error during sending low prio requests!",
551 log.Fields{"err": err, "device-id": oo.deviceID})
552 return
553 }
554}
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000555
Holger Hildebrandt34555512021-10-01 16:26:59 +0000556func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error {
557 oo.mutexHighPrioTxQueue.Lock()
558 defer oo.mutexHighPrioTxQueue.Unlock()
559 for oo.highPrioTxQueue.Len() > 0 {
560 queueElement := oo.highPrioTxQueue.Front() // First element
561 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
562 return err
mpagenko80622a52021-02-09 16:53:23 +0000563 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000564 oo.highPrioTxQueue.Remove(queueElement) // Dequeue
565 }
566 return nil
567}
568
569func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error {
570 oo.mutexLowPrioTxQueue.Lock()
571 for oo.lowPrioTxQueue.Len() > 0 {
572 queueElement := oo.lowPrioTxQueue.Front() // First element
573 if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil {
574 oo.mutexLowPrioTxQueue.Unlock()
575 return err
amit.ghosh58b704b2021-06-18 03:45:52 +0200576 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000577 oo.lowPrioTxQueue.Remove(queueElement) // Dequeue
578 // Interrupt the sending of low priority requests to process any high priority requests
579 // that may have arrived in the meantime
580 oo.mutexLowPrioTxQueue.Unlock()
581 if err := oo.sendQueuedHighPrioRequests(ctx); err != nil {
582 return err
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000583 }
Holger Hildebrandt34555512021-10-01 16:26:59 +0000584 oo.mutexLowPrioTxQueue.Lock()
585 }
586
587 oo.mutexLowPrioTxQueue.Unlock()
588 return nil
589}
590
591func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error {
592 if omciTxRequest.withFramePrint {
593 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
594 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
595 "device-id": oo.deviceID,
596 "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(),
597 "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(),
598 "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()})
599 }
600 omciMsg := &ic.OmciMessage{
601 ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(),
602 ChildDeviceId: oo.deviceID,
603 Message: omciTxRequest.txFrame,
604 ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(),
605 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
606 }
607 sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg)
608 if sendErr != nil {
609 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
610 return sendErr
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000611 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000612 return nil
613}
614
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000615// GetNextTid - TODO: add comment
616func (oo *OmciCC) GetNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000617 var next uint16
618 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000619 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000620 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530621 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000622 if oo.hpTid < 0x8000 {
623 oo.hpTid = 0x8000
624 }
mpagenko900ee4b2020-10-12 11:56:34 +0000625 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000626 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000627 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000628 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530629 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000630 if oo.tid >= 0x8000 {
631 oo.tid = 1
632 }
mpagenko900ee4b2020-10-12 11:56:34 +0000633 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000634 }
635 return next
636}
637
638// ###################################################################################
639// # utility methods provided to work on OMCI messages
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000640
641// Serialize - TODO: add comment
642func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000643 omciLayer := &omci.OMCI{
644 TransactionID: tid,
645 MessageType: msgType,
646 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000647 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000648}
649
dbainbri4d3a0dc2020-12-02 00:33:42 +0000650func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000651 var options gopacket.SerializeOptions
652 options.FixLengths = true
653
654 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530655 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000656 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000657 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000658 return nil, err
659 }
660 return buffer.Bytes(), nil
661}
662
Himani Chawla4d908332020-08-31 12:30:20 +0530663/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000664func hexEncode(omciPkt []byte) ([]byte, error) {
665 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
666 hex.Encode(dst, omciPkt)
667 return dst, nil
668}
Himani Chawla4d908332020-08-31 12:30:20 +0530669*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000670
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000671//supply a response handler for omci response messages to be transferred to the requested FSM
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000672func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000673
dbainbri4d3a0dc2020-12-02 00:33:42 +0000674 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000675 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000676
677 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000678 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000679 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200680 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000681 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000682 oo.mutexMonReq.RLock()
683 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000684 //implement non-blocking channel send to avoid blocking on mutexMonReq later
685 select {
686 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
687 default:
688 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
689 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
690 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000691 } else {
692 logger.Infow(ctx, "reqMon: map entry does not exist!",
693 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
694 }
695 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000696
697 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
698 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000699 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000700 Type: OMCI,
701 Data: OmciMessage{
702 OmciMsg: omciMsg,
703 OmciPacket: packet,
704 },
705 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000707 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000708
709 return nil
710}
711
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000712// SendMibReset sends MibResetRequest
713func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000714
dbainbri4d3a0dc2020-12-02 00:33:42 +0000715 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000716 request := &omci.MibResetRequest{
717 MeBasePacket: omci.MeBasePacket{
718 EntityClass: me.OnuDataClassID,
719 },
720 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000721 tid := oo.GetNextTid(highPrio)
722 pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000723 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000724 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000725 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000726 return err
727 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000728 omciRxCallbackPair := CallbackPair{
729 CbKey: tid,
730 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000731 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000732 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000733}
734
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000735// SendReboot sends RebootRequest
736func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
737 logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300738 request := &omci.RebootRequest{
739 MeBasePacket: omci.MeBasePacket{
740 EntityClass: me.OnuGClassID,
741 },
742 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000743 tid := oo.GetNextTid(highPrio)
744 pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300745 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000746 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000747 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300748 return err
749 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000750 omciRxCallbackPair := CallbackPair{
751 CbKey: tid,
752 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300753 }
754
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000755 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300756 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000757 logger.Errorw(ctx, "Cannot send 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 err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300762 if err != nil {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000763 logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200764 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300765 return err
766 }
767 return nil
768}
769
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000770// SendMibUpload sends MibUploadRequest
771func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000772 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000773 request := &omci.MibUploadRequest{
774 MeBasePacket: omci.MeBasePacket{
775 EntityClass: me.OnuDataClassID,
776 },
777 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000778 tid := oo.GetNextTid(highPrio)
779 pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000780 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000781 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000782 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000783 return err
784 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000785 oo.UploadSequNo = 0
786 oo.UploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000787
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000788 omciRxCallbackPair := CallbackPair{
789 CbKey: tid,
790 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000791 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000792 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000793}
794
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000795// SendMibUploadNext sends MibUploadNextRequest
796func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
797 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000798 request := &omci.MibUploadNextRequest{
799 MeBasePacket: omci.MeBasePacket{
800 EntityClass: me.OnuDataClassID,
801 },
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000802 CommandSequenceNumber: oo.UploadSequNo,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000803 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000804 tid := oo.GetNextTid(highPrio)
805 pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000806 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000807 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000808 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000809 return err
810 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000811 oo.UploadSequNo++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000812
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000813 omciRxCallbackPair := CallbackPair{
814 CbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000815 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
816 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
817 // compare also software upgrade download section handling
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000818 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000819 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000820 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000821}
822
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000823// SendGetAllAlarm gets all alarm ME instances
824func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
Himani Chawlad3dac422021-03-13 02:31:31 +0530825 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
826 request := &omci.GetAllAlarmsRequest{
827 MeBasePacket: omci.MeBasePacket{
828 EntityClass: me.OnuDataClassID,
829 },
830 AlarmRetrievalMode: byte(alarmRetreivalMode),
831 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000832 tid := oo.GetNextTid(highPrio)
833 pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530834 if err != nil {
835 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
836 "Err": err, "device-id": oo.deviceID})
837 return err
838 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000839 oo.pOnuAlarmManager.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530840
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000841 omciRxCallbackPair := CallbackPair{
842 CbKey: tid,
843 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530844 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000845 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530846}
847
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000848// SendGetAllAlarmNext gets next alarm ME instance
849func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
850 alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo()
851 logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
Himani Chawlad3dac422021-03-13 02:31:31 +0530852 "alarmUploadSeqNo": alarmUploadSeqNo})
853 request := &omci.GetAllAlarmsNextRequest{
854 MeBasePacket: omci.MeBasePacket{
855 EntityClass: me.OnuDataClassID,
856 },
857 CommandSequenceNumber: alarmUploadSeqNo,
858 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000859 tid := oo.GetNextTid(highPrio)
860 pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
Himani Chawlad3dac422021-03-13 02:31:31 +0530861 if err != nil {
862 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
863 "Err": err, "device-id": oo.deviceID})
864 return err
865 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000866 oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530867
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000868 omciRxCallbackPair := CallbackPair{
869 CbKey: tid,
870 CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true},
Himani Chawlad3dac422021-03-13 02:31:31 +0530871 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000872 return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530873}
874
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000875// SendCreateGalEthernetProfile creates GalEthernetProfile ME instance
876func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
877 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000878 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000879 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000880
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000881 meParams := me.ParamData{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000882 EntityID: GalEthernetEID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000883 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
884 }
885 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
886 if omciErr.GetError() == nil {
887 //all setByCreate parameters already set, no default option required ...
888 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
889 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000890 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000891 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300892 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000893 }
894
dbainbri4d3a0dc2020-12-02 00:33:42 +0000895 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000896 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000897 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000898 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300899 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000900 }
901
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000902 omciRxCallbackPair := CallbackPair{
903 CbKey: tid,
904 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000905 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000906 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000908 logger.Errorw(ctx, "Cannot send 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000912 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300913 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000914 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000915 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000916 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300917 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000918}
919
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000920// SendSetOnu2g sets Onu2G ME instance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000921// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000922func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
923 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000924 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000925 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000926
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000927 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
928 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000929 // By now we just use fix values to fire - this is anyway what the python adapter does
930 // read ONU-2G from DB ???? //TODO!!!
931 meParams := me.ParamData{
932 EntityID: 0,
933 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
934 }
935 meInstance, omciErr := me.NewOnu2G(meParams)
936 if omciErr.GetError() == nil {
937 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
938 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000939 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000940 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300941 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000942 }
943
dbainbri4d3a0dc2020-12-02 00:33:42 +0000944 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000945 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000946 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000947 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300948 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949 }
950
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000951 omciRxCallbackPair := CallbackPair{
952 CbKey: tid,
953 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000954 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000955 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000956 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000957 logger.Errorw(ctx, "Cannot send 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000961 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300962 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000963 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000964 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000965 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300966 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000967}
968
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +0000969// SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance
970func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context,
971 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
972 tid := oo.GetNextTid(highPrio)
973 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000974 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000975 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000976
977 meParams := me.ParamData{
978 EntityID: instID,
979 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300980 "Priority": 0x8000,
981 "MaxAge": 20 * 256, //20s
982 "HelloTime": 2 * 256, //2s
983 "ForwardDelay": 15 * 256, //15s
984 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000985 },
986 }
987
988 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
989 if omciErr.GetError() == nil {
990 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
991 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
992 omci.TransactionID(tid), omci.AddDefaults(true))
993 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000994 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000995 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300996 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000997 }
998
dbainbri4d3a0dc2020-12-02 00:33:42 +0000999 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001000 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001001 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001002 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001003 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001004 }
1005
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001006 omciRxCallbackPair := CallbackPair{
1007 CbKey: tid,
1008 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001009 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001010 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001011 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001012 logger.Errorw(ctx, "Cannot send 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001016 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001017 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001018 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001019 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001020 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001021 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001022}
1023
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001024// SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance
1025func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context,
1026 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1027 tid := oo.GetNextTid(highPrio)
1028 instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo))
Mahir Gunyel6781f962021-05-16 23:30:08 -07001029 if idErr != nil {
1030 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1031 "Err": idErr, "device-id": oo.deviceID})
1032 return nil, idErr
1033 }
1034 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001035 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001036
1037 meParams := me.ParamData{
1038 EntityID: instID,
1039 Attributes: me.AttributeValueMap{
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001040 "BridgeIdPointer": MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo),
1041 "PortNum": aPUniPort.MacBpNo,
1042 "TpType": uint8(aPUniPort.PortType),
1043 "TpPointer": aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001044 },
1045 }
1046 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1047 if omciErr.GetError() == nil {
1048 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1049 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1050 omci.TransactionID(tid), omci.AddDefaults(true))
1051 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001052 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001053 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001054 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001055 }
1056
dbainbri4d3a0dc2020-12-02 00:33:42 +00001057 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001058 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001059 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001060 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001061 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001062 }
1063
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001064 omciRxCallbackPair := CallbackPair{
1065 CbKey: tid,
1066 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001067 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001068 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001069 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001070 logger.Errorw(ctx, "Cannot send 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001074 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001075 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001076 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001077 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001078 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001079 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001080}
1081
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001082// SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance
1083func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context,
1084 aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
1085 tid := oo.GetNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001086 //same entityId is used as for MBSP (see there), but just arbitrary ...
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001087 instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001088 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001089 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001090
1091 // compare python adapter code WA VOL-1311: this is not done here!
1092 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1093 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1094 assType := uint8(2) // default AssociationType is PPTPEthUni
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001095 if aPUniPort.PortType == UniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001096 assType = uint8(10) // for VEIP
1097 }
1098 meParams := me.ParamData{
1099 EntityID: instID,
1100 Attributes: me.AttributeValueMap{
1101 "AssociationType": assType,
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001102 "AssociatedMePointer": aPUniPort.EntityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001103 },
1104 }
1105 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1106 if omciErr.GetError() == nil {
1107 //all setByCreate parameters already set, no default option required ...
1108 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1109 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001110 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001111 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001112 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001113 }
1114
dbainbri4d3a0dc2020-12-02 00:33:42 +00001115 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001116 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001117 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001118 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001119 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001120 }
1121
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001122 omciRxCallbackPair := CallbackPair{
1123 CbKey: tid,
1124 CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001125 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001126 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001127 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001129 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001130 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001131 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001132 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001133 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001134 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001135 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001136 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001137 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001138}
1139
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001140// SendSetOnuGLS sets OnuG ME instance
1141func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001142 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001143 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001144 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001145 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001146
1147 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1148 meParams := me.ParamData{
1149 EntityID: 0,
1150 Attributes: requestedAttributes,
1151 }
1152 meInstance, omciErr := me.NewOnuG(meParams)
1153 if omciErr.GetError() == nil {
1154 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1155 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001156 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001157 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001158 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001159 }
1160
dbainbri4d3a0dc2020-12-02 00:33:42 +00001161 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001162 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001163 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001164 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001165 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001166 }
1167
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001168 omciRxCallbackPair := CallbackPair{
1169 CbKey: tid,
1170 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001171 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001172 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001173 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001174 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001175 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001176 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001177 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001178 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001179 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001180 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001181 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001182 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001183 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001184}
1185
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001186// SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance
1187func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001188 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001189 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001190 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001191 "SequNo": strconv.FormatInt(int64(tid), 16)})
1192
1193 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1194 meParams := me.ParamData{
1195 EntityID: aInstNo,
1196 Attributes: requestedAttributes,
1197 }
1198 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1199 if omciErr.GetError() == nil {
1200 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1201 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001202 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001203 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001204 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001205 }
1206
dbainbri4d3a0dc2020-12-02 00:33:42 +00001207 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001208 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001209 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001210 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001211 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001212 }
1213
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001214 omciRxCallbackPair := CallbackPair{
1215 CbKey: tid,
1216 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001217 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001218 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001219 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001221 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001222 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001223 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001224 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001225 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001226 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001227 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001228 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001229 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001230}
1231
1232/* UniG obsolete by now, left here in case it should be needed once again
1233 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301234func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001235 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001236 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001237 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001238 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001239
1240 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1241 meParams := me.ParamData{
1242 EntityID: aInstNo,
1243 Attributes: requestedAttributes,
1244 }
1245 meInstance, omciErr := me.NewUniG(meParams)
1246 if omciErr.GetError() == nil {
1247 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1248 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001249 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001250 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001251 return nil
1252 }
1253
1254 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1255 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001256 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001257 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001258 return nil
1259 }
1260
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001261 omciRxCallbackPair := CallbackPair{
1262 CbKey: tid,
1263 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001264 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001265 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001266 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001267 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001268 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001269 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001270 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001271 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001272 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001273 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001274 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001275 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001276 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001277}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001278*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001279
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001280// SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance
1281func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001282 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001283 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001284 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001285 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001286
1287 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1288 meParams := me.ParamData{
1289 EntityID: aInstNo,
1290 Attributes: requestedAttributes,
1291 }
1292 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1293 if omciErr.GetError() == nil {
1294 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1295 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001296 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001297 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001298 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001299 }
1300
dbainbri4d3a0dc2020-12-02 00:33:42 +00001301 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001302 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001303 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001304 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001305 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001306 }
1307
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001308 omciRxCallbackPair := CallbackPair{
1309 CbKey: tid,
1310 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001311 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001312 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001313 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001314 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001315 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001316 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001317 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001318 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001319 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001320 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001321 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001322 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001323 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001324}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001325
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001326// SendGetMe gets ME instance
1327func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001328 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001329
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001330 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001331 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001332 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001333
1334 meParams := me.ParamData{
1335 EntityID: entityID,
1336 Attributes: requestedAttributes,
1337 }
1338 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1339 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301340 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001341 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1342 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001343 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 +03001344 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001345 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001346 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001347 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001348 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001349 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001350 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001351 omciRxCallbackPair := CallbackPair{
1352 CbKey: tid,
1353 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001354 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001355 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001356 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001357 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001358 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001359 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001360 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001361 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001362 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001363 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001364 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001365}
1366
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001367// SendGetMeWithAttributeMask gets ME instance with attribute mask
1368func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
Himani Chawla43f95ff2021-06-03 00:24:12 +05301369 timeout int, highPrio bool, rxChan chan Message) error {
1370
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001371 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301372 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1373 "SequNo": strconv.FormatInt(int64(tid), 16)})
1374
1375 request := &omci.GetRequest{
1376 MeBasePacket: omci.MeBasePacket{
1377 EntityInstance: entityID,
1378 EntityClass: classID,
1379 },
1380 AttributeMask: requestedAttributesMask,
1381 }
1382
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001383 pkt, err := Serialize(ctx, omci.GetRequestType, request, tid)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301384 if err != nil {
1385 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1386 return err
1387 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001388 omciRxCallbackPair := CallbackPair{
1389 CbKey: tid,
1390 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05301391 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001392 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05301393 if err != nil {
1394 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1395 return err
1396 }
1397 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1398 return nil
1399}
1400
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001401// SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance
1402func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001403 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001404 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001405 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001406 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1407
1408 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001409 EntityID: aInstID,
1410 Attributes: me.AttributeValueMap{
1411 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1412 "TpPointer": 0xFFFF,
1413 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1414 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1415 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1416 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1417 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1418 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1419 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1420 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1421 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001422 }
1423 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1424 if omciErr.GetError() == nil {
1425 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1426 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1427 omci.TransactionID(tid), omci.AddDefaults(true))
1428 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001429 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001430 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001431 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001432 }
1433
dbainbri4d3a0dc2020-12-02 00:33:42 +00001434 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001435 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001436 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001437 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001438 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001439 }
1440
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001441 omciRxCallbackPair := CallbackPair{
1442 CbKey: tid,
1443 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001444 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001445 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001446 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001447 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001448 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001449 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001450 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001451 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001452 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001453 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001454 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001455 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001456 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001457}
1458
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001459// SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance
1460func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001461 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001462 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001463 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001464 "SequNo": strconv.FormatInt(int64(tid), 16),
1465 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1466
1467 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1468 if omciErr.GetError() == nil {
1469 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1470 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1471 omci.TransactionID(tid), omci.AddDefaults(true))
1472 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001473 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001474 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001475 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001476 }
1477
dbainbri4d3a0dc2020-12-02 00:33:42 +00001478 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001479 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001480 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001481 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001482 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001483 }
1484
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001485 omciRxCallbackPair := CallbackPair{
1486 CbKey: tid,
1487 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001488 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001489 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001490 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001491 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001492 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001493 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001494 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001495 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001496 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001497 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001498 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001499 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001500 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001501}
1502
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001503// SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance
1504func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001505 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001506 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001507 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001508 "SequNo": strconv.FormatInt(int64(tid), 16),
1509 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1510
1511 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1512 if omciErr.GetError() == nil {
1513 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1514 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1515 omci.TransactionID(tid), omci.AddDefaults(true))
1516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001519 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001520 }
1521
dbainbri4d3a0dc2020-12-02 00:33:42 +00001522 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001523 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001524 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001525 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001526 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001527 }
1528
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001529 omciRxCallbackPair := CallbackPair{
1530 CbKey: tid,
1531 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001532 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001533 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001534 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001535 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001536 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001537 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001538 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001539 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001540 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001541 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001542 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001543 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001544 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001545}
1546
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001547// SendSetGemNCTPVar sets GemPortNetworkCtp ME instance
1548func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1549 tid := oo.GetNextTid(highPrio)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001550 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1551 "SequNo": strconv.FormatInt(int64(tid), 16),
1552 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1553
1554 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1555 if omciErr.GetError() == nil {
1556 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1557 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1558 omci.TransactionID(tid), omci.AddDefaults(true))
1559 if err != nil {
1560 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1561 "Err": err, "device-id": oo.deviceID})
1562 return nil, err
1563 }
1564
1565 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1566 if err != nil {
1567 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1568 "Err": err, "device-id": oo.deviceID})
1569 return nil, err
1570 }
1571
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001572 omciRxCallbackPair := CallbackPair{
1573 CbKey: tid,
1574 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia82b91a62021-05-21 18:54:49 +03001575 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001576 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia82b91a62021-05-21 18:54:49 +03001577 if err != nil {
1578 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1579 "Err": err, "device-id": oo.deviceID})
1580 return nil, err
1581 }
1582 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1583 return meInstance, nil
1584 }
1585 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1586 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1587 return nil, omciErr.GetError()
1588}
1589
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001590// SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance
1591func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001592 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001593 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001594 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001595 "SequNo": strconv.FormatInt(int64(tid), 16),
1596 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1597
1598 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1599 if omciErr.GetError() == nil {
1600 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1601 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1602 omci.TransactionID(tid))
1603 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001604 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001605 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001606 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001607 }
1608
dbainbri4d3a0dc2020-12-02 00:33:42 +00001609 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001610 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001611 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001612 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001613 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001614 }
1615
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001616 omciRxCallbackPair := CallbackPair{
1617 CbKey: tid,
1618 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001619 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001620 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001621 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001622 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001623 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001624 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001625 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001626 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001627 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001628 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001629 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001630 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001631 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001632}
1633
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001634// SendSetTcontVar sets TCont ME instance
1635func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001636 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001637 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001638 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001639 "SequNo": strconv.FormatInt(int64(tid), 16),
1640 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1641
1642 meInstance, omciErr := me.NewTCont(params[0])
1643 if omciErr.GetError() == nil {
1644 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1645 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001646 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001647 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001648 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001649 }
1650
dbainbri4d3a0dc2020-12-02 00:33:42 +00001651 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001652 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001653 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001654 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001655 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001656 }
1657
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001658 omciRxCallbackPair := CallbackPair{
1659 CbKey: tid,
1660 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001661 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001662 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001663 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001664 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001665 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001666 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001667 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001669 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001670 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001671 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001672 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001673 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001674}
1675
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001676// SendSetPrioQueueVar sets PriorityQueue ME instance
1677func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001678 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001679 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001680 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001681 "SequNo": strconv.FormatInt(int64(tid), 16),
1682 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1683
1684 meInstance, omciErr := me.NewPriorityQueue(params[0])
1685 if omciErr.GetError() == nil {
1686 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1687 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001688 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001689 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001690 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001691 }
1692
dbainbri4d3a0dc2020-12-02 00:33:42 +00001693 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001694 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001695 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001696 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001697 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001698 }
1699
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001700 omciRxCallbackPair := CallbackPair{
1701 CbKey: tid,
1702 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001703 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001704 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001705 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001706 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001707 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001708 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001709 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001710 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001711 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001712 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001713 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001714 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001715 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001716}
1717
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001718// SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance
1719func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001720 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001721 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001722 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001723 "SequNo": strconv.FormatInt(int64(tid), 16),
1724 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1725
1726 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1727 if omciErr.GetError() == nil {
1728 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1729 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001730 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001731 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001732 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001733 }
1734
dbainbri4d3a0dc2020-12-02 00:33:42 +00001735 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001736 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001737 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001738 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001739 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001740 }
1741
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001742 omciRxCallbackPair := CallbackPair{
1743 CbKey: tid,
1744 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001745 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001746 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001747 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001748 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001749 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001750 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001751 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001752 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001753 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001754 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001756 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001757 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001758}
mpagenkodff5dda2020-08-28 11:52:01 +00001759
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001760// SendCreateVtfdVar creates VlanTaggingFilterData ME instance
1761func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001762 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001763 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001764 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001765 "SequNo": strconv.FormatInt(int64(tid), 16),
1766 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1767
1768 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1769 if omciErr.GetError() == nil {
1770 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1771 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1772 omci.TransactionID(tid))
1773 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001774 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001775 "Err": err, "device-id": oo.deviceID})
1776 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1777 // return (dual format) error code that can be used at caller for immediate error treatment
1778 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001779 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001780 }
1781
dbainbri4d3a0dc2020-12-02 00:33:42 +00001782 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001783 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001784 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001785 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001786 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001787 }
1788
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001789 omciRxCallbackPair := CallbackPair{
1790 CbKey: tid,
1791 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001792 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001793 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001794 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001795 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001796 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001797 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001798 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001799 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001800 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001801 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001802 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001803 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001804 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001805}
1806
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001807// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001808func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001809 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001810 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001811 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001812 "SequNo": strconv.FormatInt(int64(tid), 16),
1813 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1814
1815 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1816 if omciErr.GetError() == nil {
1817 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1818 omci.TransactionID(tid))
1819 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001820 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001821 "Err": err, "device-id": oo.deviceID})
1822 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1823 // return (dual format) error code that can be used at caller for immediate error treatment
1824 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001825 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001826 }
1827
dbainbri4d3a0dc2020-12-02 00:33:42 +00001828 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001829 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001830 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001831 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001832 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001833 }
1834
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001835 omciRxCallbackPair := CallbackPair{
1836 CbKey: tid,
1837 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001838 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001839 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001840 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001841 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001842 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001843 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001844 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001845 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001846 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001847 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001848 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001849 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001850 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001851}
1852
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001853// SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance
1854func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001855 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001856 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001857 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001858 "SequNo": strconv.FormatInt(int64(tid), 16),
1859 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1860
1861 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1862 if omciErr.GetError() == nil {
1863 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1864 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001865 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001866 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001867 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001868 }
1869
dbainbri4d3a0dc2020-12-02 00:33:42 +00001870 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001871 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001872 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001873 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001874 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001875 }
1876
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001877 omciRxCallbackPair := CallbackPair{
1878 CbKey: tid,
1879 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001880 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001881 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001882 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001884 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001885 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001886 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001887 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001888 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001889 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001890 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001891 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001892 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001893}
1894
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001895// SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance
1896func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001897 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001898 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001899 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001900 "SequNo": strconv.FormatInt(int64(tid), 16),
1901 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1902
1903 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1904 if omciErr.GetError() == nil {
1905 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1906 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001907 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001908 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001909 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001910 }
1911
dbainbri4d3a0dc2020-12-02 00:33:42 +00001912 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001913 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001914 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001915 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001916 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001917 }
1918
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001919 omciRxCallbackPair := CallbackPair{
1920 CbKey: tid,
1921 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001922 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001923 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001924 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001925 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001926 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001927 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001928 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001929 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001930 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001931 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001932 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001933 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001934 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001935}
mpagenko01e726e2020-10-23 09:45:29 +00001936
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001937// SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance
1938func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001939 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001940 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001941 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001942 "SequNo": strconv.FormatInt(int64(tid), 16),
1943 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1944
1945 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1946 if omciErr.GetError() == nil {
1947 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1948 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001949 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001950 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001951 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001952 }
1953
dbainbri4d3a0dc2020-12-02 00:33:42 +00001954 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001955 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001956 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001957 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001958 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001959 }
1960
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001961 omciRxCallbackPair := CallbackPair{
1962 CbKey: tid,
1963 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001964 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001965 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001966 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001967 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001968 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001969 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001970 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001971 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001972 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001973 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001974 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001975 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001976 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001977}
1978
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001979// SendDeleteVtfd deletes VlanTaggingFilterData ME instance
1980func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001981 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00001982 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001983 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001984 "SequNo": strconv.FormatInt(int64(tid), 16),
1985 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1986
1987 meParams := me.ParamData{EntityID: aInstID}
1988 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1989 if omciErr.GetError() == nil {
1990 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1991 omci.TransactionID(tid))
1992 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001993 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001994 "Err": err, "device-id": oo.deviceID})
1995 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1996 // return (dual format) error code that can be used at caller for immediate error treatment
1997 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001998 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001999 }
2000
dbainbri4d3a0dc2020-12-02 00:33:42 +00002001 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00002002 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002003 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002004 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002005 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002006 }
2007
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002008 omciRxCallbackPair := CallbackPair{
2009 CbKey: tid,
2010 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00002011 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002012 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00002013 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002014 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002015 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002016 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00002017 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002018 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002019 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00002020 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002021 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00002022 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002023 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00002024}
ozgecanetsia422dbf32020-10-28 14:07:19 +03002025
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002026// SendCreateTDVar creates TrafficDescriptor ME instance
2027func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2028 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002029 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
2030 "SequNo": strconv.FormatInt(int64(tid), 16),
2031 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2032 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2033 if omciErr.GetError() == nil {
2034 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
2035 if err != nil {
2036 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002037 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002038 }
2039 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2040 if err != nil {
2041 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002042 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002043 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002044 omciRxCallbackPair := CallbackPair{
2045 CbKey: tid,
2046 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002047 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002048 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002049 if err != nil {
2050 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002051 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002052 }
2053 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002054 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002055 }
2056 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002057 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002058}
2059
2060// nolint: unused
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002061func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002062 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002063 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002064 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2065 "SequNo": strconv.FormatInt(int64(tid), 16),
2066 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2067
2068 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2069 if omciErr.GetError() == nil {
2070 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
2071 if err != nil {
2072 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002073 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002074 }
2075 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2076 if err != nil {
2077 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002078 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002079 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002080 omciRxCallbackPair := CallbackPair{
2081 CbKey: tid,
2082 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002083 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002084 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002085 if err != nil {
2086 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002087 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002088 }
2089 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002090 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002091 }
2092 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002093 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002094
2095}
2096
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002097// SendDeleteTD - TODO: add comment
2098func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002099 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002100 tid := oo.GetNextTid(highPrio)
ozgecanetsiab6441962021-03-10 10:58:48 +03002101 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2102 "SequNo": strconv.FormatInt(int64(tid), 16),
2103 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2104
2105 meParams := me.ParamData{EntityID: aInstID}
2106 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2107 if omciErr.GetError() == nil {
2108 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
2109 if err != nil {
2110 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002111 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002112 }
2113 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2114 if err != nil {
2115 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002116 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002117 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002118 omciRxCallbackPair := CallbackPair{
2119 CbKey: tid,
2120 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab6441962021-03-10 10:58:48 +03002121 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002122 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002123 if err != nil {
2124 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002125 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002126 }
2127 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002128 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002129 }
2130 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002131 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002132
2133}
2134
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002135// SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance
2136func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002137 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002138 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002139 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002140 "SequNo": strconv.FormatInt(int64(tid), 16),
2141 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2142
2143 meParams := me.ParamData{EntityID: aInstID}
2144 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2145 if omciErr.GetError() == nil {
2146 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2147 omci.TransactionID(tid))
2148 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002149 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002150 "Err": err, "device-id": oo.deviceID})
2151 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2152 // return (dual format) error code that can be used at caller for immediate error treatment
2153 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002154 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002155 }
2156
dbainbri4d3a0dc2020-12-02 00:33:42 +00002157 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002158 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002159 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002160 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002161 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002162 }
2163
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002164 omciRxCallbackPair := CallbackPair{
2165 CbKey: tid,
2166 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002167 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002168 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002169 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002170 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002171 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002172 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002173 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002174 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002175 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002176 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002177 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002178 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002179 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002180}
2181
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002182// SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance
2183func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002184 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002185 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002186 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002187 "SequNo": strconv.FormatInt(int64(tid), 16),
2188 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2189
2190 meParams := me.ParamData{EntityID: aInstID}
2191 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2192 if omciErr.GetError() == nil {
2193 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2194 omci.TransactionID(tid))
2195 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002196 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002197 "Err": err, "device-id": oo.deviceID})
2198 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2199 // return (dual format) error code that can be used at caller for immediate error treatment
2200 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002201 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002202 }
2203
dbainbri4d3a0dc2020-12-02 00:33:42 +00002204 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002205 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002206 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002207 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002208 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002209 }
2210
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002211 omciRxCallbackPair := CallbackPair{
2212 CbKey: tid,
2213 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002214 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002215 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002216 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002217 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002218 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002219 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002220 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002221 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002222 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002223 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002224 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002225 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002226 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002227}
2228
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002229// SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance
2230func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002231 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002232 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002233 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002234 "SequNo": strconv.FormatInt(int64(tid), 16),
2235 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2236
2237 meParams := me.ParamData{EntityID: aInstID}
2238 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2239 if omciErr.GetError() == nil {
2240 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2241 omci.TransactionID(tid))
2242 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002243 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002244 "Err": err, "device-id": oo.deviceID})
2245 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2246 // return (dual format) error code that can be used at caller for immediate error treatment
2247 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002248 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002249 }
2250
dbainbri4d3a0dc2020-12-02 00:33:42 +00002251 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002252 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002253 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002254 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002255 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002256 }
2257
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002258 omciRxCallbackPair := CallbackPair{
2259 CbKey: tid,
2260 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002261 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002262 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002263 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002264 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002265 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002266 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002267 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002268 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002269 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002270 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002271 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002272 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002273 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002274}
2275
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002276// SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance
2277func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002278 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002279 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002280 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002281 "SequNo": strconv.FormatInt(int64(tid), 16),
2282 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2283
2284 meParams := me.ParamData{EntityID: aInstID}
2285 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2286 if omciErr.GetError() == nil {
2287 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2288 omci.TransactionID(tid))
2289 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002290 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002291 "Err": err, "device-id": oo.deviceID})
2292 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2293 // return (dual format) error code that can be used at caller for immediate error treatment
2294 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002295 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002296 }
2297
dbainbri4d3a0dc2020-12-02 00:33:42 +00002298 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002299 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002300 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002301 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002302 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002303 }
2304
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002305 omciRxCallbackPair := CallbackPair{
2306 CbKey: tid,
2307 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002308 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002309 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002310 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002311 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002312 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002313 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002314 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002315 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002316 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002317 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002318 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002319 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002320 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002321}
2322
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002323// SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance
2324func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002325 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002326 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002327 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002328 "SequNo": strconv.FormatInt(int64(tid), 16),
2329 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2330
2331 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2332 if omciErr.GetError() == nil {
2333 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2334 omci.AddDefaults(true))
2335 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002337 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002338 }
2339
dbainbri4d3a0dc2020-12-02 00:33:42 +00002340 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002341 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002342 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002343 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002344 }
2345
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002346 omciRxCallbackPair := CallbackPair{CbKey: tid,
2347 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002348 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002349 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002350 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002351 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002354 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002355 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002356 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002357 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002358 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002359 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002360}
2361
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002362// SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance
2363func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002364 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002365 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002366 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002367 "SequNo": strconv.FormatInt(int64(tid), 16),
2368 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2369
2370 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2371 if omciErr.GetError() == nil {
2372 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2373 omci.AddDefaults(true))
2374 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002375 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002376 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002377 }
2378
dbainbri4d3a0dc2020-12-02 00:33:42 +00002379 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002380 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002381 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002382 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002383 }
2384
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002385 omciRxCallbackPair := CallbackPair{CbKey: tid,
2386 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002387 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002388 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002389 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002390 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP 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 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002393 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002394 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002395 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002396 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002397 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002398 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002399}
2400
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002401// SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance
2402func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002403 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002404 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002405 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002406 "SequNo": strconv.FormatInt(int64(tid), 16),
2407 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2408
2409 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2410 if omciErr.GetError() == nil {
2411 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2412 omci.AddDefaults(true))
2413 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002414 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002415 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002416 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002417 }
2418
dbainbri4d3a0dc2020-12-02 00:33:42 +00002419 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002420 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002421 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002422 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002423 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002424 }
2425
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002426 omciRxCallbackPair := CallbackPair{CbKey: tid,
2427 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002428 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002429 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002430 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002431 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002432 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002433 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002434 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002435 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002436 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002437 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002438 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002439 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002440 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002441}
2442
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002443// SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance
2444func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002445 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002446 tid := oo.GetNextTid(highPrio)
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002447 logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002448 "SequNo": strconv.FormatInt(int64(tid), 16),
2449 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2450
2451 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2452 if omciErr.GetError() == nil {
2453 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2454 omci.AddDefaults(true))
2455 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002456 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002457 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002458 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002459 }
2460
dbainbri4d3a0dc2020-12-02 00:33:42 +00002461 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002462 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002463 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002464 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002465 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002466 }
2467
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002468 omciRxCallbackPair := CallbackPair{CbKey: tid,
2469 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002470 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002471 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002472 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002473 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002474 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002475 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002476 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002477 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002478 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002479 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002480 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002481 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002482 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002483}
2484
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002485// SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance
2486func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002487 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002488 tid := oo.GetNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002489 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002490 "SequNo": strconv.FormatInt(int64(tid), 16),
2491 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2492
2493 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2494 if omciErr.GetError() == nil {
2495 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2496 omci.AddDefaults(true))
2497 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002498 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002499 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002500 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002501 }
2502
dbainbri4d3a0dc2020-12-02 00:33:42 +00002503 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002504 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002505 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002506 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002507 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002508 }
2509
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002510 omciRxCallbackPair := CallbackPair{CbKey: tid,
2511 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002512 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002513 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002514 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002515 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002516 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002517 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002518 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002519 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002520 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002521 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002522 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002523 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002524 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002525}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002526
ozgecanetsia0e3111f2021-10-19 18:04:15 +03002527// SendCreateVoipVoiceCTP nolint: unused
2528func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2529 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2530 tid := oo.GetNextTid(highPrio)
2531 logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID,
2532 "SequNo": strconv.FormatInt(int64(tid), 16),
2533 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2534
2535 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2536 if omciErr.GetError() == nil {
2537 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2538 omci.AddDefaults(true))
2539 if err != nil {
2540 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err,
2541 "device-id": oo.deviceID})
2542 return nil, err
2543 }
2544
2545 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2546 if err != nil {
2547 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err,
2548 "device-id": oo.deviceID})
2549 return nil, err
2550 }
2551
2552 omciRxCallbackPair := CallbackPair{CbKey: tid,
2553 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2554 }
2555 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2556 if err != nil {
2557 logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err,
2558 "device-id": oo.deviceID})
2559 return nil, err
2560 }
2561 logger.Debug(ctx, "send VoipVoiceCTP-create-msg done")
2562 return meInstance, nil
2563 }
2564 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2565 "device-id": oo.deviceID})
2566 return nil, omciErr.GetError()
2567}
2568
2569// SendSetVoipVoiceCTP nolint: unused
2570func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2571 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2572 tid := oo.GetNextTid(highPrio)
2573 logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID,
2574 "SequNo": strconv.FormatInt(int64(tid), 16),
2575 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2576
2577 meInstance, omciErr := me.NewVoipVoiceCtp(params[0])
2578 if omciErr.GetError() == nil {
2579 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2580 omci.AddDefaults(true))
2581 if err != nil {
2582 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err,
2583 "device-id": oo.deviceID})
2584 return nil, err
2585 }
2586
2587 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2588 if err != nil {
2589 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err,
2590 "device-id": oo.deviceID})
2591 return nil, err
2592 }
2593
2594 omciRxCallbackPair := CallbackPair{CbKey: tid,
2595 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2596 }
2597 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2598 if err != nil {
2599 logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err,
2600 "device-id": oo.deviceID})
2601 return nil, err
2602 }
2603 logger.Debug(ctx, "send VoipVoiceCTP-set-msg done")
2604 return meInstance, nil
2605 }
2606 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(),
2607 "device-id": oo.deviceID})
2608 return nil, omciErr.GetError()
2609}
2610
2611// SendDeleteVoipVoiceCTP nolint: unused
2612func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool,
2613 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2614 tid := oo.GetNextTid(highPrio)
2615 logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2616 "SequNo": strconv.FormatInt(int64(tid), 16),
2617 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2618
2619 meParams := me.ParamData{EntityID: aInstID}
2620 meInstance, omciErr := me.NewVoipVoiceCtp(meParams)
2621 if omciErr.GetError() == nil {
2622 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2623 omci.TransactionID(tid))
2624 if err != nil {
2625 logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{
2626 "Err": err, "device-id": oo.deviceID})
2627 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2628 // return (dual format) error code that can be used at caller for immediate error treatment
2629 // (relevant to all used sendXX() methods and their error conditions)
2630 return nil, err
2631 }
2632
2633 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2634 if err != nil {
2635 logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{
2636 "Err": err, "device-id": oo.deviceID})
2637 return nil, err
2638 }
2639
2640 omciRxCallbackPair := CallbackPair{
2641 CbKey: tid,
2642 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2643 }
2644 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2645 if err != nil {
2646 logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{
2647 "Err": err, "device-id": oo.deviceID})
2648 return nil, err
2649 }
2650 logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done")
2651 return meInstance, nil
2652 }
2653 logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{
2654 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2655 return nil, omciErr.GetError()
2656}
2657
2658// SendCreateVoipMediaProfile nolint: unused
2659func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2660 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2661 tid := oo.GetNextTid(highPrio)
2662 logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2663 "SequNo": strconv.FormatInt(int64(tid), 16),
2664 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2665
2666 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2667 if omciErr.GetError() == nil {
2668 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2669 omci.AddDefaults(true))
2670 if err != nil {
2671 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err,
2672 "device-id": oo.deviceID})
2673 return nil, err
2674 }
2675
2676 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2677 if err != nil {
2678 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err,
2679 "device-id": oo.deviceID})
2680 return nil, err
2681 }
2682
2683 omciRxCallbackPair := CallbackPair{CbKey: tid,
2684 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2685 }
2686 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2687 if err != nil {
2688 logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err,
2689 "device-id": oo.deviceID})
2690 return nil, err
2691 }
2692 logger.Debug(ctx, "send VoipMediaProfile-create-msg done")
2693 return meInstance, nil
2694 }
2695 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2696 "device-id": oo.deviceID})
2697 return nil, omciErr.GetError()
2698}
2699
2700// SendSetVoipMediaProfile nolint: unused
2701func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2702 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2703 tid := oo.GetNextTid(highPrio)
2704 logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2705 "SequNo": strconv.FormatInt(int64(tid), 16),
2706 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2707
2708 meInstance, omciErr := me.NewVoipMediaProfile(params[0])
2709 if omciErr.GetError() == nil {
2710 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2711 omci.AddDefaults(true))
2712 if err != nil {
2713 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err,
2714 "device-id": oo.deviceID})
2715 return nil, err
2716 }
2717
2718 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2719 if err != nil {
2720 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err,
2721 "device-id": oo.deviceID})
2722 return nil, err
2723 }
2724
2725 omciRxCallbackPair := CallbackPair{CbKey: tid,
2726 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2727 }
2728 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2729 if err != nil {
2730 logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err,
2731 "device-id": oo.deviceID})
2732 return nil, err
2733 }
2734 logger.Debug(ctx, "send VoipMediaProfile-set-msg done")
2735 return meInstance, nil
2736 }
2737 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(),
2738 "device-id": oo.deviceID})
2739 return nil, omciErr.GetError()
2740}
2741
2742// SendDeleteVoipMediaProfile nolint: unused
2743func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool,
2744 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2745 tid := oo.GetNextTid(highPrio)
2746 logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2747 "SequNo": strconv.FormatInt(int64(tid), 16),
2748 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2749
2750 meParams := me.ParamData{EntityID: aInstID}
2751 meInstance, omciErr := me.NewVoipMediaProfile(meParams)
2752 if omciErr.GetError() == nil {
2753 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2754 omci.TransactionID(tid))
2755 if err != nil {
2756 logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{
2757 "Err": err, "device-id": oo.deviceID})
2758 return nil, err
2759 }
2760
2761 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2762 if err != nil {
2763 logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{
2764 "Err": err, "device-id": oo.deviceID})
2765 return nil, err
2766 }
2767
2768 omciRxCallbackPair := CallbackPair{
2769 CbKey: tid,
2770 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2771 }
2772 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2773 if err != nil {
2774 logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{
2775 "Err": err, "device-id": oo.deviceID})
2776 return nil, err
2777 }
2778 logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done")
2779 return meInstance, nil
2780 }
2781 logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{
2782 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2783 return nil, omciErr.GetError()
2784}
2785
2786// SendCreateVoiceServiceProfile nolint: unused
2787func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2788 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2789 tid := oo.GetNextTid(highPrio)
2790 logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
2791 "SequNo": strconv.FormatInt(int64(tid), 16),
2792 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2793
2794 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2795 if omciErr.GetError() == nil {
2796 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2797 omci.AddDefaults(true))
2798 if err != nil {
2799 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err,
2800 "device-id": oo.deviceID})
2801 return nil, err
2802 }
2803
2804 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2805 if err != nil {
2806 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err,
2807 "device-id": oo.deviceID})
2808 return nil, err
2809 }
2810
2811 omciRxCallbackPair := CallbackPair{CbKey: tid,
2812 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2813 }
2814 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2815 if err != nil {
2816 logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err,
2817 "device-id": oo.deviceID})
2818 return nil, err
2819 }
2820 logger.Debug(ctx, "send VoiceServiceProfile-create-msg done")
2821 return meInstance, nil
2822 }
2823 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2824 "device-id": oo.deviceID})
2825 return nil, omciErr.GetError()
2826}
2827
2828// SendSetVoiceServiceProfile nolint: unused
2829func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2830 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2831 tid := oo.GetNextTid(highPrio)
2832 logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
2833 "SequNo": strconv.FormatInt(int64(tid), 16),
2834 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2835
2836 meInstance, omciErr := me.NewVoiceServiceProfile(params[0])
2837 if omciErr.GetError() == nil {
2838 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2839 omci.AddDefaults(true))
2840 if err != nil {
2841 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err,
2842 "device-id": oo.deviceID})
2843 return nil, err
2844 }
2845
2846 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2847 if err != nil {
2848 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err,
2849 "device-id": oo.deviceID})
2850 return nil, err
2851 }
2852
2853 omciRxCallbackPair := CallbackPair{CbKey: tid,
2854 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2855 }
2856 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2857 if err != nil {
2858 logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err,
2859 "device-id": oo.deviceID})
2860 return nil, err
2861 }
2862 logger.Debug(ctx, "send VoiceServiceProfile-set-msg done")
2863 return meInstance, nil
2864 }
2865 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
2866 "device-id": oo.deviceID})
2867 return nil, omciErr.GetError()
2868}
2869
2870// SendDeleteVoiceServiceProfile nolint: unused
2871func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool,
2872 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
2873 tid := oo.GetNextTid(highPrio)
2874 logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2875 "SequNo": strconv.FormatInt(int64(tid), 16),
2876 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2877
2878 meParams := me.ParamData{EntityID: aInstID}
2879 meInstance, omciErr := me.NewVoiceServiceProfile(meParams)
2880 if omciErr.GetError() == nil {
2881 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2882 omci.TransactionID(tid))
2883 if err != nil {
2884 logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{
2885 "Err": err, "device-id": oo.deviceID})
2886 return nil, err
2887 }
2888
2889 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2890 if err != nil {
2891 logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{
2892 "Err": err, "device-id": oo.deviceID})
2893 return nil, err
2894 }
2895
2896 omciRxCallbackPair := CallbackPair{
2897 CbKey: tid,
2898 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2899 }
2900 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2901 if err != nil {
2902 logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{
2903 "Err": err, "device-id": oo.deviceID})
2904 return nil, err
2905 }
2906 logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done")
2907 return meInstance, nil
2908 }
2909 logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{
2910 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2911 return nil, omciErr.GetError()
2912}
2913
2914// SendCreateSIPUserData nolint: unused
2915func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool,
2916 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2917 tid := oo.GetNextTid(highPrio)
2918 logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID,
2919 "SequNo": strconv.FormatInt(int64(tid), 16),
2920 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2921
2922 meInstance, omciErr := me.NewSipUserData(params[0])
2923 if omciErr.GetError() == nil {
2924 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2925 omci.AddDefaults(true))
2926 if err != nil {
2927 logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err,
2928 "device-id": oo.deviceID})
2929 return nil, err
2930 }
2931
2932 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2933 if err != nil {
2934 logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err,
2935 "device-id": oo.deviceID})
2936 return nil, err
2937 }
2938
2939 omciRxCallbackPair := CallbackPair{CbKey: tid,
2940 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2941 }
2942 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2943 if err != nil {
2944 logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err,
2945 "device-id": oo.deviceID})
2946 return nil, err
2947 }
2948 logger.Debug(ctx, "send SIPUserData-create-msg done")
2949 return meInstance, nil
2950 }
2951 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
2952 "device-id": oo.deviceID})
2953 return nil, omciErr.GetError()
2954}
2955
2956// SendSetSIPUserData nolint: unused
2957func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool,
2958 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
2959 tid := oo.GetNextTid(highPrio)
2960 logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID,
2961 "SequNo": strconv.FormatInt(int64(tid), 16),
2962 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2963
2964 meInstance, omciErr := me.NewSipUserData(params[0])
2965 if omciErr.GetError() == nil {
2966 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2967 omci.AddDefaults(true))
2968 if err != nil {
2969 logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err,
2970 "device-id": oo.deviceID})
2971 return nil, err
2972 }
2973
2974 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2975 if err != nil {
2976 logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err,
2977 "device-id": oo.deviceID})
2978 return nil, err
2979 }
2980
2981 omciRxCallbackPair := CallbackPair{CbKey: tid,
2982 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2983 }
2984 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
2985 if err != nil {
2986 logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err,
2987 "device-id": oo.deviceID})
2988 return nil, err
2989 }
2990 logger.Debug(ctx, "send SIPUserData-set-msg done")
2991 return meInstance, nil
2992 }
2993 logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(),
2994 "device-id": oo.deviceID})
2995 return nil, omciErr.GetError()
2996}
2997
2998// SendDeleteSIPUserData nolint: unused
2999func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool,
3000 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3001 tid := oo.GetNextTid(highPrio)
3002 logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3003 "SequNo": strconv.FormatInt(int64(tid), 16),
3004 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3005
3006 meParams := me.ParamData{EntityID: aInstID}
3007 meInstance, omciErr := me.NewSipUserData(meParams)
3008 if omciErr.GetError() == nil {
3009 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3010 omci.TransactionID(tid))
3011 if err != nil {
3012 logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{
3013 "Err": err, "device-id": oo.deviceID})
3014 return nil, err
3015 }
3016
3017 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3018 if err != nil {
3019 logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{
3020 "Err": err, "device-id": oo.deviceID})
3021 return nil, err
3022 }
3023
3024 omciRxCallbackPair := CallbackPair{
3025 CbKey: tid,
3026 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3027 }
3028 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3029 if err != nil {
3030 logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{
3031 "Err": err, "device-id": oo.deviceID})
3032 return nil, err
3033 }
3034 logger.Debug(ctx, "send SIPUserData-Delete-msg done")
3035 return meInstance, nil
3036 }
3037 logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{
3038 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3039 return nil, omciErr.GetError()
3040}
3041
3042// SendCreateVoipApplicationServiceProfile nolint: unused
3043func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3044 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3045 tid := oo.GetNextTid(highPrio)
3046 logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
3047 "SequNo": strconv.FormatInt(int64(tid), 16),
3048 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3049
3050 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3051 if omciErr.GetError() == nil {
3052 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3053 omci.AddDefaults(true))
3054 if err != nil {
3055 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err,
3056 "device-id": oo.deviceID})
3057 return nil, err
3058 }
3059
3060 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3061 if err != nil {
3062 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err,
3063 "device-id": oo.deviceID})
3064 return nil, err
3065 }
3066
3067 omciRxCallbackPair := CallbackPair{CbKey: tid,
3068 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3069 }
3070 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3071 if err != nil {
3072 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err,
3073 "device-id": oo.deviceID})
3074 return nil, err
3075 }
3076 logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done")
3077 return meInstance, nil
3078 }
3079 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3080 "device-id": oo.deviceID})
3081 return nil, omciErr.GetError()
3082}
3083
3084// SendSetVoipApplicationServiceProfile nolint: unused
3085func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3086 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3087 tid := oo.GetNextTid(highPrio)
3088 logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID,
3089 "SequNo": strconv.FormatInt(int64(tid), 16),
3090 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3091
3092 meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0])
3093 if omciErr.GetError() == nil {
3094 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
3095 omci.AddDefaults(true))
3096 if err != nil {
3097 logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err,
3098 "device-id": oo.deviceID})
3099 return nil, err
3100 }
3101
3102 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3103 if err != nil {
3104 logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err,
3105 "device-id": oo.deviceID})
3106 return nil, err
3107 }
3108
3109 omciRxCallbackPair := CallbackPair{CbKey: tid,
3110 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3111 }
3112 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3113 if err != nil {
3114 logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err,
3115 "device-id": oo.deviceID})
3116 return nil, err
3117 }
3118 logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done")
3119 return meInstance, nil
3120 }
3121 logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(),
3122 "device-id": oo.deviceID})
3123 return nil, omciErr.GetError()
3124}
3125
3126// SendDeleteVoipApplicationServiceProfile nolint: unused
3127func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool,
3128 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3129 tid := oo.GetNextTid(highPrio)
3130 logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3131 "SequNo": strconv.FormatInt(int64(tid), 16),
3132 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3133
3134 meParams := me.ParamData{EntityID: aInstID}
3135 meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams)
3136 if omciErr.GetError() == nil {
3137 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3138 omci.TransactionID(tid))
3139 if err != nil {
3140 logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{
3141 "Err": err, "device-id": oo.deviceID})
3142 return nil, err
3143 }
3144
3145 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3146 if err != nil {
3147 logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{
3148 "Err": err, "device-id": oo.deviceID})
3149 return nil, err
3150 }
3151
3152 omciRxCallbackPair := CallbackPair{
3153 CbKey: tid,
3154 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3155 }
3156 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3157 if err != nil {
3158 logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{
3159 "Err": err, "device-id": oo.deviceID})
3160 return nil, err
3161 }
3162 logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done")
3163 return meInstance, nil
3164 }
3165 logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{
3166 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3167 return nil, omciErr.GetError()
3168}
3169
3170// SendCreateSIPAgentConfigData nolint: unused
3171func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3172 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3173 tid := oo.GetNextTid(highPrio)
3174 logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3175 "SequNo": strconv.FormatInt(int64(tid), 16),
3176 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3177
3178 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3179 if omciErr.GetError() == nil {
3180 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3181 omci.AddDefaults(true))
3182 if err != nil {
3183 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err,
3184 "device-id": oo.deviceID})
3185 return nil, err
3186 }
3187
3188 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3189 if err != nil {
3190 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err,
3191 "device-id": oo.deviceID})
3192 return nil, err
3193 }
3194
3195 omciRxCallbackPair := CallbackPair{CbKey: tid,
3196 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3197 }
3198 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3199 if err != nil {
3200 logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err,
3201 "device-id": oo.deviceID})
3202 return nil, err
3203 }
3204 logger.Debug(ctx, "send SIPAgentConfigData-create-msg done")
3205 return meInstance, nil
3206 }
3207 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3208 "device-id": oo.deviceID})
3209 return nil, omciErr.GetError()
3210}
3211
3212// SendSetSIPAgentConfigData nolint: unused
3213func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3214 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3215 tid := oo.GetNextTid(highPrio)
3216 logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3217 "SequNo": strconv.FormatInt(int64(tid), 16),
3218 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3219
3220 meInstance, omciErr := me.NewSipAgentConfigData(params[0])
3221 if omciErr.GetError() == nil {
3222 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
3223 omci.AddDefaults(true))
3224 if err != nil {
3225 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err,
3226 "device-id": oo.deviceID})
3227 return nil, err
3228 }
3229
3230 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3231 if err != nil {
3232 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err,
3233 "device-id": oo.deviceID})
3234 return nil, err
3235 }
3236
3237 omciRxCallbackPair := CallbackPair{CbKey: tid,
3238 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3239 }
3240 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3241 if err != nil {
3242 logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err,
3243 "device-id": oo.deviceID})
3244 return nil, err
3245 }
3246 logger.Debug(ctx, "send SIPAgentConfigData-set-msg done")
3247 return meInstance, nil
3248 }
3249 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3250 "device-id": oo.deviceID})
3251 return nil, omciErr.GetError()
3252}
3253
3254// SendDeleteSIPAgentConfigData nolint: unused
3255func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool,
3256 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3257 tid := oo.GetNextTid(highPrio)
3258 logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3259 "SequNo": strconv.FormatInt(int64(tid), 16),
3260 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3261
3262 meParams := me.ParamData{EntityID: aInstID}
3263 meInstance, omciErr := me.NewSipAgentConfigData(meParams)
3264 if omciErr.GetError() == nil {
3265 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3266 omci.TransactionID(tid))
3267 if err != nil {
3268 logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{
3269 "Err": err, "device-id": oo.deviceID})
3270 return nil, err
3271 }
3272
3273 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3274 if err != nil {
3275 logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{
3276 "Err": err, "device-id": oo.deviceID})
3277 return nil, err
3278 }
3279
3280 omciRxCallbackPair := CallbackPair{
3281 CbKey: tid,
3282 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3283 }
3284 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3285 if err != nil {
3286 logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{
3287 "Err": err, "device-id": oo.deviceID})
3288 return nil, err
3289 }
3290 logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done")
3291 return meInstance, nil
3292 }
3293 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3294 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3295 return nil, omciErr.GetError()
3296}
3297
3298// SendCreateTCPUDPConfigData nolint: unused
3299func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3300 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3301 tid := oo.GetNextTid(highPrio)
3302 logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3303 "SequNo": strconv.FormatInt(int64(tid), 16),
3304 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3305
3306 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3307 if omciErr.GetError() == nil {
3308 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3309 omci.AddDefaults(true))
3310 if err != nil {
3311 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err,
3312 "device-id": oo.deviceID})
3313 return nil, err
3314 }
3315
3316 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3317 if err != nil {
3318 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err,
3319 "device-id": oo.deviceID})
3320 return nil, err
3321 }
3322
3323 omciRxCallbackPair := CallbackPair{CbKey: tid,
3324 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3325 }
3326 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3327 if err != nil {
3328 logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err,
3329 "device-id": oo.deviceID})
3330 return nil, err
3331 }
3332 logger.Debug(ctx, "send TCPUDPConfigData-create-msg done")
3333 return meInstance, nil
3334 }
3335 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3336 "device-id": oo.deviceID})
3337 return nil, omciErr.GetError()
3338}
3339
3340// SendSetTCPUDPConfigData nolint: unused
3341func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3342 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3343 tid := oo.GetNextTid(highPrio)
3344 logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3345 "SequNo": strconv.FormatInt(int64(tid), 16),
3346 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3347
3348 meInstance, omciErr := me.NewTcpUdpConfigData(params[0])
3349 if omciErr.GetError() == nil {
3350 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
3351 omci.AddDefaults(true))
3352 if err != nil {
3353 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err,
3354 "device-id": oo.deviceID})
3355 return nil, err
3356 }
3357
3358 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3359 if err != nil {
3360 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err,
3361 "device-id": oo.deviceID})
3362 return nil, err
3363 }
3364
3365 omciRxCallbackPair := CallbackPair{CbKey: tid,
3366 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3367 }
3368 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3369 if err != nil {
3370 logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err,
3371 "device-id": oo.deviceID})
3372 return nil, err
3373 }
3374 logger.Debug(ctx, "send TCPUDPConfigData-set-msg done")
3375 return meInstance, nil
3376 }
3377 logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3378 "device-id": oo.deviceID})
3379 return nil, omciErr.GetError()
3380}
3381
3382// SendDeleteTCPUDPConfigData nolint: unused
3383func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool,
3384 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3385 tid := oo.GetNextTid(highPrio)
3386 logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3387 "SequNo": strconv.FormatInt(int64(tid), 16),
3388 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3389
3390 meParams := me.ParamData{EntityID: aInstID}
3391 meInstance, omciErr := me.NewTcpUdpConfigData(meParams)
3392 if omciErr.GetError() == nil {
3393 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3394 omci.TransactionID(tid))
3395 if err != nil {
3396 logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{
3397 "Err": err, "device-id": oo.deviceID})
3398 return nil, err
3399 }
3400
3401 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3402 if err != nil {
3403 logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{
3404 "Err": err, "device-id": oo.deviceID})
3405 return nil, err
3406 }
3407
3408 omciRxCallbackPair := CallbackPair{
3409 CbKey: tid,
3410 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3411 }
3412 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3413 if err != nil {
3414 logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{
3415 "Err": err, "device-id": oo.deviceID})
3416 return nil, err
3417 }
3418 logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done")
3419 return meInstance, nil
3420 }
3421 logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{
3422 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3423 return nil, omciErr.GetError()
3424}
3425
3426// SendCreateIPHostConfigData nolint: unused
3427func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3428 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3429 tid := oo.GetNextTid(highPrio)
3430 logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID,
3431 "SequNo": strconv.FormatInt(int64(tid), 16),
3432 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3433
3434 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3435 if omciErr.GetError() == nil {
3436 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3437 omci.AddDefaults(true))
3438 if err != nil {
3439 logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err,
3440 "device-id": oo.deviceID})
3441 return nil, err
3442 }
3443
3444 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3445 if err != nil {
3446 logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err,
3447 "device-id": oo.deviceID})
3448 return nil, err
3449 }
3450
3451 omciRxCallbackPair := CallbackPair{CbKey: tid,
3452 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3453 }
3454 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3455 if err != nil {
3456 logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err,
3457 "device-id": oo.deviceID})
3458 return nil, err
3459 }
3460 logger.Debug(ctx, "send IPHostConfigData-create-msg done")
3461 return meInstance, nil
3462 }
3463 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3464 "device-id": oo.deviceID})
3465 return nil, omciErr.GetError()
3466}
3467
3468// SendSetIPHostConfigData nolint: unused
3469func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3470 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3471 tid := oo.GetNextTid(highPrio)
3472 logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID,
3473 "SequNo": strconv.FormatInt(int64(tid), 16),
3474 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3475
3476 meInstance, omciErr := me.NewIpHostConfigData(params[0])
3477 if omciErr.GetError() == nil {
3478 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
3479 omci.AddDefaults(true))
3480 if err != nil {
3481 logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err,
3482 "device-id": oo.deviceID})
3483 return nil, err
3484 }
3485
3486 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3487 if err != nil {
3488 logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err,
3489 "device-id": oo.deviceID})
3490 return nil, err
3491 }
3492
3493 omciRxCallbackPair := CallbackPair{CbKey: tid,
3494 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3495 }
3496 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3497 if err != nil {
3498 logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err,
3499 "device-id": oo.deviceID})
3500 return nil, err
3501 }
3502 logger.Debug(ctx, "send IPHostConfigData-set-msg done")
3503 return meInstance, nil
3504 }
3505 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(),
3506 "device-id": oo.deviceID})
3507 return nil, omciErr.GetError()
3508}
3509
3510// SendDeleteIPHostConfigData nolint: unused
3511func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool,
3512 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3513 tid := oo.GetNextTid(highPrio)
3514 logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3515 "SequNo": strconv.FormatInt(int64(tid), 16),
3516 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3517
3518 meParams := me.ParamData{EntityID: aInstID}
3519 meInstance, omciErr := me.NewIpHostConfigData(meParams)
3520 if omciErr.GetError() == nil {
3521 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3522 omci.TransactionID(tid))
3523 if err != nil {
3524 logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{
3525 "Err": err, "device-id": oo.deviceID})
3526 return nil, err
3527 }
3528
3529 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3530 if err != nil {
3531 logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{
3532 "Err": err, "device-id": oo.deviceID})
3533 return nil, err
3534 }
3535
3536 omciRxCallbackPair := CallbackPair{
3537 CbKey: tid,
3538 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3539 }
3540 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3541 if err != nil {
3542 logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{
3543 "Err": err, "device-id": oo.deviceID})
3544 return nil, err
3545 }
3546 logger.Debug(ctx, "send IPHostConfigData-Delete-msg done")
3547 return meInstance, nil
3548 }
3549 logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{
3550 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3551 return nil, omciErr.GetError()
3552}
3553
3554// SendCreateRTPProfileData nolint: unused
3555func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3556 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3557 tid := oo.GetNextTid(highPrio)
3558 logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID,
3559 "SequNo": strconv.FormatInt(int64(tid), 16),
3560 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3561
3562 meInstance, omciErr := me.NewRtpProfileData(params[0])
3563 if omciErr.GetError() == nil {
3564 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3565 omci.AddDefaults(true))
3566 if err != nil {
3567 logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err,
3568 "device-id": oo.deviceID})
3569 return nil, err
3570 }
3571
3572 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3573 if err != nil {
3574 logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err,
3575 "device-id": oo.deviceID})
3576 return nil, err
3577 }
3578
3579 omciRxCallbackPair := CallbackPair{CbKey: tid,
3580 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3581 }
3582 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3583 if err != nil {
3584 logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err,
3585 "device-id": oo.deviceID})
3586 return nil, err
3587 }
3588 logger.Debug(ctx, "send RTPProfileData-create-msg done")
3589 return meInstance, nil
3590 }
3591 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3592 "device-id": oo.deviceID})
3593 return nil, omciErr.GetError()
3594}
3595
3596// SendSetRTPProfileData nolint: unused
3597func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3598 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3599 tid := oo.GetNextTid(highPrio)
3600 logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID,
3601 "SequNo": strconv.FormatInt(int64(tid), 16),
3602 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3603
3604 meInstance, omciErr := me.NewRtpProfileData(params[0])
3605 if omciErr.GetError() == nil {
3606 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
3607 omci.AddDefaults(true))
3608 if err != nil {
3609 logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err,
3610 "device-id": oo.deviceID})
3611 return nil, err
3612 }
3613
3614 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3615 if err != nil {
3616 logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err,
3617 "device-id": oo.deviceID})
3618 return nil, err
3619 }
3620
3621 omciRxCallbackPair := CallbackPair{CbKey: tid,
3622 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3623 }
3624 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3625 if err != nil {
3626 logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err,
3627 "device-id": oo.deviceID})
3628 return nil, err
3629 }
3630 logger.Debug(ctx, "send RTPProfileData-set-msg done")
3631 return meInstance, nil
3632 }
3633 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(),
3634 "device-id": oo.deviceID})
3635 return nil, omciErr.GetError()
3636}
3637
3638// SendDeleteRTPProfileData nolint: unused
3639func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool,
3640 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3641 tid := oo.GetNextTid(highPrio)
3642 logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3643 "SequNo": strconv.FormatInt(int64(tid), 16),
3644 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3645
3646 meParams := me.ParamData{EntityID: aInstID}
3647 meInstance, omciErr := me.NewRtpProfileData(meParams)
3648 if omciErr.GetError() == nil {
3649 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3650 omci.TransactionID(tid))
3651 if err != nil {
3652 logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{
3653 "Err": err, "device-id": oo.deviceID})
3654 return nil, err
3655 }
3656
3657 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3658 if err != nil {
3659 logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{
3660 "Err": err, "device-id": oo.deviceID})
3661 return nil, err
3662 }
3663
3664 omciRxCallbackPair := CallbackPair{
3665 CbKey: tid,
3666 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3667 }
3668 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3669 if err != nil {
3670 logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{
3671 "Err": err, "device-id": oo.deviceID})
3672 return nil, err
3673 }
3674 logger.Debug(ctx, "send RTPProfileData-Delete-msg done")
3675 return meInstance, nil
3676 }
3677 logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{
3678 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3679 return nil, omciErr.GetError()
3680}
3681
3682// SendCreateNetworkDialPlanTable nolint: unused
3683func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3684 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3685 tid := oo.GetNextTid(highPrio)
3686 logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID,
3687 "SequNo": strconv.FormatInt(int64(tid), 16),
3688 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3689
3690 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3691 if omciErr.GetError() == nil {
3692 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3693 omci.AddDefaults(true))
3694 if err != nil {
3695 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err,
3696 "device-id": oo.deviceID})
3697 return nil, err
3698 }
3699
3700 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3701 if err != nil {
3702 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err,
3703 "device-id": oo.deviceID})
3704 return nil, err
3705 }
3706
3707 omciRxCallbackPair := CallbackPair{CbKey: tid,
3708 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3709 }
3710 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3711 if err != nil {
3712 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err,
3713 "device-id": oo.deviceID})
3714 return nil, err
3715 }
3716 logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done")
3717 return meInstance, nil
3718 }
3719 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3720 "device-id": oo.deviceID})
3721 return nil, omciErr.GetError()
3722}
3723
3724// SendSetNetworkDialPlanTable nolint: unused
3725func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3726 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
3727 tid := oo.GetNextTid(highPrio)
3728 logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID,
3729 "SequNo": strconv.FormatInt(int64(tid), 16),
3730 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
3731
3732 meInstance, omciErr := me.NewNetworkDialPlanTable(params[0])
3733 if omciErr.GetError() == nil {
3734 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
3735 omci.AddDefaults(true))
3736 if err != nil {
3737 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err,
3738 "device-id": oo.deviceID})
3739 return nil, err
3740 }
3741
3742 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3743 if err != nil {
3744 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err,
3745 "device-id": oo.deviceID})
3746 return nil, err
3747 }
3748
3749 omciRxCallbackPair := CallbackPair{CbKey: tid,
3750 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3751 }
3752 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3753 if err != nil {
3754 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err,
3755 "device-id": oo.deviceID})
3756 return nil, err
3757 }
3758 logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done")
3759 return meInstance, nil
3760 }
3761 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(),
3762 "device-id": oo.deviceID})
3763 return nil, omciErr.GetError()
3764}
3765
3766// SendDeleteNetworkDialPlanTable nolint: unused
3767func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool,
3768 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
3769 tid := oo.GetNextTid(highPrio)
3770 logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID,
3771 "SequNo": strconv.FormatInt(int64(tid), 16),
3772 "InstId": strconv.FormatInt(int64(aInstID), 16)})
3773
3774 meParams := me.ParamData{EntityID: aInstID}
3775 meInstance, omciErr := me.NewNetworkDialPlanTable(meParams)
3776 if omciErr.GetError() == nil {
3777 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
3778 omci.TransactionID(tid))
3779 if err != nil {
3780 logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{
3781 "Err": err, "device-id": oo.deviceID})
3782 return nil, err
3783 }
3784
3785 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3786 if err != nil {
3787 logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{
3788 "Err": err, "device-id": oo.deviceID})
3789 return nil, err
3790 }
3791
3792 omciRxCallbackPair := CallbackPair{
3793 CbKey: tid,
3794 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3795 }
3796 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
3797 if err != nil {
3798 logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{
3799 "Err": err, "device-id": oo.deviceID})
3800 return nil, err
3801 }
3802 logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done")
3803 return meInstance, nil
3804 }
3805 logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{
3806 "Err": omciErr.GetError(), "device-id": oo.deviceID})
3807 return nil, omciErr.GetError()
3808}
3809
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003810// SendSyncTime sends SynchronizeTimeRequest
3811func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
3812 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003813 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
3814 "SequNo": strconv.FormatInt(int64(tid), 16)})
3815
3816 omciLayer := &omci.OMCI{
3817 TransactionID: tid,
3818 MessageType: omci.SynchronizeTimeRequestType,
3819 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3820 // Length: 0x28, // Optional, defaults to 40 octets
3821 }
3822 utcTime := time.Now().UTC()
3823 request := &omci.SynchronizeTimeRequest{
3824 MeBasePacket: omci.MeBasePacket{
3825 EntityClass: me.OnuGClassID,
3826 // Default Instance ID is 0
3827 },
3828 Year: uint16(utcTime.Year()),
3829 Month: uint8(utcTime.Month()),
3830 Day: uint8(utcTime.Day()),
3831 Hour: uint8(utcTime.Hour()),
3832 Minute: uint8(utcTime.Minute()),
3833 Second: uint8(utcTime.Second()),
3834 }
3835
3836 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
3837 if err != nil {
3838 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
3839 "device-id": oo.deviceID})
3840 return err
3841 }
3842
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003843 omciRxCallbackPair := CallbackPair{CbKey: tid,
3844 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003845 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003846 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003847 if err != nil {
3848 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
3849 "device-id": oo.deviceID})
3850 return err
3851 }
3852 logger.Debug(ctx, "send synchronize time request done")
3853 return nil
3854}
3855
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003856// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
3857func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003858 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003859 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003860 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3861 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3862 meParam := me.ParamData{EntityID: entityID}
3863 var meInstance *me.ManagedEntity
3864 var omciErr me.OmciErrors
3865 if upstream {
3866 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
3867 } else {
3868 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
3869 }
3870 if omciErr.GetError() == nil {
3871 var omciLayer *omci.OMCI
3872 var msgLayer gopacket.SerializableLayer
3873 var err error
3874 if create {
3875 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3876 omci.AddDefaults(true))
3877 } else {
3878 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
3879 omci.AddDefaults(true))
3880 }
3881 if err != nil {
3882 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
3883 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003884 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003885 }
3886
3887 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3888 if err != nil {
3889 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
3890 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003891 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003892 }
3893
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003894 omciRxCallbackPair := CallbackPair{CbKey: tid,
3895 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003896 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003897 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003898 if err != nil {
3899 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
3900 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003901 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003902 }
3903 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
3904 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003905 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08003906 }
3907 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
3908 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 +03003909 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08003910}
3911
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003912// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
3913func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003914 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003915 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003916 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3917 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
3918 meParam := me.ParamData{EntityID: entityID}
3919 var meInstance *me.ManagedEntity
3920 var omciErr me.OmciErrors
3921 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
3922
3923 if omciErr.GetError() == nil {
3924 var omciLayer *omci.OMCI
3925 var msgLayer gopacket.SerializableLayer
3926 var err error
3927 if create {
3928 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3929 omci.AddDefaults(true))
3930 } else {
3931 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
3932 omci.AddDefaults(true))
3933 }
3934 if err != nil {
3935 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
3936 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003937 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003938 }
3939
3940 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3941 if err != nil {
3942 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
3943 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003944 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003945 }
3946
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003947 omciRxCallbackPair := CallbackPair{CbKey: tid,
3948 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08003949 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003950 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08003951 if err != nil {
3952 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
3953 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003954 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08003955 }
3956 logger.Debugw(ctx, "send ethernet uni history data ME done",
3957 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003958 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08003959 }
3960 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
3961 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003962 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08003963}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003964
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003965// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
3966func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03003967 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003968 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003969 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
3970 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
3971 meParam := me.ParamData{EntityID: entityID}
3972 var meInstance *me.ManagedEntity
3973 var omciErr me.OmciErrors
3974 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
3975
3976 if omciErr.GetError() == nil {
3977 var omciLayer *omci.OMCI
3978 var msgLayer gopacket.SerializableLayer
3979 var err error
3980 if create {
3981 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3982 omci.AddDefaults(true))
3983 } else {
3984 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
3985 omci.AddDefaults(true))
3986 }
3987 if err != nil {
3988 logger.Errorw(ctx, "Cannot encode fec history data ME",
3989 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003990 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003991 }
3992
3993 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3994 if err != nil {
3995 logger.Errorw(ctx, "Cannot serialize fec history data ME",
3996 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03003997 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08003998 }
3999
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004000 omciRxCallbackPair := CallbackPair{CbKey: tid,
4001 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004002 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004003 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004004 if err != nil {
4005 logger.Errorw(ctx, "Cannot send fec history data ME",
4006 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004007 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004008 }
4009 logger.Debugw(ctx, "send fec history data ME done",
4010 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004011 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004012 }
4013 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
4014 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004015 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004016}
4017
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004018// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
4019func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03004020 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004021 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004022 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
4023 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
4024 meParam := me.ParamData{EntityID: entityID}
4025 var meInstance *me.ManagedEntity
4026 var omciErr me.OmciErrors
4027 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
4028
4029 if omciErr.GetError() == nil {
4030 var omciLayer *omci.OMCI
4031 var msgLayer gopacket.SerializableLayer
4032 var err error
4033 if create {
4034 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
4035 omci.AddDefaults(true))
4036 } else {
4037 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
4038 omci.AddDefaults(true))
4039 }
4040 if err != nil {
4041 logger.Errorw(ctx, "Cannot encode gemport history data ME",
4042 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004043 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004044 }
4045
4046 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4047 if err != nil {
4048 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
4049 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004050 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004051 }
4052
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004053 omciRxCallbackPair := CallbackPair{CbKey: tid,
4054 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004055 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004056 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004057 if err != nil {
4058 logger.Errorw(ctx, "Cannot send gemport history data ME",
4059 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004060 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004061 }
4062 logger.Debugw(ctx, "send gemport history data ME done",
4063 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004064 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004065 }
4066 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
4067 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03004068 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08004069}
4070
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004071// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
4072func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004073 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004074 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004075 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4076 "SequNo": strconv.FormatInt(int64(tid), 16),
4077 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4078
4079 omciLayer := &omci.OMCI{
4080 TransactionID: tid,
4081 MessageType: omci.StartSoftwareDownloadRequestType,
4082 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4083 // Length: 0x28, // Optional, defaults to 40 octets
4084 }
4085 request := &omci.StartSoftwareDownloadRequest{
4086 MeBasePacket: omci.MeBasePacket{
4087 EntityClass: me.SoftwareImageClassID,
4088 EntityInstance: aImageMeID, //inactive image
4089 },
4090 WindowSize: aDownloadWindowSize,
4091 ImageSize: aFileLen,
4092 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
4093 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
4094 }
4095
4096 var options gopacket.SerializeOptions
4097 options.FixLengths = true
4098 buffer := gopacket.NewSerializeBuffer()
4099 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4100 if err != nil {
4101 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
4102 "device-id": oo.deviceID})
4103 return err
4104 }
4105 outgoingPacket := buffer.Bytes()
4106
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004107 omciRxCallbackPair := CallbackPair{CbKey: tid,
4108 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004109 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004110 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004111 if err != nil {
4112 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
4113 "device-id": oo.deviceID})
4114 return err
4115 }
4116 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004117 return nil
4118}
4119
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004120// SendDownloadSection sends DownloadSectionRequestWithResponse
4121func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004122 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004123 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004124 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
4125 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00004126 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00004127
4128 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
4129 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00004130 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00004131 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00004132 if aAckRequest > 0 {
4133 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00004134 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00004135 }
mpagenko80622a52021-02-09 16:53:23 +00004136 omciLayer := &omci.OMCI{
4137 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004138 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00004139 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4140 // Length: 0x28, // Optional, defaults to 40 octets
4141 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05304142 localSectionData := make([]byte, len(aSection))
4143
mpagenko15ff4a52021-03-02 10:09:20 +00004144 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00004145 request := &omci.DownloadSectionRequest{
4146 MeBasePacket: omci.MeBasePacket{
4147 EntityClass: me.SoftwareImageClassID,
4148 EntityInstance: aImageMeID, //inactive image
4149 },
4150 SectionNumber: aDownloadSectionNo,
4151 SectionData: localSectionData,
4152 }
4153
4154 var options gopacket.SerializeOptions
4155 options.FixLengths = true
4156 buffer := gopacket.NewSerializeBuffer()
4157 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4158 if err != nil {
4159 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
4160 "device-id": oo.deviceID})
4161 return err
4162 }
4163 outgoingPacket := buffer.Bytes()
4164
mpagenko15ff4a52021-03-02 10:09:20 +00004165 //for initial debug purpose overrule the requested print state for some frames
4166 printFrame := aPrint
4167 if aAckRequest > 0 || aDownloadSectionNo == 0 {
4168 printFrame = true
4169 }
4170
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004171 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00004172 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
4173 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004174 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00004175 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004176 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004177 if err != nil {
4178 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
4179 "device-id": oo.deviceID})
4180 return err
4181 }
4182 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004183 return nil
4184}
4185
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004186//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
4187func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004188 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004189 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004190 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
4191 "SequNo": strconv.FormatInt(int64(tid), 16),
4192 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4193
mpagenko15ff4a52021-03-02 10:09:20 +00004194 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004195 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004196 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004197 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4198 // Length: 0x28, // Optional, defaults to 40 octets
4199 }
mpagenko15ff4a52021-03-02 10:09:20 +00004200 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00004201 MeBasePacket: omci.MeBasePacket{
4202 EntityClass: me.SoftwareImageClassID,
4203 EntityInstance: aImageMeID, //inactive image
4204 },
mpagenko15ff4a52021-03-02 10:09:20 +00004205 CRC32: aImageCrc,
4206 ImageSize: aFileLen,
4207 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
4208 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00004209 }
mpagenko15ff4a52021-03-02 10:09:20 +00004210
4211 var options gopacket.SerializeOptions
4212 options.FixLengths = true
4213 buffer := gopacket.NewSerializeBuffer()
4214 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4215 if err != nil {
4216 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004217 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004218 return err
mpagenko80622a52021-02-09 16:53:23 +00004219 }
mpagenko15ff4a52021-03-02 10:09:20 +00004220 outgoingPacket := buffer.Bytes()
4221
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004222 omciRxCallbackPair := CallbackPair{CbKey: tid,
4223 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004224 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004225 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004226 if err != nil {
4227 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
4228 "device-id": oo.deviceID})
4229 return err
4230 }
4231 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004232 return nil
4233}
4234
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004235// SendActivateSoftware sends ActivateSoftwareRequest
4236func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00004237 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004238 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00004239 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
4240 "SequNo": strconv.FormatInt(int64(tid), 16),
4241 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4242
4243 omciLayer := &omci.OMCI{
4244 TransactionID: tid,
4245 MessageType: omci.ActivateSoftwareRequestType,
4246 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4247 // Length: 0x28, // Optional, defaults to 40 octets
4248 }
4249 request := &omci.ActivateSoftwareRequest{
4250 MeBasePacket: omci.MeBasePacket{
4251 EntityClass: me.SoftwareImageClassID,
4252 EntityInstance: aImageMeID, //inactive image
4253 },
4254 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
4255 }
4256
4257 var options gopacket.SerializeOptions
4258 options.FixLengths = true
4259 buffer := gopacket.NewSerializeBuffer()
4260 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4261 if err != nil {
4262 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
4263 "device-id": oo.deviceID})
4264 return err
4265 }
4266 outgoingPacket := buffer.Bytes()
4267
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004268 omciRxCallbackPair := CallbackPair{CbKey: tid,
4269 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00004270 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004271 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00004272 if err != nil {
4273 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
4274 "device-id": oo.deviceID})
4275 return err
4276 }
4277 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00004278 return nil
4279}
mpagenko80622a52021-02-09 16:53:23 +00004280
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004281// SendCommitSoftware sends CommitSoftwareRequest
4282func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko15ff4a52021-03-02 10:09:20 +00004283 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004284 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00004285 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
4286 "SequNo": strconv.FormatInt(int64(tid), 16),
4287 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
4288
4289 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00004290 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00004291 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00004292 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4293 // Length: 0x28, // Optional, defaults to 40 octets
4294 }
mpagenko15ff4a52021-03-02 10:09:20 +00004295 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00004296 MeBasePacket: omci.MeBasePacket{
4297 EntityClass: me.SoftwareImageClassID,
4298 EntityInstance: aImageMeID, //inactive image
4299 },
mpagenko80622a52021-02-09 16:53:23 +00004300 }
mpagenko15ff4a52021-03-02 10:09:20 +00004301
4302 var options gopacket.SerializeOptions
4303 options.FixLengths = true
4304 buffer := gopacket.NewSerializeBuffer()
4305 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4306 if err != nil {
4307 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00004308 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00004309 return err
mpagenko80622a52021-02-09 16:53:23 +00004310 }
mpagenko15ff4a52021-03-02 10:09:20 +00004311 outgoingPacket := buffer.Bytes()
4312
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004313 omciRxCallbackPair := CallbackPair{CbKey: tid,
4314 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00004315 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004316 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00004317 if err != nil {
4318 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
4319 "device-id": oo.deviceID})
4320 return err
4321 }
4322 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00004323 return nil
4324}
4325
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004326//SendSelfTestReq sends TestRequest
4327func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
4328 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004329 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
4330 "SequNo": strconv.FormatInt(int64(tid), 16),
4331 "InstId": strconv.FormatInt(int64(instdID), 16)})
4332 omciLayer := &omci.OMCI{
4333 TransactionID: tid,
4334 MessageType: omci.TestRequestType,
4335 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
4336 // Length: 0x28, // Optional, defaults to 40 octets
4337 }
4338
4339 var request *omci.OpticalLineSupervisionTestRequest
4340 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004341 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004342 request = &omci.OpticalLineSupervisionTestRequest{
4343 MeBasePacket: omci.MeBasePacket{
4344 EntityClass: classID,
4345 EntityInstance: instdID,
4346 },
4347 SelectTest: uint8(7), // self test
4348 GeneralPurposeBuffer: uint16(0),
4349 VendorSpecificParameters: uint16(0),
4350 }
4351 default:
4352 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
4353 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
4354 }
4355 // Test serialization back to former string
4356 var options gopacket.SerializeOptions
4357 options.FixLengths = true
4358
4359 buffer := gopacket.NewSerializeBuffer()
4360 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
4361 if err != nil {
4362 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
4363 "device-id": oo.deviceID})
4364 return err
4365 }
4366 outgoingPacket := buffer.Bytes()
4367
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004368 omciRxCallbackPair := CallbackPair{CbKey: tid,
4369 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004370 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004371 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004372 if err != nil {
4373 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
4374 "device-id": oo.deviceID})
4375 return err
4376 }
4377 logger.Debug(ctx, "send self test request done")
4378 return nil
4379}
4380
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004381//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004382func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004383 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004384 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07004385 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004386 msgLayer := (*packet).Layer(nextLayer)
4387 switch nextLayer {
4388 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004389 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
4390 if resp.Result == me.Success {
4391 return true
4392 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004393 }
4394 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004395 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
4396 if resp.Result == me.Success {
4397 return true
4398 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004399 }
4400 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004401 if resp := msgLayer.(*omci.SetResponse); resp != nil {
4402 if resp.Result == me.Success {
4403 return true
4404 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004405 }
4406 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004407 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
4408 if resp.Result == me.Success {
4409 return true
4410 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004411 }
4412 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004413 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
4414 if resp.Result == me.Success {
4415 return true
4416 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004417 }
4418 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004419 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
4420 if resp.Result == me.Success {
4421 return true
4422 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004423 }
4424 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00004425 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
4426 if resp.Result == me.Success {
4427 return true
4428 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00004429 }
4430 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00004431 }
4432 }
4433 return false
4434}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004435
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004436func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004437 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00004438 if timeout == 0 {
4439 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00004440 // enqueue
4441 if aOmciTxRequest.highPrio {
4442 oo.mutexHighPrioTxQueue.Lock()
4443 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4444 oo.mutexHighPrioTxQueue.Unlock()
4445 } else {
4446 oo.mutexLowPrioTxQueue.Lock()
4447 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4448 oo.mutexLowPrioTxQueue.Unlock()
4449 }
4450 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00004451 } else {
mpagenko7455fd42021-06-10 16:25:55 +00004452 //the supervised sending with waiting on the response (based on TID) is called in background
4453 // to avoid blocking of the sender for the complete OMCI handshake procedure
4454 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
4455 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
4456 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004457 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004458}
4459
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004460func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00004461 chSuccess := make(chan bool)
4462 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004463 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00004464 oo.mutexMonReq.Lock()
4465 oo.monitoredRequests[tid] = aOmciTxRequest
4466 oo.mutexMonReq.Unlock()
4467
4468 retries := aOmciTxRequest.retries
4469 retryCounter := 0
4470loop:
4471 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00004472 // enqueue
4473 if aOmciTxRequest.highPrio {
4474 oo.mutexHighPrioTxQueue.Lock()
4475 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
4476 oo.mutexHighPrioTxQueue.Unlock()
4477 } else {
4478 oo.mutexLowPrioTxQueue.Lock()
4479 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
4480 oo.mutexLowPrioTxQueue.Unlock()
4481 }
4482 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00004483
4484 select {
4485 case success := <-chSuccess:
4486 if success {
4487 logger.Debugw(ctx, "reqMon: response received in time",
4488 log.Fields{"tid": tid, "device-id": oo.deviceID})
4489 } else {
4490 logger.Debugw(ctx, "reqMon: wait for response aborted",
4491 log.Fields{"tid": tid, "device-id": oo.deviceID})
4492 }
4493 break loop
4494 case <-time.After(time.Duration(aTimeout) * time.Second):
4495 if retryCounter == retries {
4496 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
4497 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4498 break loop
4499 } else {
4500 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
4501 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
4502 }
4503 }
4504 retryCounter++
4505 }
4506 oo.mutexMonReq.Lock()
4507 delete(oo.monitoredRequests, tid)
4508 oo.mutexMonReq.Unlock()
4509}
4510
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004511//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004512func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004513 oo.mutexMonReq.RLock()
4514 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00004515 //implement non-blocking channel send to avoid blocking on mutexMonReq later
4516 select {
4517 case oo.monitoredRequests[k].chSuccess <- false:
4518 default:
4519 logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
4520 "index": k, "device-id": oo.deviceID})
4521 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004522 }
4523 oo.mutexMonReq.RUnlock()
4524}
4525
4526//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
4527//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004528func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
4529 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00004530}
Himani Chawla43f95ff2021-06-03 00:24:12 +05304531
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004532// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
4533func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05304534 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004535 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304536 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
4537 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
4538
4539 meParam := me.ParamData{EntityID: entityID,
4540 Attributes: me.AttributeValueMap{"ControlBlock": controlBlock},
4541 }
4542 var meInstance *me.ManagedEntity
4543 var omciErr me.OmciErrors
4544 if classID == me.EthernetFrameExtendedPmClassID {
4545 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
4546 } else {
4547 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
4548 }
4549
4550 if omciErr.GetError() == nil {
4551 var omciLayer *omci.OMCI
4552 var msgLayer gopacket.SerializableLayer
4553 var err error
4554 if create {
4555 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
4556 omci.AddDefaults(true))
4557 } else {
4558 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
4559 omci.AddDefaults(true))
4560 }
4561 if err != nil {
4562 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4563 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4564 return nil, err
4565 }
4566
4567 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4568 if err != nil {
4569 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
4570 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4571 return nil, err
4572 }
4573
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004574 omciRxCallbackPair := CallbackPair{CbKey: tid,
4575 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05304576 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004577 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05304578 if err != nil {
4579 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4580 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4581 return nil, err
4582 }
4583 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
4584 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4585 return meInstance, nil
4586 }
4587 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4588 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4589 return nil, omciErr.GetError()
4590}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00004591
4592// RLockMutexMonReq lock read access to monitoredRequests
4593func (oo *OmciCC) RLockMutexMonReq() {
4594 oo.mutexMonReq.RLock()
4595}
4596
4597// RUnlockMutexMonReq unlock read access to monitoredRequests
4598func (oo *OmciCC) RUnlockMutexMonReq() {
4599 oo.mutexMonReq.RUnlock()
4600}
4601
4602// GetMonitoredRequest get OmciTransferStructure for an omciTransID
4603func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
4604 value, exist = oo.monitoredRequests[omciTransID]
4605 return value, exist
4606}
4607
4608// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
4609func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
4610 oo.monitoredRequests[omciTransID].chSuccess <- chVal
4611}
Himani Chawlaee10b542021-09-20 16:46:40 +05304612
4613// SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me
4614func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
4615 rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
4616 tid := oo.GetNextTid(highPrio)
4617 logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID,
4618 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)})
4619
4620 meParams := me.ParamData{EntityID: entityID,
4621 Attributes: me.AttributeValueMap{"ControlBlock": controlBlock},
4622 }
4623 var meInstance *me.ManagedEntity
4624 var omciErr me.OmciErrors
4625 if classID == me.EthernetFrameExtendedPmClassID {
4626 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams)
4627 } else {
4628 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams)
4629 }
4630
4631 if omciErr.GetError() == nil {
4632 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
4633 if err != nil {
4634 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
4635 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4636 return nil, err
4637 }
4638 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
4639 if err != nil {
4640 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg",
4641 log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4642 return nil, err
4643 }
4644 omciRxCallbackPair := CallbackPair{
4645 CbKey: tid,
4646 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
4647 }
4648 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
4649 if err != nil {
4650 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
4651 log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4652 return nil, err
4653 }
4654 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done",
4655 log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4656 return meInstance, nil
4657 }
4658 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
4659 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)})
4660 return nil, omciErr.GetError()
4661}