blob: e8c669de7a12145be7157c60a1c10ec22f29382c [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)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002447 logger.Debugw(ctx, "send MulticastOperationProfile-create-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
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002527// SendSyncTime sends SynchronizeTimeRequest
2528func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2529 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002530 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2531 "SequNo": strconv.FormatInt(int64(tid), 16)})
2532
2533 omciLayer := &omci.OMCI{
2534 TransactionID: tid,
2535 MessageType: omci.SynchronizeTimeRequestType,
2536 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2537 // Length: 0x28, // Optional, defaults to 40 octets
2538 }
2539 utcTime := time.Now().UTC()
2540 request := &omci.SynchronizeTimeRequest{
2541 MeBasePacket: omci.MeBasePacket{
2542 EntityClass: me.OnuGClassID,
2543 // Default Instance ID is 0
2544 },
2545 Year: uint16(utcTime.Year()),
2546 Month: uint8(utcTime.Month()),
2547 Day: uint8(utcTime.Day()),
2548 Hour: uint8(utcTime.Hour()),
2549 Minute: uint8(utcTime.Minute()),
2550 Second: uint8(utcTime.Second()),
2551 }
2552
2553 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2554 if err != nil {
2555 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2556 "device-id": oo.deviceID})
2557 return err
2558 }
2559
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002560 omciRxCallbackPair := CallbackPair{CbKey: tid,
2561 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002562 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002563 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002564 if err != nil {
2565 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2566 "device-id": oo.deviceID})
2567 return err
2568 }
2569 logger.Debug(ctx, "send synchronize time request done")
2570 return nil
2571}
2572
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002573// SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance
2574func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002575 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002576 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002577 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2578 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2579 meParam := me.ParamData{EntityID: entityID}
2580 var meInstance *me.ManagedEntity
2581 var omciErr me.OmciErrors
2582 if upstream {
2583 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2584 } else {
2585 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2586 }
2587 if omciErr.GetError() == nil {
2588 var omciLayer *omci.OMCI
2589 var msgLayer gopacket.SerializableLayer
2590 var err error
2591 if create {
2592 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2593 omci.AddDefaults(true))
2594 } else {
2595 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2596 omci.AddDefaults(true))
2597 }
2598 if err != nil {
2599 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2600 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002601 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002602 }
2603
2604 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2605 if err != nil {
2606 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2607 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002608 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002609 }
2610
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002611 omciRxCallbackPair := CallbackPair{CbKey: tid,
2612 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002613 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002614 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002615 if err != nil {
2616 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2617 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002618 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002619 }
2620 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2621 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002622 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002623 }
2624 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2625 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 +03002626 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002627}
2628
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002629// SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance
2630func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002631 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002632 tid := oo.GetNextTid(highPrio)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002633 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2634 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2635 meParam := me.ParamData{EntityID: entityID}
2636 var meInstance *me.ManagedEntity
2637 var omciErr me.OmciErrors
2638 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2639
2640 if omciErr.GetError() == nil {
2641 var omciLayer *omci.OMCI
2642 var msgLayer gopacket.SerializableLayer
2643 var err error
2644 if create {
2645 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2646 omci.AddDefaults(true))
2647 } else {
2648 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2649 omci.AddDefaults(true))
2650 }
2651 if err != nil {
2652 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2653 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002654 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002655 }
2656
2657 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2658 if err != nil {
2659 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2660 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002661 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002662 }
2663
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002664 omciRxCallbackPair := CallbackPair{CbKey: tid,
2665 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002666 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002667 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002668 if err != nil {
2669 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2670 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002671 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002672 }
2673 logger.Debugw(ctx, "send ethernet uni history data ME done",
2674 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002675 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002676 }
2677 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2678 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002679 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002680}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002681
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002682// SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance
2683func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002684 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002685 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002686 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2687 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2688 meParam := me.ParamData{EntityID: entityID}
2689 var meInstance *me.ManagedEntity
2690 var omciErr me.OmciErrors
2691 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2692
2693 if omciErr.GetError() == nil {
2694 var omciLayer *omci.OMCI
2695 var msgLayer gopacket.SerializableLayer
2696 var err error
2697 if create {
2698 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2699 omci.AddDefaults(true))
2700 } else {
2701 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2702 omci.AddDefaults(true))
2703 }
2704 if err != nil {
2705 logger.Errorw(ctx, "Cannot encode fec history data ME",
2706 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002707 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002708 }
2709
2710 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2711 if err != nil {
2712 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2713 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002714 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002715 }
2716
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002717 omciRxCallbackPair := CallbackPair{CbKey: tid,
2718 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002719 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002720 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002721 if err != nil {
2722 logger.Errorw(ctx, "Cannot send fec history data ME",
2723 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002724 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002725 }
2726 logger.Debugw(ctx, "send fec history data ME done",
2727 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002728 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002729 }
2730 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2731 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002732 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002733}
2734
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002735// SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance
2736func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002737 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002738 tid := oo.GetNextTid(highPrio)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002739 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2740 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2741 meParam := me.ParamData{EntityID: entityID}
2742 var meInstance *me.ManagedEntity
2743 var omciErr me.OmciErrors
2744 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2745
2746 if omciErr.GetError() == nil {
2747 var omciLayer *omci.OMCI
2748 var msgLayer gopacket.SerializableLayer
2749 var err error
2750 if create {
2751 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2752 omci.AddDefaults(true))
2753 } else {
2754 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2755 omci.AddDefaults(true))
2756 }
2757 if err != nil {
2758 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2759 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002760 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002761 }
2762
2763 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2764 if err != nil {
2765 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2766 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002767 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002768 }
2769
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002770 omciRxCallbackPair := CallbackPair{CbKey: tid,
2771 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002772 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002773 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002774 if err != nil {
2775 logger.Errorw(ctx, "Cannot send gemport history data ME",
2776 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002777 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002778 }
2779 logger.Debugw(ctx, "send gemport history data ME done",
2780 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002781 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002782 }
2783 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2784 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002785 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002786}
2787
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002788// SendStartSoftwareDownload sends StartSoftwareDownloadRequest
2789func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002790 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002791 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00002792 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2793 "SequNo": strconv.FormatInt(int64(tid), 16),
2794 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2795
2796 omciLayer := &omci.OMCI{
2797 TransactionID: tid,
2798 MessageType: omci.StartSoftwareDownloadRequestType,
2799 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2800 // Length: 0x28, // Optional, defaults to 40 octets
2801 }
2802 request := &omci.StartSoftwareDownloadRequest{
2803 MeBasePacket: omci.MeBasePacket{
2804 EntityClass: me.SoftwareImageClassID,
2805 EntityInstance: aImageMeID, //inactive image
2806 },
2807 WindowSize: aDownloadWindowSize,
2808 ImageSize: aFileLen,
2809 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2810 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2811 }
2812
2813 var options gopacket.SerializeOptions
2814 options.FixLengths = true
2815 buffer := gopacket.NewSerializeBuffer()
2816 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2817 if err != nil {
2818 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2819 "device-id": oo.deviceID})
2820 return err
2821 }
2822 outgoingPacket := buffer.Bytes()
2823
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002824 omciRxCallbackPair := CallbackPair{CbKey: tid,
2825 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00002826 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002827 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002828 if err != nil {
2829 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2830 "device-id": oo.deviceID})
2831 return err
2832 }
2833 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002834 return nil
2835}
2836
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002837// SendDownloadSection sends DownloadSectionRequestWithResponse
2838func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002839 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002840 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00002841 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2842 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002843 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002844
2845 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2846 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002847 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00002848 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00002849 if aAckRequest > 0 {
2850 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00002851 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00002852 }
mpagenko80622a52021-02-09 16:53:23 +00002853 omciLayer := &omci.OMCI{
2854 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002855 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002856 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2857 // Length: 0x28, // Optional, defaults to 40 octets
2858 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05302859 localSectionData := make([]byte, len(aSection))
2860
mpagenko15ff4a52021-03-02 10:09:20 +00002861 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002862 request := &omci.DownloadSectionRequest{
2863 MeBasePacket: omci.MeBasePacket{
2864 EntityClass: me.SoftwareImageClassID,
2865 EntityInstance: aImageMeID, //inactive image
2866 },
2867 SectionNumber: aDownloadSectionNo,
2868 SectionData: localSectionData,
2869 }
2870
2871 var options gopacket.SerializeOptions
2872 options.FixLengths = true
2873 buffer := gopacket.NewSerializeBuffer()
2874 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2875 if err != nil {
2876 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2877 "device-id": oo.deviceID})
2878 return err
2879 }
2880 outgoingPacket := buffer.Bytes()
2881
mpagenko15ff4a52021-03-02 10:09:20 +00002882 //for initial debug purpose overrule the requested print state for some frames
2883 printFrame := aPrint
2884 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2885 printFrame = true
2886 }
2887
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002888 omciRxCallbackPair := CallbackPair{CbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00002889 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
2890 // (used to avoid retransmission of frames with the same TID)
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002891 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002892 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002893 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002894 if err != nil {
2895 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2896 "device-id": oo.deviceID})
2897 return err
2898 }
2899 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002900 return nil
2901}
2902
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002903//SendEndSoftwareDownload sends EndSoftwareDownloadRequest
2904func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002905 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002906 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00002907 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2908 "SequNo": strconv.FormatInt(int64(tid), 16),
2909 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2910
mpagenko15ff4a52021-03-02 10:09:20 +00002911 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002912 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002913 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002914 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2915 // Length: 0x28, // Optional, defaults to 40 octets
2916 }
mpagenko15ff4a52021-03-02 10:09:20 +00002917 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002918 MeBasePacket: omci.MeBasePacket{
2919 EntityClass: me.SoftwareImageClassID,
2920 EntityInstance: aImageMeID, //inactive image
2921 },
mpagenko15ff4a52021-03-02 10:09:20 +00002922 CRC32: aImageCrc,
2923 ImageSize: aFileLen,
2924 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2925 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002926 }
mpagenko15ff4a52021-03-02 10:09:20 +00002927
2928 var options gopacket.SerializeOptions
2929 options.FixLengths = true
2930 buffer := gopacket.NewSerializeBuffer()
2931 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2932 if err != nil {
2933 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002934 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002935 return err
mpagenko80622a52021-02-09 16:53:23 +00002936 }
mpagenko15ff4a52021-03-02 10:09:20 +00002937 outgoingPacket := buffer.Bytes()
2938
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002939 omciRxCallbackPair := CallbackPair{CbKey: tid,
2940 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00002941 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002942 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002943 if err != nil {
2944 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2945 "device-id": oo.deviceID})
2946 return err
2947 }
2948 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002949 return nil
2950}
2951
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002952// SendActivateSoftware sends ActivateSoftwareRequest
2953func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002954 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002955 tid := oo.GetNextTid(highPrio)
mpagenko80622a52021-02-09 16:53:23 +00002956 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2957 "SequNo": strconv.FormatInt(int64(tid), 16),
2958 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2959
2960 omciLayer := &omci.OMCI{
2961 TransactionID: tid,
2962 MessageType: omci.ActivateSoftwareRequestType,
2963 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2964 // Length: 0x28, // Optional, defaults to 40 octets
2965 }
2966 request := &omci.ActivateSoftwareRequest{
2967 MeBasePacket: omci.MeBasePacket{
2968 EntityClass: me.SoftwareImageClassID,
2969 EntityInstance: aImageMeID, //inactive image
2970 },
2971 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2972 }
2973
2974 var options gopacket.SerializeOptions
2975 options.FixLengths = true
2976 buffer := gopacket.NewSerializeBuffer()
2977 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2978 if err != nil {
2979 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2980 "device-id": oo.deviceID})
2981 return err
2982 }
2983 outgoingPacket := buffer.Bytes()
2984
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002985 omciRxCallbackPair := CallbackPair{CbKey: tid,
2986 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko80622a52021-02-09 16:53:23 +00002987 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002988 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002989 if err != nil {
2990 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2991 "device-id": oo.deviceID})
2992 return err
2993 }
2994 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002995 return nil
2996}
mpagenko80622a52021-02-09 16:53:23 +00002997
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00002998// SendCommitSoftware sends CommitSoftwareRequest
2999func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
mpagenko15ff4a52021-03-02 10:09:20 +00003000 rxChan chan Message, aImageMeID uint16) error {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003001 tid := oo.GetNextTid(highPrio)
mpagenko15ff4a52021-03-02 10:09:20 +00003002 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
3003 "SequNo": strconv.FormatInt(int64(tid), 16),
3004 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
3005
3006 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00003007 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00003008 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00003009 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3010 // Length: 0x28, // Optional, defaults to 40 octets
3011 }
mpagenko15ff4a52021-03-02 10:09:20 +00003012 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00003013 MeBasePacket: omci.MeBasePacket{
3014 EntityClass: me.SoftwareImageClassID,
3015 EntityInstance: aImageMeID, //inactive image
3016 },
mpagenko80622a52021-02-09 16:53:23 +00003017 }
mpagenko15ff4a52021-03-02 10:09:20 +00003018
3019 var options gopacket.SerializeOptions
3020 options.FixLengths = true
3021 buffer := gopacket.NewSerializeBuffer()
3022 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
3023 if err != nil {
3024 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00003025 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00003026 return err
mpagenko80622a52021-02-09 16:53:23 +00003027 }
mpagenko15ff4a52021-03-02 10:09:20 +00003028 outgoingPacket := buffer.Bytes()
3029
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003030 omciRxCallbackPair := CallbackPair{CbKey: tid,
3031 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko15ff4a52021-03-02 10:09:20 +00003032 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003033 err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00003034 if err != nil {
3035 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
3036 "device-id": oo.deviceID})
3037 return err
3038 }
3039 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00003040 return nil
3041}
3042
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003043//SendSelfTestReq sends TestRequest
3044func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
3045 tid := oo.GetNextTid(highPrio)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07003046 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
3047 "SequNo": strconv.FormatInt(int64(tid), 16),
3048 "InstId": strconv.FormatInt(int64(instdID), 16)})
3049 omciLayer := &omci.OMCI{
3050 TransactionID: tid,
3051 MessageType: omci.TestRequestType,
3052 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3053 // Length: 0x28, // Optional, defaults to 40 octets
3054 }
3055
3056 var request *omci.OpticalLineSupervisionTestRequest
3057 switch classID {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003058 case me.AniGClassID:
Girish Gowdra6afb56a2021-04-27 17:47:57 -07003059 request = &omci.OpticalLineSupervisionTestRequest{
3060 MeBasePacket: omci.MeBasePacket{
3061 EntityClass: classID,
3062 EntityInstance: instdID,
3063 },
3064 SelectTest: uint8(7), // self test
3065 GeneralPurposeBuffer: uint16(0),
3066 VendorSpecificParameters: uint16(0),
3067 }
3068 default:
3069 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
3070 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
3071 }
3072 // Test serialization back to former string
3073 var options gopacket.SerializeOptions
3074 options.FixLengths = true
3075
3076 buffer := gopacket.NewSerializeBuffer()
3077 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
3078 if err != nil {
3079 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
3080 "device-id": oo.deviceID})
3081 return err
3082 }
3083 outgoingPacket := buffer.Bytes()
3084
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003085 omciRxCallbackPair := CallbackPair{CbKey: tid,
3086 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra6afb56a2021-04-27 17:47:57 -07003087 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003088 err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
Girish Gowdra6afb56a2021-04-27 17:47:57 -07003089 if err != nil {
3090 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
3091 "device-id": oo.deviceID})
3092 return err
3093 }
3094 logger.Debug(ctx, "send self test request done")
3095 return nil
3096}
3097
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003098//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003099func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003100 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003101 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07003102 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003103 msgLayer := (*packet).Layer(nextLayer)
3104 switch nextLayer {
3105 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003106 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
3107 if resp.Result == me.Success {
3108 return true
3109 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003110 }
3111 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003112 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
3113 if resp.Result == me.Success {
3114 return true
3115 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003116 }
3117 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003118 if resp := msgLayer.(*omci.SetResponse); resp != nil {
3119 if resp.Result == me.Success {
3120 return true
3121 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003122 }
3123 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003124 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
3125 if resp.Result == me.Success {
3126 return true
3127 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003128 }
3129 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003130 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
3131 if resp.Result == me.Success {
3132 return true
3133 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003134 }
3135 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003136 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
3137 if resp.Result == me.Success {
3138 return true
3139 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003140 }
3141 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003142 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
3143 if resp.Result == me.Success {
3144 return true
3145 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003146 }
3147 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003148 }
3149 }
3150 return false
3151}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003152
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003153func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003154 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00003155 if timeout == 0 {
3156 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt34555512021-10-01 16:26:59 +00003157 // enqueue
3158 if aOmciTxRequest.highPrio {
3159 oo.mutexHighPrioTxQueue.Lock()
3160 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
3161 oo.mutexHighPrioTxQueue.Unlock()
3162 } else {
3163 oo.mutexLowPrioTxQueue.Lock()
3164 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
3165 oo.mutexLowPrioTxQueue.Unlock()
3166 }
3167 go oo.sendQueuedRequests(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00003168 } else {
mpagenko7455fd42021-06-10 16:25:55 +00003169 //the supervised sending with waiting on the response (based on TID) is called in background
3170 // to avoid blocking of the sender for the complete OMCI handshake procedure
3171 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
3172 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
3173 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003174 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003175}
3176
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003177func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) {
mpagenko7455fd42021-06-10 16:25:55 +00003178 chSuccess := make(chan bool)
3179 aOmciTxRequest.chSuccess = chSuccess
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003180 tid := aOmciTxRequest.cbPair.CbKey
mpagenko7455fd42021-06-10 16:25:55 +00003181 oo.mutexMonReq.Lock()
3182 oo.monitoredRequests[tid] = aOmciTxRequest
3183 oo.mutexMonReq.Unlock()
3184
3185 retries := aOmciTxRequest.retries
3186 retryCounter := 0
3187loop:
3188 for retryCounter <= retries {
Holger Hildebrandt34555512021-10-01 16:26:59 +00003189 // enqueue
3190 if aOmciTxRequest.highPrio {
3191 oo.mutexHighPrioTxQueue.Lock()
3192 oo.highPrioTxQueue.PushBack(aOmciTxRequest)
3193 oo.mutexHighPrioTxQueue.Unlock()
3194 } else {
3195 oo.mutexLowPrioTxQueue.Lock()
3196 oo.lowPrioTxQueue.PushBack(aOmciTxRequest)
3197 oo.mutexLowPrioTxQueue.Unlock()
3198 }
3199 go oo.sendQueuedRequests(ctx)
mpagenko7455fd42021-06-10 16:25:55 +00003200
3201 select {
3202 case success := <-chSuccess:
3203 if success {
3204 logger.Debugw(ctx, "reqMon: response received in time",
3205 log.Fields{"tid": tid, "device-id": oo.deviceID})
3206 } else {
3207 logger.Debugw(ctx, "reqMon: wait for response aborted",
3208 log.Fields{"tid": tid, "device-id": oo.deviceID})
3209 }
3210 break loop
3211 case <-time.After(time.Duration(aTimeout) * time.Second):
3212 if retryCounter == retries {
3213 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
3214 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3215 break loop
3216 } else {
3217 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
3218 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3219 }
3220 }
3221 retryCounter++
3222 }
3223 oo.mutexMonReq.Lock()
3224 delete(oo.monitoredRequests, tid)
3225 oo.mutexMonReq.Unlock()
3226}
3227
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003228//CancelRequestMonitoring terminates monitoring of outstanding omci requests
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003229func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003230 oo.mutexMonReq.RLock()
3231 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00003232 //implement non-blocking channel send to avoid blocking on mutexMonReq later
3233 select {
3234 case oo.monitoredRequests[k].chSuccess <- false:
3235 default:
3236 logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
3237 "index": k, "device-id": oo.deviceID})
3238 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003239 }
3240 oo.mutexMonReq.RUnlock()
3241}
3242
3243//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
3244//time consumed for retry processing of a particular OMCI-request
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003245func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
3246 return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003247}
Himani Chawla43f95ff2021-06-03 00:24:12 +05303248
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003249// SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance
3250func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
Himani Chawla43f95ff2021-06-03 00:24:12 +05303251 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003252 tid := oo.GetNextTid(highPrio)
Himani Chawla43f95ff2021-06-03 00:24:12 +05303253 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
3254 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3255
3256 meParam := me.ParamData{EntityID: entityID,
3257 Attributes: me.AttributeValueMap{"ControlBlock": controlBlock},
3258 }
3259 var meInstance *me.ManagedEntity
3260 var omciErr me.OmciErrors
3261 if classID == me.EthernetFrameExtendedPmClassID {
3262 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
3263 } else {
3264 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
3265 }
3266
3267 if omciErr.GetError() == nil {
3268 var omciLayer *omci.OMCI
3269 var msgLayer gopacket.SerializableLayer
3270 var err error
3271 if create {
3272 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3273 omci.AddDefaults(true))
3274 } else {
3275 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
3276 omci.AddDefaults(true))
3277 }
3278 if err != nil {
3279 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
3280 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3281 return nil, err
3282 }
3283
3284 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3285 if err != nil {
3286 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
3287 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3288 return nil, err
3289 }
3290
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003291 omciRxCallbackPair := CallbackPair{CbKey: tid,
3292 CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Himani Chawla43f95ff2021-06-03 00:24:12 +05303293 }
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003294 err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawla43f95ff2021-06-03 00:24:12 +05303295 if err != nil {
3296 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
3297 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3298 return nil, err
3299 }
3300 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
3301 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3302 return meInstance, nil
3303 }
3304 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
3305 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3306 return nil, omciErr.GetError()
3307}
Holger Hildebrandt4b5e73f2021-08-19 06:51:21 +00003308
3309// RLockMutexMonReq lock read access to monitoredRequests
3310func (oo *OmciCC) RLockMutexMonReq() {
3311 oo.mutexMonReq.RLock()
3312}
3313
3314// RUnlockMutexMonReq unlock read access to monitoredRequests
3315func (oo *OmciCC) RUnlockMutexMonReq() {
3316 oo.mutexMonReq.RUnlock()
3317}
3318
3319// GetMonitoredRequest get OmciTransferStructure for an omciTransID
3320func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) {
3321 value, exist = oo.monitoredRequests[omciTransID]
3322 return value, exist
3323}
3324
3325// SetChMonitoredRequest sets chSuccess to indicate whether response was received or not
3326func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) {
3327 oo.monitoredRequests[omciTransID].chSuccess <- chVal
3328}