blob: 5d28f59f0a0d356a94e5e200a6c8b13c31b07091 [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"
Girish Gowdra50e56422021-06-01 16:46:04 -070036 "github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
amit.ghosh58b704b2021-06-18 03:45:52 +020038 "github.com/opencord/voltha-protos/v4/go/common"
Girish Gowdra50e56422021-06-01 16:46:04 -070039 //"github.com/opencord/voltha-lib-go/v5/pkg/kafka"
40 "github.com/opencord/voltha-lib-go/v5/pkg/log"
dbainbri4d3a0dc2020-12-02 00:33:42 +000041 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
42 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
43 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000044)
45
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000046// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053047
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000048const maxGemPayloadSize = uint16(48)
49const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053050
51//const defaultTPID = uint16(0x8100)
52//const broadComDefaultVID = uint16(4091)
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
mpagenko8cd1bf72021-06-22 10:11:19 +0000173 oo.CancelRequestMonitoring(ctx)
mpagenko900ee4b2020-10-12 11:56:34 +0000174 oo.mutexTxQueue.Lock()
175 oo.txQueue.Init() // clear the tx queue
176 oo.mutexTxQueue.Unlock()
177 oo.mutexRxSchedMap.Lock()
178 for k := range oo.rxSchedulerMap {
179 delete(oo.rxSchedulerMap, k) //clear the scheduler map
180 }
181 oo.mutexRxSchedMap.Unlock()
182 oo.mutexHpTid.Lock()
183 oo.hpTid = 0x8000 //reset the high prio transactionId
184 oo.mutexHpTid.Unlock()
185 oo.mutexTid.Lock()
186 oo.tid = 1 //reset the low prio transactionId
187 oo.mutexTid.Unlock()
188 //reset control values
189 oo.uploadSequNo = 0
190 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000191 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000192 //reset the stats counter - which might be topic of discussion ...
193 oo.txFrames = 0
194 oo.txOnuFrames = 0
195 oo.rxFrames = 0
196 oo.rxOnuFrames = 0
197 oo.rxOnuDiscards = 0
198
199 return nil
200}
201
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000202// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530203func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000204 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000205 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530206 switch omciMsg.MessageType {
207 case omci.AlarmNotificationType:
208 data := OmciMessage{
209 OmciMsg: omciMsg,
210 OmciPacket: packet,
211 }
212 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
213 return nil
214 default:
215 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
216 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000217 /*
218 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
219 rxOnuFrames++
220
221 switch msgType {
222 case AlarmNotification:
223 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000224 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000225 // python code was:
226 //if msg_type == EntityOperations.AlarmNotification.value:
227 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
228 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
229 //
230 return errors.New("RxAlarmNotification unimplemented")
231 }
232 case AttributeValueChange:
233 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000234 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000235 // python code was:
236 //elif msg_type == EntityOperations.AttributeValueChange.value:
237 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
238 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
239 //
240 return errors.New("RxAttributeValueChange unimplemented")
241 }
242 case TestResult:
243 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000244 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000245 // python code was:
246 //elif msg_type == EntityOperations.TestResult.value:
247 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
248 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
249 //
250 return errors.New("RxTestResult unimplemented")
251 }
252 default:
253 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000254 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000255 rxOnuDiscards++
256 return errors.New("RxOnuMsgType unimplemented")
257 }
258 }
259 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000260}
261
mpagenko80622a52021-02-09 16:53:23 +0000262func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
263 //assuming omci message content is hex coded!
264 // with restricted output of 16bytes would be ...rxMsg[:16]
265 logger.Debugw(ctx, "omci-message-received:", log.Fields{
266 "RxOmciMessage": hex.EncodeToString(rxMsg),
267 "device-id": oo.deviceID})
268}
269
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000270// Rx handler for onu messages
271// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530272func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000273 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000274 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
275 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000276 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000277 trailerLenData := rxMsg[42:44]
278 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000279 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000280 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
281 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
282 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
283 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
284 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
285 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
286 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
287 }
288 }
289 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
290 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
291 // (an extendedFormat message could be destroyed this way!)
292 // extend/overwrite with trailer
293 trailer := make([]byte, 8)
294 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
295 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
296 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
297 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
298 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
299 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
300 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000301 }
302 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000303 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
304 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000305 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200306 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000307 }
308
309 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
310 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000311 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000312 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200313 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000314 }
315 omciLayer := packet.Layer(omci.LayerTypeOMCI)
316 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000317 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000318 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200319 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000320 }
321 omciMsg, ok := omciLayer.(*omci.OMCI)
322 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000323 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000324 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200325 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000326 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000327 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000328 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700329 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
330 // We expect to find the TID in the oo.rxSchedulerMap
331 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000332 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000333 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000334 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000335 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530336 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000337 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000338 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200339 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000340 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200341 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530342 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000343 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530344 oo.mutexRxSchedMap.Lock()
345 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
346 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000347 if rxCallbackEntry.framePrint {
348 oo.printRxMessage(ctx, rxMsg)
349 }
Himani Chawla4d908332020-08-31 12:30:20 +0530350 //disadvantage of decoupling: error verification made difficult, but anyway the question is
351 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000352 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000353 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000354 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
355 }
mpagenkoc8bba412021-01-15 15:38:44 +0000356
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700357 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
358 // so do not clean up the TransactionID in that case.
359 if omciMsg.MessageType != omci.TestResponseType {
360 // having posted the response the request is regarded as 'done'
361 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
362 }
Himani Chawla4d908332020-08-31 12:30:20 +0530363 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000364 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000365 }
mpagenko80622a52021-02-09 16:53:23 +0000366 oo.mutexRxSchedMap.Unlock()
367 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
368 oo.printRxMessage(ctx, rxMsg)
369 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000370
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000371 /* py code was:
372 Receive and OMCI message from the proxy channel to the OLT.
373
374 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
375 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
376 """
377 if not self.enabled:
378 return
379
380 try:
381 now = arrow.utcnow()
382 d = None
383
384 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
385 # save the current value of the entity_id_to_class_map, then
386 # replace it with our custom one before decode, and then finally
387 # restore it later. Tried other ways but really made the code messy.
388 saved_me_map = omci_entities.entity_id_to_class_map
389 omci_entities.entity_id_to_class_map = self._me_map
390
391 try:
392 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000393 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000394 except KeyError as e:
395 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000396 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000397 rx_frame = self._decode_unknown_me(msg)
398 self._rx_unknown_me += 1
399
400 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000401 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000402 return
403
404 finally:
405 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
406
407 rx_tid = rx_frame.fields['transaction_id']
408 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000409 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000410 # Filter the Test Result frame and route through receive onu
411 # message method.
412 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000413 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000414 return self._receive_onu_message(rx_frame)
415
416 # Previously unreachable if this is the very first round-trip Rx or we
417 # have been running consecutive errors
418 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000419 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000420 self.reactor.callLater(0, self._publish_connectivity_event, True)
421
422 self._rx_frames += 1
423 self._consecutive_errors = 0
424
425 try:
426 high_priority = self._tid_is_high_priority(rx_tid)
427 index = self._get_priority_index(high_priority)
428
429 # (timestamp, defer, frame, timeout, retry, delayedCall)
430 last_tx_tuple = self._tx_request[index]
431
432 if last_tx_tuple is None or \
433 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
434 # Possible late Rx on a message that timed-out
435 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000436 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000437 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
438 self._rx_unknown_tid += 1
439 self._rx_late += 1
440 return
441
442 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
443 if dc is not None and not dc.cancelled and not dc.called:
444 dc.cancel()
445
446 _secs = self._update_rx_tx_stats(now, ts)
447
448 # Late arrival already serviced by a timeout?
449 if d.called:
450 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000451 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000452 return
453
454 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000455 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000456 if d is not None:
457 return d.errback(failure.Failure(e))
458 return
459
460 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000461 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000462 tx_tid = tx_frame.fields['transaction_id'])
463 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
464
465 # begin success callback chain (will cancel timeout and queue next Tx message)
466 self._rx_response[index] = rx_frame
467 d.callback(rx_frame)
468
469 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000470 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000471 */
472}
473
Himani Chawla6d2ae152020-09-02 13:11:20 +0530474/*
475func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530476 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530477 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000478}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530479*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000480
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700481// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
482func (oo *omciCC) ReleaseTid(ctx context.Context, tid uint16) {
483 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
484 delete(oo.rxSchedulerMap, tid)
485}
486
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000487//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530488func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
489 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000490
mpagenkoc26d4c02021-05-06 14:27:57 +0000491 if timeout != 0 {
492 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
493 oo.mutexRxSchedMap.Lock()
494 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
495 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
496 oo.mutexRxSchedMap.Unlock()
497 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000498
mpagenkoc26d4c02021-05-06 14:27:57 +0000499 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000500 //just use a simple list for starting - might need some more effort, especially for multi source write access
501 omciTxRequest := omciTransferStructure{
502 txFrame,
503 timeout,
504 retry,
505 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000506 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000507 receiveCallbackPair,
508 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000509 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000510 oo.mutexMonReq.Lock()
511 defer oo.mutexMonReq.Unlock()
512 if _, exist := oo.monitoredRequests[receiveCallbackPair.cbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000513 // do not call processRequestMonitoring in background here to ensure correct sequencing
514 // of requested messages into txQueue (especially for non-response-supervised messages)
515 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000516 return nil
517 }
518 logger.Errorw(ctx, "A message with this tid is processed already!",
519 log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
520 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000521}
522
523//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530524func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000525 // return errors.New("sendNextRequest unimplemented")
526
527 // just try to get something transferred !!
528 // avoid accessing the txQueue from parallel send requests
529 // block parallel omci send requests at least until SendIAP is 'committed'
530 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
531 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000532 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000533 for oo.txQueue.Len() > 0 {
534 queueElement := oo.txQueue.Front() // First element
535 omciTxRequest := queueElement.Value.(omciTransferStructure)
536 /* compare olt device handler code:
537 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000538 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000539 var deviceType string
540 var deviceID string
541 var proxyDeviceID string
542
543 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
544
545 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
546
dbainbri4d3a0dc2020-12-02 00:33:42 +0000547 logger.Debugw(ctx,"omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000548 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
549 kwargs := make(map[string]interface{})
550 kwargs["onu_id"] = omciInd.OnuId
551 kwargs["parent_port_no"] = ponPort
552
dbainbri4d3a0dc2020-12-02 00:33:42 +0000553 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000555 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000556 return
557 }
558 deviceType = onuDevice.Type
559 deviceID = onuDevice.Id
560 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
561 //if not exist in cache, then add to cache.
562 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
563 } else {
564 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000565 logger.Debugw(ctx,"omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566 deviceType = onuInCache.(*OnuDevice).deviceType
567 deviceID = onuInCache.(*OnuDevice).deviceID
568 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
569 }
570 */
571 /* and compare onu_adapter py code:
572 omci_msg = InterAdapterOmciMessage(
573 message=bytes(frame),
574 proxy_address=self._proxy_address,
575 connect_status=self._device.connect_status)
576
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000577 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000578
579 yield self._adapter_proxy.send_inter_adapter_message(
580 msg=omci_msg,
581 type=InterAdapterMessageType.OMCI_REQUEST,
582 from_adapter=self._device.type,
583 to_adapter=self._proxy_address.device_type,
584 to_device_id=self._device_id,
585 proxy_device_id=self._proxy_address.device_id
586 )
587 */
mpagenko80622a52021-02-09 16:53:23 +0000588 if omciTxRequest.withFramePrint {
589 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
590 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
591 "device-id": oo.deviceID,
592 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
593 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
594 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200595 omciMsg := &ic.InterAdapterOmciMessage{
596 Message: omciTxRequest.txFrame,
597 ProxyAddress: oo.pBaseDeviceHandler.device.ProxyAddress,
598 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
599 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000600 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000601 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800602 //fromTopic,toType,toDevId, ProxyDevId
603 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000605 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000606 return sendErr
607 }
608 oo.txQueue.Remove(queueElement) // Dequeue
609 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000610 return nil
611}
612
Himani Chawla6d2ae152020-09-02 13:11:20 +0530613func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000614 var next uint16
615 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000616 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000617 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530618 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 if oo.hpTid < 0x8000 {
620 oo.hpTid = 0x8000
621 }
mpagenko900ee4b2020-10-12 11:56:34 +0000622 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000623 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000624 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000625 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530626 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000627 if oo.tid >= 0x8000 {
628 oo.tid = 1
629 }
mpagenko900ee4b2020-10-12 11:56:34 +0000630 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000631 }
632 return next
633}
634
635// ###################################################################################
636// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000637func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000638 omciLayer := &omci.OMCI{
639 TransactionID: tid,
640 MessageType: msgType,
641 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000642 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000643}
644
dbainbri4d3a0dc2020-12-02 00:33:42 +0000645func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000646 var options gopacket.SerializeOptions
647 options.FixLengths = true
648
649 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530650 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000651 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000652 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000653 return nil, err
654 }
655 return buffer.Bytes(), nil
656}
657
Himani Chawla4d908332020-08-31 12:30:20 +0530658/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000659func hexEncode(omciPkt []byte) ([]byte, error) {
660 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
661 hex.Encode(dst, omciPkt)
662 return dst, nil
663}
Himani Chawla4d908332020-08-31 12:30:20 +0530664*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000665
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000666//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000667func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000668
dbainbri4d3a0dc2020-12-02 00:33:42 +0000669 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000670 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000671
672 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000673 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000674 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200675 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000676 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000677 oo.mutexMonReq.RLock()
678 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
mpagenko8cd1bf72021-06-22 10:11:19 +0000679 //implement non-blocking channel send to avoid blocking on mutexMonReq later
680 select {
681 case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true:
682 default:
683 logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{
684 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
685 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000686 } else {
687 logger.Infow(ctx, "reqMon: map entry does not exist!",
688 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
689 }
690 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000691
692 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
693 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000694 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000695 Type: OMCI,
696 Data: OmciMessage{
697 OmciMsg: omciMsg,
698 OmciPacket: packet,
699 },
700 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000701 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000702 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000703
704 return nil
705}
706
Himani Chawla6d2ae152020-09-02 13:11:20 +0530707func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000708
dbainbri4d3a0dc2020-12-02 00:33:42 +0000709 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000710 request := &omci.MibResetRequest{
711 MeBasePacket: omci.MeBasePacket{
712 EntityClass: me.OnuDataClassID,
713 },
714 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530715 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000716 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000718 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000719 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000720 return err
721 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530722 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000723 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000724 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000725 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000726 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000727}
728
Himani Chawla6d2ae152020-09-02 13:11:20 +0530729func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000730 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300731 request := &omci.RebootRequest{
732 MeBasePacket: omci.MeBasePacket{
733 EntityClass: me.OnuGClassID,
734 },
735 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530736 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000737 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300738 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000739 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000740 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300741 return err
742 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530743 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300744 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000745 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300746 }
747
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000748 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300749 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000750 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000751 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300752 return err
753 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000754 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300755 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000756 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200757 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300758 return err
759 }
760 return nil
761}
762
Himani Chawla6d2ae152020-09-02 13:11:20 +0530763func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000764 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000765 request := &omci.MibUploadRequest{
766 MeBasePacket: omci.MeBasePacket{
767 EntityClass: me.OnuDataClassID,
768 },
769 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530770 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000771 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000772 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000773 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000774 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000775 return err
776 }
777 oo.uploadSequNo = 0
778 oo.uploadNoOfCmds = 0
779
Himani Chawla6d2ae152020-09-02 13:11:20 +0530780 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000781 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000782 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000783 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000784 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000785}
786
Himani Chawla6d2ae152020-09-02 13:11:20 +0530787func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000788 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000789 request := &omci.MibUploadNextRequest{
790 MeBasePacket: omci.MeBasePacket{
791 EntityClass: me.OnuDataClassID,
792 },
793 CommandSequenceNumber: oo.uploadSequNo,
794 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530795 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000796 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000797 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000798 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000799 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000800 return err
801 }
802 oo.uploadSequNo++
803
Himani Chawla6d2ae152020-09-02 13:11:20 +0530804 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000805 cbKey: tid,
806 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
807 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
808 // compare also software upgrade download section handling
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000809 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000810 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000811 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000812}
813
Himani Chawlad3dac422021-03-13 02:31:31 +0530814func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
815 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
816 request := &omci.GetAllAlarmsRequest{
817 MeBasePacket: omci.MeBasePacket{
818 EntityClass: me.OnuDataClassID,
819 },
820 AlarmRetrievalMode: byte(alarmRetreivalMode),
821 }
822 tid := oo.getNextTid(highPrio)
823 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
824 if err != nil {
825 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
826 "Err": err, "device-id": oo.deviceID})
827 return err
828 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000829 oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530830
831 omciRxCallbackPair := callbackPair{
832 cbKey: tid,
833 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
834 oo.receiveOmciResponse, true},
835 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000836 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530837}
838
839func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000840 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530841 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
842 "alarmUploadSeqNo": alarmUploadSeqNo})
843 request := &omci.GetAllAlarmsNextRequest{
844 MeBasePacket: omci.MeBasePacket{
845 EntityClass: me.OnuDataClassID,
846 },
847 CommandSequenceNumber: alarmUploadSeqNo,
848 }
849 tid := oo.getNextTid(highPrio)
850 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
851 if err != nil {
852 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
853 "Err": err, "device-id": oo.deviceID})
854 return err
855 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000856 oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530857
858 omciRxCallbackPair := callbackPair{
859 cbKey: tid,
860 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
861 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000862 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530863}
864
ozgecanetsiab36ed572021-04-01 10:38:48 +0300865func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530866 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000867 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000868 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000869
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000870 meParams := me.ParamData{
871 EntityID: galEthernetEID,
872 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
873 }
874 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
875 if omciErr.GetError() == nil {
876 //all setByCreate parameters already set, no default option required ...
877 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
878 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000879 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000880 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300881 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000882 }
883
dbainbri4d3a0dc2020-12-02 00:33:42 +0000884 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000885 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000886 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000887 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300888 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000889 }
890
Himani Chawla6d2ae152020-09-02 13:11:20 +0530891 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000892 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000893 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000894 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000895 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000896 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000897 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000898 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300899 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000900 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000901 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300902 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000903 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000904 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000905 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300906 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907}
908
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000909// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
ozgecanetsiab36ed572021-04-01 10:38:48 +0300910func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530911 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000912 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000913 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000914
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000915 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
916 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000917 // By now we just use fix values to fire - this is anyway what the python adapter does
918 // read ONU-2G from DB ???? //TODO!!!
919 meParams := me.ParamData{
920 EntityID: 0,
921 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
922 }
923 meInstance, omciErr := me.NewOnu2G(meParams)
924 if omciErr.GetError() == nil {
925 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
926 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000927 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000928 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300929 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000930 }
931
dbainbri4d3a0dc2020-12-02 00:33:42 +0000932 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000933 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000934 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000935 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300936 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000937 }
938
Himani Chawla6d2ae152020-09-02 13:11:20 +0530939 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000940 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000941 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000942 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000943 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000944 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000945 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000946 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300947 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000948 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000949 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300950 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000951 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000952 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000953 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300954 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000955}
956
Himani Chawla6d2ae152020-09-02 13:11:20 +0530957func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +0300958 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530959 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530960 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000961 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000962 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000963
964 meParams := me.ParamData{
965 EntityID: instID,
966 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300967 "Priority": 0x8000,
968 "MaxAge": 20 * 256, //20s
969 "HelloTime": 2 * 256, //2s
970 "ForwardDelay": 15 * 256, //15s
971 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000972 },
973 }
974
975 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
976 if omciErr.GetError() == nil {
977 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
978 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
979 omci.TransactionID(tid), omci.AddDefaults(true))
980 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000981 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000982 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300983 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000984 }
985
dbainbri4d3a0dc2020-12-02 00:33:42 +0000986 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000987 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000988 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000989 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300990 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000991 }
992
Himani Chawla6d2ae152020-09-02 13:11:20 +0530993 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000994 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000995 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000996 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000997 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000998 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000999 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001000 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001001 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001002 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001003 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001004 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001005 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001006 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001007 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001008 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001009}
1010
Mahir Gunyel6781f962021-05-16 23:30:08 -07001011func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001012 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301013 tid := oo.getNextTid(highPrio)
Mahir Gunyel6781f962021-05-16 23:30:08 -07001014 instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
1015 if idErr != nil {
1016 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1017 "Err": idErr, "device-id": oo.deviceID})
1018 return nil, idErr
1019 }
1020 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
1021 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.macBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001022
1023 meParams := me.ParamData{
1024 EntityID: instID,
1025 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +05301026 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
1027 "PortNum": aPUniPort.macBpNo,
1028 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +05301029 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001030 },
1031 }
1032 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1033 if omciErr.GetError() == nil {
1034 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1035 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1036 omci.TransactionID(tid), omci.AddDefaults(true))
1037 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001038 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001039 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001040 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001041 }
1042
dbainbri4d3a0dc2020-12-02 00:33:42 +00001043 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001044 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001045 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001046 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001047 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001048 }
1049
Himani Chawla6d2ae152020-09-02 13:11:20 +05301050 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001051 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001052 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001053 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001054 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001055 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001056 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001057 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001058 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001059 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001060 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001061 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001062 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001063 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001064 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001065 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001066}
1067
Himani Chawla6d2ae152020-09-02 13:11:20 +05301068func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001069 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301070 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001071 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301072 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001073 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001074 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001075
1076 // compare python adapter code WA VOL-1311: this is not done here!
1077 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1078 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1079 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301080 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001081 assType = uint8(10) // for VEIP
1082 }
1083 meParams := me.ParamData{
1084 EntityID: instID,
1085 Attributes: me.AttributeValueMap{
1086 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301087 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001088 },
1089 }
1090 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1091 if omciErr.GetError() == nil {
1092 //all setByCreate parameters already set, no default option required ...
1093 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1094 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001095 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001096 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001097 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001098 }
1099
dbainbri4d3a0dc2020-12-02 00:33:42 +00001100 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001101 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001102 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001103 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001104 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001105 }
1106
Himani Chawla6d2ae152020-09-02 13:11:20 +05301107 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001108 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001109 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001110 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001111 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001112 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001113 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001114 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001115 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001116 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001117 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001118 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001119 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001120 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001121 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001122 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001123}
1124
Himani Chawla6d2ae152020-09-02 13:11:20 +05301125func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001126 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301127 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001129 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001130
1131 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1132 meParams := me.ParamData{
1133 EntityID: 0,
1134 Attributes: requestedAttributes,
1135 }
1136 meInstance, omciErr := me.NewOnuG(meParams)
1137 if omciErr.GetError() == nil {
1138 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1139 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001140 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001141 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001142 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001143 }
1144
dbainbri4d3a0dc2020-12-02 00:33:42 +00001145 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001146 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001147 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001148 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001149 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001150 }
1151
Himani Chawla6d2ae152020-09-02 13:11:20 +05301152 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001153 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001154 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001155 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001156 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001157 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001158 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001159 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001160 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001161 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001162 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001163 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001164 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001165 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001166 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001167 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001168}
1169
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001170func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001171 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001172 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001173 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001174 "SequNo": strconv.FormatInt(int64(tid), 16)})
1175
1176 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1177 meParams := me.ParamData{
1178 EntityID: aInstNo,
1179 Attributes: requestedAttributes,
1180 }
1181 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1182 if omciErr.GetError() == nil {
1183 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1184 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001185 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001186 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001187 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001188 }
1189
dbainbri4d3a0dc2020-12-02 00:33:42 +00001190 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001191 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001192 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001193 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001194 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001195 }
1196
1197 omciRxCallbackPair := callbackPair{
1198 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001199 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001200 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001201 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001202 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001203 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001204 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001205 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001206 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001207 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001208 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001209 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001210 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001211 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001212 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001213}
1214
1215/* UniG obsolete by now, left here in case it should be needed once again
1216 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301217func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001218 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301219 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001221 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001222
1223 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1224 meParams := me.ParamData{
1225 EntityID: aInstNo,
1226 Attributes: requestedAttributes,
1227 }
1228 meInstance, omciErr := me.NewUniG(meParams)
1229 if omciErr.GetError() == nil {
1230 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1231 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001232 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001233 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001234 return nil
1235 }
1236
1237 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1238 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001239 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001240 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001241 return nil
1242 }
1243
Himani Chawla6d2ae152020-09-02 13:11:20 +05301244 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001245 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001246 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001247 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001248 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001249 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001250 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001251 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001252 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001253 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001254 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001255 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001256 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001257 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001258 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001259 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001260}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001261*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001262
Himani Chawla6d2ae152020-09-02 13:11:20 +05301263func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001264 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301265 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001267 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001268
1269 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1270 meParams := me.ParamData{
1271 EntityID: aInstNo,
1272 Attributes: requestedAttributes,
1273 }
1274 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1275 if omciErr.GetError() == nil {
1276 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1277 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001278 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001279 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001280 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001281 }
1282
dbainbri4d3a0dc2020-12-02 00:33:42 +00001283 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001284 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001285 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001286 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001287 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001288 }
1289
Himani Chawla6d2ae152020-09-02 13:11:20 +05301290 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001291 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001292 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001293 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001294 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001295 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001296 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001297 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001298 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001299 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001300 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001301 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001302 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001303 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001304 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001305 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001306}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001307
Himani Chawla6d2ae152020-09-02 13:11:20 +05301308func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001309 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001310
Himani Chawla6d2ae152020-09-02 13:11:20 +05301311 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001312 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001313 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001314
1315 meParams := me.ParamData{
1316 EntityID: entityID,
1317 Attributes: requestedAttributes,
1318 }
1319 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1320 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301321 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001322 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1323 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001324 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 +03001325 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001326 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001327 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001328 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001329 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001330 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001331 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301332 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001333 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001334 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001335 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001336 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001337 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001338 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001339 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001340 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001341 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001342 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001343 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001344 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001345 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001346}
1347
Himani Chawla43f95ff2021-06-03 00:24:12 +05301348func (oo *omciCC) sendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16,
1349 timeout int, highPrio bool, rxChan chan Message) error {
1350
1351 tid := oo.getNextTid(highPrio)
1352 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
1353 "SequNo": strconv.FormatInt(int64(tid), 16)})
1354
1355 request := &omci.GetRequest{
1356 MeBasePacket: omci.MeBasePacket{
1357 EntityInstance: entityID,
1358 EntityClass: classID,
1359 },
1360 AttributeMask: requestedAttributesMask,
1361 }
1362
1363 pkt, err := serialize(ctx, omci.GetRequestType, request, tid)
1364 if err != nil {
1365 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1366 return err
1367 }
1368 omciRxCallbackPair := callbackPair{
1369 cbKey: tid,
1370 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1371 }
1372 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
1373 if err != nil {
1374 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID})
1375 return err
1376 }
1377 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID})
1378 return nil
1379}
1380
Himani Chawla6d2ae152020-09-02 13:11:20 +05301381func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001382 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301383 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001384 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001385 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1386
1387 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001388 EntityID: aInstID,
1389 Attributes: me.AttributeValueMap{
1390 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1391 "TpPointer": 0xFFFF,
1392 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1393 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1394 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1395 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1396 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1397 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1398 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1399 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1400 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001401 }
1402 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1403 if omciErr.GetError() == nil {
1404 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1405 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1406 omci.TransactionID(tid), omci.AddDefaults(true))
1407 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001408 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001409 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001410 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001411 }
1412
dbainbri4d3a0dc2020-12-02 00:33:42 +00001413 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001414 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001416 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001417 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001418 }
1419
Himani Chawla6d2ae152020-09-02 13:11:20 +05301420 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001422 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001423 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001424 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001426 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001427 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001428 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001429 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001431 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001432 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001434 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001435 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001436}
1437
Himani Chawla6d2ae152020-09-02 13:11:20 +05301438func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001439 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301440 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001441 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001442 "SequNo": strconv.FormatInt(int64(tid), 16),
1443 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1444
1445 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1446 if omciErr.GetError() == nil {
1447 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1448 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1449 omci.TransactionID(tid), omci.AddDefaults(true))
1450 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001451 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001452 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001453 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001454 }
1455
dbainbri4d3a0dc2020-12-02 00:33:42 +00001456 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001457 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001458 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001459 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001460 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001461 }
1462
Himani Chawla6d2ae152020-09-02 13:11:20 +05301463 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001464 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001465 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001467 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001468 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001469 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001470 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001471 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001472 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001473 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001474 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001475 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001476 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001477 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001478 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001479}
1480
Himani Chawla6d2ae152020-09-02 13:11:20 +05301481func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001482 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301483 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001484 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001485 "SequNo": strconv.FormatInt(int64(tid), 16),
1486 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1487
1488 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1489 if omciErr.GetError() == nil {
1490 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1491 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1492 omci.TransactionID(tid), omci.AddDefaults(true))
1493 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001494 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001495 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001496 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001497 }
1498
dbainbri4d3a0dc2020-12-02 00:33:42 +00001499 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001500 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001501 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001502 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001503 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001504 }
1505
Himani Chawla6d2ae152020-09-02 13:11:20 +05301506 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001507 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001508 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001509 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001510 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001511 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001512 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001513 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001514 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001515 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001516 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001517 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001518 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001519 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001520 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001521 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001522}
1523
ozgecanetsia82b91a62021-05-21 18:54:49 +03001524func (oo *omciCC) sendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
1525 tid := oo.getNextTid(highPrio)
1526 logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID,
1527 "SequNo": strconv.FormatInt(int64(tid), 16),
1528 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1529
1530 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1531 if omciErr.GetError() == nil {
1532 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1533 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1534 omci.TransactionID(tid), omci.AddDefaults(true))
1535 if err != nil {
1536 logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{
1537 "Err": err, "device-id": oo.deviceID})
1538 return nil, err
1539 }
1540
1541 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1542 if err != nil {
1543 logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{
1544 "Err": err, "device-id": oo.deviceID})
1545 return nil, err
1546 }
1547
1548 omciRxCallbackPair := callbackPair{
1549 cbKey: tid,
1550 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1551 }
1552 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
1553 if err != nil {
1554 logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{
1555 "Err": err, "device-id": oo.deviceID})
1556 return nil, err
1557 }
1558 logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID})
1559 return meInstance, nil
1560 }
1561 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
1562 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1563 return nil, omciErr.GetError()
1564}
1565
Himani Chawla6d2ae152020-09-02 13:11:20 +05301566func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001567 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301568 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001569 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001570 "SequNo": strconv.FormatInt(int64(tid), 16),
1571 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1572
1573 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1574 if omciErr.GetError() == nil {
1575 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1576 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1577 omci.TransactionID(tid))
1578 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001579 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001580 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001581 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001582 }
1583
dbainbri4d3a0dc2020-12-02 00:33:42 +00001584 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001585 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001586 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001587 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001588 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001589 }
1590
Himani Chawla6d2ae152020-09-02 13:11:20 +05301591 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001592 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001593 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001594 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001595 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001596 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001597 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001598 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001599 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001600 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001601 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001602 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001603 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001604 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001605 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001606 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001607}
1608
Himani Chawla6d2ae152020-09-02 13:11:20 +05301609func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001610 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301611 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001612 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001613 "SequNo": strconv.FormatInt(int64(tid), 16),
1614 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1615
1616 meInstance, omciErr := me.NewTCont(params[0])
1617 if omciErr.GetError() == nil {
1618 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1619 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001620 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001621 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001622 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001623 }
1624
dbainbri4d3a0dc2020-12-02 00:33:42 +00001625 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001626 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001627 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001628 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001629 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001630 }
1631
Himani Chawla6d2ae152020-09-02 13:11:20 +05301632 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001633 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001634 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001635 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001636 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001637 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001638 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001639 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001640 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001641 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001642 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001643 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001644 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001645 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001646 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001647 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001648}
1649
Himani Chawla6d2ae152020-09-02 13:11:20 +05301650func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001651 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301652 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001653 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001654 "SequNo": strconv.FormatInt(int64(tid), 16),
1655 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1656
1657 meInstance, omciErr := me.NewPriorityQueue(params[0])
1658 if omciErr.GetError() == nil {
1659 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1660 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001662 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001663 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001664 }
1665
dbainbri4d3a0dc2020-12-02 00:33:42 +00001666 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001667 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001668 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001669 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001670 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001671 }
1672
Himani Chawla6d2ae152020-09-02 13:11:20 +05301673 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001674 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001675 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001676 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001677 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001678 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001679 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001680 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001681 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001682 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001683 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001684 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001685 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001686 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001687 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001688 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001689}
1690
Himani Chawla6d2ae152020-09-02 13:11:20 +05301691func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001692 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301693 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001694 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001695 "SequNo": strconv.FormatInt(int64(tid), 16),
1696 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1697
1698 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1699 if omciErr.GetError() == nil {
1700 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1701 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001702 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001703 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001704 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001705 }
1706
dbainbri4d3a0dc2020-12-02 00:33:42 +00001707 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001708 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001709 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001710 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001711 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001712 }
1713
Himani Chawla6d2ae152020-09-02 13:11:20 +05301714 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001715 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001716 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001717 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001718 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001719 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001720 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001721 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001722 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001723 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001724 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001725 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001726 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001727 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001728 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001729 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001730}
mpagenkodff5dda2020-08-28 11:52:01 +00001731
Himani Chawla6d2ae152020-09-02 13:11:20 +05301732func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001733 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301734 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001735 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001736 "SequNo": strconv.FormatInt(int64(tid), 16),
1737 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1738
1739 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1740 if omciErr.GetError() == nil {
1741 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1742 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1743 omci.TransactionID(tid))
1744 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001745 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001746 "Err": err, "device-id": oo.deviceID})
1747 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1748 // return (dual format) error code that can be used at caller for immediate error treatment
1749 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001750 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001751 }
1752
dbainbri4d3a0dc2020-12-02 00:33:42 +00001753 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001756 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001757 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001758 }
1759
Himani Chawla6d2ae152020-09-02 13:11:20 +05301760 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001761 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001762 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001763 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001764 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001765 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001766 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001767 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001768 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001769 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001770 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001771 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001772 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001773 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001774 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001775 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001776}
1777
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001778// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001779func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001780 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001781 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001782 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001783 "SequNo": strconv.FormatInt(int64(tid), 16),
1784 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1785
1786 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1787 if omciErr.GetError() == nil {
1788 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1789 omci.TransactionID(tid))
1790 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001791 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001792 "Err": err, "device-id": oo.deviceID})
1793 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1794 // return (dual format) error code that can be used at caller for immediate error treatment
1795 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001796 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001797 }
1798
dbainbri4d3a0dc2020-12-02 00:33:42 +00001799 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001800 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001801 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001802 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001803 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001804 }
1805
1806 omciRxCallbackPair := callbackPair{
1807 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001808 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001809 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001810 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001811 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001812 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001813 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001814 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001815 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001816 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001817 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001818 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001819 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001820 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001821 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001822}
1823
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001824func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001825 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001826 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001827 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001828 "SequNo": strconv.FormatInt(int64(tid), 16),
1829 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1830
1831 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1832 if omciErr.GetError() == nil {
1833 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1834 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001835 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001836 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001837 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001838 }
1839
dbainbri4d3a0dc2020-12-02 00:33:42 +00001840 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001841 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001842 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001843 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001844 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001845 }
1846
1847 omciRxCallbackPair := callbackPair{
1848 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001849 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001850 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001851 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001852 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001853 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001854 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001855 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001856 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001857 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001858 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001859 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001860 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001861 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001862 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001863}
1864
Himani Chawla6d2ae152020-09-02 13:11:20 +05301865func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001866 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301867 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001868 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001869 "SequNo": strconv.FormatInt(int64(tid), 16),
1870 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1871
1872 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1873 if omciErr.GetError() == nil {
1874 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1875 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001876 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001877 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001878 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001879 }
1880
dbainbri4d3a0dc2020-12-02 00:33:42 +00001881 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001882 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001883 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001884 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001885 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001886 }
1887
Himani Chawla6d2ae152020-09-02 13:11:20 +05301888 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001889 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001890 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001891 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001892 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001893 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001894 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001895 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001896 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001897 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001899 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001900 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001901 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001902 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001903 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001904}
mpagenko01e726e2020-10-23 09:45:29 +00001905
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001906func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001907 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001908 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001909 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001910 "SequNo": strconv.FormatInt(int64(tid), 16),
1911 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1912
1913 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1914 if omciErr.GetError() == nil {
1915 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1916 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001917 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001918 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001919 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001920 }
1921
dbainbri4d3a0dc2020-12-02 00:33:42 +00001922 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001923 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001924 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001925 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001926 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001927 }
1928
1929 omciRxCallbackPair := callbackPair{
1930 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001931 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001932 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001933 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001934 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001935 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001936 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001937 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001938 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001939 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001940 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001941 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001942 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001943 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001944 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001945}
1946
mpagenko01e726e2020-10-23 09:45:29 +00001947func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001948 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko01e726e2020-10-23 09:45:29 +00001949 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001950 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001951 "SequNo": strconv.FormatInt(int64(tid), 16),
1952 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1953
1954 meParams := me.ParamData{EntityID: aInstID}
1955 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1956 if omciErr.GetError() == nil {
1957 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1958 omci.TransactionID(tid))
1959 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001960 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001961 "Err": err, "device-id": oo.deviceID})
1962 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1963 // return (dual format) error code that can be used at caller for immediate error treatment
1964 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001965 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001966 }
1967
dbainbri4d3a0dc2020-12-02 00:33:42 +00001968 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001969 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001970 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001971 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001972 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001973 }
1974
1975 omciRxCallbackPair := callbackPair{
1976 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001977 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001978 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001979 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00001980 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001981 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001982 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001983 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001984 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001985 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001986 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00001987 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001988 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001989 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001990 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00001991}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001992
ozgecanetsia82b91a62021-05-21 18:54:49 +03001993func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001994 tid := oo.getNextTid(highPrio)
1995 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1996 "SequNo": strconv.FormatInt(int64(tid), 16),
1997 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1998 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1999 if omciErr.GetError() == nil {
2000 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
2001 if err != nil {
2002 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002003 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002004 }
2005 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2006 if err != nil {
2007 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002008 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002009 }
2010 omciRxCallbackPair := callbackPair{
2011 cbKey: tid,
2012 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2013 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002014 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002015 if err != nil {
2016 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002017 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002018 }
2019 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002020 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002021 }
2022 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002023 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002024}
2025
2026// nolint: unused
2027func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002028 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03002029 tid := oo.getNextTid(highPrio)
2030 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
2031 "SequNo": strconv.FormatInt(int64(tid), 16),
2032 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2033
2034 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
2035 if omciErr.GetError() == nil {
2036 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
2037 if err != nil {
2038 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002039 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002040 }
2041 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2042 if err != nil {
2043 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002044 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002045 }
2046 omciRxCallbackPair := callbackPair{
2047 cbKey: tid,
2048 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2049 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002050 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002051 if err != nil {
2052 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002053 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002054 }
2055 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002056 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002057 }
2058 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002059 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002060
2061}
2062
2063// nolint: unused
2064func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002065 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03002066 tid := oo.getNextTid(highPrio)
2067 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
2068 "SequNo": strconv.FormatInt(int64(tid), 16),
2069 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2070
2071 meParams := me.ParamData{EntityID: aInstID}
2072 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
2073 if omciErr.GetError() == nil {
2074 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
2075 if err != nil {
2076 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002077 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002078 }
2079 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2080 if err != nil {
2081 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002082 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002083 }
2084 omciRxCallbackPair := callbackPair{
2085 cbKey: tid,
2086 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2087 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002088 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002089 if err != nil {
2090 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002091 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002092 }
2093 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002094 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002095 }
2096 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002097 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002098
2099}
2100
mpagenko8b07c1b2020-11-26 10:36:31 +00002101func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002102 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002103 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002104 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002105 "SequNo": strconv.FormatInt(int64(tid), 16),
2106 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2107
2108 meParams := me.ParamData{EntityID: aInstID}
2109 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2110 if omciErr.GetError() == nil {
2111 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2112 omci.TransactionID(tid))
2113 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002114 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002115 "Err": err, "device-id": oo.deviceID})
2116 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2117 // return (dual format) error code that can be used at caller for immediate error treatment
2118 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002119 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002120 }
2121
dbainbri4d3a0dc2020-12-02 00:33:42 +00002122 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002123 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002124 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002125 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002126 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002127 }
2128
2129 omciRxCallbackPair := callbackPair{
2130 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002131 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002132 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002133 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002134 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002136 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002137 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002138 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002139 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002140 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002141 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002142 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002143 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002144 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002145}
2146
2147func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002148 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002149 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002150 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002151 "SequNo": strconv.FormatInt(int64(tid), 16),
2152 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2153
2154 meParams := me.ParamData{EntityID: aInstID}
2155 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2156 if omciErr.GetError() == nil {
2157 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2158 omci.TransactionID(tid))
2159 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002160 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002161 "Err": err, "device-id": oo.deviceID})
2162 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2163 // return (dual format) error code that can be used at caller for immediate error treatment
2164 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002165 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002166 }
2167
dbainbri4d3a0dc2020-12-02 00:33:42 +00002168 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002169 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002170 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002171 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002172 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002173 }
2174
2175 omciRxCallbackPair := callbackPair{
2176 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002177 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002178 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002179 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002180 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002181 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002182 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002183 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002184 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002185 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002186 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002187 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002188 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002189 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002190 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002191}
2192
2193func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002194 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002195 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002196 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002197 "SequNo": strconv.FormatInt(int64(tid), 16),
2198 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2199
2200 meParams := me.ParamData{EntityID: aInstID}
2201 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2202 if omciErr.GetError() == nil {
2203 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2204 omci.TransactionID(tid))
2205 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002206 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002207 "Err": err, "device-id": oo.deviceID})
2208 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2209 // return (dual format) error code that can be used at caller for immediate error treatment
2210 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002211 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002212 }
2213
dbainbri4d3a0dc2020-12-02 00:33:42 +00002214 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002215 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002216 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002217 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002218 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002219 }
2220
2221 omciRxCallbackPair := callbackPair{
2222 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002223 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002224 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002225 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002226 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002227 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002228 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002229 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002230 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002231 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002232 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002233 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002235 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002236 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002237}
2238
2239func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002240 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002241 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002242 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002243 "SequNo": strconv.FormatInt(int64(tid), 16),
2244 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2245
2246 meParams := me.ParamData{EntityID: aInstID}
2247 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2248 if omciErr.GetError() == nil {
2249 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2250 omci.TransactionID(tid))
2251 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002252 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002253 "Err": err, "device-id": oo.deviceID})
2254 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2255 // return (dual format) error code that can be used at caller for immediate error treatment
2256 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002257 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002258 }
2259
dbainbri4d3a0dc2020-12-02 00:33:42 +00002260 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002261 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002262 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002263 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002264 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002265 }
2266
2267 omciRxCallbackPair := callbackPair{
2268 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002269 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002270 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002271 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002272 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002273 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002274 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002275 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002276 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002277 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002278 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002279 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002280 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002281 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002282 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002283}
2284
ozgecanetsia422dbf32020-10-28 14:07:19 +03002285func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002286 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002287 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002288 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002289 "SequNo": strconv.FormatInt(int64(tid), 16),
2290 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2291
2292 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2293 if omciErr.GetError() == nil {
2294 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2295 omci.AddDefaults(true))
2296 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002297 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002298 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002299 }
2300
dbainbri4d3a0dc2020-12-02 00:33:42 +00002301 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002302 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002303 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002304 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002305 }
2306
2307 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002308 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002309 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002310 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002311 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002312 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002313 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002314 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002315 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002316 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002317 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002318 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002319 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002320 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002321}
2322
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002323func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002324 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002325 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002326 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002327 "SequNo": strconv.FormatInt(int64(tid), 16),
2328 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2329
2330 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2331 if omciErr.GetError() == nil {
2332 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2333 omci.AddDefaults(true))
2334 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002335 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002336 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002337 }
2338
dbainbri4d3a0dc2020-12-02 00:33:42 +00002339 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002340 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002341 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002342 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002343 }
2344
2345 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002346 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002347 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002348 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002349 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002350 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002351 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002352 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002353 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002354 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002355 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002356 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002357 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002358 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002359}
2360
ozgecanetsia422dbf32020-10-28 14:07:19 +03002361func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002362 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002363 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002364 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002365 "SequNo": strconv.FormatInt(int64(tid), 16),
2366 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2367
2368 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2369 if omciErr.GetError() == nil {
2370 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2371 omci.AddDefaults(true))
2372 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002373 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002374 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002375 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002376 }
2377
dbainbri4d3a0dc2020-12-02 00:33:42 +00002378 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002379 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002380 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002381 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002382 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002383 }
2384
2385 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002386 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002387 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002388 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002389 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002390 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002391 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002392 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002394 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002395 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002396 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002397 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002398 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002399 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002400}
2401
2402func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002403 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002404 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002405 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002406 "SequNo": strconv.FormatInt(int64(tid), 16),
2407 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2408
2409 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2410 if omciErr.GetError() == nil {
2411 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2412 omci.AddDefaults(true))
2413 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002414 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002415 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002416 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002417 }
2418
dbainbri4d3a0dc2020-12-02 00:33:42 +00002419 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002420 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002421 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002422 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002423 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002424 }
2425
2426 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002427 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002428 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002429 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002430 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002431 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002432 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002433 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002434 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002435 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002436 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002437 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002438 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002439 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002440 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002441}
2442
2443func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002444 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002445 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002446 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002447 "SequNo": strconv.FormatInt(int64(tid), 16),
2448 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2449
2450 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2451 if omciErr.GetError() == nil {
2452 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2453 omci.AddDefaults(true))
2454 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002455 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002456 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002457 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002458 }
2459
dbainbri4d3a0dc2020-12-02 00:33:42 +00002460 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002461 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002462 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002463 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002464 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002465 }
2466
2467 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002468 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002469 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002470 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002471 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002472 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002473 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002474 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002475 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002476 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002477 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002478 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002479 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002480 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002481 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002482}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002483
Girish Gowdrae0140f02021-02-02 16:55:09 -08002484func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2485 tid := oo.getNextTid(highPrio)
2486 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2487 "SequNo": strconv.FormatInt(int64(tid), 16)})
2488
2489 omciLayer := &omci.OMCI{
2490 TransactionID: tid,
2491 MessageType: omci.SynchronizeTimeRequestType,
2492 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2493 // Length: 0x28, // Optional, defaults to 40 octets
2494 }
2495 utcTime := time.Now().UTC()
2496 request := &omci.SynchronizeTimeRequest{
2497 MeBasePacket: omci.MeBasePacket{
2498 EntityClass: me.OnuGClassID,
2499 // Default Instance ID is 0
2500 },
2501 Year: uint16(utcTime.Year()),
2502 Month: uint8(utcTime.Month()),
2503 Day: uint8(utcTime.Day()),
2504 Hour: uint8(utcTime.Hour()),
2505 Minute: uint8(utcTime.Minute()),
2506 Second: uint8(utcTime.Second()),
2507 }
2508
2509 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2510 if err != nil {
2511 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2512 "device-id": oo.deviceID})
2513 return err
2514 }
2515
2516 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002517 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002518 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002519 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002520 if err != nil {
2521 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2522 "device-id": oo.deviceID})
2523 return err
2524 }
2525 logger.Debug(ctx, "send synchronize time request done")
2526 return nil
2527}
2528
2529func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002530 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002531 tid := oo.getNextTid(highPrio)
2532 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2533 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2534 meParam := me.ParamData{EntityID: entityID}
2535 var meInstance *me.ManagedEntity
2536 var omciErr me.OmciErrors
2537 if upstream {
2538 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2539 } else {
2540 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2541 }
2542 if omciErr.GetError() == nil {
2543 var omciLayer *omci.OMCI
2544 var msgLayer gopacket.SerializableLayer
2545 var err error
2546 if create {
2547 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2548 omci.AddDefaults(true))
2549 } else {
2550 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2551 omci.AddDefaults(true))
2552 }
2553 if err != nil {
2554 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2555 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002556 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002557 }
2558
2559 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2560 if err != nil {
2561 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2562 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002563 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002564 }
2565
2566 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002567 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002568 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002569 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002570 if err != nil {
2571 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2572 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002573 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002574 }
2575 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2576 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002577 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002578 }
2579 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2580 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 +03002581 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002582}
2583
2584func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002585 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002586 tid := oo.getNextTid(highPrio)
2587 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2588 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2589 meParam := me.ParamData{EntityID: entityID}
2590 var meInstance *me.ManagedEntity
2591 var omciErr me.OmciErrors
2592 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2593
2594 if omciErr.GetError() == nil {
2595 var omciLayer *omci.OMCI
2596 var msgLayer gopacket.SerializableLayer
2597 var err error
2598 if create {
2599 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2600 omci.AddDefaults(true))
2601 } else {
2602 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2603 omci.AddDefaults(true))
2604 }
2605 if err != nil {
2606 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2607 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002608 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002609 }
2610
2611 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2612 if err != nil {
2613 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2614 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002615 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002616 }
2617
2618 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002619 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002620 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002621 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002622 if err != nil {
2623 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2624 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002625 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002626 }
2627 logger.Debugw(ctx, "send ethernet uni history data ME done",
2628 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002629 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002630 }
2631 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2632 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002633 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002634}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002635
2636func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002637 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002638 tid := oo.getNextTid(highPrio)
2639 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2640 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2641 meParam := me.ParamData{EntityID: entityID}
2642 var meInstance *me.ManagedEntity
2643 var omciErr me.OmciErrors
2644 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2645
2646 if omciErr.GetError() == nil {
2647 var omciLayer *omci.OMCI
2648 var msgLayer gopacket.SerializableLayer
2649 var err error
2650 if create {
2651 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2652 omci.AddDefaults(true))
2653 } else {
2654 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2655 omci.AddDefaults(true))
2656 }
2657 if err != nil {
2658 logger.Errorw(ctx, "Cannot encode fec history data ME",
2659 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002660 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002661 }
2662
2663 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2664 if err != nil {
2665 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2666 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002667 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002668 }
2669
2670 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002671 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002672 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002673 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002674 if err != nil {
2675 logger.Errorw(ctx, "Cannot send fec history data ME",
2676 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002677 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002678 }
2679 logger.Debugw(ctx, "send fec history data ME done",
2680 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002681 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002682 }
2683 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2684 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002685 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002686}
2687
2688func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002689 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002690 tid := oo.getNextTid(highPrio)
2691 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2692 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2693 meParam := me.ParamData{EntityID: entityID}
2694 var meInstance *me.ManagedEntity
2695 var omciErr me.OmciErrors
2696 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2697
2698 if omciErr.GetError() == nil {
2699 var omciLayer *omci.OMCI
2700 var msgLayer gopacket.SerializableLayer
2701 var err error
2702 if create {
2703 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2704 omci.AddDefaults(true))
2705 } else {
2706 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2707 omci.AddDefaults(true))
2708 }
2709 if err != nil {
2710 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2711 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002712 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002713 }
2714
2715 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2716 if err != nil {
2717 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2718 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002719 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002720 }
2721
2722 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002723 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002724 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002725 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002726 if err != nil {
2727 logger.Errorw(ctx, "Cannot send gemport history data ME",
2728 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002729 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002730 }
2731 logger.Debugw(ctx, "send gemport history data ME done",
2732 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002733 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002734 }
2735 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2736 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002737 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002738}
2739
mpagenko80622a52021-02-09 16:53:23 +00002740func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2741 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2742 tid := oo.getNextTid(highPrio)
2743 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2744 "SequNo": strconv.FormatInt(int64(tid), 16),
2745 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2746
2747 omciLayer := &omci.OMCI{
2748 TransactionID: tid,
2749 MessageType: omci.StartSoftwareDownloadRequestType,
2750 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2751 // Length: 0x28, // Optional, defaults to 40 octets
2752 }
2753 request := &omci.StartSoftwareDownloadRequest{
2754 MeBasePacket: omci.MeBasePacket{
2755 EntityClass: me.SoftwareImageClassID,
2756 EntityInstance: aImageMeID, //inactive image
2757 },
2758 WindowSize: aDownloadWindowSize,
2759 ImageSize: aFileLen,
2760 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2761 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2762 }
2763
2764 var options gopacket.SerializeOptions
2765 options.FixLengths = true
2766 buffer := gopacket.NewSerializeBuffer()
2767 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2768 if err != nil {
2769 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2770 "device-id": oo.deviceID})
2771 return err
2772 }
2773 outgoingPacket := buffer.Bytes()
2774
2775 omciRxCallbackPair := callbackPair{cbKey: tid,
2776 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2777 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002778 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002779 if err != nil {
2780 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2781 "device-id": oo.deviceID})
2782 return err
2783 }
2784 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002785 return nil
2786}
2787
mpagenkoc26d4c02021-05-06 14:27:57 +00002788func (oo *omciCC) sendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002789 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2790 tid := oo.getNextTid(highPrio)
2791 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2792 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002793 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002794
2795 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2796 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002797 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00002798 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00002799 if aAckRequest > 0 {
2800 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00002801 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00002802 }
mpagenko80622a52021-02-09 16:53:23 +00002803 omciLayer := &omci.OMCI{
2804 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002805 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002806 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2807 // Length: 0x28, // Optional, defaults to 40 octets
2808 }
Himani Chawla43f95ff2021-06-03 00:24:12 +05302809 localSectionData := make([]byte, len(aSection))
2810
mpagenko15ff4a52021-03-02 10:09:20 +00002811 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002812 request := &omci.DownloadSectionRequest{
2813 MeBasePacket: omci.MeBasePacket{
2814 EntityClass: me.SoftwareImageClassID,
2815 EntityInstance: aImageMeID, //inactive image
2816 },
2817 SectionNumber: aDownloadSectionNo,
2818 SectionData: localSectionData,
2819 }
2820
2821 var options gopacket.SerializeOptions
2822 options.FixLengths = true
2823 buffer := gopacket.NewSerializeBuffer()
2824 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2825 if err != nil {
2826 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2827 "device-id": oo.deviceID})
2828 return err
2829 }
2830 outgoingPacket := buffer.Bytes()
2831
mpagenko15ff4a52021-03-02 10:09:20 +00002832 //for initial debug purpose overrule the requested print state for some frames
2833 printFrame := aPrint
2834 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2835 printFrame = true
2836 }
2837
mpagenko80622a52021-02-09 16:53:23 +00002838 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00002839 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
2840 // (used to avoid retransmission of frames with the same TID)
mpagenko15ff4a52021-03-02 10:09:20 +00002841 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002842 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002843 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002844 if err != nil {
2845 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2846 "device-id": oo.deviceID})
2847 return err
2848 }
2849 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002850 return nil
2851}
2852
2853func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2854 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2855 tid := oo.getNextTid(highPrio)
2856 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2857 "SequNo": strconv.FormatInt(int64(tid), 16),
2858 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2859
mpagenko15ff4a52021-03-02 10:09:20 +00002860 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002861 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002862 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002863 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2864 // Length: 0x28, // Optional, defaults to 40 octets
2865 }
mpagenko15ff4a52021-03-02 10:09:20 +00002866 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002867 MeBasePacket: omci.MeBasePacket{
2868 EntityClass: me.SoftwareImageClassID,
2869 EntityInstance: aImageMeID, //inactive image
2870 },
mpagenko15ff4a52021-03-02 10:09:20 +00002871 CRC32: aImageCrc,
2872 ImageSize: aFileLen,
2873 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2874 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002875 }
mpagenko15ff4a52021-03-02 10:09:20 +00002876
2877 var options gopacket.SerializeOptions
2878 options.FixLengths = true
2879 buffer := gopacket.NewSerializeBuffer()
2880 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2881 if err != nil {
2882 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002883 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002884 return err
mpagenko80622a52021-02-09 16:53:23 +00002885 }
mpagenko15ff4a52021-03-02 10:09:20 +00002886 outgoingPacket := buffer.Bytes()
2887
2888 omciRxCallbackPair := callbackPair{cbKey: tid,
2889 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2890 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002891 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002892 if err != nil {
2893 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2894 "device-id": oo.deviceID})
2895 return err
2896 }
2897 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002898 return nil
2899}
2900
2901func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2902 rxChan chan Message, aImageMeID uint16) error {
2903 tid := oo.getNextTid(highPrio)
2904 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2905 "SequNo": strconv.FormatInt(int64(tid), 16),
2906 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2907
2908 omciLayer := &omci.OMCI{
2909 TransactionID: tid,
2910 MessageType: omci.ActivateSoftwareRequestType,
2911 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2912 // Length: 0x28, // Optional, defaults to 40 octets
2913 }
2914 request := &omci.ActivateSoftwareRequest{
2915 MeBasePacket: omci.MeBasePacket{
2916 EntityClass: me.SoftwareImageClassID,
2917 EntityInstance: aImageMeID, //inactive image
2918 },
2919 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2920 }
2921
2922 var options gopacket.SerializeOptions
2923 options.FixLengths = true
2924 buffer := gopacket.NewSerializeBuffer()
2925 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2926 if err != nil {
2927 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2928 "device-id": oo.deviceID})
2929 return err
2930 }
2931 outgoingPacket := buffer.Bytes()
2932
2933 omciRxCallbackPair := callbackPair{cbKey: tid,
2934 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2935 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002936 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002937 if err != nil {
2938 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2939 "device-id": oo.deviceID})
2940 return err
2941 }
2942 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002943 return nil
2944}
mpagenko80622a52021-02-09 16:53:23 +00002945
mpagenko15ff4a52021-03-02 10:09:20 +00002946func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2947 rxChan chan Message, aImageMeID uint16) error {
2948 tid := oo.getNextTid(highPrio)
2949 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2950 "SequNo": strconv.FormatInt(int64(tid), 16),
2951 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2952
2953 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002954 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002955 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002956 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2957 // Length: 0x28, // Optional, defaults to 40 octets
2958 }
mpagenko15ff4a52021-03-02 10:09:20 +00002959 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002960 MeBasePacket: omci.MeBasePacket{
2961 EntityClass: me.SoftwareImageClassID,
2962 EntityInstance: aImageMeID, //inactive image
2963 },
mpagenko80622a52021-02-09 16:53:23 +00002964 }
mpagenko15ff4a52021-03-02 10:09:20 +00002965
2966 var options gopacket.SerializeOptions
2967 options.FixLengths = true
2968 buffer := gopacket.NewSerializeBuffer()
2969 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2970 if err != nil {
2971 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002972 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002973 return err
mpagenko80622a52021-02-09 16:53:23 +00002974 }
mpagenko15ff4a52021-03-02 10:09:20 +00002975 outgoingPacket := buffer.Bytes()
2976
2977 omciRxCallbackPair := callbackPair{cbKey: tid,
2978 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2979 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002980 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002981 if err != nil {
2982 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2983 "device-id": oo.deviceID})
2984 return err
2985 }
2986 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002987 return nil
2988}
2989
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002990func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
2991 tid := oo.getNextTid(highPrio)
2992 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
2993 "SequNo": strconv.FormatInt(int64(tid), 16),
2994 "InstId": strconv.FormatInt(int64(instdID), 16)})
2995 omciLayer := &omci.OMCI{
2996 TransactionID: tid,
2997 MessageType: omci.TestRequestType,
2998 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2999 // Length: 0x28, // Optional, defaults to 40 octets
3000 }
3001
3002 var request *omci.OpticalLineSupervisionTestRequest
3003 switch classID {
3004 case aniGClassID:
3005 request = &omci.OpticalLineSupervisionTestRequest{
3006 MeBasePacket: omci.MeBasePacket{
3007 EntityClass: classID,
3008 EntityInstance: instdID,
3009 },
3010 SelectTest: uint8(7), // self test
3011 GeneralPurposeBuffer: uint16(0),
3012 VendorSpecificParameters: uint16(0),
3013 }
3014 default:
3015 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
3016 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
3017 }
3018 // Test serialization back to former string
3019 var options gopacket.SerializeOptions
3020 options.FixLengths = true
3021
3022 buffer := gopacket.NewSerializeBuffer()
3023 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
3024 if err != nil {
3025 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
3026 "device-id": oo.deviceID})
3027 return err
3028 }
3029 outgoingPacket := buffer.Bytes()
3030
3031 omciRxCallbackPair := callbackPair{cbKey: tid,
3032 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3033 }
3034 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
3035 if err != nil {
3036 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
3037 "device-id": oo.deviceID})
3038 return err
3039 }
3040 logger.Debug(ctx, "send self test request done")
3041 return nil
3042}
3043
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003044//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003045func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003046 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003047 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07003048 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003049 msgLayer := (*packet).Layer(nextLayer)
3050 switch nextLayer {
3051 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003052 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
3053 if resp.Result == me.Success {
3054 return true
3055 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003056 }
3057 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003058 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
3059 if resp.Result == me.Success {
3060 return true
3061 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003062 }
3063 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003064 if resp := msgLayer.(*omci.SetResponse); resp != nil {
3065 if resp.Result == me.Success {
3066 return true
3067 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003068 }
3069 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003070 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
3071 if resp.Result == me.Success {
3072 return true
3073 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003074 }
3075 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003076 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
3077 if resp.Result == me.Success {
3078 return true
3079 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003080 }
3081 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003082 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
3083 if resp.Result == me.Success {
3084 return true
3085 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003086 }
3087 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003088 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
3089 if resp.Result == me.Success {
3090 return true
3091 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003092 }
3093 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003094 }
3095 }
3096 return false
3097}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003098
3099func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003100 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00003101 if timeout == 0 {
3102 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003103 oo.mutexTxQueue.Lock()
3104 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3105 oo.mutexTxQueue.Unlock()
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003106 go oo.sendNextRequest(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00003107 } else {
mpagenko7455fd42021-06-10 16:25:55 +00003108 //the supervised sending with waiting on the response (based on TID) is called in background
3109 // to avoid blocking of the sender for the complete OMCI handshake procedure
3110 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
3111 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
3112 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003113 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003114}
3115
mpagenko7455fd42021-06-10 16:25:55 +00003116func (oo *omciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest omciTransferStructure, aTimeout int) {
3117 chSuccess := make(chan bool)
3118 aOmciTxRequest.chSuccess = chSuccess
3119 tid := aOmciTxRequest.cbPair.cbKey
3120 oo.mutexMonReq.Lock()
3121 oo.monitoredRequests[tid] = aOmciTxRequest
3122 oo.mutexMonReq.Unlock()
3123
3124 retries := aOmciTxRequest.retries
3125 retryCounter := 0
3126loop:
3127 for retryCounter <= retries {
3128
3129 oo.mutexTxQueue.Lock()
3130 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3131 oo.mutexTxQueue.Unlock()
3132 go oo.sendNextRequest(ctx)
3133
3134 select {
3135 case success := <-chSuccess:
3136 if success {
3137 logger.Debugw(ctx, "reqMon: response received in time",
3138 log.Fields{"tid": tid, "device-id": oo.deviceID})
3139 } else {
3140 logger.Debugw(ctx, "reqMon: wait for response aborted",
3141 log.Fields{"tid": tid, "device-id": oo.deviceID})
3142 }
3143 break loop
3144 case <-time.After(time.Duration(aTimeout) * time.Second):
3145 if retryCounter == retries {
3146 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
3147 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3148 break loop
3149 } else {
3150 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
3151 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3152 }
3153 }
3154 retryCounter++
3155 }
3156 oo.mutexMonReq.Lock()
3157 delete(oo.monitoredRequests, tid)
3158 oo.mutexMonReq.Unlock()
3159}
3160
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003161//CancelRequestMonitoring terminates monitoring of outstanding omci requests
mpagenko8cd1bf72021-06-22 10:11:19 +00003162func (oo *omciCC) CancelRequestMonitoring(ctx context.Context) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003163 oo.mutexMonReq.RLock()
3164 for k := range oo.monitoredRequests {
mpagenko8cd1bf72021-06-22 10:11:19 +00003165 //implement non-blocking channel send to avoid blocking on mutexMonReq later
3166 select {
3167 case oo.monitoredRequests[k].chSuccess <- false:
3168 default:
3169 logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{
3170 "index": k, "device-id": oo.deviceID})
3171 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003172 }
3173 oo.mutexMonReq.RUnlock()
3174}
3175
3176//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
3177//time consumed for retry processing of a particular OMCI-request
3178func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
3179 return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
3180}
Himani Chawla43f95ff2021-06-03 00:24:12 +05303181
3182func (oo *omciCC) sendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool,
3183 upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) {
3184 tid := oo.getNextTid(highPrio)
3185 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID,
3186 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
3187
3188 meParam := me.ParamData{EntityID: entityID,
3189 Attributes: me.AttributeValueMap{"ControlBlock": controlBlock},
3190 }
3191 var meInstance *me.ManagedEntity
3192 var omciErr me.OmciErrors
3193 if classID == me.EthernetFrameExtendedPmClassID {
3194 meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam)
3195 } else {
3196 meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam)
3197 }
3198
3199 if omciErr.GetError() == nil {
3200 var omciLayer *omci.OMCI
3201 var msgLayer gopacket.SerializableLayer
3202 var err error
3203 if create {
3204 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
3205 omci.AddDefaults(true))
3206 } else {
3207 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
3208 omci.AddDefaults(true))
3209 }
3210 if err != nil {
3211 logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me",
3212 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3213 return nil, err
3214 }
3215
3216 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
3217 if err != nil {
3218 logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me",
3219 log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3220 return nil, err
3221 }
3222
3223 omciRxCallbackPair := callbackPair{cbKey: tid,
3224 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3225 }
3226 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
3227 if err != nil {
3228 logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me",
3229 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3230 return nil, err
3231 }
3232 logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done",
3233 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3234 return meInstance, nil
3235 }
3236 logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance",
3237 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)})
3238 return nil, omciErr.GetError()
3239}
Holger Hildebrandtddc4fbd2022-02-04 14:10:36 +00003240
3241// PrepareForGarbageCollection - remove references to prepare for garbage collection
3242func (oo *omciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
3243 logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
3244 oo.pBaseDeviceHandler = nil
3245 oo.pOnuDeviceEntry = nil
3246}