blob: 649b58f31a1a01ca3af9d1a8279a07ede7d83b3f [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 {
513 go oo.processRequestMonitoring(ctx, omciTxRequest)
514 return nil
515 }
516 logger.Errorw(ctx, "A message with this tid is processed already!",
517 log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
518 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000519}
520
521//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530522func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000523 // return errors.New("sendNextRequest unimplemented")
524
525 // just try to get something transferred !!
526 // avoid accessing the txQueue from parallel send requests
527 // block parallel omci send requests at least until SendIAP is 'committed'
528 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
529 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000530 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000531 for oo.txQueue.Len() > 0 {
532 queueElement := oo.txQueue.Front() // First element
533 omciTxRequest := queueElement.Value.(omciTransferStructure)
534 /* compare olt device handler code:
535 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000536 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000537 var deviceType string
538 var deviceID string
539 var proxyDeviceID string
540
541 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
542
543 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
544
dbainbri4d3a0dc2020-12-02 00:33:42 +0000545 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 +0000546 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
547 kwargs := make(map[string]interface{})
548 kwargs["onu_id"] = omciInd.OnuId
549 kwargs["parent_port_no"] = ponPort
550
dbainbri4d3a0dc2020-12-02 00:33:42 +0000551 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000552 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000553 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554 return
555 }
556 deviceType = onuDevice.Type
557 deviceID = onuDevice.Id
558 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
559 //if not exist in cache, then add to cache.
560 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
561 } else {
562 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000563 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 +0000564 deviceType = onuInCache.(*OnuDevice).deviceType
565 deviceID = onuInCache.(*OnuDevice).deviceID
566 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
567 }
568 */
569 /* and compare onu_adapter py code:
570 omci_msg = InterAdapterOmciMessage(
571 message=bytes(frame),
572 proxy_address=self._proxy_address,
573 connect_status=self._device.connect_status)
574
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000575 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000576
577 yield self._adapter_proxy.send_inter_adapter_message(
578 msg=omci_msg,
579 type=InterAdapterMessageType.OMCI_REQUEST,
580 from_adapter=self._device.type,
581 to_adapter=self._proxy_address.device_type,
582 to_device_id=self._device_id,
583 proxy_device_id=self._proxy_address.device_id
584 )
585 */
mpagenko80622a52021-02-09 16:53:23 +0000586 if omciTxRequest.withFramePrint {
587 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
588 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
589 "device-id": oo.deviceID,
590 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
591 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
592 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000593 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000594 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000595 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800596 //fromTopic,toType,toDevId, ProxyDevId
597 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000598 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000599 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000600 return sendErr
601 }
602 oo.txQueue.Remove(queueElement) // Dequeue
603 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 return nil
605}
606
Himani Chawla6d2ae152020-09-02 13:11:20 +0530607func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000608 var next uint16
609 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000610 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000611 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530612 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000613 if oo.hpTid < 0x8000 {
614 oo.hpTid = 0x8000
615 }
mpagenko900ee4b2020-10-12 11:56:34 +0000616 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000617 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000618 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530620 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000621 if oo.tid >= 0x8000 {
622 oo.tid = 1
623 }
mpagenko900ee4b2020-10-12 11:56:34 +0000624 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000625 }
626 return next
627}
628
629// ###################################################################################
630// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000631func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000632 omciLayer := &omci.OMCI{
633 TransactionID: tid,
634 MessageType: msgType,
635 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000636 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000637}
638
dbainbri4d3a0dc2020-12-02 00:33:42 +0000639func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000640 var options gopacket.SerializeOptions
641 options.FixLengths = true
642
643 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530644 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000645 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000646 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000647 return nil, err
648 }
649 return buffer.Bytes(), nil
650}
651
Himani Chawla4d908332020-08-31 12:30:20 +0530652/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000653func hexEncode(omciPkt []byte) ([]byte, error) {
654 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
655 hex.Encode(dst, omciPkt)
656 return dst, nil
657}
Himani Chawla4d908332020-08-31 12:30:20 +0530658*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000659
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000660//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000661func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662
dbainbri4d3a0dc2020-12-02 00:33:42 +0000663 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000664 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000665
666 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000667 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000668 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200669 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000670 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000671 oo.mutexMonReq.RLock()
672 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
673 oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
674 } else {
675 logger.Infow(ctx, "reqMon: map entry does not exist!",
676 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
677 }
678 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000679
680 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
681 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000682 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000683 Type: OMCI,
684 Data: OmciMessage{
685 OmciMsg: omciMsg,
686 OmciPacket: packet,
687 },
688 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000689 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000690 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000691
692 return nil
693}
694
Himani Chawla6d2ae152020-09-02 13:11:20 +0530695func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000696
dbainbri4d3a0dc2020-12-02 00:33:42 +0000697 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000698 request := &omci.MibResetRequest{
699 MeBasePacket: omci.MeBasePacket{
700 EntityClass: me.OnuDataClassID,
701 },
702 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530703 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000704 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000705 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000707 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000708 return err
709 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530710 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000711 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000712 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000713 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000714 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000715}
716
Himani Chawla6d2ae152020-09-02 13:11:20 +0530717func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000718 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300719 request := &omci.RebootRequest{
720 MeBasePacket: omci.MeBasePacket{
721 EntityClass: me.OnuGClassID,
722 },
723 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530724 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000725 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300726 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000727 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000728 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300729 return err
730 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530731 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300732 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000733 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300734 }
735
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000736 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300737 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000738 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000739 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300740 return err
741 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000742 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300743 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000744 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200745 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300746 return err
747 }
748 return nil
749}
750
Himani Chawla6d2ae152020-09-02 13:11:20 +0530751func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000752 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000753 request := &omci.MibUploadRequest{
754 MeBasePacket: omci.MeBasePacket{
755 EntityClass: me.OnuDataClassID,
756 },
757 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530758 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000759 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000760 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000761 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000762 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000763 return err
764 }
765 oo.uploadSequNo = 0
766 oo.uploadNoOfCmds = 0
767
Himani Chawla6d2ae152020-09-02 13:11:20 +0530768 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000769 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000770 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000771 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000772 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000773}
774
Himani Chawla6d2ae152020-09-02 13:11:20 +0530775func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000776 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000777 request := &omci.MibUploadNextRequest{
778 MeBasePacket: omci.MeBasePacket{
779 EntityClass: me.OnuDataClassID,
780 },
781 CommandSequenceNumber: oo.uploadSequNo,
782 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530783 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000784 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000785 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000786 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000787 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000788 return err
789 }
790 oo.uploadSequNo++
791
Himani Chawla6d2ae152020-09-02 13:11:20 +0530792 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000793 cbKey: tid,
794 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
795 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
796 // compare also software upgrade download section handling
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000797 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000798 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000799 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000800}
801
Himani Chawlad3dac422021-03-13 02:31:31 +0530802func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
803 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
804 request := &omci.GetAllAlarmsRequest{
805 MeBasePacket: omci.MeBasePacket{
806 EntityClass: me.OnuDataClassID,
807 },
808 AlarmRetrievalMode: byte(alarmRetreivalMode),
809 }
810 tid := oo.getNextTid(highPrio)
811 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
812 if err != nil {
813 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
814 "Err": err, "device-id": oo.deviceID})
815 return err
816 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000817 oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530818
819 omciRxCallbackPair := callbackPair{
820 cbKey: tid,
821 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
822 oo.receiveOmciResponse, true},
823 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000824 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530825}
826
827func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000828 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530829 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
830 "alarmUploadSeqNo": alarmUploadSeqNo})
831 request := &omci.GetAllAlarmsNextRequest{
832 MeBasePacket: omci.MeBasePacket{
833 EntityClass: me.OnuDataClassID,
834 },
835 CommandSequenceNumber: alarmUploadSeqNo,
836 }
837 tid := oo.getNextTid(highPrio)
838 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
839 if err != nil {
840 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
841 "Err": err, "device-id": oo.deviceID})
842 return err
843 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000844 oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530845
846 omciRxCallbackPair := callbackPair{
847 cbKey: tid,
848 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
849 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000850 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530851}
852
ozgecanetsiab36ed572021-04-01 10:38:48 +0300853func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530854 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000855 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000856 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000857
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000858 meParams := me.ParamData{
859 EntityID: galEthernetEID,
860 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
861 }
862 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
863 if omciErr.GetError() == nil {
864 //all setByCreate parameters already set, no default option required ...
865 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
866 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000867 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000868 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300869 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000870 }
871
dbainbri4d3a0dc2020-12-02 00:33:42 +0000872 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000873 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000874 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000875 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300876 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000877 }
878
Himani Chawla6d2ae152020-09-02 13:11:20 +0530879 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000880 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000881 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000882 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000883 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000884 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000885 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000886 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300887 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000888 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000889 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300890 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000891 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000892 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000893 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300894 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000895}
896
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000897// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
ozgecanetsiab36ed572021-04-01 10:38:48 +0300898func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530899 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000900 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000901 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000902
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000903 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
904 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000905 // By now we just use fix values to fire - this is anyway what the python adapter does
906 // read ONU-2G from DB ???? //TODO!!!
907 meParams := me.ParamData{
908 EntityID: 0,
909 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
910 }
911 meInstance, omciErr := me.NewOnu2G(meParams)
912 if omciErr.GetError() == nil {
913 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
914 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000915 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000916 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300917 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000918 }
919
dbainbri4d3a0dc2020-12-02 00:33:42 +0000920 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000921 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000922 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000923 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300924 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000925 }
926
Himani Chawla6d2ae152020-09-02 13:11:20 +0530927 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000928 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000929 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000930 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000931 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000932 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000933 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000934 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300935 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000936 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000937 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300938 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000939 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000940 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000941 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300942 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000943}
944
Himani Chawla6d2ae152020-09-02 13:11:20 +0530945func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +0300946 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530947 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530948 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000949 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000950 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000951
952 meParams := me.ParamData{
953 EntityID: instID,
954 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300955 "Priority": 0x8000,
956 "MaxAge": 20 * 256, //20s
957 "HelloTime": 2 * 256, //2s
958 "ForwardDelay": 15 * 256, //15s
959 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000960 },
961 }
962
963 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
964 if omciErr.GetError() == nil {
965 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
966 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
967 omci.TransactionID(tid), omci.AddDefaults(true))
968 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000969 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000970 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300971 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000972 }
973
dbainbri4d3a0dc2020-12-02 00:33:42 +0000974 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000975 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000976 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000977 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300978 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000979 }
980
Himani Chawla6d2ae152020-09-02 13:11:20 +0530981 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000982 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000983 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000984 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000985 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000986 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000987 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000988 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300989 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000990 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000991 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300992 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000993 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000994 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000995 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300996 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000997}
998
Mahir Gunyel6781f962021-05-16 23:30:08 -0700999func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001000 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301001 tid := oo.getNextTid(highPrio)
Mahir Gunyel6781f962021-05-16 23:30:08 -07001002 instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
1003 if idErr != nil {
1004 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1005 "Err": idErr, "device-id": oo.deviceID})
1006 return nil, idErr
1007 }
1008 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
1009 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.macBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001010
1011 meParams := me.ParamData{
1012 EntityID: instID,
1013 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +05301014 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
1015 "PortNum": aPUniPort.macBpNo,
1016 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +05301017 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001018 },
1019 }
1020 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1021 if omciErr.GetError() == nil {
1022 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1023 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1024 omci.TransactionID(tid), omci.AddDefaults(true))
1025 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001026 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001027 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001028 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001029 }
1030
dbainbri4d3a0dc2020-12-02 00:33:42 +00001031 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001032 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001033 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001034 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001035 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001036 }
1037
Himani Chawla6d2ae152020-09-02 13:11:20 +05301038 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001039 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001040 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001041 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001042 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001043 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001044 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001045 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001046 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001047 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001048 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001049 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001050 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001051 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001052 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001053 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001054}
1055
Himani Chawla6d2ae152020-09-02 13:11:20 +05301056func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001057 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301058 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001059 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301060 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001061 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001062 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001063
1064 // compare python adapter code WA VOL-1311: this is not done here!
1065 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1066 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1067 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301068 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001069 assType = uint8(10) // for VEIP
1070 }
1071 meParams := me.ParamData{
1072 EntityID: instID,
1073 Attributes: me.AttributeValueMap{
1074 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301075 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001076 },
1077 }
1078 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1079 if omciErr.GetError() == nil {
1080 //all setByCreate parameters already set, no default option required ...
1081 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1082 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001083 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001084 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001085 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001086 }
1087
dbainbri4d3a0dc2020-12-02 00:33:42 +00001088 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001089 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001090 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001091 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001092 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001093 }
1094
Himani Chawla6d2ae152020-09-02 13:11:20 +05301095 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001096 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001097 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001098 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001099 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001100 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001101 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001102 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001103 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001104 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001105 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001106 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001107 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001108 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001109 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001110 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001111}
1112
Himani Chawla6d2ae152020-09-02 13:11:20 +05301113func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001114 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301115 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001116 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001117 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001118
1119 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1120 meParams := me.ParamData{
1121 EntityID: 0,
1122 Attributes: requestedAttributes,
1123 }
1124 meInstance, omciErr := me.NewOnuG(meParams)
1125 if omciErr.GetError() == nil {
1126 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1127 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001129 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001130 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001131 }
1132
dbainbri4d3a0dc2020-12-02 00:33:42 +00001133 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001134 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001135 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001136 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001137 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001138 }
1139
Himani Chawla6d2ae152020-09-02 13:11:20 +05301140 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001141 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001142 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001143 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001144 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001145 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001146 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001147 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001148 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001149 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001150 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001151 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001152 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001153 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001154 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001155 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001156}
1157
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001158func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001159 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001160 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001161 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001162 "SequNo": strconv.FormatInt(int64(tid), 16)})
1163
1164 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1165 meParams := me.ParamData{
1166 EntityID: aInstNo,
1167 Attributes: requestedAttributes,
1168 }
1169 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1170 if omciErr.GetError() == nil {
1171 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1172 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001173 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001174 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001175 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001176 }
1177
dbainbri4d3a0dc2020-12-02 00:33:42 +00001178 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001179 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001180 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001181 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001182 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001183 }
1184
1185 omciRxCallbackPair := callbackPair{
1186 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001187 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001188 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001189 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001190 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001191 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001192 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001193 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001194 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001195 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001196 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001197 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001199 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001200 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001201}
1202
1203/* UniG obsolete by now, left here in case it should be needed once again
1204 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301205func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001206 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301207 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001208 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001209 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001210
1211 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1212 meParams := me.ParamData{
1213 EntityID: aInstNo,
1214 Attributes: requestedAttributes,
1215 }
1216 meInstance, omciErr := me.NewUniG(meParams)
1217 if omciErr.GetError() == nil {
1218 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1219 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001221 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001222 return nil
1223 }
1224
1225 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1226 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001227 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001228 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001229 return nil
1230 }
1231
Himani Chawla6d2ae152020-09-02 13:11:20 +05301232 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001233 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001234 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001235 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001236 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001237 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001238 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001239 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001240 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001241 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001242 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001243 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001244 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001245 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001246 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001247 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001248}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001249*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250
Himani Chawla6d2ae152020-09-02 13:11:20 +05301251func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001252 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301253 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001254 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001255 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001256
1257 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1258 meParams := me.ParamData{
1259 EntityID: aInstNo,
1260 Attributes: requestedAttributes,
1261 }
1262 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1263 if omciErr.GetError() == nil {
1264 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1265 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001267 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001268 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001269 }
1270
dbainbri4d3a0dc2020-12-02 00:33:42 +00001271 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001272 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001273 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001274 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001275 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001276 }
1277
Himani Chawla6d2ae152020-09-02 13:11:20 +05301278 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001279 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001280 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001281 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001282 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001283 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001284 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001285 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001286 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001287 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001288 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001289 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001290 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001291 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001292 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001293 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001294}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001295
Himani Chawla6d2ae152020-09-02 13:11:20 +05301296func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001297 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001298
Himani Chawla6d2ae152020-09-02 13:11:20 +05301299 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001300 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001301 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001302
1303 meParams := me.ParamData{
1304 EntityID: entityID,
1305 Attributes: requestedAttributes,
1306 }
1307 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1308 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301309 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001310 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1311 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001312 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 +03001313 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001314 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001315 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001316 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001317 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001318 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001319 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301320 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001321 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001322 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001323 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001324 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001325 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001326 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001327 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001328 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001329 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001330 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001331 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001332 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001333 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001334}
1335
Himani Chawla6d2ae152020-09-02 13:11:20 +05301336func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001337 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301338 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001339 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001340 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1341
1342 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001343 EntityID: aInstID,
1344 Attributes: me.AttributeValueMap{
1345 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1346 "TpPointer": 0xFFFF,
1347 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1348 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1349 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1350 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1351 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1352 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1353 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1354 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1355 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001356 }
1357 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1358 if omciErr.GetError() == nil {
1359 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1360 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1361 omci.TransactionID(tid), omci.AddDefaults(true))
1362 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001363 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001364 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001365 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001366 }
1367
dbainbri4d3a0dc2020-12-02 00:33:42 +00001368 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001369 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001370 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001371 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001372 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001373 }
1374
Himani Chawla6d2ae152020-09-02 13:11:20 +05301375 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001376 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001377 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001379 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001380 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001381 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001382 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001383 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001384 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001385 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001386 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001387 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001388 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001389 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001390 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001391}
1392
Himani Chawla6d2ae152020-09-02 13:11:20 +05301393func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001394 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301395 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001396 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001397 "SequNo": strconv.FormatInt(int64(tid), 16),
1398 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1399
1400 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1401 if omciErr.GetError() == nil {
1402 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1403 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1404 omci.TransactionID(tid), omci.AddDefaults(true))
1405 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001406 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001407 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001408 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001409 }
1410
dbainbri4d3a0dc2020-12-02 00:33:42 +00001411 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001412 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001413 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001414 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001415 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001416 }
1417
Himani Chawla6d2ae152020-09-02 13:11:20 +05301418 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001419 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001420 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001422 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001423 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001424 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001425 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001426 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001427 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001428 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001429 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001430 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001431 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001432 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001433 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001434}
1435
Himani Chawla6d2ae152020-09-02 13:11:20 +05301436func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001437 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301438 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001439 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001440 "SequNo": strconv.FormatInt(int64(tid), 16),
1441 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1442
1443 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1444 if omciErr.GetError() == nil {
1445 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1446 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1447 omci.TransactionID(tid), omci.AddDefaults(true))
1448 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001449 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001450 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001451 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001452 }
1453
dbainbri4d3a0dc2020-12-02 00:33:42 +00001454 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001455 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001456 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001457 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001458 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001459 }
1460
Himani Chawla6d2ae152020-09-02 13:11:20 +05301461 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001462 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001463 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001464 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001465 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001467 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001468 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001469 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001470 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001471 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001472 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001473 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001474 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001475 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001476 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001477}
1478
Himani Chawla6d2ae152020-09-02 13:11:20 +05301479func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001480 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301481 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001482 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001483 "SequNo": strconv.FormatInt(int64(tid), 16),
1484 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1485
1486 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1487 if omciErr.GetError() == nil {
1488 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1489 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1490 omci.TransactionID(tid))
1491 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001492 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001493 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001494 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001495 }
1496
dbainbri4d3a0dc2020-12-02 00:33:42 +00001497 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001498 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001499 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001500 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001501 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001502 }
1503
Himani Chawla6d2ae152020-09-02 13:11:20 +05301504 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001505 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001506 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001507 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001508 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001509 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001510 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001511 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001512 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001513 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001514 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001515 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001519 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001520}
1521
Himani Chawla6d2ae152020-09-02 13:11:20 +05301522func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001523 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301524 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001525 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001526 "SequNo": strconv.FormatInt(int64(tid), 16),
1527 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1528
1529 meInstance, omciErr := me.NewTCont(params[0])
1530 if omciErr.GetError() == nil {
1531 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1532 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001533 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001534 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001535 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001536 }
1537
dbainbri4d3a0dc2020-12-02 00:33:42 +00001538 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001539 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001540 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001541 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001542 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001543 }
1544
Himani Chawla6d2ae152020-09-02 13:11:20 +05301545 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001546 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001547 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001548 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001549 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001550 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001551 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001552 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001553 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001554 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001555 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001556 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001557 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001558 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001559 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001560 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001561}
1562
Himani Chawla6d2ae152020-09-02 13:11:20 +05301563func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001564 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301565 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001566 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001567 "SequNo": strconv.FormatInt(int64(tid), 16),
1568 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1569
1570 meInstance, omciErr := me.NewPriorityQueue(params[0])
1571 if omciErr.GetError() == nil {
1572 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1573 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001574 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001575 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001576 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001577 }
1578
dbainbri4d3a0dc2020-12-02 00:33:42 +00001579 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001580 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001581 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001582 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001583 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001584 }
1585
Himani Chawla6d2ae152020-09-02 13:11:20 +05301586 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001587 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001588 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001589 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001590 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001591 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001592 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001593 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001594 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001595 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001596 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001597 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001598 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001599 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001600 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001601 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001602}
1603
Himani Chawla6d2ae152020-09-02 13:11:20 +05301604func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001605 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301606 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001607 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001608 "SequNo": strconv.FormatInt(int64(tid), 16),
1609 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1610
1611 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1612 if omciErr.GetError() == nil {
1613 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1614 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001615 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001616 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001617 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001618 }
1619
dbainbri4d3a0dc2020-12-02 00:33:42 +00001620 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001621 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001622 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001623 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001624 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001625 }
1626
Himani Chawla6d2ae152020-09-02 13:11:20 +05301627 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001628 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001629 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001630 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001631 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001632 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001633 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001634 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001635 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001636 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001637 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001638 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001639 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001640 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001641 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001642 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001643}
mpagenkodff5dda2020-08-28 11:52:01 +00001644
Himani Chawla6d2ae152020-09-02 13:11:20 +05301645func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001646 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301647 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001648 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001649 "SequNo": strconv.FormatInt(int64(tid), 16),
1650 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1651
1652 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1653 if omciErr.GetError() == nil {
1654 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1655 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1656 omci.TransactionID(tid))
1657 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001658 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001659 "Err": err, "device-id": oo.deviceID})
1660 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1661 // return (dual format) error code that can be used at caller for immediate error treatment
1662 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001663 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001664 }
1665
dbainbri4d3a0dc2020-12-02 00:33:42 +00001666 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001667 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001669 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001670 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001671 }
1672
Himani Chawla6d2ae152020-09-02 13:11:20 +05301673 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001674 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001675 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001676 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001677 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001678 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001679 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001680 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001681 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001682 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001683 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001684 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001685 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001686 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001687 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001688 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001689}
1690
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001691// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001692func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001693 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001694 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001695 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001696 "SequNo": strconv.FormatInt(int64(tid), 16),
1697 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1698
1699 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1700 if omciErr.GetError() == nil {
1701 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1702 omci.TransactionID(tid))
1703 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001704 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001705 "Err": err, "device-id": oo.deviceID})
1706 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1707 // return (dual format) error code that can be used at caller for immediate error treatment
1708 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001709 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001710 }
1711
dbainbri4d3a0dc2020-12-02 00:33:42 +00001712 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001713 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001714 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001715 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001716 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001717 }
1718
1719 omciRxCallbackPair := callbackPair{
1720 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001721 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001722 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001723 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001724 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001725 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001726 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001727 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001728 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001729 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001730 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001731 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001732 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001733 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001734 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001735}
1736
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001737func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001738 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001739 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001740 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001741 "SequNo": strconv.FormatInt(int64(tid), 16),
1742 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1743
1744 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1745 if omciErr.GetError() == nil {
1746 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1747 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001748 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001749 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001750 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001751 }
1752
dbainbri4d3a0dc2020-12-02 00:33:42 +00001753 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001756 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001757 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001758 }
1759
1760 omciRxCallbackPair := callbackPair{
1761 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001762 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001763 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001764 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001765 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001766 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001767 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001768 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001769 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001770 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001771 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001772 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001773 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001774 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001775 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001776}
1777
Himani Chawla6d2ae152020-09-02 13:11:20 +05301778func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001779 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301780 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001781 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001782 "SequNo": strconv.FormatInt(int64(tid), 16),
1783 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1784
1785 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1786 if omciErr.GetError() == nil {
1787 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1788 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001789 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001790 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001791 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001792 }
1793
dbainbri4d3a0dc2020-12-02 00:33:42 +00001794 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001795 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001796 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001797 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001798 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001799 }
1800
Himani Chawla6d2ae152020-09-02 13:11:20 +05301801 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001802 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001803 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001804 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001805 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001806 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001807 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001808 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001809 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001810 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001811 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001812 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001813 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001815 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001816 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001817}
mpagenko01e726e2020-10-23 09:45:29 +00001818
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001819func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001820 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001821 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001822 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001823 "SequNo": strconv.FormatInt(int64(tid), 16),
1824 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1825
1826 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1827 if omciErr.GetError() == nil {
1828 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1829 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001830 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001831 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001832 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001833 }
1834
dbainbri4d3a0dc2020-12-02 00:33:42 +00001835 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001836 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001837 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001838 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001839 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001840 }
1841
1842 omciRxCallbackPair := callbackPair{
1843 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001844 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001845 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001846 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001847 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001848 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001849 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001850 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001851 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001852 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001853 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001854 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001855 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001856 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001857 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001858}
1859
mpagenko01e726e2020-10-23 09:45:29 +00001860func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001861 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko01e726e2020-10-23 09:45:29 +00001862 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001863 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001864 "SequNo": strconv.FormatInt(int64(tid), 16),
1865 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1866
1867 meParams := me.ParamData{EntityID: aInstID}
1868 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1869 if omciErr.GetError() == nil {
1870 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1871 omci.TransactionID(tid))
1872 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001873 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001874 "Err": err, "device-id": oo.deviceID})
1875 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1876 // return (dual format) error code that can be used at caller for immediate error treatment
1877 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001878 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001879 }
1880
dbainbri4d3a0dc2020-12-02 00:33:42 +00001881 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001882 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001884 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001885 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001886 }
1887
1888 omciRxCallbackPair := callbackPair{
1889 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001890 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001891 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001892 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00001893 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001894 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001895 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001896 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001897 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001899 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00001900 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001901 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001902 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001903 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00001904}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001905
ozgecanetsiab6441962021-03-10 10:58:48 +03001906// nolint: unused
1907func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001908 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001909 tid := oo.getNextTid(highPrio)
1910 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1911 "SequNo": strconv.FormatInt(int64(tid), 16),
1912 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1913 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1914 if omciErr.GetError() == nil {
1915 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1916 if err != nil {
1917 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001918 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001919 }
1920 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1921 if err != nil {
1922 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001923 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001924 }
1925 omciRxCallbackPair := callbackPair{
1926 cbKey: tid,
1927 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1928 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001929 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001930 if err != nil {
1931 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001932 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001933 }
1934 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001935 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001936 }
1937 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001938 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001939}
1940
1941// nolint: unused
1942func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001943 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001944 tid := oo.getNextTid(highPrio)
1945 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1946 "SequNo": strconv.FormatInt(int64(tid), 16),
1947 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1948
1949 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1950 if omciErr.GetError() == nil {
1951 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1952 if err != nil {
1953 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001954 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001955 }
1956 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1957 if err != nil {
1958 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001959 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001960 }
1961 omciRxCallbackPair := callbackPair{
1962 cbKey: tid,
1963 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1964 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001965 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001966 if err != nil {
1967 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001968 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001969 }
1970 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001971 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001972 }
1973 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001974 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001975
1976}
1977
1978// nolint: unused
1979func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001980 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001981 tid := oo.getNextTid(highPrio)
1982 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1983 "SequNo": strconv.FormatInt(int64(tid), 16),
1984 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1985
1986 meParams := me.ParamData{EntityID: aInstID}
1987 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1988 if omciErr.GetError() == nil {
1989 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1990 if err != nil {
1991 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001992 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001993 }
1994 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1995 if err != nil {
1996 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001997 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001998 }
1999 omciRxCallbackPair := callbackPair{
2000 cbKey: tid,
2001 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2002 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002003 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002004 if err != nil {
2005 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002006 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002007 }
2008 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002009 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002010 }
2011 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002012 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002013
2014}
2015
mpagenko8b07c1b2020-11-26 10:36:31 +00002016func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002017 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002018 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002019 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002020 "SequNo": strconv.FormatInt(int64(tid), 16),
2021 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2022
2023 meParams := me.ParamData{EntityID: aInstID}
2024 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2025 if omciErr.GetError() == nil {
2026 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2027 omci.TransactionID(tid))
2028 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002030 "Err": err, "device-id": oo.deviceID})
2031 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2032 // return (dual format) error code that can be used at caller for immediate error treatment
2033 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002034 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002035 }
2036
dbainbri4d3a0dc2020-12-02 00:33:42 +00002037 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002038 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002039 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002040 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002041 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002042 }
2043
2044 omciRxCallbackPair := callbackPair{
2045 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002046 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002047 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002048 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002049 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002050 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002051 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002052 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002053 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002054 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002055 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002056 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002057 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002058 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002059 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002060}
2061
2062func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002063 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002064 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002065 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002066 "SequNo": strconv.FormatInt(int64(tid), 16),
2067 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2068
2069 meParams := me.ParamData{EntityID: aInstID}
2070 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2071 if omciErr.GetError() == nil {
2072 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2073 omci.TransactionID(tid))
2074 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002075 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002076 "Err": err, "device-id": oo.deviceID})
2077 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2078 // return (dual format) error code that can be used at caller for immediate error treatment
2079 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002080 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002081 }
2082
dbainbri4d3a0dc2020-12-02 00:33:42 +00002083 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002084 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002085 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002086 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002087 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002088 }
2089
2090 omciRxCallbackPair := callbackPair{
2091 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002092 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002093 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002094 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002095 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002096 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002097 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002098 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002099 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002100 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002101 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002102 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002103 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002104 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002105 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002106}
2107
2108func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002109 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002110 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002111 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002112 "SequNo": strconv.FormatInt(int64(tid), 16),
2113 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2114
2115 meParams := me.ParamData{EntityID: aInstID}
2116 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2117 if omciErr.GetError() == nil {
2118 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2119 omci.TransactionID(tid))
2120 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002121 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002122 "Err": err, "device-id": oo.deviceID})
2123 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2124 // return (dual format) error code that can be used at caller for immediate error treatment
2125 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002126 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002127 }
2128
dbainbri4d3a0dc2020-12-02 00:33:42 +00002129 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002130 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002131 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002132 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002133 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002134 }
2135
2136 omciRxCallbackPair := callbackPair{
2137 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002138 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002139 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002140 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002141 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002142 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002143 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002144 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002145 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002146 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002147 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002148 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002149 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002150 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002151 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002152}
2153
2154func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002155 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002156 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002157 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002158 "SequNo": strconv.FormatInt(int64(tid), 16),
2159 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2160
2161 meParams := me.ParamData{EntityID: aInstID}
2162 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2163 if omciErr.GetError() == nil {
2164 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2165 omci.TransactionID(tid))
2166 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002167 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002168 "Err": err, "device-id": oo.deviceID})
2169 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2170 // return (dual format) error code that can be used at caller for immediate error treatment
2171 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002172 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002173 }
2174
dbainbri4d3a0dc2020-12-02 00:33:42 +00002175 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002176 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002177 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002178 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002179 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002180 }
2181
2182 omciRxCallbackPair := callbackPair{
2183 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002184 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002185 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002186 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002187 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002188 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002189 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002190 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002191 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002192 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002193 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002194 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002195 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002196 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002197 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002198}
2199
ozgecanetsia422dbf32020-10-28 14:07:19 +03002200func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002201 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002202 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002203 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002204 "SequNo": strconv.FormatInt(int64(tid), 16),
2205 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2206
2207 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2208 if omciErr.GetError() == nil {
2209 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2210 omci.AddDefaults(true))
2211 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002212 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002213 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002214 }
2215
dbainbri4d3a0dc2020-12-02 00:33:42 +00002216 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002217 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002218 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002219 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002220 }
2221
2222 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002223 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002224 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002225 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002226 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002227 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002228 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002229 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002230 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002231 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002232 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002233 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002234 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002235 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002236}
2237
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002238func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002239 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002240 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002241 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002242 "SequNo": strconv.FormatInt(int64(tid), 16),
2243 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2244
2245 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2246 if omciErr.GetError() == nil {
2247 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2248 omci.AddDefaults(true))
2249 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002250 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002251 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002252 }
2253
dbainbri4d3a0dc2020-12-02 00:33:42 +00002254 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002255 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002256 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002257 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002258 }
2259
2260 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002261 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002262 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002263 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002264 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002265 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002266 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002267 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002268 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002269 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002270 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002271 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002272 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002273 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002274}
2275
ozgecanetsia422dbf32020-10-28 14:07:19 +03002276func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002277 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002278 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002279 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002280 "SequNo": strconv.FormatInt(int64(tid), 16),
2281 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2282
2283 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2284 if omciErr.GetError() == nil {
2285 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2286 omci.AddDefaults(true))
2287 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002288 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002289 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002290 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002291 }
2292
dbainbri4d3a0dc2020-12-02 00:33:42 +00002293 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002294 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002295 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002296 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002297 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002298 }
2299
2300 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002301 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002302 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002303 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002304 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002305 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002306 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002307 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002308 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002309 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002310 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002311 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002312 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002313 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002314 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002315}
2316
2317func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002318 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002319 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002320 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002321 "SequNo": strconv.FormatInt(int64(tid), 16),
2322 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2323
2324 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2325 if omciErr.GetError() == nil {
2326 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2327 omci.AddDefaults(true))
2328 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002329 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002330 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002331 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002332 }
2333
dbainbri4d3a0dc2020-12-02 00:33:42 +00002334 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002335 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002337 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002338 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002339 }
2340
2341 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002342 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002343 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002344 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002345 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002346 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002347 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002348 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002349 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002350 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002351 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002352 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002353 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002354 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002355 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002356}
2357
2358func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002359 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002360 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002361 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002362 "SequNo": strconv.FormatInt(int64(tid), 16),
2363 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2364
2365 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2366 if omciErr.GetError() == nil {
2367 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2368 omci.AddDefaults(true))
2369 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002370 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002371 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002372 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002373 }
2374
dbainbri4d3a0dc2020-12-02 00:33:42 +00002375 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002376 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002377 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002378 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002379 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002380 }
2381
2382 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002383 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002384 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002385 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002386 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002387 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002388 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002389 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002390 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002391 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002392 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002394 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002395 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002396 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002397}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002398
Girish Gowdrae0140f02021-02-02 16:55:09 -08002399func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2400 tid := oo.getNextTid(highPrio)
2401 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2402 "SequNo": strconv.FormatInt(int64(tid), 16)})
2403
2404 omciLayer := &omci.OMCI{
2405 TransactionID: tid,
2406 MessageType: omci.SynchronizeTimeRequestType,
2407 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2408 // Length: 0x28, // Optional, defaults to 40 octets
2409 }
2410 utcTime := time.Now().UTC()
2411 request := &omci.SynchronizeTimeRequest{
2412 MeBasePacket: omci.MeBasePacket{
2413 EntityClass: me.OnuGClassID,
2414 // Default Instance ID is 0
2415 },
2416 Year: uint16(utcTime.Year()),
2417 Month: uint8(utcTime.Month()),
2418 Day: uint8(utcTime.Day()),
2419 Hour: uint8(utcTime.Hour()),
2420 Minute: uint8(utcTime.Minute()),
2421 Second: uint8(utcTime.Second()),
2422 }
2423
2424 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2425 if err != nil {
2426 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2427 "device-id": oo.deviceID})
2428 return err
2429 }
2430
2431 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002432 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002433 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002434 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002435 if err != nil {
2436 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2437 "device-id": oo.deviceID})
2438 return err
2439 }
2440 logger.Debug(ctx, "send synchronize time request done")
2441 return nil
2442}
2443
2444func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002445 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002446 tid := oo.getNextTid(highPrio)
2447 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2448 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2449 meParam := me.ParamData{EntityID: entityID}
2450 var meInstance *me.ManagedEntity
2451 var omciErr me.OmciErrors
2452 if upstream {
2453 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2454 } else {
2455 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2456 }
2457 if omciErr.GetError() == nil {
2458 var omciLayer *omci.OMCI
2459 var msgLayer gopacket.SerializableLayer
2460 var err error
2461 if create {
2462 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2463 omci.AddDefaults(true))
2464 } else {
2465 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2466 omci.AddDefaults(true))
2467 }
2468 if err != nil {
2469 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2470 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002471 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002472 }
2473
2474 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2475 if err != nil {
2476 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2477 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002478 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002479 }
2480
2481 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002482 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002483 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002484 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002485 if err != nil {
2486 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2487 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002488 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002489 }
2490 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2491 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002492 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002493 }
2494 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2495 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 +03002496 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002497}
2498
2499func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002500 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002501 tid := oo.getNextTid(highPrio)
2502 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2503 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2504 meParam := me.ParamData{EntityID: entityID}
2505 var meInstance *me.ManagedEntity
2506 var omciErr me.OmciErrors
2507 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2508
2509 if omciErr.GetError() == nil {
2510 var omciLayer *omci.OMCI
2511 var msgLayer gopacket.SerializableLayer
2512 var err error
2513 if create {
2514 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2515 omci.AddDefaults(true))
2516 } else {
2517 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2518 omci.AddDefaults(true))
2519 }
2520 if err != nil {
2521 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2522 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002523 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002524 }
2525
2526 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2527 if err != nil {
2528 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2529 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002530 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002531 }
2532
2533 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002534 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002535 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002536 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002537 if err != nil {
2538 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2539 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002540 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002541 }
2542 logger.Debugw(ctx, "send ethernet uni history data ME done",
2543 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002544 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002545 }
2546 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2547 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002548 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002549}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002550
2551func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002552 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002553 tid := oo.getNextTid(highPrio)
2554 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2555 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2556 meParam := me.ParamData{EntityID: entityID}
2557 var meInstance *me.ManagedEntity
2558 var omciErr me.OmciErrors
2559 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2560
2561 if omciErr.GetError() == nil {
2562 var omciLayer *omci.OMCI
2563 var msgLayer gopacket.SerializableLayer
2564 var err error
2565 if create {
2566 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2567 omci.AddDefaults(true))
2568 } else {
2569 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2570 omci.AddDefaults(true))
2571 }
2572 if err != nil {
2573 logger.Errorw(ctx, "Cannot encode fec history data ME",
2574 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002575 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002576 }
2577
2578 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2579 if err != nil {
2580 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2581 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002582 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002583 }
2584
2585 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002586 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002587 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002588 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002589 if err != nil {
2590 logger.Errorw(ctx, "Cannot send fec history data ME",
2591 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002592 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002593 }
2594 logger.Debugw(ctx, "send fec history data ME done",
2595 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002596 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002597 }
2598 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2599 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002600 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002601}
2602
2603func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002604 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002605 tid := oo.getNextTid(highPrio)
2606 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2607 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2608 meParam := me.ParamData{EntityID: entityID}
2609 var meInstance *me.ManagedEntity
2610 var omciErr me.OmciErrors
2611 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2612
2613 if omciErr.GetError() == nil {
2614 var omciLayer *omci.OMCI
2615 var msgLayer gopacket.SerializableLayer
2616 var err error
2617 if create {
2618 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2619 omci.AddDefaults(true))
2620 } else {
2621 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2622 omci.AddDefaults(true))
2623 }
2624 if err != nil {
2625 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2626 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002627 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002628 }
2629
2630 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2631 if err != nil {
2632 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2633 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002634 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002635 }
2636
2637 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002638 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002639 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002640 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002641 if err != nil {
2642 logger.Errorw(ctx, "Cannot send gemport history data ME",
2643 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002644 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002645 }
2646 logger.Debugw(ctx, "send gemport history data ME done",
2647 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002648 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002649 }
2650 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2651 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002652 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002653}
2654
mpagenko80622a52021-02-09 16:53:23 +00002655func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2656 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2657 tid := oo.getNextTid(highPrio)
2658 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2659 "SequNo": strconv.FormatInt(int64(tid), 16),
2660 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2661
2662 omciLayer := &omci.OMCI{
2663 TransactionID: tid,
2664 MessageType: omci.StartSoftwareDownloadRequestType,
2665 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2666 // Length: 0x28, // Optional, defaults to 40 octets
2667 }
2668 request := &omci.StartSoftwareDownloadRequest{
2669 MeBasePacket: omci.MeBasePacket{
2670 EntityClass: me.SoftwareImageClassID,
2671 EntityInstance: aImageMeID, //inactive image
2672 },
2673 WindowSize: aDownloadWindowSize,
2674 ImageSize: aFileLen,
2675 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2676 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2677 }
2678
2679 var options gopacket.SerializeOptions
2680 options.FixLengths = true
2681 buffer := gopacket.NewSerializeBuffer()
2682 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2683 if err != nil {
2684 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2685 "device-id": oo.deviceID})
2686 return err
2687 }
2688 outgoingPacket := buffer.Bytes()
2689
2690 omciRxCallbackPair := callbackPair{cbKey: tid,
2691 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2692 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002693 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002694 if err != nil {
2695 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2696 "device-id": oo.deviceID})
2697 return err
2698 }
2699 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002700 return nil
2701}
2702
mpagenkoc26d4c02021-05-06 14:27:57 +00002703func (oo *omciCC) sendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002704 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2705 tid := oo.getNextTid(highPrio)
2706 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2707 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002708 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002709
2710 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2711 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002712 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00002713 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00002714 if aAckRequest > 0 {
2715 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00002716 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00002717 }
mpagenko80622a52021-02-09 16:53:23 +00002718 omciLayer := &omci.OMCI{
2719 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002720 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002721 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2722 // Length: 0x28, // Optional, defaults to 40 octets
2723 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002724 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002725 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002726 request := &omci.DownloadSectionRequest{
2727 MeBasePacket: omci.MeBasePacket{
2728 EntityClass: me.SoftwareImageClassID,
2729 EntityInstance: aImageMeID, //inactive image
2730 },
2731 SectionNumber: aDownloadSectionNo,
2732 SectionData: localSectionData,
2733 }
2734
2735 var options gopacket.SerializeOptions
2736 options.FixLengths = true
2737 buffer := gopacket.NewSerializeBuffer()
2738 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2739 if err != nil {
2740 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2741 "device-id": oo.deviceID})
2742 return err
2743 }
2744 outgoingPacket := buffer.Bytes()
2745
mpagenko15ff4a52021-03-02 10:09:20 +00002746 //for initial debug purpose overrule the requested print state for some frames
2747 printFrame := aPrint
2748 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2749 printFrame = true
2750 }
2751
mpagenko80622a52021-02-09 16:53:23 +00002752 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00002753 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
2754 // (used to avoid retransmission of frames with the same TID)
mpagenko15ff4a52021-03-02 10:09:20 +00002755 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002756 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002757 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002758 if err != nil {
2759 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2760 "device-id": oo.deviceID})
2761 return err
2762 }
2763 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002764 return nil
2765}
2766
2767func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2768 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2769 tid := oo.getNextTid(highPrio)
2770 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2771 "SequNo": strconv.FormatInt(int64(tid), 16),
2772 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2773
mpagenko15ff4a52021-03-02 10:09:20 +00002774 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002775 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002776 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002777 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2778 // Length: 0x28, // Optional, defaults to 40 octets
2779 }
mpagenko15ff4a52021-03-02 10:09:20 +00002780 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002781 MeBasePacket: omci.MeBasePacket{
2782 EntityClass: me.SoftwareImageClassID,
2783 EntityInstance: aImageMeID, //inactive image
2784 },
mpagenko15ff4a52021-03-02 10:09:20 +00002785 CRC32: aImageCrc,
2786 ImageSize: aFileLen,
2787 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2788 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002789 }
mpagenko15ff4a52021-03-02 10:09:20 +00002790
2791 var options gopacket.SerializeOptions
2792 options.FixLengths = true
2793 buffer := gopacket.NewSerializeBuffer()
2794 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2795 if err != nil {
2796 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002797 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002798 return err
mpagenko80622a52021-02-09 16:53:23 +00002799 }
mpagenko15ff4a52021-03-02 10:09:20 +00002800 outgoingPacket := buffer.Bytes()
2801
2802 omciRxCallbackPair := callbackPair{cbKey: tid,
2803 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2804 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002805 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002806 if err != nil {
2807 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2808 "device-id": oo.deviceID})
2809 return err
2810 }
2811 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002812 return nil
2813}
2814
2815func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2816 rxChan chan Message, aImageMeID uint16) error {
2817 tid := oo.getNextTid(highPrio)
2818 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2819 "SequNo": strconv.FormatInt(int64(tid), 16),
2820 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2821
2822 omciLayer := &omci.OMCI{
2823 TransactionID: tid,
2824 MessageType: omci.ActivateSoftwareRequestType,
2825 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2826 // Length: 0x28, // Optional, defaults to 40 octets
2827 }
2828 request := &omci.ActivateSoftwareRequest{
2829 MeBasePacket: omci.MeBasePacket{
2830 EntityClass: me.SoftwareImageClassID,
2831 EntityInstance: aImageMeID, //inactive image
2832 },
2833 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2834 }
2835
2836 var options gopacket.SerializeOptions
2837 options.FixLengths = true
2838 buffer := gopacket.NewSerializeBuffer()
2839 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2840 if err != nil {
2841 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2842 "device-id": oo.deviceID})
2843 return err
2844 }
2845 outgoingPacket := buffer.Bytes()
2846
2847 omciRxCallbackPair := callbackPair{cbKey: tid,
2848 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2849 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002850 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002851 if err != nil {
2852 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2853 "device-id": oo.deviceID})
2854 return err
2855 }
2856 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002857 return nil
2858}
mpagenko80622a52021-02-09 16:53:23 +00002859
mpagenko15ff4a52021-03-02 10:09:20 +00002860func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2861 rxChan chan Message, aImageMeID uint16) error {
2862 tid := oo.getNextTid(highPrio)
2863 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2864 "SequNo": strconv.FormatInt(int64(tid), 16),
2865 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2866
2867 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002868 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002869 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002870 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2871 // Length: 0x28, // Optional, defaults to 40 octets
2872 }
mpagenko15ff4a52021-03-02 10:09:20 +00002873 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002874 MeBasePacket: omci.MeBasePacket{
2875 EntityClass: me.SoftwareImageClassID,
2876 EntityInstance: aImageMeID, //inactive image
2877 },
mpagenko80622a52021-02-09 16:53:23 +00002878 }
mpagenko15ff4a52021-03-02 10:09:20 +00002879
2880 var options gopacket.SerializeOptions
2881 options.FixLengths = true
2882 buffer := gopacket.NewSerializeBuffer()
2883 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2884 if err != nil {
2885 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002886 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002887 return err
mpagenko80622a52021-02-09 16:53:23 +00002888 }
mpagenko15ff4a52021-03-02 10:09:20 +00002889 outgoingPacket := buffer.Bytes()
2890
2891 omciRxCallbackPair := callbackPair{cbKey: tid,
2892 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2893 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002894 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002895 if err != nil {
2896 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2897 "device-id": oo.deviceID})
2898 return err
2899 }
2900 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002901 return nil
2902}
2903
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002904func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
2905 tid := oo.getNextTid(highPrio)
2906 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
2907 "SequNo": strconv.FormatInt(int64(tid), 16),
2908 "InstId": strconv.FormatInt(int64(instdID), 16)})
2909 omciLayer := &omci.OMCI{
2910 TransactionID: tid,
2911 MessageType: omci.TestRequestType,
2912 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2913 // Length: 0x28, // Optional, defaults to 40 octets
2914 }
2915
2916 var request *omci.OpticalLineSupervisionTestRequest
2917 switch classID {
2918 case aniGClassID:
2919 request = &omci.OpticalLineSupervisionTestRequest{
2920 MeBasePacket: omci.MeBasePacket{
2921 EntityClass: classID,
2922 EntityInstance: instdID,
2923 },
2924 SelectTest: uint8(7), // self test
2925 GeneralPurposeBuffer: uint16(0),
2926 VendorSpecificParameters: uint16(0),
2927 }
2928 default:
2929 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
2930 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
2931 }
2932 // Test serialization back to former string
2933 var options gopacket.SerializeOptions
2934 options.FixLengths = true
2935
2936 buffer := gopacket.NewSerializeBuffer()
2937 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2938 if err != nil {
2939 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
2940 "device-id": oo.deviceID})
2941 return err
2942 }
2943 outgoingPacket := buffer.Bytes()
2944
2945 omciRxCallbackPair := callbackPair{cbKey: tid,
2946 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2947 }
2948 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2949 if err != nil {
2950 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
2951 "device-id": oo.deviceID})
2952 return err
2953 }
2954 logger.Debug(ctx, "send self test request done")
2955 return nil
2956}
2957
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002958//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002959func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002960 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002961 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002962 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002963 msgLayer := (*packet).Layer(nextLayer)
2964 switch nextLayer {
2965 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002966 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
2967 if resp.Result == me.Success {
2968 return true
2969 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002970 }
2971 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002972 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
2973 if resp.Result == me.Success {
2974 return true
2975 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002976 }
2977 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002978 if resp := msgLayer.(*omci.SetResponse); resp != nil {
2979 if resp.Result == me.Success {
2980 return true
2981 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002982 }
2983 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002984 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
2985 if resp.Result == me.Success {
2986 return true
2987 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002988 }
2989 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002990 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
2991 if resp.Result == me.Success {
2992 return true
2993 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002994 }
2995 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002996 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
2997 if resp.Result == me.Success {
2998 return true
2999 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003000 }
3001 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003002 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
3003 if resp.Result == me.Success {
3004 return true
3005 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003006 }
3007 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003008 }
3009 }
3010 return false
3011}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003012
3013func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
3014
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003015 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00003016 if timeout == 0 {
3017 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003018 oo.mutexTxQueue.Lock()
3019 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3020 oo.mutexTxQueue.Unlock()
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003021 go oo.sendNextRequest(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00003022 } else {
3023 chSuccess := make(chan bool)
3024 aOmciTxRequest.chSuccess = chSuccess
3025 tid := aOmciTxRequest.cbPair.cbKey
3026 retries := aOmciTxRequest.retries
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003027
mpagenkoc26d4c02021-05-06 14:27:57 +00003028 oo.mutexMonReq.Lock()
3029 oo.monitoredRequests[tid] = aOmciTxRequest
3030 oo.mutexMonReq.Unlock()
3031
3032 retryCounter := 0
3033 loop:
3034 for retryCounter <= retries {
3035
3036 oo.mutexTxQueue.Lock()
3037 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3038 oo.mutexTxQueue.Unlock()
3039 go oo.sendNextRequest(ctx)
3040
3041 select {
3042 case success := <-chSuccess:
3043 if success {
3044 logger.Debugw(ctx, "reqMon: response received in time",
3045 log.Fields{"tid": tid, "device-id": oo.deviceID})
3046 } else {
3047 logger.Debugw(ctx, "reqMon: wait for response aborted",
3048 log.Fields{"tid": tid, "device-id": oo.deviceID})
3049 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003050 break loop
mpagenkoc26d4c02021-05-06 14:27:57 +00003051 case <-time.After(time.Duration(timeout) * time.Second):
3052 if retryCounter == retries {
3053 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
3054 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3055 break loop
3056 } else {
3057 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
3058 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3059 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003060 }
mpagenkoc26d4c02021-05-06 14:27:57 +00003061 retryCounter++
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003062 }
mpagenkoc26d4c02021-05-06 14:27:57 +00003063 oo.mutexMonReq.Lock()
3064 delete(oo.monitoredRequests, tid)
3065 oo.mutexMonReq.Unlock()
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003066 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003067}
3068
3069//CancelRequestMonitoring terminates monitoring of outstanding omci requests
3070func (oo *omciCC) CancelRequestMonitoring() {
3071 oo.mutexMonReq.RLock()
3072 for k := range oo.monitoredRequests {
3073 oo.monitoredRequests[k].chSuccess <- false
3074 }
3075 oo.mutexMonReq.RUnlock()
3076}
3077
3078//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
3079//time consumed for retry processing of a particular OMCI-request
3080func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
3081 return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
3082}