blob: fd931098674218fa9980aceb5cea160a2987f766 [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
Andrea Campanella6515c582020-10-05 11:25:00 +020025 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000027 "sync"
mpagenko80622a52021-02-09 16:53:23 +000028 "time" //by now for testing
Holger Hildebrandtfa074992020-03-27 15:42:06 +000029
30 "github.com/google/gopacket"
31 // TODO!!! Some references could be resolved auto, but some need specific context ....
32 gp "github.com/google/gopacket"
33
34 "github.com/opencord/omci-lib-go"
35 me "github.com/opencord/omci-lib-go/generated"
dbainbri4d3a0dc2020-12-02 00:33:42 +000036 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
39 "github.com/opencord/voltha-lib-go/v4/pkg/log"
amit.ghosh58b704b2021-06-18 03:45:52 +020040 "github.com/opencord/voltha-protos/v4/go/common"
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)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000053
mpagenko8b07c1b2020-11-26 10:36:31 +000054const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
55
mpagenkoc8bba412021-01-15 15:38:44 +000056const cOmciBaseMessageTrailerLen = 40
57
58// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
59type tOmciReceiveError uint8
60
61const (
62 // cOmciMessageReceiveNoError - default start state
63 cOmciMessageReceiveNoError tOmciReceiveError = iota
64 // Error indication wrong trailer length within the message
65 cOmciMessageReceiveErrorTrailerLen
66 // Error indication missing trailer within the message
67 cOmciMessageReceiveErrorMissTrailer
68)
69
Holger Hildebrandt366ef192021-05-05 11:07:44 +000070const cDefaultRetries = 2
71
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000072// ### OMCI related definitions - end
73
Himani Chawla6d2ae152020-09-02 13:11:20 +053074//callbackPairEntry to be used for OMCI send/receive correlation
75type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000076 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000077 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
mpagenko80622a52021-02-09 16:53:23 +000078 framePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000079}
80
Himani Chawla6d2ae152020-09-02 13:11:20 +053081//callbackPair to be used for ReceiveCallback init
82type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000083 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053084 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000085}
86
87type omciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000088 txFrame []byte
89 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000090 retries int
mpagenko80622a52021-02-09 16:53:23 +000091 highPrio bool
92 withFramePrint bool
Holger Hildebrandt366ef192021-05-05 11:07:44 +000093 cbPair callbackPair
94 chSuccess chan bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000095}
96
Himani Chawla6d2ae152020-09-02 13:11:20 +053097//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
98type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +000099 enabled bool
100 pOnuDeviceEntry *OnuDeviceEntry
101 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +0530102 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000103 coreProxy adapterif.CoreProxy
104 adapterProxy adapterif.AdapterProxy
105 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000106 rxOmciFrameError tOmciReceiveError
107
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000108 txFrames, txOnuFrames uint32
109 rxFrames, rxOnuFrames, rxOnuDiscards uint32
110
111 // OMCI params
112 mutexTid sync.Mutex
113 tid uint16
114 mutexHpTid sync.Mutex
115 hpTid uint16
116 uploadSequNo uint16
117 uploadNoOfCmds uint16
118
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000119 mutexTxQueue sync.Mutex
120 txQueue *list.List
121 mutexRxSchedMap sync.Mutex
122 rxSchedulerMap map[uint16]callbackPairEntry
123 mutexMonReq sync.RWMutex
124 monitoredRequests map[uint16]omciTransferStructure
125 mutexPLastTxMeInstance sync.RWMutex
126 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000127}
128
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000129var responsesWithMibDataSync = []omci.MessageType{
130 omci.CreateResponseType,
131 omci.DeleteResponseType,
132 omci.SetResponseType,
133 omci.StartSoftwareDownloadResponseType,
134 omci.EndSoftwareDownloadResponseType,
135 omci.ActivateSoftwareResponseType,
136 omci.CommitSoftwareResponseType,
137}
138
Himani Chawla6d2ae152020-09-02 13:11:20 +0530139//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000140//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530141func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
142 deviceID string, deviceHandler *deviceHandler,
143 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000144 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530145 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000146 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530147 omciCC.pOnuDeviceEntry = onuDeviceEntry
148 omciCC.deviceID = deviceID
149 omciCC.pBaseDeviceHandler = deviceHandler
150 omciCC.coreProxy = coreProxy
151 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000152 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000153 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000154 omciCC.txFrames = 0
155 omciCC.txOnuFrames = 0
156 omciCC.rxFrames = 0
157 omciCC.rxOnuFrames = 0
158 omciCC.rxOnuDiscards = 0
159 omciCC.tid = 0x1
160 omciCC.hpTid = 0x8000
161 omciCC.uploadSequNo = 0
162 omciCC.uploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000163 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530164 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000165 omciCC.monitoredRequests = make(map[uint16]omciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000166
167 return &omciCC
168}
169
mpagenko900ee4b2020-10-12 11:56:34 +0000170//stop stops/resets the omciCC
171func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000172 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000173 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000174 oo.CancelRequestMonitoring()
mpagenko900ee4b2020-10-12 11:56:34 +0000175 oo.mutexTxQueue.Lock()
176 oo.txQueue.Init() // clear the tx queue
177 oo.mutexTxQueue.Unlock()
178 oo.mutexRxSchedMap.Lock()
179 for k := range oo.rxSchedulerMap {
180 delete(oo.rxSchedulerMap, k) //clear the scheduler map
181 }
182 oo.mutexRxSchedMap.Unlock()
183 oo.mutexHpTid.Lock()
184 oo.hpTid = 0x8000 //reset the high prio transactionId
185 oo.mutexHpTid.Unlock()
186 oo.mutexTid.Lock()
187 oo.tid = 1 //reset the low prio transactionId
188 oo.mutexTid.Unlock()
189 //reset control values
190 oo.uploadSequNo = 0
191 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000192 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000193 //reset the stats counter - which might be topic of discussion ...
194 oo.txFrames = 0
195 oo.txOnuFrames = 0
196 oo.rxFrames = 0
197 oo.rxOnuFrames = 0
198 oo.rxOnuDiscards = 0
199
200 return nil
201}
202
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000203// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530204func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000205 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000206 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530207 switch omciMsg.MessageType {
208 case omci.AlarmNotificationType:
209 data := OmciMessage{
210 OmciMsg: omciMsg,
211 OmciPacket: packet,
212 }
213 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
214 return nil
215 default:
216 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
217 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000218 /*
219 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
220 rxOnuFrames++
221
222 switch msgType {
223 case AlarmNotification:
224 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000225 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000226 // python code was:
227 //if msg_type == EntityOperations.AlarmNotification.value:
228 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
229 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
230 //
231 return errors.New("RxAlarmNotification unimplemented")
232 }
233 case AttributeValueChange:
234 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000235 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000236 // python code was:
237 //elif msg_type == EntityOperations.AttributeValueChange.value:
238 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
239 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
240 //
241 return errors.New("RxAttributeValueChange unimplemented")
242 }
243 case TestResult:
244 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000245 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000246 // python code was:
247 //elif msg_type == EntityOperations.TestResult.value:
248 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
249 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
250 //
251 return errors.New("RxTestResult unimplemented")
252 }
253 default:
254 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000255 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000256 rxOnuDiscards++
257 return errors.New("RxOnuMsgType unimplemented")
258 }
259 }
260 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000261}
262
mpagenko80622a52021-02-09 16:53:23 +0000263func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
264 //assuming omci message content is hex coded!
265 // with restricted output of 16bytes would be ...rxMsg[:16]
266 logger.Debugw(ctx, "omci-message-received:", log.Fields{
267 "RxOmciMessage": hex.EncodeToString(rxMsg),
268 "device-id": oo.deviceID})
269}
270
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000271// Rx handler for onu messages
272// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530273func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000274 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000275 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
276 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000277 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000278 trailerLenData := rxMsg[42:44]
279 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000280 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000281 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
282 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
283 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
284 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
285 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
286 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
287 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
288 }
289 }
290 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
291 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
292 // (an extendedFormat message could be destroyed this way!)
293 // extend/overwrite with trailer
294 trailer := make([]byte, 8)
295 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
296 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
297 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
298 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
299 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
300 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
301 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000302 }
303 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000304 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
305 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000306 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200307 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000308 }
309
310 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
311 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000312 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000313 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200314 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000315 }
316 omciLayer := packet.Layer(omci.LayerTypeOMCI)
317 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000318 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000319 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200320 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000321 }
322 omciMsg, ok := omciLayer.(*omci.OMCI)
323 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000324 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000325 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200326 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000327 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000328 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000329 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700330 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
331 // We expect to find the TID in the oo.rxSchedulerMap
332 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000333 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000334 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000335 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000336 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530337 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000338 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000339 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200340 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000341 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200342 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530343 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000344 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530345 oo.mutexRxSchedMap.Lock()
346 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
347 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000348 if rxCallbackEntry.framePrint {
349 oo.printRxMessage(ctx, rxMsg)
350 }
Himani Chawla4d908332020-08-31 12:30:20 +0530351 //disadvantage of decoupling: error verification made difficult, but anyway the question is
352 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000353 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000354 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000355 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
356 }
mpagenkoc8bba412021-01-15 15:38:44 +0000357
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700358 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
359 // so do not clean up the TransactionID in that case.
360 if omciMsg.MessageType != omci.TestResponseType {
361 // having posted the response the request is regarded as 'done'
362 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
363 }
Himani Chawla4d908332020-08-31 12:30:20 +0530364 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000365 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000366 }
mpagenko80622a52021-02-09 16:53:23 +0000367 oo.mutexRxSchedMap.Unlock()
368 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
369 oo.printRxMessage(ctx, rxMsg)
370 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000371
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000372 /* py code was:
373 Receive and OMCI message from the proxy channel to the OLT.
374
375 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
376 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
377 """
378 if not self.enabled:
379 return
380
381 try:
382 now = arrow.utcnow()
383 d = None
384
385 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
386 # save the current value of the entity_id_to_class_map, then
387 # replace it with our custom one before decode, and then finally
388 # restore it later. Tried other ways but really made the code messy.
389 saved_me_map = omci_entities.entity_id_to_class_map
390 omci_entities.entity_id_to_class_map = self._me_map
391
392 try:
393 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000394 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000395 except KeyError as e:
396 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000397 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000398 rx_frame = self._decode_unknown_me(msg)
399 self._rx_unknown_me += 1
400
401 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000402 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000403 return
404
405 finally:
406 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
407
408 rx_tid = rx_frame.fields['transaction_id']
409 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000410 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000411 # Filter the Test Result frame and route through receive onu
412 # message method.
413 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000414 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000415 return self._receive_onu_message(rx_frame)
416
417 # Previously unreachable if this is the very first round-trip Rx or we
418 # have been running consecutive errors
419 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000420 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000421 self.reactor.callLater(0, self._publish_connectivity_event, True)
422
423 self._rx_frames += 1
424 self._consecutive_errors = 0
425
426 try:
427 high_priority = self._tid_is_high_priority(rx_tid)
428 index = self._get_priority_index(high_priority)
429
430 # (timestamp, defer, frame, timeout, retry, delayedCall)
431 last_tx_tuple = self._tx_request[index]
432
433 if last_tx_tuple is None or \
434 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
435 # Possible late Rx on a message that timed-out
436 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000437 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000438 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
439 self._rx_unknown_tid += 1
440 self._rx_late += 1
441 return
442
443 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
444 if dc is not None and not dc.cancelled and not dc.called:
445 dc.cancel()
446
447 _secs = self._update_rx_tx_stats(now, ts)
448
449 # Late arrival already serviced by a timeout?
450 if d.called:
451 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000452 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000453 return
454
455 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000456 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000457 if d is not None:
458 return d.errback(failure.Failure(e))
459 return
460
461 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000462 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000463 tx_tid = tx_frame.fields['transaction_id'])
464 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
465
466 # begin success callback chain (will cancel timeout and queue next Tx message)
467 self._rx_response[index] = rx_frame
468 d.callback(rx_frame)
469
470 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000471 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000472 */
473}
474
Himani Chawla6d2ae152020-09-02 13:11:20 +0530475/*
476func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530477 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530478 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000479}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530480*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000481
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700482// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
483func (oo *omciCC) ReleaseTid(ctx context.Context, tid uint16) {
484 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
485 delete(oo.rxSchedulerMap, tid)
486}
487
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000488//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530489func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
490 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000491
mpagenkoc26d4c02021-05-06 14:27:57 +0000492 if timeout != 0 {
493 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
494 oo.mutexRxSchedMap.Lock()
495 // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ...
496 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
497 oo.mutexRxSchedMap.Unlock()
498 } //else timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000499
mpagenkoc26d4c02021-05-06 14:27:57 +0000500 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000501 //just use a simple list for starting - might need some more effort, especially for multi source write access
502 omciTxRequest := omciTransferStructure{
503 txFrame,
504 timeout,
505 retry,
506 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000507 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000508 receiveCallbackPair,
509 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000510 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000511 oo.mutexMonReq.Lock()
512 defer oo.mutexMonReq.Unlock()
513 if _, exist := oo.monitoredRequests[receiveCallbackPair.cbKey]; !exist {
mpagenko7455fd42021-06-10 16:25:55 +0000514 // do not call processRequestMonitoring in background here to ensure correct sequencing
515 // of requested messages into txQueue (especially for non-response-supervised messages)
516 oo.processRequestMonitoring(ctx, omciTxRequest)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000517 return nil
518 }
519 logger.Errorw(ctx, "A message with this tid is processed already!",
520 log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
521 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000522}
523
524//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530525func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000526 // return errors.New("sendNextRequest unimplemented")
527
528 // just try to get something transferred !!
529 // avoid accessing the txQueue from parallel send requests
530 // block parallel omci send requests at least until SendIAP is 'committed'
531 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
532 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000533 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000534 for oo.txQueue.Len() > 0 {
535 queueElement := oo.txQueue.Front() // First element
536 omciTxRequest := queueElement.Value.(omciTransferStructure)
537 /* compare olt device handler code:
538 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000539 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000540 var deviceType string
541 var deviceID string
542 var proxyDeviceID string
543
544 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
545
546 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
547
dbainbri4d3a0dc2020-12-02 00:33:42 +0000548 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 +0000549 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
550 kwargs := make(map[string]interface{})
551 kwargs["onu_id"] = omciInd.OnuId
552 kwargs["parent_port_no"] = ponPort
553
dbainbri4d3a0dc2020-12-02 00:33:42 +0000554 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000555 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000556 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000557 return
558 }
559 deviceType = onuDevice.Type
560 deviceID = onuDevice.Id
561 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
562 //if not exist in cache, then add to cache.
563 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
564 } else {
565 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000566 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 +0000567 deviceType = onuInCache.(*OnuDevice).deviceType
568 deviceID = onuInCache.(*OnuDevice).deviceID
569 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
570 }
571 */
572 /* and compare onu_adapter py code:
573 omci_msg = InterAdapterOmciMessage(
574 message=bytes(frame),
575 proxy_address=self._proxy_address,
576 connect_status=self._device.connect_status)
577
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000578 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000579
580 yield self._adapter_proxy.send_inter_adapter_message(
581 msg=omci_msg,
582 type=InterAdapterMessageType.OMCI_REQUEST,
583 from_adapter=self._device.type,
584 to_adapter=self._proxy_address.device_type,
585 to_device_id=self._device_id,
586 proxy_device_id=self._proxy_address.device_id
587 )
588 */
mpagenko80622a52021-02-09 16:53:23 +0000589 if omciTxRequest.withFramePrint {
590 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
591 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
592 "device-id": oo.deviceID,
593 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
594 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
595 }
amit.ghosh58b704b2021-06-18 03:45:52 +0200596 omciMsg := &ic.InterAdapterOmciMessage{
597 Message: omciTxRequest.txFrame,
598 ProxyAddress: oo.pBaseDeviceHandler.device.ProxyAddress,
599 ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here
600 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000601 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000602 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800603 //fromTopic,toType,toDevId, ProxyDevId
604 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000605 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000606 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000607 return sendErr
608 }
609 oo.txQueue.Remove(queueElement) // Dequeue
610 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000611 return nil
612}
613
Himani Chawla6d2ae152020-09-02 13:11:20 +0530614func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000615 var next uint16
616 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000617 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000618 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530619 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000620 if oo.hpTid < 0x8000 {
621 oo.hpTid = 0x8000
622 }
mpagenko900ee4b2020-10-12 11:56:34 +0000623 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000624 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000625 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000626 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530627 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000628 if oo.tid >= 0x8000 {
629 oo.tid = 1
630 }
mpagenko900ee4b2020-10-12 11:56:34 +0000631 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000632 }
633 return next
634}
635
636// ###################################################################################
637// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000638func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000639 omciLayer := &omci.OMCI{
640 TransactionID: tid,
641 MessageType: msgType,
642 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000643 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000644}
645
dbainbri4d3a0dc2020-12-02 00:33:42 +0000646func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000647 var options gopacket.SerializeOptions
648 options.FixLengths = true
649
650 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530651 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000652 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000653 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000654 return nil, err
655 }
656 return buffer.Bytes(), nil
657}
658
Himani Chawla4d908332020-08-31 12:30:20 +0530659/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000660func hexEncode(omciPkt []byte) ([]byte, error) {
661 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
662 hex.Encode(dst, omciPkt)
663 return dst, nil
664}
Himani Chawla4d908332020-08-31 12:30:20 +0530665*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000666
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000667//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000668func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000669
dbainbri4d3a0dc2020-12-02 00:33:42 +0000670 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000671 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000672
673 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000674 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000675 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200676 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000677 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000678 oo.mutexMonReq.RLock()
679 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
680 oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
681 } else {
682 logger.Infow(ctx, "reqMon: map entry does not exist!",
683 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
684 }
685 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000686
687 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
688 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000689 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000690 Type: OMCI,
691 Data: OmciMessage{
692 OmciMsg: omciMsg,
693 OmciPacket: packet,
694 },
695 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000696 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000697 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000698
699 return nil
700}
701
Himani Chawla6d2ae152020-09-02 13:11:20 +0530702func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000703
dbainbri4d3a0dc2020-12-02 00:33:42 +0000704 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000705 request := &omci.MibResetRequest{
706 MeBasePacket: omci.MeBasePacket{
707 EntityClass: me.OnuDataClassID,
708 },
709 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530710 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000711 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000712 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000713 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000714 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000715 return err
716 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530717 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000718 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000719 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000720 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000721 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000722}
723
Himani Chawla6d2ae152020-09-02 13:11:20 +0530724func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000725 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300726 request := &omci.RebootRequest{
727 MeBasePacket: omci.MeBasePacket{
728 EntityClass: me.OnuGClassID,
729 },
730 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530731 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000732 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300733 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000734 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000735 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300736 return err
737 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530738 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300739 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000740 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300741 }
742
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000743 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300744 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000745 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000746 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300747 return err
748 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000749 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300750 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000751 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200752 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300753 return err
754 }
755 return nil
756}
757
Himani Chawla6d2ae152020-09-02 13:11:20 +0530758func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000759 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000760 request := &omci.MibUploadRequest{
761 MeBasePacket: omci.MeBasePacket{
762 EntityClass: me.OnuDataClassID,
763 },
764 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530765 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000766 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000767 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000768 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000769 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000770 return err
771 }
772 oo.uploadSequNo = 0
773 oo.uploadNoOfCmds = 0
774
Himani Chawla6d2ae152020-09-02 13:11:20 +0530775 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000776 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000777 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000778 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000779 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000780}
781
Himani Chawla6d2ae152020-09-02 13:11:20 +0530782func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000783 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000784 request := &omci.MibUploadNextRequest{
785 MeBasePacket: omci.MeBasePacket{
786 EntityClass: me.OnuDataClassID,
787 },
788 CommandSequenceNumber: oo.uploadSequNo,
789 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530790 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000791 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000792 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000793 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000794 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000795 return err
796 }
797 oo.uploadSequNo++
798
Himani Chawla6d2ae152020-09-02 13:11:20 +0530799 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000800 cbKey: tid,
801 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
802 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
803 // compare also software upgrade download section handling
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000804 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000805 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000806 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000807}
808
Himani Chawlad3dac422021-03-13 02:31:31 +0530809func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
810 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
811 request := &omci.GetAllAlarmsRequest{
812 MeBasePacket: omci.MeBasePacket{
813 EntityClass: me.OnuDataClassID,
814 },
815 AlarmRetrievalMode: byte(alarmRetreivalMode),
816 }
817 tid := oo.getNextTid(highPrio)
818 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
819 if err != nil {
820 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
821 "Err": err, "device-id": oo.deviceID})
822 return err
823 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000824 oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530825
826 omciRxCallbackPair := callbackPair{
827 cbKey: tid,
828 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
829 oo.receiveOmciResponse, true},
830 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000831 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530832}
833
834func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000835 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530836 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
837 "alarmUploadSeqNo": alarmUploadSeqNo})
838 request := &omci.GetAllAlarmsNextRequest{
839 MeBasePacket: omci.MeBasePacket{
840 EntityClass: me.OnuDataClassID,
841 },
842 CommandSequenceNumber: alarmUploadSeqNo,
843 }
844 tid := oo.getNextTid(highPrio)
845 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
846 if err != nil {
847 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
848 "Err": err, "device-id": oo.deviceID})
849 return err
850 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000851 oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530852
853 omciRxCallbackPair := callbackPair{
854 cbKey: tid,
855 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
856 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000857 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530858}
859
ozgecanetsiab36ed572021-04-01 10:38:48 +0300860func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530861 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000862 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000863 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000864
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000865 meParams := me.ParamData{
866 EntityID: galEthernetEID,
867 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
868 }
869 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
870 if omciErr.GetError() == nil {
871 //all setByCreate parameters already set, no default option required ...
872 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
873 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000874 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000875 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300876 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000877 }
878
dbainbri4d3a0dc2020-12-02 00:33:42 +0000879 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000880 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000881 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000882 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300883 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000884 }
885
Himani Chawla6d2ae152020-09-02 13:11:20 +0530886 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000887 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000888 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000889 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000890 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000891 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000892 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000893 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300894 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000895 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000896 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300897 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000898 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000899 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000900 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300901 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000902}
903
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000904// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
ozgecanetsiab36ed572021-04-01 10:38:48 +0300905func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530906 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000907 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000908 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000909
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000910 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
911 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000912 // By now we just use fix values to fire - this is anyway what the python adapter does
913 // read ONU-2G from DB ???? //TODO!!!
914 meParams := me.ParamData{
915 EntityID: 0,
916 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
917 }
918 meInstance, omciErr := me.NewOnu2G(meParams)
919 if omciErr.GetError() == nil {
920 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
921 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000922 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000923 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300924 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000925 }
926
dbainbri4d3a0dc2020-12-02 00:33:42 +0000927 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000928 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000929 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000930 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300931 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000932 }
933
Himani Chawla6d2ae152020-09-02 13:11:20 +0530934 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000935 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000936 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000937 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000938 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000939 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000940 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000941 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300942 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000943 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000944 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300945 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000946 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000947 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000948 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300949 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000950}
951
Himani Chawla6d2ae152020-09-02 13:11:20 +0530952func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +0300953 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530954 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530955 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000956 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000957 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000958
959 meParams := me.ParamData{
960 EntityID: instID,
961 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300962 "Priority": 0x8000,
963 "MaxAge": 20 * 256, //20s
964 "HelloTime": 2 * 256, //2s
965 "ForwardDelay": 15 * 256, //15s
966 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000967 },
968 }
969
970 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
971 if omciErr.GetError() == nil {
972 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
973 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
974 omci.TransactionID(tid), omci.AddDefaults(true))
975 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000976 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000977 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300978 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000979 }
980
dbainbri4d3a0dc2020-12-02 00:33:42 +0000981 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000982 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000983 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000984 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300985 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000986 }
987
Himani Chawla6d2ae152020-09-02 13:11:20 +0530988 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000989 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000990 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000991 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000992 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000993 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000994 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000995 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300996 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000997 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000998 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300999 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001000 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001001 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001002 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001003 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001004}
1005
Mahir Gunyel6781f962021-05-16 23:30:08 -07001006func (oo *omciCC) sendCreateMBPConfigDataUniSide(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001007 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301008 tid := oo.getNextTid(highPrio)
Mahir Gunyel6781f962021-05-16 23:30:08 -07001009 instID, idErr := generateUNISideMBPCDEID(uint16(aPUniPort.macBpNo))
1010 if idErr != nil {
1011 logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{
1012 "Err": idErr, "device-id": oo.deviceID})
1013 return nil, idErr
1014 }
1015 logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID,
1016 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.macBpNo})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001017
1018 meParams := me.ParamData{
1019 EntityID: instID,
1020 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +05301021 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
1022 "PortNum": aPUniPort.macBpNo,
1023 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +05301024 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001025 },
1026 }
1027 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1028 if omciErr.GetError() == nil {
1029 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1030 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1031 omci.TransactionID(tid), omci.AddDefaults(true))
1032 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001033 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001034 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001035 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001036 }
1037
dbainbri4d3a0dc2020-12-02 00:33:42 +00001038 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001039 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001040 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001041 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001042 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001043 }
1044
Himani Chawla6d2ae152020-09-02 13:11:20 +05301045 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001046 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001047 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001048 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001049 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001050 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001051 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001052 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001053 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001054 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001055 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001056 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001057 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001058 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001059 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001060 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001061}
1062
Himani Chawla6d2ae152020-09-02 13:11:20 +05301063func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001064 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301065 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001066 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301067 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001068 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001069 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001070
1071 // compare python adapter code WA VOL-1311: this is not done here!
1072 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1073 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1074 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301075 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001076 assType = uint8(10) // for VEIP
1077 }
1078 meParams := me.ParamData{
1079 EntityID: instID,
1080 Attributes: me.AttributeValueMap{
1081 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301082 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001083 },
1084 }
1085 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1086 if omciErr.GetError() == nil {
1087 //all setByCreate parameters already set, no default option required ...
1088 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1089 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001090 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001091 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001092 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001093 }
1094
dbainbri4d3a0dc2020-12-02 00:33:42 +00001095 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001096 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001097 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001098 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001099 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001100 }
1101
Himani Chawla6d2ae152020-09-02 13:11:20 +05301102 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001103 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001104 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001105 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001106 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001107 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001108 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001109 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001110 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001111 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001112 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001113 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001114 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001115 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001116 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001117 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001118}
1119
Himani Chawla6d2ae152020-09-02 13:11:20 +05301120func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001121 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301122 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001123 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001124 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001125
1126 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1127 meParams := me.ParamData{
1128 EntityID: 0,
1129 Attributes: requestedAttributes,
1130 }
1131 meInstance, omciErr := me.NewOnuG(meParams)
1132 if omciErr.GetError() == nil {
1133 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1134 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001135 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001136 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001137 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001138 }
1139
dbainbri4d3a0dc2020-12-02 00:33:42 +00001140 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001141 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001142 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001143 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001144 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001145 }
1146
Himani Chawla6d2ae152020-09-02 13:11:20 +05301147 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001148 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001149 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001150 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001151 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001152 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001153 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001154 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001155 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001156 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001157 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001158 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001159 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001160 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001161 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001162 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001163}
1164
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001165func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001166 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001167 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001168 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001169 "SequNo": strconv.FormatInt(int64(tid), 16)})
1170
1171 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1172 meParams := me.ParamData{
1173 EntityID: aInstNo,
1174 Attributes: requestedAttributes,
1175 }
1176 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1177 if omciErr.GetError() == nil {
1178 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1179 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001180 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001181 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001182 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001183 }
1184
dbainbri4d3a0dc2020-12-02 00:33:42 +00001185 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001187 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001188 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001189 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001190 }
1191
1192 omciRxCallbackPair := callbackPair{
1193 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001194 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001195 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001196 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001197 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001199 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001200 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001201 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001202 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001203 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001204 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001205 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001206 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001207 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001208}
1209
1210/* UniG obsolete by now, left here in case it should be needed once again
1211 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301212func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001213 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301214 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001215 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001216 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001217
1218 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1219 meParams := me.ParamData{
1220 EntityID: aInstNo,
1221 Attributes: requestedAttributes,
1222 }
1223 meInstance, omciErr := me.NewUniG(meParams)
1224 if omciErr.GetError() == nil {
1225 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1226 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001227 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001228 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001229 return nil
1230 }
1231
1232 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1233 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001234 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001235 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001236 return nil
1237 }
1238
Himani Chawla6d2ae152020-09-02 13:11:20 +05301239 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001240 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001241 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001242 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001243 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001244 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001245 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001246 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001247 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001248 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001249 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001250 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001251 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001252 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001253 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001254 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001255}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001256*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001257
Himani Chawla6d2ae152020-09-02 13:11:20 +05301258func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001259 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301260 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001261 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001262 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001263
1264 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1265 meParams := me.ParamData{
1266 EntityID: aInstNo,
1267 Attributes: requestedAttributes,
1268 }
1269 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1270 if omciErr.GetError() == nil {
1271 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1272 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001273 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001274 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001275 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001276 }
1277
dbainbri4d3a0dc2020-12-02 00:33:42 +00001278 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001279 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001280 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001281 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001282 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001283 }
1284
Himani Chawla6d2ae152020-09-02 13:11:20 +05301285 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001286 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001287 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001288 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001289 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001290 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001291 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001292 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001293 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001294 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001295 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001296 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001297 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001298 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001299 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001300 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001301}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001302
Himani Chawla6d2ae152020-09-02 13:11:20 +05301303func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001304 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001305
Himani Chawla6d2ae152020-09-02 13:11:20 +05301306 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001307 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001308 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001309
1310 meParams := me.ParamData{
1311 EntityID: entityID,
1312 Attributes: requestedAttributes,
1313 }
1314 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1315 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301316 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001317 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1318 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001319 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 +03001320 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001321 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001322 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001323 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001324 logger.Errorw(ctx, "Cannot serialize 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 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301327 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001328 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001329 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001330 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001331 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001332 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001333 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001334 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001335 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001336 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001337 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001338 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001339 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001340 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001341}
1342
Himani Chawla6d2ae152020-09-02 13:11:20 +05301343func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001344 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301345 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001346 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001347 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1348
1349 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001350 EntityID: aInstID,
1351 Attributes: me.AttributeValueMap{
1352 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1353 "TpPointer": 0xFFFF,
1354 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1355 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1356 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1357 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1358 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1359 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1360 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1361 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1362 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001363 }
1364 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1365 if omciErr.GetError() == nil {
1366 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1367 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1368 omci.TransactionID(tid), omci.AddDefaults(true))
1369 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001370 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001371 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001372 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001373 }
1374
dbainbri4d3a0dc2020-12-02 00:33:42 +00001375 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001376 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001377 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001378 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001379 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001380 }
1381
Himani Chawla6d2ae152020-09-02 13:11:20 +05301382 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001383 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001384 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001385 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001386 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001387 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001388 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001389 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001390 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001391 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001392 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001393 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001394 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001395 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001396 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001397 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001398}
1399
Himani Chawla6d2ae152020-09-02 13:11:20 +05301400func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001401 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301402 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001403 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001404 "SequNo": strconv.FormatInt(int64(tid), 16),
1405 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1406
1407 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1408 if omciErr.GetError() == nil {
1409 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1410 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1411 omci.TransactionID(tid), omci.AddDefaults(true))
1412 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001413 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001414 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001415 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001416 }
1417
dbainbri4d3a0dc2020-12-02 00:33:42 +00001418 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001419 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001420 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001421 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001422 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001423 }
1424
Himani Chawla6d2ae152020-09-02 13:11:20 +05301425 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001426 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001427 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001428 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001429 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001430 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001431 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001432 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001433 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001434 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001435 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001436 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001437 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001438 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001439 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001440 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001441}
1442
Himani Chawla6d2ae152020-09-02 13:11:20 +05301443func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001444 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301445 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001446 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001447 "SequNo": strconv.FormatInt(int64(tid), 16),
1448 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1449
1450 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1451 if omciErr.GetError() == nil {
1452 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1453 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1454 omci.TransactionID(tid), omci.AddDefaults(true))
1455 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001456 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001457 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001458 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001459 }
1460
dbainbri4d3a0dc2020-12-02 00:33:42 +00001461 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001462 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001463 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001464 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001465 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 }
1467
Himani Chawla6d2ae152020-09-02 13:11:20 +05301468 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001469 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001470 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001471 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001472 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001473 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001474 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001475 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001476 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001477 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001478 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001479 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001480 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001481 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001482 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001483 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001484}
1485
Himani Chawla6d2ae152020-09-02 13:11:20 +05301486func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001487 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301488 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001489 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001490 "SequNo": strconv.FormatInt(int64(tid), 16),
1491 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1492
1493 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1494 if omciErr.GetError() == nil {
1495 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1496 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1497 omci.TransactionID(tid))
1498 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001499 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001500 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001501 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001502 }
1503
dbainbri4d3a0dc2020-12-02 00:33:42 +00001504 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001505 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001506 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001507 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001508 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001509 }
1510
Himani Chawla6d2ae152020-09-02 13:11:20 +05301511 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001512 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001513 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001514 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001515 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001519 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001520 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001521 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001522 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001523 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001524 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001525 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001526 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001527}
1528
Himani Chawla6d2ae152020-09-02 13:11:20 +05301529func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001530 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301531 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001532 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001533 "SequNo": strconv.FormatInt(int64(tid), 16),
1534 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1535
1536 meInstance, omciErr := me.NewTCont(params[0])
1537 if omciErr.GetError() == nil {
1538 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1539 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001540 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001541 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001542 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001543 }
1544
dbainbri4d3a0dc2020-12-02 00:33:42 +00001545 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001546 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001547 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001548 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001549 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001550 }
1551
Himani Chawla6d2ae152020-09-02 13:11:20 +05301552 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001553 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001554 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001555 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001556 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001557 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001558 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001559 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001560 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001561 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001562 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001563 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001564 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001565 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001566 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001567 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001568}
1569
Himani Chawla6d2ae152020-09-02 13:11:20 +05301570func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001571 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301572 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001573 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001574 "SequNo": strconv.FormatInt(int64(tid), 16),
1575 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1576
1577 meInstance, omciErr := me.NewPriorityQueue(params[0])
1578 if omciErr.GetError() == nil {
1579 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1580 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001581 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001582 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001583 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001584 }
1585
dbainbri4d3a0dc2020-12-02 00:33:42 +00001586 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001587 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001588 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001589 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001590 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001591 }
1592
Himani Chawla6d2ae152020-09-02 13:11:20 +05301593 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001594 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001595 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001596 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001597 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001598 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001599 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001600 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001601 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001602 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001603 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001604 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001605 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001606 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001607 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001608 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001609}
1610
Himani Chawla6d2ae152020-09-02 13:11:20 +05301611func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001612 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301613 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001614 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001615 "SequNo": strconv.FormatInt(int64(tid), 16),
1616 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1617
1618 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1619 if omciErr.GetError() == nil {
1620 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1621 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001622 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001623 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001624 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001625 }
1626
dbainbri4d3a0dc2020-12-02 00:33:42 +00001627 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001628 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001629 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001630 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001631 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001632 }
1633
Himani Chawla6d2ae152020-09-02 13:11:20 +05301634 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001635 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001636 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001637 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001638 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001639 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001640 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001641 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001642 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001643 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001644 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001645 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001646 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001647 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001648 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001649 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001650}
mpagenkodff5dda2020-08-28 11:52:01 +00001651
Himani Chawla6d2ae152020-09-02 13:11:20 +05301652func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001653 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301654 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001655 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001656 "SequNo": strconv.FormatInt(int64(tid), 16),
1657 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1658
1659 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1660 if omciErr.GetError() == nil {
1661 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1662 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1663 omci.TransactionID(tid))
1664 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001665 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001666 "Err": err, "device-id": oo.deviceID})
1667 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1668 // return (dual format) error code that can be used at caller for immediate error treatment
1669 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001670 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001671 }
1672
dbainbri4d3a0dc2020-12-02 00:33:42 +00001673 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001674 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001675 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001676 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001677 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001678 }
1679
Himani Chawla6d2ae152020-09-02 13:11:20 +05301680 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001681 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001682 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001683 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001684 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001685 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001686 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001687 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001688 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001689 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001690 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001691 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001692 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001693 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001694 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001695 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001696}
1697
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001698// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001699func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001700 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001701 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001702 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001703 "SequNo": strconv.FormatInt(int64(tid), 16),
1704 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1705
1706 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1707 if omciErr.GetError() == nil {
1708 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1709 omci.TransactionID(tid))
1710 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001711 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001712 "Err": err, "device-id": oo.deviceID})
1713 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1714 // return (dual format) error code that can be used at caller for immediate error treatment
1715 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001716 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001717 }
1718
dbainbri4d3a0dc2020-12-02 00:33:42 +00001719 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001720 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001721 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001722 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001723 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001724 }
1725
1726 omciRxCallbackPair := callbackPair{
1727 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001728 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001729 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001730 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001731 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001732 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001733 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001734 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001735 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001736 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001737 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001738 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001739 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001740 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001741 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001742}
1743
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001744func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001745 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001746 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001747 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001748 "SequNo": strconv.FormatInt(int64(tid), 16),
1749 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1750
1751 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1752 if omciErr.GetError() == nil {
1753 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001756 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001757 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001758 }
1759
dbainbri4d3a0dc2020-12-02 00:33:42 +00001760 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001761 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001762 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001763 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001764 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001765 }
1766
1767 omciRxCallbackPair := callbackPair{
1768 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001769 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001770 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001771 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001772 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001773 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001774 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001775 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001776 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001777 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001778 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001779 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001780 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001781 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001782 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001783}
1784
Himani Chawla6d2ae152020-09-02 13:11:20 +05301785func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001786 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301787 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001788 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001789 "SequNo": strconv.FormatInt(int64(tid), 16),
1790 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1791
1792 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1793 if omciErr.GetError() == nil {
1794 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1795 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001796 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001797 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001798 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001799 }
1800
dbainbri4d3a0dc2020-12-02 00:33:42 +00001801 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001802 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001803 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001804 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001805 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001806 }
1807
Himani Chawla6d2ae152020-09-02 13:11:20 +05301808 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001809 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001810 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001811 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001812 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001813 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001815 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001816 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001817 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001818 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001819 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001820 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001821 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001822 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001823 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001824}
mpagenko01e726e2020-10-23 09:45:29 +00001825
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001826func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001827 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001828 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001829 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001830 "SequNo": strconv.FormatInt(int64(tid), 16),
1831 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1832
1833 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1834 if omciErr.GetError() == nil {
1835 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1836 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001837 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001838 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001839 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001840 }
1841
dbainbri4d3a0dc2020-12-02 00:33:42 +00001842 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001843 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001844 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001845 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001846 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001847 }
1848
1849 omciRxCallbackPair := callbackPair{
1850 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001851 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001852 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001853 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001854 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001855 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001856 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001857 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001858 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001859 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001860 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001861 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001862 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001863 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001864 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001865}
1866
mpagenko01e726e2020-10-23 09:45:29 +00001867func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001868 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko01e726e2020-10-23 09:45:29 +00001869 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001870 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001871 "SequNo": strconv.FormatInt(int64(tid), 16),
1872 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1873
1874 meParams := me.ParamData{EntityID: aInstID}
1875 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1876 if omciErr.GetError() == nil {
1877 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1878 omci.TransactionID(tid))
1879 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001880 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001881 "Err": err, "device-id": oo.deviceID})
1882 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1883 // return (dual format) error code that can be used at caller for immediate error treatment
1884 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001885 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001886 }
1887
dbainbri4d3a0dc2020-12-02 00:33:42 +00001888 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001889 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001890 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001891 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001892 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001893 }
1894
1895 omciRxCallbackPair := callbackPair{
1896 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001897 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001898 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001899 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00001900 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001901 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001902 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001903 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001904 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001905 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001906 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00001907 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001908 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001909 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001910 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00001911}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001912
ozgecanetsiab6441962021-03-10 10:58:48 +03001913// nolint: unused
1914func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001915 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001916 tid := oo.getNextTid(highPrio)
1917 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1918 "SequNo": strconv.FormatInt(int64(tid), 16),
1919 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1920 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1921 if omciErr.GetError() == nil {
1922 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1923 if err != nil {
1924 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001925 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001926 }
1927 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1928 if err != nil {
1929 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001930 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001931 }
1932 omciRxCallbackPair := callbackPair{
1933 cbKey: tid,
1934 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1935 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001936 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001937 if err != nil {
1938 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001939 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001940 }
1941 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001942 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001943 }
1944 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001945 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001946}
1947
1948// nolint: unused
1949func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001950 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001951 tid := oo.getNextTid(highPrio)
1952 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1953 "SequNo": strconv.FormatInt(int64(tid), 16),
1954 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1955
1956 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1957 if omciErr.GetError() == nil {
1958 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1959 if err != nil {
1960 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001961 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001962 }
1963 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1964 if err != nil {
1965 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001966 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001967 }
1968 omciRxCallbackPair := callbackPair{
1969 cbKey: tid,
1970 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1971 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001972 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001973 if err != nil {
1974 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001975 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001976 }
1977 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001978 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001979 }
1980 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001981 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001982
1983}
1984
1985// nolint: unused
1986func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001987 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001988 tid := oo.getNextTid(highPrio)
1989 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1990 "SequNo": strconv.FormatInt(int64(tid), 16),
1991 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1992
1993 meParams := me.ParamData{EntityID: aInstID}
1994 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1995 if omciErr.GetError() == nil {
1996 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1997 if err != nil {
1998 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001999 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002000 }
2001 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2002 if err != nil {
2003 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002004 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002005 }
2006 omciRxCallbackPair := callbackPair{
2007 cbKey: tid,
2008 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2009 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002010 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002011 if err != nil {
2012 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002013 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002014 }
2015 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002016 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002017 }
2018 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002019 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002020
2021}
2022
mpagenko8b07c1b2020-11-26 10:36:31 +00002023func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002024 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002025 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002026 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002027 "SequNo": strconv.FormatInt(int64(tid), 16),
2028 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2029
2030 meParams := me.ParamData{EntityID: aInstID}
2031 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2032 if omciErr.GetError() == nil {
2033 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2034 omci.TransactionID(tid))
2035 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002036 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002037 "Err": err, "device-id": oo.deviceID})
2038 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2039 // return (dual format) error code that can be used at caller for immediate error treatment
2040 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002041 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002042 }
2043
dbainbri4d3a0dc2020-12-02 00:33:42 +00002044 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002045 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002046 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002047 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002048 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002049 }
2050
2051 omciRxCallbackPair := callbackPair{
2052 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002053 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002054 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002055 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002056 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002057 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002058 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002059 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002060 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002061 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002062 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002063 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002064 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002065 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002066 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002067}
2068
2069func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002070 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002071 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002072 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002073 "SequNo": strconv.FormatInt(int64(tid), 16),
2074 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2075
2076 meParams := me.ParamData{EntityID: aInstID}
2077 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2078 if omciErr.GetError() == nil {
2079 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2080 omci.TransactionID(tid))
2081 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002082 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002083 "Err": err, "device-id": oo.deviceID})
2084 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2085 // return (dual format) error code that can be used at caller for immediate error treatment
2086 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002087 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002088 }
2089
dbainbri4d3a0dc2020-12-02 00:33:42 +00002090 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002091 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002092 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002093 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002094 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002095 }
2096
2097 omciRxCallbackPair := callbackPair{
2098 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002099 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002100 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002101 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002102 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002103 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002104 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002105 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002106 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002107 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002108 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002109 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002110 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002111 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002112 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002113}
2114
2115func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002116 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002117 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002118 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002119 "SequNo": strconv.FormatInt(int64(tid), 16),
2120 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2121
2122 meParams := me.ParamData{EntityID: aInstID}
2123 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2124 if omciErr.GetError() == nil {
2125 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2126 omci.TransactionID(tid))
2127 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002128 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002129 "Err": err, "device-id": oo.deviceID})
2130 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2131 // return (dual format) error code that can be used at caller for immediate error treatment
2132 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002133 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002134 }
2135
dbainbri4d3a0dc2020-12-02 00:33:42 +00002136 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002137 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002138 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002139 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002140 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002141 }
2142
2143 omciRxCallbackPair := callbackPair{
2144 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002145 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002146 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002147 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002148 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002149 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002150 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002151 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002152 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002153 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002154 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002155 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002156 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002157 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002158 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002159}
2160
2161func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002162 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002163 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002164 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002165 "SequNo": strconv.FormatInt(int64(tid), 16),
2166 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2167
2168 meParams := me.ParamData{EntityID: aInstID}
2169 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2170 if omciErr.GetError() == nil {
2171 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2172 omci.TransactionID(tid))
2173 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002174 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002175 "Err": err, "device-id": oo.deviceID})
2176 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2177 // return (dual format) error code that can be used at caller for immediate error treatment
2178 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002179 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002180 }
2181
dbainbri4d3a0dc2020-12-02 00:33:42 +00002182 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002183 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002184 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002185 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002186 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002187 }
2188
2189 omciRxCallbackPair := callbackPair{
2190 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002191 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002192 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002193 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002194 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002195 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002196 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002197 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002198 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002199 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002200 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002201 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002202 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002203 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002204 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002205}
2206
ozgecanetsia422dbf32020-10-28 14:07:19 +03002207func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002208 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002209 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002210 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002211 "SequNo": strconv.FormatInt(int64(tid), 16),
2212 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2213
2214 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2215 if omciErr.GetError() == nil {
2216 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2217 omci.AddDefaults(true))
2218 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002219 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002220 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002221 }
2222
dbainbri4d3a0dc2020-12-02 00:33:42 +00002223 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002224 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002225 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002226 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002227 }
2228
2229 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002230 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002231 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002232 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002233 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002235 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002236 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002237 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002238 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002239 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002240 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002241 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002242 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002243}
2244
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002245func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002246 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002247 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002248 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002249 "SequNo": strconv.FormatInt(int64(tid), 16),
2250 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2251
2252 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2253 if omciErr.GetError() == nil {
2254 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2255 omci.AddDefaults(true))
2256 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002257 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002258 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002259 }
2260
dbainbri4d3a0dc2020-12-02 00:33:42 +00002261 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002262 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002263 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002264 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002265 }
2266
2267 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002268 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002269 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002270 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002271 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002272 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002273 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002274 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002275 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002276 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002277 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002278 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002279 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002280 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002281}
2282
ozgecanetsia422dbf32020-10-28 14:07:19 +03002283func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002284 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002285 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002286 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002287 "SequNo": strconv.FormatInt(int64(tid), 16),
2288 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2289
2290 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2291 if omciErr.GetError() == nil {
2292 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2293 omci.AddDefaults(true))
2294 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002295 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002296 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002297 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002298 }
2299
dbainbri4d3a0dc2020-12-02 00:33:42 +00002300 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002301 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002302 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002303 "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 MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002313 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002314 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002315 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002316 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002317 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002318 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002319 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002320 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002321 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002322}
2323
2324func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002325 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002326 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002327 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002328 "SequNo": strconv.FormatInt(int64(tid), 16),
2329 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2330
2331 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2332 if omciErr.GetError() == nil {
2333 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2334 omci.AddDefaults(true))
2335 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002337 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002338 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002339 }
2340
dbainbri4d3a0dc2020-12-02 00:33:42 +00002341 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002342 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002343 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002344 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002345 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002346 }
2347
2348 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002349 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002350 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002351 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002352 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002353 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002354 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002355 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002356 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002357 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002358 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002359 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002360 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002361 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002362 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002363}
2364
2365func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002366 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002367 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002368 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002369 "SequNo": strconv.FormatInt(int64(tid), 16),
2370 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2371
2372 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2373 if omciErr.GetError() == nil {
2374 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2375 omci.AddDefaults(true))
2376 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002377 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002378 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002379 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002380 }
2381
dbainbri4d3a0dc2020-12-02 00:33:42 +00002382 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002383 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002384 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002385 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002386 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002387 }
2388
2389 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002390 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002391 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002392 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002393 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002394 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002395 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002396 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002397 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002398 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002399 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002400 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002401 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002402 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002403 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002404}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002405
Girish Gowdrae0140f02021-02-02 16:55:09 -08002406func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2407 tid := oo.getNextTid(highPrio)
2408 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2409 "SequNo": strconv.FormatInt(int64(tid), 16)})
2410
2411 omciLayer := &omci.OMCI{
2412 TransactionID: tid,
2413 MessageType: omci.SynchronizeTimeRequestType,
2414 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2415 // Length: 0x28, // Optional, defaults to 40 octets
2416 }
2417 utcTime := time.Now().UTC()
2418 request := &omci.SynchronizeTimeRequest{
2419 MeBasePacket: omci.MeBasePacket{
2420 EntityClass: me.OnuGClassID,
2421 // Default Instance ID is 0
2422 },
2423 Year: uint16(utcTime.Year()),
2424 Month: uint8(utcTime.Month()),
2425 Day: uint8(utcTime.Day()),
2426 Hour: uint8(utcTime.Hour()),
2427 Minute: uint8(utcTime.Minute()),
2428 Second: uint8(utcTime.Second()),
2429 }
2430
2431 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2432 if err != nil {
2433 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2434 "device-id": oo.deviceID})
2435 return err
2436 }
2437
2438 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002439 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002440 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002441 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002442 if err != nil {
2443 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2444 "device-id": oo.deviceID})
2445 return err
2446 }
2447 logger.Debug(ctx, "send synchronize time request done")
2448 return nil
2449}
2450
2451func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002452 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002453 tid := oo.getNextTid(highPrio)
2454 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2455 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2456 meParam := me.ParamData{EntityID: entityID}
2457 var meInstance *me.ManagedEntity
2458 var omciErr me.OmciErrors
2459 if upstream {
2460 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2461 } else {
2462 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2463 }
2464 if omciErr.GetError() == nil {
2465 var omciLayer *omci.OMCI
2466 var msgLayer gopacket.SerializableLayer
2467 var err error
2468 if create {
2469 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2470 omci.AddDefaults(true))
2471 } else {
2472 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2473 omci.AddDefaults(true))
2474 }
2475 if err != nil {
2476 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2477 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002478 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002479 }
2480
2481 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2482 if err != nil {
2483 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2484 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002485 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002486 }
2487
2488 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002489 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002490 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002491 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002492 if err != nil {
2493 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2494 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002495 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002496 }
2497 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2498 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002499 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002500 }
2501 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2502 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 +03002503 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002504}
2505
2506func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002507 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002508 tid := oo.getNextTid(highPrio)
2509 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2510 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2511 meParam := me.ParamData{EntityID: entityID}
2512 var meInstance *me.ManagedEntity
2513 var omciErr me.OmciErrors
2514 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2515
2516 if omciErr.GetError() == nil {
2517 var omciLayer *omci.OMCI
2518 var msgLayer gopacket.SerializableLayer
2519 var err error
2520 if create {
2521 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2522 omci.AddDefaults(true))
2523 } else {
2524 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2525 omci.AddDefaults(true))
2526 }
2527 if err != nil {
2528 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2529 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002530 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002531 }
2532
2533 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2534 if err != nil {
2535 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2536 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002537 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002538 }
2539
2540 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002541 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002542 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002543 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002544 if err != nil {
2545 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2546 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002547 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002548 }
2549 logger.Debugw(ctx, "send ethernet uni history data ME done",
2550 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002551 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002552 }
2553 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2554 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002555 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002556}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002557
2558func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002559 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002560 tid := oo.getNextTid(highPrio)
2561 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2562 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2563 meParam := me.ParamData{EntityID: entityID}
2564 var meInstance *me.ManagedEntity
2565 var omciErr me.OmciErrors
2566 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2567
2568 if omciErr.GetError() == nil {
2569 var omciLayer *omci.OMCI
2570 var msgLayer gopacket.SerializableLayer
2571 var err error
2572 if create {
2573 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2574 omci.AddDefaults(true))
2575 } else {
2576 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2577 omci.AddDefaults(true))
2578 }
2579 if err != nil {
2580 logger.Errorw(ctx, "Cannot encode fec history data ME",
2581 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002582 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002583 }
2584
2585 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2586 if err != nil {
2587 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2588 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002589 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002590 }
2591
2592 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002593 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002594 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002595 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002596 if err != nil {
2597 logger.Errorw(ctx, "Cannot send fec history data ME",
2598 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002599 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002600 }
2601 logger.Debugw(ctx, "send fec history data ME done",
2602 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002603 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002604 }
2605 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2606 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002607 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002608}
2609
2610func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002611 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002612 tid := oo.getNextTid(highPrio)
2613 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2614 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2615 meParam := me.ParamData{EntityID: entityID}
2616 var meInstance *me.ManagedEntity
2617 var omciErr me.OmciErrors
2618 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2619
2620 if omciErr.GetError() == nil {
2621 var omciLayer *omci.OMCI
2622 var msgLayer gopacket.SerializableLayer
2623 var err error
2624 if create {
2625 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2626 omci.AddDefaults(true))
2627 } else {
2628 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2629 omci.AddDefaults(true))
2630 }
2631 if err != nil {
2632 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2633 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002634 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002635 }
2636
2637 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2638 if err != nil {
2639 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2640 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002641 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002642 }
2643
2644 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002645 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002646 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002647 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002648 if err != nil {
2649 logger.Errorw(ctx, "Cannot send gemport history data ME",
2650 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002651 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002652 }
2653 logger.Debugw(ctx, "send gemport history data ME done",
2654 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002655 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002656 }
2657 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2658 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002659 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002660}
2661
mpagenko80622a52021-02-09 16:53:23 +00002662func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2663 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2664 tid := oo.getNextTid(highPrio)
2665 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2666 "SequNo": strconv.FormatInt(int64(tid), 16),
2667 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2668
2669 omciLayer := &omci.OMCI{
2670 TransactionID: tid,
2671 MessageType: omci.StartSoftwareDownloadRequestType,
2672 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2673 // Length: 0x28, // Optional, defaults to 40 octets
2674 }
2675 request := &omci.StartSoftwareDownloadRequest{
2676 MeBasePacket: omci.MeBasePacket{
2677 EntityClass: me.SoftwareImageClassID,
2678 EntityInstance: aImageMeID, //inactive image
2679 },
2680 WindowSize: aDownloadWindowSize,
2681 ImageSize: aFileLen,
2682 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2683 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2684 }
2685
2686 var options gopacket.SerializeOptions
2687 options.FixLengths = true
2688 buffer := gopacket.NewSerializeBuffer()
2689 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2690 if err != nil {
2691 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2692 "device-id": oo.deviceID})
2693 return err
2694 }
2695 outgoingPacket := buffer.Bytes()
2696
2697 omciRxCallbackPair := callbackPair{cbKey: tid,
2698 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2699 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002700 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002701 if err != nil {
2702 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2703 "device-id": oo.deviceID})
2704 return err
2705 }
2706 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002707 return nil
2708}
2709
mpagenkoc26d4c02021-05-06 14:27:57 +00002710func (oo *omciCC) sendDownloadSection(ctx context.Context, aTimeout int, highPrio bool,
mpagenko80622a52021-02-09 16:53:23 +00002711 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2712 tid := oo.getNextTid(highPrio)
2713 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2714 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002715 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002716
2717 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2718 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002719 msgType := omci.DownloadSectionRequestType
mpagenkoc26d4c02021-05-06 14:27:57 +00002720 var timeout int = 0 //default value for no response expected
mpagenko15ff4a52021-03-02 10:09:20 +00002721 if aAckRequest > 0 {
2722 msgType = omci.DownloadSectionRequestWithResponseType
mpagenkoc26d4c02021-05-06 14:27:57 +00002723 timeout = aTimeout
mpagenko15ff4a52021-03-02 10:09:20 +00002724 }
mpagenko80622a52021-02-09 16:53:23 +00002725 omciLayer := &omci.OMCI{
2726 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002727 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002728 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2729 // Length: 0x28, // Optional, defaults to 40 octets
2730 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002731 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002732 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002733 request := &omci.DownloadSectionRequest{
2734 MeBasePacket: omci.MeBasePacket{
2735 EntityClass: me.SoftwareImageClassID,
2736 EntityInstance: aImageMeID, //inactive image
2737 },
2738 SectionNumber: aDownloadSectionNo,
2739 SectionData: localSectionData,
2740 }
2741
2742 var options gopacket.SerializeOptions
2743 options.FixLengths = true
2744 buffer := gopacket.NewSerializeBuffer()
2745 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2746 if err != nil {
2747 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2748 "device-id": oo.deviceID})
2749 return err
2750 }
2751 outgoingPacket := buffer.Bytes()
2752
mpagenko15ff4a52021-03-02 10:09:20 +00002753 //for initial debug purpose overrule the requested print state for some frames
2754 printFrame := aPrint
2755 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2756 printFrame = true
2757 }
2758
mpagenko80622a52021-02-09 16:53:23 +00002759 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenkoc26d4c02021-05-06 14:27:57 +00002760 // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway
2761 // (used to avoid retransmission of frames with the same TID)
mpagenko15ff4a52021-03-02 10:09:20 +00002762 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002763 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002764 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002765 if err != nil {
2766 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2767 "device-id": oo.deviceID})
2768 return err
2769 }
2770 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002771 return nil
2772}
2773
2774func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2775 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2776 tid := oo.getNextTid(highPrio)
2777 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2778 "SequNo": strconv.FormatInt(int64(tid), 16),
2779 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2780
mpagenko15ff4a52021-03-02 10:09:20 +00002781 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002782 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002783 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002784 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2785 // Length: 0x28, // Optional, defaults to 40 octets
2786 }
mpagenko15ff4a52021-03-02 10:09:20 +00002787 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002788 MeBasePacket: omci.MeBasePacket{
2789 EntityClass: me.SoftwareImageClassID,
2790 EntityInstance: aImageMeID, //inactive image
2791 },
mpagenko15ff4a52021-03-02 10:09:20 +00002792 CRC32: aImageCrc,
2793 ImageSize: aFileLen,
2794 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2795 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002796 }
mpagenko15ff4a52021-03-02 10:09:20 +00002797
2798 var options gopacket.SerializeOptions
2799 options.FixLengths = true
2800 buffer := gopacket.NewSerializeBuffer()
2801 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2802 if err != nil {
2803 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002804 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002805 return err
mpagenko80622a52021-02-09 16:53:23 +00002806 }
mpagenko15ff4a52021-03-02 10:09:20 +00002807 outgoingPacket := buffer.Bytes()
2808
2809 omciRxCallbackPair := callbackPair{cbKey: tid,
2810 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2811 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002812 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002813 if err != nil {
2814 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2815 "device-id": oo.deviceID})
2816 return err
2817 }
2818 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002819 return nil
2820}
2821
2822func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2823 rxChan chan Message, aImageMeID uint16) error {
2824 tid := oo.getNextTid(highPrio)
2825 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2826 "SequNo": strconv.FormatInt(int64(tid), 16),
2827 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2828
2829 omciLayer := &omci.OMCI{
2830 TransactionID: tid,
2831 MessageType: omci.ActivateSoftwareRequestType,
2832 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2833 // Length: 0x28, // Optional, defaults to 40 octets
2834 }
2835 request := &omci.ActivateSoftwareRequest{
2836 MeBasePacket: omci.MeBasePacket{
2837 EntityClass: me.SoftwareImageClassID,
2838 EntityInstance: aImageMeID, //inactive image
2839 },
2840 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2841 }
2842
2843 var options gopacket.SerializeOptions
2844 options.FixLengths = true
2845 buffer := gopacket.NewSerializeBuffer()
2846 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2847 if err != nil {
2848 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2849 "device-id": oo.deviceID})
2850 return err
2851 }
2852 outgoingPacket := buffer.Bytes()
2853
2854 omciRxCallbackPair := callbackPair{cbKey: tid,
2855 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2856 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002857 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002858 if err != nil {
2859 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2860 "device-id": oo.deviceID})
2861 return err
2862 }
2863 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002864 return nil
2865}
mpagenko80622a52021-02-09 16:53:23 +00002866
mpagenko15ff4a52021-03-02 10:09:20 +00002867func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2868 rxChan chan Message, aImageMeID uint16) error {
2869 tid := oo.getNextTid(highPrio)
2870 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2871 "SequNo": strconv.FormatInt(int64(tid), 16),
2872 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2873
2874 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002875 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002876 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002877 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2878 // Length: 0x28, // Optional, defaults to 40 octets
2879 }
mpagenko15ff4a52021-03-02 10:09:20 +00002880 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002881 MeBasePacket: omci.MeBasePacket{
2882 EntityClass: me.SoftwareImageClassID,
2883 EntityInstance: aImageMeID, //inactive image
2884 },
mpagenko80622a52021-02-09 16:53:23 +00002885 }
mpagenko15ff4a52021-03-02 10:09:20 +00002886
2887 var options gopacket.SerializeOptions
2888 options.FixLengths = true
2889 buffer := gopacket.NewSerializeBuffer()
2890 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2891 if err != nil {
2892 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002893 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002894 return err
mpagenko80622a52021-02-09 16:53:23 +00002895 }
mpagenko15ff4a52021-03-02 10:09:20 +00002896 outgoingPacket := buffer.Bytes()
2897
2898 omciRxCallbackPair := callbackPair{cbKey: tid,
2899 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2900 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002901 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002902 if err != nil {
2903 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2904 "device-id": oo.deviceID})
2905 return err
2906 }
2907 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002908 return nil
2909}
2910
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002911func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
2912 tid := oo.getNextTid(highPrio)
2913 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
2914 "SequNo": strconv.FormatInt(int64(tid), 16),
2915 "InstId": strconv.FormatInt(int64(instdID), 16)})
2916 omciLayer := &omci.OMCI{
2917 TransactionID: tid,
2918 MessageType: omci.TestRequestType,
2919 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2920 // Length: 0x28, // Optional, defaults to 40 octets
2921 }
2922
2923 var request *omci.OpticalLineSupervisionTestRequest
2924 switch classID {
2925 case aniGClassID:
2926 request = &omci.OpticalLineSupervisionTestRequest{
2927 MeBasePacket: omci.MeBasePacket{
2928 EntityClass: classID,
2929 EntityInstance: instdID,
2930 },
2931 SelectTest: uint8(7), // self test
2932 GeneralPurposeBuffer: uint16(0),
2933 VendorSpecificParameters: uint16(0),
2934 }
2935 default:
2936 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
2937 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
2938 }
2939 // Test serialization back to former string
2940 var options gopacket.SerializeOptions
2941 options.FixLengths = true
2942
2943 buffer := gopacket.NewSerializeBuffer()
2944 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2945 if err != nil {
2946 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
2947 "device-id": oo.deviceID})
2948 return err
2949 }
2950 outgoingPacket := buffer.Bytes()
2951
2952 omciRxCallbackPair := callbackPair{cbKey: tid,
2953 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2954 }
2955 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2956 if err != nil {
2957 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
2958 "device-id": oo.deviceID})
2959 return err
2960 }
2961 logger.Debug(ctx, "send self test request done")
2962 return nil
2963}
2964
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002965//nolint: gocyclo
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002966func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002967 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002968 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002969 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002970 msgLayer := (*packet).Layer(nextLayer)
2971 switch nextLayer {
2972 case omci.LayerTypeCreateResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002973 if resp := msgLayer.(*omci.CreateResponse); resp != nil {
2974 if resp.Result == me.Success {
2975 return true
2976 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002977 }
2978 case omci.LayerTypeDeleteResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002979 if resp := msgLayer.(*omci.DeleteResponse); resp != nil {
2980 if resp.Result == me.Success {
2981 return true
2982 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002983 }
2984 case omci.LayerTypeSetResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002985 if resp := msgLayer.(*omci.SetResponse); resp != nil {
2986 if resp.Result == me.Success {
2987 return true
2988 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002989 }
2990 case omci.LayerTypeStartSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002991 if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil {
2992 if resp.Result == me.Success {
2993 return true
2994 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002995 }
2996 case omci.LayerTypeEndSoftwareDownloadResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00002997 if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil {
2998 if resp.Result == me.Success {
2999 return true
3000 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003001 }
3002 case omci.LayerTypeActivateSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003003 if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil {
3004 if resp.Result == me.Success {
3005 return true
3006 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003007 }
3008 case omci.LayerTypeCommitSoftwareResponse:
Holger Hildebrandt8680ca32021-05-19 10:30:53 +00003009 if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil {
3010 if resp.Result == me.Success {
3011 return true
3012 }
Holger Hildebrandt3124e302021-03-23 12:47:03 +00003013 }
3014 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003015 }
3016 }
3017 return false
3018}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003019
3020func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003021 timeout := aOmciTxRequest.timeout
mpagenkoc26d4c02021-05-06 14:27:57 +00003022 if timeout == 0 {
3023 //timeout 0 indicates that no response is expected - fire and forget
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003024 oo.mutexTxQueue.Lock()
3025 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3026 oo.mutexTxQueue.Unlock()
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003027 go oo.sendNextRequest(ctx)
mpagenkoc26d4c02021-05-06 14:27:57 +00003028 } else {
mpagenko7455fd42021-06-10 16:25:55 +00003029 //the supervised sending with waiting on the response (based on TID) is called in background
3030 // to avoid blocking of the sender for the complete OMCI handshake procedure
3031 // to stay consistent with the processing tested so far, sending of next messages of the same control procedure
3032 // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there)
3033 go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout)
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003034 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003035}
3036
mpagenko7455fd42021-06-10 16:25:55 +00003037func (oo *omciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest omciTransferStructure, aTimeout int) {
3038 chSuccess := make(chan bool)
3039 aOmciTxRequest.chSuccess = chSuccess
3040 tid := aOmciTxRequest.cbPair.cbKey
3041 oo.mutexMonReq.Lock()
3042 oo.monitoredRequests[tid] = aOmciTxRequest
3043 oo.mutexMonReq.Unlock()
3044
3045 retries := aOmciTxRequest.retries
3046 retryCounter := 0
3047loop:
3048 for retryCounter <= retries {
3049
3050 oo.mutexTxQueue.Lock()
3051 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3052 oo.mutexTxQueue.Unlock()
3053 go oo.sendNextRequest(ctx)
3054
3055 select {
3056 case success := <-chSuccess:
3057 if success {
3058 logger.Debugw(ctx, "reqMon: response received in time",
3059 log.Fields{"tid": tid, "device-id": oo.deviceID})
3060 } else {
3061 logger.Debugw(ctx, "reqMon: wait for response aborted",
3062 log.Fields{"tid": tid, "device-id": oo.deviceID})
3063 }
3064 break loop
3065 case <-time.After(time.Duration(aTimeout) * time.Second):
3066 if retryCounter == retries {
3067 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
3068 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3069 break loop
3070 } else {
3071 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
3072 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3073 }
3074 }
3075 retryCounter++
3076 }
3077 oo.mutexMonReq.Lock()
3078 delete(oo.monitoredRequests, tid)
3079 oo.mutexMonReq.Unlock()
3080}
3081
Holger Hildebrandt366ef192021-05-05 11:07:44 +00003082//CancelRequestMonitoring terminates monitoring of outstanding omci requests
3083func (oo *omciCC) CancelRequestMonitoring() {
3084 oo.mutexMonReq.RLock()
3085 for k := range oo.monitoredRequests {
3086 oo.monitoredRequests[k].chSuccess <- false
3087 }
3088 oo.mutexMonReq.RUnlock()
3089}
3090
3091//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
3092//time consumed for retry processing of a particular OMCI-request
3093func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
3094 return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
3095}