blob: ed4d59d13304cf6742773275b9a479bfc3852057 [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 Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
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"
dbainbri4d3a0dc2020-12-02 00:33:42 +000036 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
39 "github.com/opencord/voltha-lib-go/v4/pkg/log"
40 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
41 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
42 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000043)
44
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000045// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053046
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047const maxGemPayloadSize = uint16(48)
48const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053049
50//const defaultTPID = uint16(0x8100)
51//const broadComDefaultVID = uint16(4091)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000052
mpagenko8b07c1b2020-11-26 10:36:31 +000053const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
54
mpagenkoc8bba412021-01-15 15:38:44 +000055const cOmciBaseMessageTrailerLen = 40
56
57// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
58type tOmciReceiveError uint8
59
60const (
61 // cOmciMessageReceiveNoError - default start state
62 cOmciMessageReceiveNoError tOmciReceiveError = iota
63 // Error indication wrong trailer length within the message
64 cOmciMessageReceiveErrorTrailerLen
65 // Error indication missing trailer within the message
66 cOmciMessageReceiveErrorMissTrailer
67)
68
Holger Hildebrandt366ef192021-05-05 11:07:44 +000069const cDefaultRetries = 2
70
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000071// ### OMCI related definitions - end
72
Himani Chawla6d2ae152020-09-02 13:11:20 +053073//callbackPairEntry to be used for OMCI send/receive correlation
74type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000075 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000076 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
mpagenko80622a52021-02-09 16:53:23 +000077 framePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000078}
79
Himani Chawla6d2ae152020-09-02 13:11:20 +053080//callbackPair to be used for ReceiveCallback init
81type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000082 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053083 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000084}
85
86type omciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000087 txFrame []byte
88 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000089 retries int
mpagenko80622a52021-02-09 16:53:23 +000090 highPrio bool
91 withFramePrint bool
Holger Hildebrandt366ef192021-05-05 11:07:44 +000092 cbPair callbackPair
93 chSuccess chan bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000094}
95
Himani Chawla6d2ae152020-09-02 13:11:20 +053096//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
97type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +000098 enabled bool
99 pOnuDeviceEntry *OnuDeviceEntry
100 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +0530101 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000102 coreProxy adapterif.CoreProxy
103 adapterProxy adapterif.AdapterProxy
104 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000105 rxOmciFrameError tOmciReceiveError
106
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000107 txFrames, txOnuFrames uint32
108 rxFrames, rxOnuFrames, rxOnuDiscards uint32
109
110 // OMCI params
111 mutexTid sync.Mutex
112 tid uint16
113 mutexHpTid sync.Mutex
114 hpTid uint16
115 uploadSequNo uint16
116 uploadNoOfCmds uint16
117
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000118 mutexTxQueue sync.Mutex
119 txQueue *list.List
120 mutexRxSchedMap sync.Mutex
121 rxSchedulerMap map[uint16]callbackPairEntry
122 mutexMonReq sync.RWMutex
123 monitoredRequests map[uint16]omciTransferStructure
124 mutexPLastTxMeInstance sync.RWMutex
125 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000126}
127
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000128var responsesWithMibDataSync = []omci.MessageType{
129 omci.CreateResponseType,
130 omci.DeleteResponseType,
131 omci.SetResponseType,
132 omci.StartSoftwareDownloadResponseType,
133 omci.EndSoftwareDownloadResponseType,
134 omci.ActivateSoftwareResponseType,
135 omci.CommitSoftwareResponseType,
136}
137
Himani Chawla6d2ae152020-09-02 13:11:20 +0530138//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000139//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530140func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
141 deviceID string, deviceHandler *deviceHandler,
142 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000143 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530144 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000145 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530146 omciCC.pOnuDeviceEntry = onuDeviceEntry
147 omciCC.deviceID = deviceID
148 omciCC.pBaseDeviceHandler = deviceHandler
149 omciCC.coreProxy = coreProxy
150 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000151 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000152 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000153 omciCC.txFrames = 0
154 omciCC.txOnuFrames = 0
155 omciCC.rxFrames = 0
156 omciCC.rxOnuFrames = 0
157 omciCC.rxOnuDiscards = 0
158 omciCC.tid = 0x1
159 omciCC.hpTid = 0x8000
160 omciCC.uploadSequNo = 0
161 omciCC.uploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000162 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530163 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000164 omciCC.monitoredRequests = make(map[uint16]omciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000165
166 return &omciCC
167}
168
mpagenko900ee4b2020-10-12 11:56:34 +0000169//stop stops/resets the omciCC
170func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000171 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000172 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000173 oo.CancelRequestMonitoring()
mpagenko900ee4b2020-10-12 11:56:34 +0000174 oo.mutexTxQueue.Lock()
175 oo.txQueue.Init() // clear the tx queue
176 oo.mutexTxQueue.Unlock()
177 oo.mutexRxSchedMap.Lock()
178 for k := range oo.rxSchedulerMap {
179 delete(oo.rxSchedulerMap, k) //clear the scheduler map
180 }
181 oo.mutexRxSchedMap.Unlock()
182 oo.mutexHpTid.Lock()
183 oo.hpTid = 0x8000 //reset the high prio transactionId
184 oo.mutexHpTid.Unlock()
185 oo.mutexTid.Lock()
186 oo.tid = 1 //reset the low prio transactionId
187 oo.mutexTid.Unlock()
188 //reset control values
189 oo.uploadSequNo = 0
190 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000191 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000192 //reset the stats counter - which might be topic of discussion ...
193 oo.txFrames = 0
194 oo.txOnuFrames = 0
195 oo.rxFrames = 0
196 oo.rxOnuFrames = 0
197 oo.rxOnuDiscards = 0
198
199 return nil
200}
201
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000202// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530203func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000204 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000205 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530206 switch omciMsg.MessageType {
207 case omci.AlarmNotificationType:
208 data := OmciMessage{
209 OmciMsg: omciMsg,
210 OmciPacket: packet,
211 }
212 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
213 return nil
214 default:
215 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
216 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000217 /*
218 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
219 rxOnuFrames++
220
221 switch msgType {
222 case AlarmNotification:
223 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000224 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000225 // python code was:
226 //if msg_type == EntityOperations.AlarmNotification.value:
227 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
228 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
229 //
230 return errors.New("RxAlarmNotification unimplemented")
231 }
232 case AttributeValueChange:
233 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000234 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000235 // python code was:
236 //elif msg_type == EntityOperations.AttributeValueChange.value:
237 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
238 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
239 //
240 return errors.New("RxAttributeValueChange unimplemented")
241 }
242 case TestResult:
243 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000244 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000245 // python code was:
246 //elif msg_type == EntityOperations.TestResult.value:
247 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
248 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
249 //
250 return errors.New("RxTestResult unimplemented")
251 }
252 default:
253 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000254 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000255 rxOnuDiscards++
256 return errors.New("RxOnuMsgType unimplemented")
257 }
258 }
259 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000260}
261
mpagenko80622a52021-02-09 16:53:23 +0000262func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
263 //assuming omci message content is hex coded!
264 // with restricted output of 16bytes would be ...rxMsg[:16]
265 logger.Debugw(ctx, "omci-message-received:", log.Fields{
266 "RxOmciMessage": hex.EncodeToString(rxMsg),
267 "device-id": oo.deviceID})
268}
269
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000270// Rx handler for onu messages
271// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530272func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000273 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000274 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
275 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000276 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000277 trailerLenData := rxMsg[42:44]
278 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000279 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000280 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
281 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
282 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
283 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
284 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
285 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
286 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
287 }
288 }
289 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
290 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
291 // (an extendedFormat message could be destroyed this way!)
292 // extend/overwrite with trailer
293 trailer := make([]byte, 8)
294 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
295 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
296 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
297 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
298 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
299 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
300 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000301 }
302 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000303 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
304 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000305 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200306 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000307 }
308
309 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
310 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000311 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000312 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200313 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000314 }
315 omciLayer := packet.Layer(omci.LayerTypeOMCI)
316 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000317 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000318 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200319 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000320 }
321 omciMsg, ok := omciLayer.(*omci.OMCI)
322 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000323 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000324 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200325 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000326 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000327 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000328 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700329 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
330 // We expect to find the TID in the oo.rxSchedulerMap
331 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000332 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000333 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000334 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000335 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530336 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000337 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000338 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200339 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000340 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200341 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530342 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000343 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530344 oo.mutexRxSchedMap.Lock()
345 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
346 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000347 if rxCallbackEntry.framePrint {
348 oo.printRxMessage(ctx, rxMsg)
349 }
Himani Chawla4d908332020-08-31 12:30:20 +0530350 //disadvantage of decoupling: error verification made difficult, but anyway the question is
351 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000352 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000353 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000354 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
355 }
mpagenkoc8bba412021-01-15 15:38:44 +0000356
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700357 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
358 // so do not clean up the TransactionID in that case.
359 if omciMsg.MessageType != omci.TestResponseType {
360 // having posted the response the request is regarded as 'done'
361 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
362 }
Himani Chawla4d908332020-08-31 12:30:20 +0530363 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000364 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000365 }
mpagenko80622a52021-02-09 16:53:23 +0000366 oo.mutexRxSchedMap.Unlock()
367 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
368 oo.printRxMessage(ctx, rxMsg)
369 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000370
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000371 /* py code was:
372 Receive and OMCI message from the proxy channel to the OLT.
373
374 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
375 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
376 """
377 if not self.enabled:
378 return
379
380 try:
381 now = arrow.utcnow()
382 d = None
383
384 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
385 # save the current value of the entity_id_to_class_map, then
386 # replace it with our custom one before decode, and then finally
387 # restore it later. Tried other ways but really made the code messy.
388 saved_me_map = omci_entities.entity_id_to_class_map
389 omci_entities.entity_id_to_class_map = self._me_map
390
391 try:
392 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000393 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000394 except KeyError as e:
395 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000396 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000397 rx_frame = self._decode_unknown_me(msg)
398 self._rx_unknown_me += 1
399
400 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000401 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000402 return
403
404 finally:
405 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
406
407 rx_tid = rx_frame.fields['transaction_id']
408 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000409 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000410 # Filter the Test Result frame and route through receive onu
411 # message method.
412 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000413 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000414 return self._receive_onu_message(rx_frame)
415
416 # Previously unreachable if this is the very first round-trip Rx or we
417 # have been running consecutive errors
418 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000419 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000420 self.reactor.callLater(0, self._publish_connectivity_event, True)
421
422 self._rx_frames += 1
423 self._consecutive_errors = 0
424
425 try:
426 high_priority = self._tid_is_high_priority(rx_tid)
427 index = self._get_priority_index(high_priority)
428
429 # (timestamp, defer, frame, timeout, retry, delayedCall)
430 last_tx_tuple = self._tx_request[index]
431
432 if last_tx_tuple is None or \
433 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
434 # Possible late Rx on a message that timed-out
435 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000436 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000437 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
438 self._rx_unknown_tid += 1
439 self._rx_late += 1
440 return
441
442 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
443 if dc is not None and not dc.cancelled and not dc.called:
444 dc.cancel()
445
446 _secs = self._update_rx_tx_stats(now, ts)
447
448 # Late arrival already serviced by a timeout?
449 if d.called:
450 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000451 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000452 return
453
454 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000455 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000456 if d is not None:
457 return d.errback(failure.Failure(e))
458 return
459
460 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000461 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000462 tx_tid = tx_frame.fields['transaction_id'])
463 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
464
465 # begin success callback chain (will cancel timeout and queue next Tx message)
466 self._rx_response[index] = rx_frame
467 d.callback(rx_frame)
468
469 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000470 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000471 */
472}
473
Himani Chawla6d2ae152020-09-02 13:11:20 +0530474/*
475func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530476 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530477 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000478}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530479*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000480
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700481// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
482func (oo *omciCC) ReleaseTid(ctx context.Context, tid uint16) {
483 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
484 delete(oo.rxSchedulerMap, tid)
485}
486
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000487//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530488func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
489 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000490
mpagenkoc26d4c02021-05-06 14:27:57 +0000491 if timeout != 0 {
492 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
493 oo.mutexRxSchedMap.Lock()
494 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
495 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
496 oo.mutexRxSchedMap.Unlock()
497 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000498
mpagenkoc26d4c02021-05-06 14:27:57 +0000499 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000500 //just use a simple list for starting - might need some more effort, especially for multi source write access
501 omciTxRequest := omciTransferStructure{
502 txFrame,
503 timeout,
504 retry,
505 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000506 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000507 receiveCallbackPair,
508 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000509 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000510 oo.mutexMonReq.Lock()
511 defer oo.mutexMonReq.Unlock()
512 if _, exist := oo.monitoredRequests[receiveCallbackPair.cbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000513 // do not call processRequestMonitoring in background here to ensure correct sequencing
514 // of requested messages into txQueue (especially for non-response-supervised messages)
515 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000516 return nil
517 }
518 logger.Errorw(ctx, "A message with this tid is processed already!",
519 log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
520 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000521}
522
523//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530524func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000525 // return errors.New("sendNextRequest unimplemented")
526
527 // just try to get something transferred !!
528 // avoid accessing the txQueue from parallel send requests
529 // block parallel omci send requests at least until SendIAP is 'committed'
530 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
531 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000532 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000533 for oo.txQueue.Len() > 0 {
534 queueElement := oo.txQueue.Front() // First element
535 omciTxRequest := queueElement.Value.(omciTransferStructure)
536 /* compare olt device handler code:
537 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000538 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000539 var deviceType string
540 var deviceID string
541 var proxyDeviceID string
542
543 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
544
545 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
546
dbainbri4d3a0dc2020-12-02 00:33:42 +0000547 logger.Debugw(ctx,"omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000548 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
549 kwargs := make(map[string]interface{})
550 kwargs["onu_id"] = omciInd.OnuId
551 kwargs["parent_port_no"] = ponPort
552
dbainbri4d3a0dc2020-12-02 00:33:42 +0000553 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000555 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000556 return
557 }
558 deviceType = onuDevice.Type
559 deviceID = onuDevice.Id
560 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
561 //if not exist in cache, then add to cache.
562 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
563 } else {
564 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000565 logger.Debugw(ctx,"omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566 deviceType = onuInCache.(*OnuDevice).deviceType
567 deviceID = onuInCache.(*OnuDevice).deviceID
568 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
569 }
570 */
571 /* and compare onu_adapter py code:
572 omci_msg = InterAdapterOmciMessage(
573 message=bytes(frame),
574 proxy_address=self._proxy_address,
575 connect_status=self._device.connect_status)
576
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000577 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000578
579 yield self._adapter_proxy.send_inter_adapter_message(
580 msg=omci_msg,
581 type=InterAdapterMessageType.OMCI_REQUEST,
582 from_adapter=self._device.type,
583 to_adapter=self._proxy_address.device_type,
584 to_device_id=self._device_id,
585 proxy_device_id=self._proxy_address.device_id
586 )
587 */
mpagenko80622a52021-02-09 16:53:23 +0000588 if omciTxRequest.withFramePrint {
589 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
590 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
591 "device-id": oo.deviceID,
592 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
593 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
594 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000595 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000596 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000597 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800598 //fromTopic,toType,toDevId, ProxyDevId
599 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000600 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000601 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000602 return sendErr
603 }
604 oo.txQueue.Remove(queueElement) // Dequeue
605 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000606 return nil
607}
608
Himani Chawla6d2ae152020-09-02 13:11:20 +0530609func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000610 var next uint16
611 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000612 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000613 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530614 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000615 if oo.hpTid < 0x8000 {
616 oo.hpTid = 0x8000
617 }
mpagenko900ee4b2020-10-12 11:56:34 +0000618 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000620 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000621 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530622 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000623 if oo.tid >= 0x8000 {
624 oo.tid = 1
625 }
mpagenko900ee4b2020-10-12 11:56:34 +0000626 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000627 }
628 return next
629}
630
631// ###################################################################################
632// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000633func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000634 omciLayer := &omci.OMCI{
635 TransactionID: tid,
636 MessageType: msgType,
637 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000638 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000639}
640
dbainbri4d3a0dc2020-12-02 00:33:42 +0000641func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000642 var options gopacket.SerializeOptions
643 options.FixLengths = true
644
645 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530646 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000647 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000648 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000649 return nil, err
650 }
651 return buffer.Bytes(), nil
652}
653
Himani Chawla4d908332020-08-31 12:30:20 +0530654/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000655func hexEncode(omciPkt []byte) ([]byte, error) {
656 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
657 hex.Encode(dst, omciPkt)
658 return dst, nil
659}
Himani Chawla4d908332020-08-31 12:30:20 +0530660*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000661
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000662//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000663func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000664
dbainbri4d3a0dc2020-12-02 00:33:42 +0000665 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000666 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000667
668 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000669 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000670 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200671 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000672 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000673 oo.mutexMonReq.RLock()
674 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
675 oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
676 } else {
677 logger.Infow(ctx, "reqMon: map entry does not exist!",
678 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
679 }
680 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000681
682 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
683 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000684 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000685 Type: OMCI,
686 Data: OmciMessage{
687 OmciMsg: omciMsg,
688 OmciPacket: packet,
689 },
690 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000691 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000692 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000693
694 return nil
695}
696
Himani Chawla6d2ae152020-09-02 13:11:20 +0530697func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000698
dbainbri4d3a0dc2020-12-02 00:33:42 +0000699 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000700 request := &omci.MibResetRequest{
701 MeBasePacket: omci.MeBasePacket{
702 EntityClass: me.OnuDataClassID,
703 },
704 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530705 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000707 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000708 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000709 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000710 return err
711 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530712 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000713 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000714 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000715 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000716 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717}
718
Himani Chawla6d2ae152020-09-02 13:11:20 +0530719func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000720 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300721 request := &omci.RebootRequest{
722 MeBasePacket: omci.MeBasePacket{
723 EntityClass: me.OnuGClassID,
724 },
725 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530726 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000727 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300728 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000729 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000730 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300731 return err
732 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530733 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300734 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000735 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300736 }
737
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000738 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300739 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000740 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000741 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300742 return err
743 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000744 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300745 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000746 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200747 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300748 return err
749 }
750 return nil
751}
752
Himani Chawla6d2ae152020-09-02 13:11:20 +0530753func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000754 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000755 request := &omci.MibUploadRequest{
756 MeBasePacket: omci.MeBasePacket{
757 EntityClass: me.OnuDataClassID,
758 },
759 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530760 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000761 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000762 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000763 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000764 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000765 return err
766 }
767 oo.uploadSequNo = 0
768 oo.uploadNoOfCmds = 0
769
Himani Chawla6d2ae152020-09-02 13:11:20 +0530770 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000771 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000772 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000773 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000774 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000775}
776
Himani Chawla6d2ae152020-09-02 13:11:20 +0530777func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000778 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000779 request := &omci.MibUploadNextRequest{
780 MeBasePacket: omci.MeBasePacket{
781 EntityClass: me.OnuDataClassID,
782 },
783 CommandSequenceNumber: oo.uploadSequNo,
784 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530785 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000786 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000787 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000788 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000789 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000790 return err
791 }
792 oo.uploadSequNo++
793
Himani Chawla6d2ae152020-09-02 13:11:20 +0530794 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000795 cbKey: tid,
796 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
797 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
798 // compare also software upgrade download section handling
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000799 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000800 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000801 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000802}
803
Himani Chawlad3dac422021-03-13 02:31:31 +0530804func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
805 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
806 request := &omci.GetAllAlarmsRequest{
807 MeBasePacket: omci.MeBasePacket{
808 EntityClass: me.OnuDataClassID,
809 },
810 AlarmRetrievalMode: byte(alarmRetreivalMode),
811 }
812 tid := oo.getNextTid(highPrio)
813 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
814 if err != nil {
815 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
816 "Err": err, "device-id": oo.deviceID})
817 return err
818 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000819 oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530820
821 omciRxCallbackPair := callbackPair{
822 cbKey: tid,
823 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
824 oo.receiveOmciResponse, true},
825 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000826 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530827}
828
829func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000830 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530831 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
832 "alarmUploadSeqNo": alarmUploadSeqNo})
833 request := &omci.GetAllAlarmsNextRequest{
834 MeBasePacket: omci.MeBasePacket{
835 EntityClass: me.OnuDataClassID,
836 },
837 CommandSequenceNumber: alarmUploadSeqNo,
838 }
839 tid := oo.getNextTid(highPrio)
840 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
841 if err != nil {
842 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
843 "Err": err, "device-id": oo.deviceID})
844 return err
845 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000846 oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530847
848 omciRxCallbackPair := callbackPair{
849 cbKey: tid,
850 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
851 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000852 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530853}
854
ozgecanetsiab36ed572021-04-01 10:38:48 +0300855func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530856 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000857 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000858 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000859
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000860 meParams := me.ParamData{
861 EntityID: galEthernetEID,
862 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
863 }
864 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
865 if omciErr.GetError() == nil {
866 //all setByCreate parameters already set, no default option required ...
867 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
868 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000869 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000870 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300871 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000872 }
873
dbainbri4d3a0dc2020-12-02 00:33:42 +0000874 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000875 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000876 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000877 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300878 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000879 }
880
Himani Chawla6d2ae152020-09-02 13:11:20 +0530881 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000882 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000883 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000884 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000885 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000886 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000887 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000888 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300889 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000890 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000891 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300892 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000893 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000894 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000895 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300896 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000897}
898
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000899// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
ozgecanetsiab36ed572021-04-01 10:38:48 +0300900func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530901 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000902 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000903 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000904
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000905 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
906 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907 // By now we just use fix values to fire - this is anyway what the python adapter does
908 // read ONU-2G from DB ???? //TODO!!!
909 meParams := me.ParamData{
910 EntityID: 0,
911 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
912 }
913 meInstance, omciErr := me.NewOnu2G(meParams)
914 if omciErr.GetError() == nil {
915 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
916 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000917 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000918 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300919 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000920 }
921
dbainbri4d3a0dc2020-12-02 00:33:42 +0000922 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000923 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000924 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000925 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300926 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000927 }
928
Himani Chawla6d2ae152020-09-02 13:11:20 +0530929 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000930 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000931 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000932 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000933 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000934 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000935 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000936 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300937 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000938 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000939 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300940 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000941 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000942 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000943 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300944 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000945}
946
Himani Chawla6d2ae152020-09-02 13:11:20 +0530947func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +0300948 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530949 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530950 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000951 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000952 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000953
954 meParams := me.ParamData{
955 EntityID: instID,
956 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300957 "Priority": 0x8000,
958 "MaxAge": 20 * 256, //20s
959 "HelloTime": 2 * 256, //2s
960 "ForwardDelay": 15 * 256, //15s
961 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000962 },
963 }
964
965 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
966 if omciErr.GetError() == nil {
967 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
968 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
969 omci.TransactionID(tid), omci.AddDefaults(true))
970 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000971 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000972 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300973 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000974 }
975
dbainbri4d3a0dc2020-12-02 00:33:42 +0000976 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000977 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000978 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000979 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300980 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000981 }
982
Himani Chawla6d2ae152020-09-02 13:11:20 +0530983 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000984 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000985 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000986 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000987 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000988 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000989 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000990 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300991 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000992 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000993 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300994 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000995 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000996 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000997 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300998 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000999}
1000
Mahir Gunyel6781f962021-05-16 23:30:08 -07001001func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001002 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301003 tid := oo.getNextTid(highPrio)
Mahir Gunyel6781f962021-05-16 23:30:08 -07001004 instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
1005 if idErr != nil {
1006 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1007 "Err": idErr, "device-id": oo.deviceID})
1008 return nil, idErr
1009 }
1010 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
1011 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.macBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001012
1013 meParams := me.ParamData{
1014 EntityID: instID,
1015 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +05301016 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
1017 "PortNum": aPUniPort.macBpNo,
1018 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +05301019 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001020 },
1021 }
1022 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1023 if omciErr.GetError() == nil {
1024 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1025 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1026 omci.TransactionID(tid), omci.AddDefaults(true))
1027 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001028 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001029 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001030 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001031 }
1032
dbainbri4d3a0dc2020-12-02 00:33:42 +00001033 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001034 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001035 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001036 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001037 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001038 }
1039
Himani Chawla6d2ae152020-09-02 13:11:20 +05301040 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001041 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001042 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001043 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001044 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001045 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001046 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001047 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001048 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001049 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001050 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001051 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001052 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001053 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001054 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001055 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001056}
1057
Himani Chawla6d2ae152020-09-02 13:11:20 +05301058func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001059 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301060 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001061 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301062 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001063 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001064 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001065
1066 // compare python adapter code WA VOL-1311: this is not done here!
1067 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1068 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1069 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301070 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001071 assType = uint8(10) // for VEIP
1072 }
1073 meParams := me.ParamData{
1074 EntityID: instID,
1075 Attributes: me.AttributeValueMap{
1076 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301077 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001078 },
1079 }
1080 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1081 if omciErr.GetError() == nil {
1082 //all setByCreate parameters already set, no default option required ...
1083 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1084 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001085 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001086 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001087 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001088 }
1089
dbainbri4d3a0dc2020-12-02 00:33:42 +00001090 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001091 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001092 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001093 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001094 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001095 }
1096
Himani Chawla6d2ae152020-09-02 13:11:20 +05301097 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001098 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001099 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001100 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001101 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001102 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001103 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001104 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001105 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001106 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001107 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001108 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001109 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001110 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001111 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001112 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001113}
1114
Himani Chawla6d2ae152020-09-02 13:11:20 +05301115func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001116 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301117 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001118 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001119 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001120
1121 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1122 meParams := me.ParamData{
1123 EntityID: 0,
1124 Attributes: requestedAttributes,
1125 }
1126 meInstance, omciErr := me.NewOnuG(meParams)
1127 if omciErr.GetError() == nil {
1128 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1129 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001130 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001131 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001132 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001133 }
1134
dbainbri4d3a0dc2020-12-02 00:33:42 +00001135 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001136 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001137 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001138 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001139 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001140 }
1141
Himani Chawla6d2ae152020-09-02 13:11:20 +05301142 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001143 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001144 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001145 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001146 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001147 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001148 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001149 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001150 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001151 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001152 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001153 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001154 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001155 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001156 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001157 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001158}
1159
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001160func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001161 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001162 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001163 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001164 "SequNo": strconv.FormatInt(int64(tid), 16)})
1165
1166 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1167 meParams := me.ParamData{
1168 EntityID: aInstNo,
1169 Attributes: requestedAttributes,
1170 }
1171 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1172 if omciErr.GetError() == nil {
1173 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1174 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001175 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001176 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001177 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001178 }
1179
dbainbri4d3a0dc2020-12-02 00:33:42 +00001180 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001181 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001182 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001183 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001184 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001185 }
1186
1187 omciRxCallbackPair := callbackPair{
1188 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001189 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001190 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001191 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001192 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001193 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001194 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001195 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001196 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001197 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001198 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001199 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001200 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001201 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001202 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001203}
1204
1205/* UniG obsolete by now, left here in case it should be needed once again
1206 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301207func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001208 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301209 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001210 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001211 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001212
1213 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1214 meParams := me.ParamData{
1215 EntityID: aInstNo,
1216 Attributes: requestedAttributes,
1217 }
1218 meInstance, omciErr := me.NewUniG(meParams)
1219 if omciErr.GetError() == nil {
1220 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1221 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001222 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001223 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001224 return nil
1225 }
1226
1227 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1228 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001229 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001230 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001231 return nil
1232 }
1233
Himani Chawla6d2ae152020-09-02 13:11:20 +05301234 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001235 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001236 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001237 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001238 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001239 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001240 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001241 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001242 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001243 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001245 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001246 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001247 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001248 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001249 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001251*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001252
Himani Chawla6d2ae152020-09-02 13:11:20 +05301253func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001254 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301255 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001256 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001257 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001258
1259 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1260 meParams := me.ParamData{
1261 EntityID: aInstNo,
1262 Attributes: requestedAttributes,
1263 }
1264 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1265 if omciErr.GetError() == nil {
1266 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1267 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001268 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001269 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001270 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001271 }
1272
dbainbri4d3a0dc2020-12-02 00:33:42 +00001273 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001274 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001276 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001277 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001278 }
1279
Himani Chawla6d2ae152020-09-02 13:11:20 +05301280 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001281 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001282 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001283 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001284 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001285 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001286 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001287 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001288 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001289 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001291 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001292 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001293 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001294 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001295 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001296}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001297
Himani Chawla6d2ae152020-09-02 13:11:20 +05301298func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001299 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001300
Himani Chawla6d2ae152020-09-02 13:11:20 +05301301 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001302 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001303 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001304
1305 meParams := me.ParamData{
1306 EntityID: entityID,
1307 Attributes: requestedAttributes,
1308 }
1309 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1310 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301311 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001312 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1313 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001314 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 +03001315 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001316 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001317 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001318 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001319 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001320 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001321 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301322 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001323 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001324 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001325 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001326 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001327 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001328 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001329 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001330 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001331 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001332 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001333 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001334 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001335 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001336}
1337
Himani Chawla6d2ae152020-09-02 13:11:20 +05301338func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001339 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301340 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001341 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001342 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1343
1344 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001345 EntityID: aInstID,
1346 Attributes: me.AttributeValueMap{
1347 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1348 "TpPointer": 0xFFFF,
1349 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1350 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1351 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1352 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1353 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1354 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1355 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1356 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1357 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001358 }
1359 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1360 if omciErr.GetError() == nil {
1361 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1362 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1363 omci.TransactionID(tid), omci.AddDefaults(true))
1364 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001365 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001366 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001367 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001368 }
1369
dbainbri4d3a0dc2020-12-02 00:33:42 +00001370 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001371 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001372 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001373 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001374 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001375 }
1376
Himani Chawla6d2ae152020-09-02 13:11:20 +05301377 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001379 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001380 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001381 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001382 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001383 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001384 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001385 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001386 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001387 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001388 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001389 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001390 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001391 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001392 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001393}
1394
Himani Chawla6d2ae152020-09-02 13:11:20 +05301395func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001396 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301397 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001398 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001399 "SequNo": strconv.FormatInt(int64(tid), 16),
1400 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1401
1402 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1403 if omciErr.GetError() == nil {
1404 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1405 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1406 omci.TransactionID(tid), omci.AddDefaults(true))
1407 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001408 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001409 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001410 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001411 }
1412
dbainbri4d3a0dc2020-12-02 00:33:42 +00001413 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001414 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001416 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001417 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001418 }
1419
Himani Chawla6d2ae152020-09-02 13:11:20 +05301420 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001422 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001423 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001424 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001426 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001427 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001428 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001429 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001431 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001432 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001434 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001435 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001436}
1437
Himani Chawla6d2ae152020-09-02 13:11:20 +05301438func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001439 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301440 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001441 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001442 "SequNo": strconv.FormatInt(int64(tid), 16),
1443 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1444
1445 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1446 if omciErr.GetError() == nil {
1447 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1448 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1449 omci.TransactionID(tid), omci.AddDefaults(true))
1450 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001451 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001452 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001453 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001454 }
1455
dbainbri4d3a0dc2020-12-02 00:33:42 +00001456 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001457 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001458 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001459 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001460 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001461 }
1462
Himani Chawla6d2ae152020-09-02 13:11:20 +05301463 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001464 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001465 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001467 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001468 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001469 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001470 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001471 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001472 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001473 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001474 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001475 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001476 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001477 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001478 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001479}
1480
Himani Chawla6d2ae152020-09-02 13:11:20 +05301481func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001482 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301483 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001484 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001485 "SequNo": strconv.FormatInt(int64(tid), 16),
1486 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1487
1488 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1489 if omciErr.GetError() == nil {
1490 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1491 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1492 omci.TransactionID(tid))
1493 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001494 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001495 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001496 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001497 }
1498
dbainbri4d3a0dc2020-12-02 00:33:42 +00001499 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001500 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001501 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001502 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001503 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001504 }
1505
Himani Chawla6d2ae152020-09-02 13:11:20 +05301506 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001507 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001508 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001509 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001510 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001511 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001512 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001513 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001514 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001515 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001516 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001517 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001518 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001519 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001520 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001521 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001522}
1523
Himani Chawla6d2ae152020-09-02 13:11:20 +05301524func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001525 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301526 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001527 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001528 "SequNo": strconv.FormatInt(int64(tid), 16),
1529 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1530
1531 meInstance, omciErr := me.NewTCont(params[0])
1532 if omciErr.GetError() == nil {
1533 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1534 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001535 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001536 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001537 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001538 }
1539
dbainbri4d3a0dc2020-12-02 00:33:42 +00001540 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001541 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001542 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001543 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001544 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001545 }
1546
Himani Chawla6d2ae152020-09-02 13:11:20 +05301547 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001548 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001549 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001550 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001551 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001552 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001553 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001554 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001555 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001556 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001557 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001558 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001559 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001560 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001561 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001562 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001563}
1564
Himani Chawla6d2ae152020-09-02 13:11:20 +05301565func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001566 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301567 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001568 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001569 "SequNo": strconv.FormatInt(int64(tid), 16),
1570 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1571
1572 meInstance, omciErr := me.NewPriorityQueue(params[0])
1573 if omciErr.GetError() == nil {
1574 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1575 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001576 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001577 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001578 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001579 }
1580
dbainbri4d3a0dc2020-12-02 00:33:42 +00001581 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001582 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001583 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001584 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001585 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001586 }
1587
Himani Chawla6d2ae152020-09-02 13:11:20 +05301588 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001589 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001590 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001591 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001592 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001593 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001594 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001595 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001596 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001597 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001598 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001599 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001600 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001601 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001602 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001603 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001604}
1605
Himani Chawla6d2ae152020-09-02 13:11:20 +05301606func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001607 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301608 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001609 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001610 "SequNo": strconv.FormatInt(int64(tid), 16),
1611 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1612
1613 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1614 if omciErr.GetError() == nil {
1615 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1616 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001617 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001618 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001619 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001620 }
1621
dbainbri4d3a0dc2020-12-02 00:33:42 +00001622 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001623 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001624 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001625 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001626 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001627 }
1628
Himani Chawla6d2ae152020-09-02 13:11:20 +05301629 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001630 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001631 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001632 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001633 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001634 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001635 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001636 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001637 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001638 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001639 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001640 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001641 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001642 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001643 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001644 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001645}
mpagenkodff5dda2020-08-28 11:52:01 +00001646
Himani Chawla6d2ae152020-09-02 13:11:20 +05301647func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001648 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301649 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001650 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001651 "SequNo": strconv.FormatInt(int64(tid), 16),
1652 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1653
1654 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1655 if omciErr.GetError() == nil {
1656 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1657 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1658 omci.TransactionID(tid))
1659 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001660 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001661 "Err": err, "device-id": oo.deviceID})
1662 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1663 // return (dual format) error code that can be used at caller for immediate error treatment
1664 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001665 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001666 }
1667
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001669 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001670 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001671 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001672 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001673 }
1674
Himani Chawla6d2ae152020-09-02 13:11:20 +05301675 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001676 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001677 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001678 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001679 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001680 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001681 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001682 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001683 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001684 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001685 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001686 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001687 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001688 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001689 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001690 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001691}
1692
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001693// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001694func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001695 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001696 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001697 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001698 "SequNo": strconv.FormatInt(int64(tid), 16),
1699 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1700
1701 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1702 if omciErr.GetError() == nil {
1703 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1704 omci.TransactionID(tid))
1705 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001706 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001707 "Err": err, "device-id": oo.deviceID})
1708 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1709 // return (dual format) error code that can be used at caller for immediate error treatment
1710 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001711 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001712 }
1713
dbainbri4d3a0dc2020-12-02 00:33:42 +00001714 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001715 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001716 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001717 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001718 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001719 }
1720
1721 omciRxCallbackPair := callbackPair{
1722 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001723 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001724 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001725 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001726 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001727 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001728 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001729 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001730 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001731 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001732 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001733 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001734 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001735 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001736 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001737}
1738
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001739func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001740 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001741 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001742 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001743 "SequNo": strconv.FormatInt(int64(tid), 16),
1744 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1745
1746 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1747 if omciErr.GetError() == nil {
1748 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1749 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001750 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001751 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001752 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001753 }
1754
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001756 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001757 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001758 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001759 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001760 }
1761
1762 omciRxCallbackPair := callbackPair{
1763 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001764 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001765 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001766 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001767 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001768 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001769 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001770 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001771 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001772 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001773 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001774 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001775 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001776 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001777 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001778}
1779
Himani Chawla6d2ae152020-09-02 13:11:20 +05301780func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001781 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301782 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001783 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001784 "SequNo": strconv.FormatInt(int64(tid), 16),
1785 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1786
1787 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1788 if omciErr.GetError() == nil {
1789 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1790 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001791 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001792 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001793 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001794 }
1795
dbainbri4d3a0dc2020-12-02 00:33:42 +00001796 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001797 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001798 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001799 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001800 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001801 }
1802
Himani Chawla6d2ae152020-09-02 13:11:20 +05301803 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001804 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001805 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001806 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001807 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001808 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001809 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001810 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001811 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001812 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001813 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001814 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001815 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001816 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001817 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001818 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001819}
mpagenko01e726e2020-10-23 09:45:29 +00001820
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001821func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001822 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001823 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001824 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001825 "SequNo": strconv.FormatInt(int64(tid), 16),
1826 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1827
1828 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1829 if omciErr.GetError() == nil {
1830 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1831 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001832 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001833 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001834 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001835 }
1836
dbainbri4d3a0dc2020-12-02 00:33:42 +00001837 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001838 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001839 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001840 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001841 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001842 }
1843
1844 omciRxCallbackPair := callbackPair{
1845 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001846 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001847 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001848 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001849 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001850 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001851 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001852 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001853 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001854 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001855 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001856 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001857 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001858 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001859 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001860}
1861
mpagenko01e726e2020-10-23 09:45:29 +00001862func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001863 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko01e726e2020-10-23 09:45:29 +00001864 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001865 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001866 "SequNo": strconv.FormatInt(int64(tid), 16),
1867 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1868
1869 meParams := me.ParamData{EntityID: aInstID}
1870 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1871 if omciErr.GetError() == nil {
1872 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1873 omci.TransactionID(tid))
1874 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001875 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001876 "Err": err, "device-id": oo.deviceID})
1877 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1878 // return (dual format) error code that can be used at caller for immediate error treatment
1879 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001880 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001881 }
1882
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001884 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001885 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001886 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001887 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001888 }
1889
1890 omciRxCallbackPair := callbackPair{
1891 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001892 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001893 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001894 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00001895 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001896 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001897 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001898 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001899 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001900 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001901 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00001902 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001903 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001904 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001905 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00001906}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001907
ozgecanetsiab6441962021-03-10 10:58:48 +03001908// nolint: unused
1909func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001910 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001911 tid := oo.getNextTid(highPrio)
1912 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1913 "SequNo": strconv.FormatInt(int64(tid), 16),
1914 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1915 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1916 if omciErr.GetError() == nil {
1917 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1918 if err != nil {
1919 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001920 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001921 }
1922 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1923 if err != nil {
1924 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001925 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001926 }
1927 omciRxCallbackPair := callbackPair{
1928 cbKey: tid,
1929 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1930 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001931 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001932 if err != nil {
1933 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001934 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001935 }
1936 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001937 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001938 }
1939 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001940 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001941}
1942
1943// nolint: unused
1944func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001945 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001946 tid := oo.getNextTid(highPrio)
1947 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1948 "SequNo": strconv.FormatInt(int64(tid), 16),
1949 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1950
1951 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1952 if omciErr.GetError() == nil {
1953 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1954 if err != nil {
1955 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001956 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001957 }
1958 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1959 if err != nil {
1960 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001961 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001962 }
1963 omciRxCallbackPair := callbackPair{
1964 cbKey: tid,
1965 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1966 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001967 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001968 if err != nil {
1969 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001970 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001971 }
1972 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001973 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001974 }
1975 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001976 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001977
1978}
1979
1980// nolint: unused
1981func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001982 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001983 tid := oo.getNextTid(highPrio)
1984 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1985 "SequNo": strconv.FormatInt(int64(tid), 16),
1986 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1987
1988 meParams := me.ParamData{EntityID: aInstID}
1989 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1990 if omciErr.GetError() == nil {
1991 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1992 if err != nil {
1993 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001994 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001995 }
1996 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1997 if err != nil {
1998 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001999 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002000 }
2001 omciRxCallbackPair := callbackPair{
2002 cbKey: tid,
2003 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2004 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002005 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002006 if err != nil {
2007 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002008 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002009 }
2010 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002011 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002012 }
2013 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002014 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002015
2016}
2017
mpagenko8b07c1b2020-11-26 10:36:31 +00002018func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002019 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002020 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002021 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002022 "SequNo": strconv.FormatInt(int64(tid), 16),
2023 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2024
2025 meParams := me.ParamData{EntityID: aInstID}
2026 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2027 if omciErr.GetError() == nil {
2028 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2029 omci.TransactionID(tid))
2030 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002031 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002032 "Err": err, "device-id": oo.deviceID})
2033 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2034 // return (dual format) error code that can be used at caller for immediate error treatment
2035 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002036 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002037 }
2038
dbainbri4d3a0dc2020-12-02 00:33:42 +00002039 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002040 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002041 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002042 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002043 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002044 }
2045
2046 omciRxCallbackPair := callbackPair{
2047 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002048 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002049 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002050 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002051 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002052 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002053 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002054 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002055 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002056 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002057 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002058 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002059 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002060 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002061 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002062}
2063
2064func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002065 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002066 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002067 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002068 "SequNo": strconv.FormatInt(int64(tid), 16),
2069 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2070
2071 meParams := me.ParamData{EntityID: aInstID}
2072 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2073 if omciErr.GetError() == nil {
2074 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2075 omci.TransactionID(tid))
2076 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002077 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002078 "Err": err, "device-id": oo.deviceID})
2079 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2080 // return (dual format) error code that can be used at caller for immediate error treatment
2081 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002082 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002083 }
2084
dbainbri4d3a0dc2020-12-02 00:33:42 +00002085 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002086 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002087 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002088 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002089 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002090 }
2091
2092 omciRxCallbackPair := callbackPair{
2093 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002094 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002095 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002096 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002097 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002098 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002099 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002100 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002101 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002102 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002103 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002104 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002105 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002106 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002107 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002108}
2109
2110func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002111 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002112 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002113 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002114 "SequNo": strconv.FormatInt(int64(tid), 16),
2115 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2116
2117 meParams := me.ParamData{EntityID: aInstID}
2118 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2119 if omciErr.GetError() == nil {
2120 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2121 omci.TransactionID(tid))
2122 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002123 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002124 "Err": err, "device-id": oo.deviceID})
2125 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2126 // return (dual format) error code that can be used at caller for immediate error treatment
2127 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002128 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002129 }
2130
dbainbri4d3a0dc2020-12-02 00:33:42 +00002131 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002132 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002133 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002134 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002135 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002136 }
2137
2138 omciRxCallbackPair := callbackPair{
2139 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002140 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002141 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002142 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002143 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002144 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002145 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002146 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002147 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002148 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002149 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002150 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002151 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002152 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002153 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002154}
2155
2156func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002157 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002158 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002159 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002160 "SequNo": strconv.FormatInt(int64(tid), 16),
2161 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2162
2163 meParams := me.ParamData{EntityID: aInstID}
2164 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2165 if omciErr.GetError() == nil {
2166 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2167 omci.TransactionID(tid))
2168 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002169 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002170 "Err": err, "device-id": oo.deviceID})
2171 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2172 // return (dual format) error code that can be used at caller for immediate error treatment
2173 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002174 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002175 }
2176
dbainbri4d3a0dc2020-12-02 00:33:42 +00002177 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002178 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002179 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002180 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002181 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002182 }
2183
2184 omciRxCallbackPair := callbackPair{
2185 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002186 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002187 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002188 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002189 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002190 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002191 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002192 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002193 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002194 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002195 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002196 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002197 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002198 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002199 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002200}
2201
ozgecanetsia422dbf32020-10-28 14:07:19 +03002202func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002203 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002204 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002205 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002206 "SequNo": strconv.FormatInt(int64(tid), 16),
2207 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2208
2209 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2210 if omciErr.GetError() == nil {
2211 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2212 omci.AddDefaults(true))
2213 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002214 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002215 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002216 }
2217
dbainbri4d3a0dc2020-12-02 00:33:42 +00002218 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002219 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002220 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002221 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002222 }
2223
2224 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002225 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002226 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002227 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002228 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002229 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002230 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002231 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002232 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002233 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002234 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002235 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002236 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002237 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002238}
2239
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002240func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002242 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002243 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002244 "SequNo": strconv.FormatInt(int64(tid), 16),
2245 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2246
2247 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2248 if omciErr.GetError() == nil {
2249 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2250 omci.AddDefaults(true))
2251 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002252 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002253 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002254 }
2255
dbainbri4d3a0dc2020-12-02 00:33:42 +00002256 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002257 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002258 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002259 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002260 }
2261
2262 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002263 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002264 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002265 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002266 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002267 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002268 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002269 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002270 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002271 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002272 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002273 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002274 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002275 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002276}
2277
ozgecanetsia422dbf32020-10-28 14:07:19 +03002278func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002279 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002280 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002281 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002282 "SequNo": strconv.FormatInt(int64(tid), 16),
2283 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2284
2285 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2286 if omciErr.GetError() == nil {
2287 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2288 omci.AddDefaults(true))
2289 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002290 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002291 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002292 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002293 }
2294
dbainbri4d3a0dc2020-12-02 00:33:42 +00002295 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002296 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002297 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002298 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002299 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002300 }
2301
2302 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002303 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002304 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002305 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002306 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002307 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002308 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002309 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002310 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002311 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002312 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002313 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002314 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002315 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002316 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002317}
2318
2319func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002320 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002321 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002322 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002323 "SequNo": strconv.FormatInt(int64(tid), 16),
2324 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2325
2326 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2327 if omciErr.GetError() == nil {
2328 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2329 omci.AddDefaults(true))
2330 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002331 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002332 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002333 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002334 }
2335
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002337 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002338 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002339 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002340 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002341 }
2342
2343 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002344 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002345 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002346 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002347 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002348 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002349 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002350 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002351 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002352 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002353 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002354 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002355 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002356 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002357 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002358}
2359
2360func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002361 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002362 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002363 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002364 "SequNo": strconv.FormatInt(int64(tid), 16),
2365 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2366
2367 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2368 if omciErr.GetError() == nil {
2369 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2370 omci.AddDefaults(true))
2371 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002372 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002373 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002374 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002375 }
2376
dbainbri4d3a0dc2020-12-02 00:33:42 +00002377 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002378 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002379 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002380 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002381 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002382 }
2383
2384 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002385 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002386 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002387 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002388 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002389 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002390 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002391 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002392 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002393 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002394 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002395 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002396 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002397 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002398 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002399}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002400
Girish Gowdrae0140f02021-02-02 16:55:09 -08002401func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2402 tid := oo.getNextTid(highPrio)
2403 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2404 "SequNo": strconv.FormatInt(int64(tid), 16)})
2405
2406 omciLayer := &omci.OMCI{
2407 TransactionID: tid,
2408 MessageType: omci.SynchronizeTimeRequestType,
2409 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2410 // Length: 0x28, // Optional, defaults to 40 octets
2411 }
2412 utcTime := time.Now().UTC()
2413 request := &omci.SynchronizeTimeRequest{
2414 MeBasePacket: omci.MeBasePacket{
2415 EntityClass: me.OnuGClassID,
2416 // Default Instance ID is 0
2417 },
2418 Year: uint16(utcTime.Year()),
2419 Month: uint8(utcTime.Month()),
2420 Day: uint8(utcTime.Day()),
2421 Hour: uint8(utcTime.Hour()),
2422 Minute: uint8(utcTime.Minute()),
2423 Second: uint8(utcTime.Second()),
2424 }
2425
2426 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2427 if err != nil {
2428 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2429 "device-id": oo.deviceID})
2430 return err
2431 }
2432
2433 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002434 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002435 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002436 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002437 if err != nil {
2438 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2439 "device-id": oo.deviceID})
2440 return err
2441 }
2442 logger.Debug(ctx, "send synchronize time request done")
2443 return nil
2444}
2445
2446func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002447 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002448 tid := oo.getNextTid(highPrio)
2449 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2450 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2451 meParam := me.ParamData{EntityID: entityID}
2452 var meInstance *me.ManagedEntity
2453 var omciErr me.OmciErrors
2454 if upstream {
2455 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2456 } else {
2457 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2458 }
2459 if omciErr.GetError() == nil {
2460 var omciLayer *omci.OMCI
2461 var msgLayer gopacket.SerializableLayer
2462 var err error
2463 if create {
2464 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2465 omci.AddDefaults(true))
2466 } else {
2467 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2468 omci.AddDefaults(true))
2469 }
2470 if err != nil {
2471 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2472 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002473 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002474 }
2475
2476 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2477 if err != nil {
2478 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2479 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002480 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002481 }
2482
2483 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002484 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002485 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002486 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002487 if err != nil {
2488 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2489 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002490 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002491 }
2492 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2493 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002494 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002495 }
2496 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2497 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 +03002498 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002499}
2500
2501func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002502 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002503 tid := oo.getNextTid(highPrio)
2504 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2505 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2506 meParam := me.ParamData{EntityID: entityID}
2507 var meInstance *me.ManagedEntity
2508 var omciErr me.OmciErrors
2509 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2510
2511 if omciErr.GetError() == nil {
2512 var omciLayer *omci.OMCI
2513 var msgLayer gopacket.SerializableLayer
2514 var err error
2515 if create {
2516 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2517 omci.AddDefaults(true))
2518 } else {
2519 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2520 omci.AddDefaults(true))
2521 }
2522 if err != nil {
2523 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2524 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002525 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002526 }
2527
2528 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2529 if err != nil {
2530 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2531 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002532 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002533 }
2534
2535 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002536 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002537 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002538 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002539 if err != nil {
2540 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2541 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002542 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002543 }
2544 logger.Debugw(ctx, "send ethernet uni history data ME done",
2545 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002546 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002547 }
2548 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2549 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002550 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002551}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002552
2553func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002554 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002555 tid := oo.getNextTid(highPrio)
2556 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2557 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2558 meParam := me.ParamData{EntityID: entityID}
2559 var meInstance *me.ManagedEntity
2560 var omciErr me.OmciErrors
2561 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2562
2563 if omciErr.GetError() == nil {
2564 var omciLayer *omci.OMCI
2565 var msgLayer gopacket.SerializableLayer
2566 var err error
2567 if create {
2568 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2569 omci.AddDefaults(true))
2570 } else {
2571 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2572 omci.AddDefaults(true))
2573 }
2574 if err != nil {
2575 logger.Errorw(ctx, "Cannot encode fec history data ME",
2576 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002577 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002578 }
2579
2580 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2581 if err != nil {
2582 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2583 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002584 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002585 }
2586
2587 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002588 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002589 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002590 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002591 if err != nil {
2592 logger.Errorw(ctx, "Cannot send fec history data ME",
2593 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002594 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002595 }
2596 logger.Debugw(ctx, "send fec history data ME done",
2597 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002598 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002599 }
2600 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2601 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002602 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002603}
2604
2605func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002606 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002607 tid := oo.getNextTid(highPrio)
2608 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2609 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2610 meParam := me.ParamData{EntityID: entityID}
2611 var meInstance *me.ManagedEntity
2612 var omciErr me.OmciErrors
2613 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2614
2615 if omciErr.GetError() == nil {
2616 var omciLayer *omci.OMCI
2617 var msgLayer gopacket.SerializableLayer
2618 var err error
2619 if create {
2620 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2621 omci.AddDefaults(true))
2622 } else {
2623 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2624 omci.AddDefaults(true))
2625 }
2626 if err != nil {
2627 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2628 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002629 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002630 }
2631
2632 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2633 if err != nil {
2634 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2635 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002636 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002637 }
2638
2639 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002640 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002641 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002642 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002643 if err != nil {
2644 logger.Errorw(ctx, "Cannot send gemport history data ME",
2645 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002646 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002647 }
2648 logger.Debugw(ctx, "send gemport history data ME done",
2649 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002650 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002651 }
2652 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2653 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002654 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002655}
2656
mpagenko80622a52021-02-09 16:53:23 +00002657func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2658 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2659 tid := oo.getNextTid(highPrio)
2660 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2661 "SequNo": strconv.FormatInt(int64(tid), 16),
2662 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2663
2664 omciLayer := &omci.OMCI{
2665 TransactionID: tid,
2666 MessageType: omci.StartSoftwareDownloadRequestType,
2667 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2668 // Length: 0x28, // Optional, defaults to 40 octets
2669 }
2670 request := &omci.StartSoftwareDownloadRequest{
2671 MeBasePacket: omci.MeBasePacket{
2672 EntityClass: me.SoftwareImageClassID,
2673 EntityInstance: aImageMeID, //inactive image
2674 },
2675 WindowSize: aDownloadWindowSize,
2676 ImageSize: aFileLen,
2677 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2678 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2679 }
2680
2681 var options gopacket.SerializeOptions
2682 options.FixLengths = true
2683 buffer := gopacket.NewSerializeBuffer()
2684 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2685 if err != nil {
2686 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2687 "device-id": oo.deviceID})
2688 return err
2689 }
2690 outgoingPacket := buffer.Bytes()
2691
2692 omciRxCallbackPair := callbackPair{cbKey: tid,
2693 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2694 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002695 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002696 if err != nil {
2697 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2698 "device-id": oo.deviceID})
2699 return err
2700 }
2701 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002702 return nil
2703}
2704
mpagenkoc26d4c02021-05-06 14:27:57 +00002705func (oo *omciCC) sendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002706 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2707 tid := oo.getNextTid(highPrio)
2708 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2709 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002710 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002711
2712 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2713 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002714 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00002715 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00002716 if aAckRequest > 0 {
2717 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00002718 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00002719 }
mpagenko80622a52021-02-09 16:53:23 +00002720 omciLayer := &omci.OMCI{
2721 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002722 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002723 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2724 // Length: 0x28, // Optional, defaults to 40 octets
2725 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002726 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002727 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002728 request := &omci.DownloadSectionRequest{
2729 MeBasePacket: omci.MeBasePacket{
2730 EntityClass: me.SoftwareImageClassID,
2731 EntityInstance: aImageMeID, //inactive image
2732 },
2733 SectionNumber: aDownloadSectionNo,
2734 SectionData: localSectionData,
2735 }
2736
2737 var options gopacket.SerializeOptions
2738 options.FixLengths = true
2739 buffer := gopacket.NewSerializeBuffer()
2740 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2741 if err != nil {
2742 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2743 "device-id": oo.deviceID})
2744 return err
2745 }
2746 outgoingPacket := buffer.Bytes()
2747
mpagenko15ff4a52021-03-02 10:09:20 +00002748 //for initial debug purpose overrule the requested print state for some frames
2749 printFrame := aPrint
2750 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2751 printFrame = true
2752 }
2753
mpagenko80622a52021-02-09 16:53:23 +00002754 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00002755 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
2756 // (used to avoid retransmission of frames with the same TID)
mpagenko15ff4a52021-03-02 10:09:20 +00002757 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002758 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002759 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002760 if err != nil {
2761 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2762 "device-id": oo.deviceID})
2763 return err
2764 }
2765 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002766 return nil
2767}
2768
2769func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2770 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2771 tid := oo.getNextTid(highPrio)
2772 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2773 "SequNo": strconv.FormatInt(int64(tid), 16),
2774 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2775
mpagenko15ff4a52021-03-02 10:09:20 +00002776 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002777 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002778 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002779 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2780 // Length: 0x28, // Optional, defaults to 40 octets
2781 }
mpagenko15ff4a52021-03-02 10:09:20 +00002782 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002783 MeBasePacket: omci.MeBasePacket{
2784 EntityClass: me.SoftwareImageClassID,
2785 EntityInstance: aImageMeID, //inactive image
2786 },
mpagenko15ff4a52021-03-02 10:09:20 +00002787 CRC32: aImageCrc,
2788 ImageSize: aFileLen,
2789 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2790 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002791 }
mpagenko15ff4a52021-03-02 10:09:20 +00002792
2793 var options gopacket.SerializeOptions
2794 options.FixLengths = true
2795 buffer := gopacket.NewSerializeBuffer()
2796 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2797 if err != nil {
2798 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002799 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002800 return err
mpagenko80622a52021-02-09 16:53:23 +00002801 }
mpagenko15ff4a52021-03-02 10:09:20 +00002802 outgoingPacket := buffer.Bytes()
2803
2804 omciRxCallbackPair := callbackPair{cbKey: tid,
2805 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2806 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002807 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002808 if err != nil {
2809 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2810 "device-id": oo.deviceID})
2811 return err
2812 }
2813 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002814 return nil
2815}
2816
2817func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2818 rxChan chan Message, aImageMeID uint16) error {
2819 tid := oo.getNextTid(highPrio)
2820 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2821 "SequNo": strconv.FormatInt(int64(tid), 16),
2822 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2823
2824 omciLayer := &omci.OMCI{
2825 TransactionID: tid,
2826 MessageType: omci.ActivateSoftwareRequestType,
2827 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2828 // Length: 0x28, // Optional, defaults to 40 octets
2829 }
2830 request := &omci.ActivateSoftwareRequest{
2831 MeBasePacket: omci.MeBasePacket{
2832 EntityClass: me.SoftwareImageClassID,
2833 EntityInstance: aImageMeID, //inactive image
2834 },
2835 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2836 }
2837
2838 var options gopacket.SerializeOptions
2839 options.FixLengths = true
2840 buffer := gopacket.NewSerializeBuffer()
2841 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2842 if err != nil {
2843 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2844 "device-id": oo.deviceID})
2845 return err
2846 }
2847 outgoingPacket := buffer.Bytes()
2848
2849 omciRxCallbackPair := callbackPair{cbKey: tid,
2850 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2851 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002852 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002853 if err != nil {
2854 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2855 "device-id": oo.deviceID})
2856 return err
2857 }
2858 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002859 return nil
2860}
mpagenko80622a52021-02-09 16:53:23 +00002861
mpagenko15ff4a52021-03-02 10:09:20 +00002862func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2863 rxChan chan Message, aImageMeID uint16) error {
2864 tid := oo.getNextTid(highPrio)
2865 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2866 "SequNo": strconv.FormatInt(int64(tid), 16),
2867 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2868
2869 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002870 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002871 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002872 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2873 // Length: 0x28, // Optional, defaults to 40 octets
2874 }
mpagenko15ff4a52021-03-02 10:09:20 +00002875 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002876 MeBasePacket: omci.MeBasePacket{
2877 EntityClass: me.SoftwareImageClassID,
2878 EntityInstance: aImageMeID, //inactive image
2879 },
mpagenko80622a52021-02-09 16:53:23 +00002880 }
mpagenko15ff4a52021-03-02 10:09:20 +00002881
2882 var options gopacket.SerializeOptions
2883 options.FixLengths = true
2884 buffer := gopacket.NewSerializeBuffer()
2885 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2886 if err != nil {
2887 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002888 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002889 return err
mpagenko80622a52021-02-09 16:53:23 +00002890 }
mpagenko15ff4a52021-03-02 10:09:20 +00002891 outgoingPacket := buffer.Bytes()
2892
2893 omciRxCallbackPair := callbackPair{cbKey: tid,
2894 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2895 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002896 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002897 if err != nil {
2898 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2899 "device-id": oo.deviceID})
2900 return err
2901 }
2902 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002903 return nil
2904}
2905
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002906func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
2907 tid := oo.getNextTid(highPrio)
2908 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
2909 "SequNo": strconv.FormatInt(int64(tid), 16),
2910 "InstId": strconv.FormatInt(int64(instdID), 16)})
2911 omciLayer := &omci.OMCI{
2912 TransactionID: tid,
2913 MessageType: omci.TestRequestType,
2914 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2915 // Length: 0x28, // Optional, defaults to 40 octets
2916 }
2917
2918 var request *omci.OpticalLineSupervisionTestRequest
2919 switch classID {
2920 case aniGClassID:
2921 request = &omci.OpticalLineSupervisionTestRequest{
2922 MeBasePacket: omci.MeBasePacket{
2923 EntityClass: classID,
2924 EntityInstance: instdID,
2925 },
2926 SelectTest: uint8(7), // self test
2927 GeneralPurposeBuffer: uint16(0),
2928 VendorSpecificParameters: uint16(0),
2929 }
2930 default:
2931 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
2932 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
2933 }
2934 // Test serialization back to former string
2935 var options gopacket.SerializeOptions
2936 options.FixLengths = true
2937
2938 buffer := gopacket.NewSerializeBuffer()
2939 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2940 if err != nil {
2941 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
2942 "device-id": oo.deviceID})
2943 return err
2944 }
2945 outgoingPacket := buffer.Bytes()
2946
2947 omciRxCallbackPair := callbackPair{cbKey: tid,
2948 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2949 }
2950 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2951 if err != nil {
2952 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
2953 "device-id": oo.deviceID})
2954 return err
2955 }
2956 logger.Debug(ctx, "send self test request done")
2957 return nil
2958}
2959
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002960//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002961func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002962 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002963 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002964 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002965 msgLayer := (*packet).Layer(nextLayer)
2966 switch nextLayer {
2967 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002968 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
2969 if resp.Result == me.Success {
2970 return true
2971 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002972 }
2973 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002974 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
2975 if resp.Result == me.Success {
2976 return true
2977 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002978 }
2979 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002980 if resp := msgLayer.(*omci.SetResponse); resp != nil {
2981 if resp.Result == me.Success {
2982 return true
2983 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002984 }
2985 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002986 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
2987 if resp.Result == me.Success {
2988 return true
2989 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002990 }
2991 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002992 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
2993 if resp.Result == me.Success {
2994 return true
2995 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002996 }
2997 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002998 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
2999 if resp.Result == me.Success {
3000 return true
3001 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003002 }
3003 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003004 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
3005 if resp.Result == me.Success {
3006 return true
3007 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003008 }
3009 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003010 }
3011 }
3012 return false
3013}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003014
3015func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003016 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00003017 if timeout == 0 {
3018 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003019 oo.mutexTxQueue.Lock()
3020 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3021 oo.mutexTxQueue.Unlock()
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003022 go oo.sendNextRequest(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00003023 } else {
mpagenko7455fd42021-06-10 16:25:55 +00003024 //the supervised sending with waiting on the response (based on TID) is called in background
3025 // to avoid blocking of the sender for the complete OMCI handshake procedure
3026 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
3027 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
3028 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003029 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003030}
3031
mpagenko7455fd42021-06-10 16:25:55 +00003032func (oo *omciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest omciTransferStructure, aTimeout int) {
3033 chSuccess := make(chan bool)
3034 aOmciTxRequest.chSuccess = chSuccess
3035 tid := aOmciTxRequest.cbPair.cbKey
3036 oo.mutexMonReq.Lock()
3037 oo.monitoredRequests[tid] = aOmciTxRequest
3038 oo.mutexMonReq.Unlock()
3039
3040 retries := aOmciTxRequest.retries
3041 retryCounter := 0
3042loop:
3043 for retryCounter <= retries {
3044
3045 oo.mutexTxQueue.Lock()
3046 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3047 oo.mutexTxQueue.Unlock()
3048 go oo.sendNextRequest(ctx)
3049
3050 select {
3051 case success := <-chSuccess:
3052 if success {
3053 logger.Debugw(ctx, "reqMon: response received in time",
3054 log.Fields{"tid": tid, "device-id": oo.deviceID})
3055 } else {
3056 logger.Debugw(ctx, "reqMon: wait for response aborted",
3057 log.Fields{"tid": tid, "device-id": oo.deviceID})
3058 }
3059 break loop
3060 case <-time.After(time.Duration(aTimeout) * time.Second):
3061 if retryCounter == retries {
3062 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
3063 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3064 break loop
3065 } else {
3066 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
3067 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3068 }
3069 }
3070 retryCounter++
3071 }
3072 oo.mutexMonReq.Lock()
3073 delete(oo.monitoredRequests, tid)
3074 oo.mutexMonReq.Unlock()
3075}
3076
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003077//CancelRequestMonitoring terminates monitoring of outstanding omci requests
3078func (oo *omciCC) CancelRequestMonitoring() {
3079 oo.mutexMonReq.RLock()
3080 for k := range oo.monitoredRequests {
3081 oo.monitoredRequests[k].chSuccess <- false
3082 }
3083 oo.mutexMonReq.RUnlock()
3084}
3085
3086//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
3087//time consumed for retry processing of a particular OMCI-request
3088func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
3089 return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
3090}