blob: 7a85e4a105f4422454997987b580c51ca64c7fcd [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
Andrea Campanella6515c582020-10-05 11:25:00 +020025 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000027 "sync"
mpagenko80622a52021-02-09 16:53:23 +000028 "time" //by now for testing
Holger Hildebrandtfa074992020-03-27 15:42:06 +000029
30 "github.com/google/gopacket"
31 // TODO!!! Some references could be resolved auto, but some need specific context ....
32 gp "github.com/google/gopacket"
33
34 "github.com/opencord/omci-lib-go"
35 me "github.com/opencord/omci-lib-go/generated"
dbainbri4d3a0dc2020-12-02 00:33:42 +000036 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
39 "github.com/opencord/voltha-lib-go/v4/pkg/log"
40 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
41 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
42 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000043)
44
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000045// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053046
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047const galEthernetEID = uint16(1)
48const 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 +000053const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
54const ieeeMapperServiceProfileEID = uint16(0x8001)
55const macBridgePortAniEID = uint16(0x2102)
56
mpagenko8b07c1b2020-11-26 10:36:31 +000057const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
58
mpagenkoc8bba412021-01-15 15:38:44 +000059const cOmciBaseMessageTrailerLen = 40
60
61// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
62type tOmciReceiveError uint8
63
64const (
65 // cOmciMessageReceiveNoError - default start state
66 cOmciMessageReceiveNoError tOmciReceiveError = iota
67 // Error indication wrong trailer length within the message
68 cOmciMessageReceiveErrorTrailerLen
69 // Error indication missing trailer within the message
70 cOmciMessageReceiveErrorMissTrailer
71)
72
Holger Hildebrandt366ef192021-05-05 11:07:44 +000073const cDefaultRetries = 2
74
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000075// ### OMCI related definitions - end
76
Himani Chawla6d2ae152020-09-02 13:11:20 +053077//callbackPairEntry to be used for OMCI send/receive correlation
78type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000079 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000080 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
mpagenko80622a52021-02-09 16:53:23 +000081 framePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000082}
83
Himani Chawla6d2ae152020-09-02 13:11:20 +053084//callbackPair to be used for ReceiveCallback init
85type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000086 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053087 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000088}
89
90type omciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000091 txFrame []byte
92 timeout int
Holger Hildebrandt366ef192021-05-05 11:07:44 +000093 retries int
mpagenko80622a52021-02-09 16:53:23 +000094 highPrio bool
95 withFramePrint bool
Holger Hildebrandt366ef192021-05-05 11:07:44 +000096 cbPair callbackPair
97 chSuccess chan bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000098}
99
Himani Chawla6d2ae152020-09-02 13:11:20 +0530100//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
101type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000102 enabled bool
103 pOnuDeviceEntry *OnuDeviceEntry
104 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +0530105 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000106 coreProxy adapterif.CoreProxy
107 adapterProxy adapterif.AdapterProxy
108 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000109 rxOmciFrameError tOmciReceiveError
110
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000111 txFrames, txOnuFrames uint32
112 rxFrames, rxOnuFrames, rxOnuDiscards uint32
113
114 // OMCI params
115 mutexTid sync.Mutex
116 tid uint16
117 mutexHpTid sync.Mutex
118 hpTid uint16
119 uploadSequNo uint16
120 uploadNoOfCmds uint16
121
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000122 mutexTxQueue sync.Mutex
123 txQueue *list.List
124 mutexRxSchedMap sync.Mutex
125 rxSchedulerMap map[uint16]callbackPairEntry
126 mutexMonReq sync.RWMutex
127 monitoredRequests map[uint16]omciTransferStructure
128 mutexPLastTxMeInstance sync.RWMutex
129 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000130}
131
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000132var responsesWithMibDataSync = []omci.MessageType{
133 omci.CreateResponseType,
134 omci.DeleteResponseType,
135 omci.SetResponseType,
136 omci.StartSoftwareDownloadResponseType,
137 omci.EndSoftwareDownloadResponseType,
138 omci.ActivateSoftwareResponseType,
139 omci.CommitSoftwareResponseType,
140}
141
Himani Chawla6d2ae152020-09-02 13:11:20 +0530142//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000143//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530144func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
145 deviceID string, deviceHandler *deviceHandler,
146 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000147 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530148 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000149 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530150 omciCC.pOnuDeviceEntry = onuDeviceEntry
151 omciCC.deviceID = deviceID
152 omciCC.pBaseDeviceHandler = deviceHandler
153 omciCC.coreProxy = coreProxy
154 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000155 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000156 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000157 omciCC.txFrames = 0
158 omciCC.txOnuFrames = 0
159 omciCC.rxFrames = 0
160 omciCC.rxOnuFrames = 0
161 omciCC.rxOnuDiscards = 0
162 omciCC.tid = 0x1
163 omciCC.hpTid = 0x8000
164 omciCC.uploadSequNo = 0
165 omciCC.uploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000166 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530167 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000168 omciCC.monitoredRequests = make(map[uint16]omciTransferStructure)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000169
170 return &omciCC
171}
172
mpagenko900ee4b2020-10-12 11:56:34 +0000173//stop stops/resets the omciCC
174func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000175 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000176 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000177 oo.CancelRequestMonitoring()
mpagenko900ee4b2020-10-12 11:56:34 +0000178 oo.mutexTxQueue.Lock()
179 oo.txQueue.Init() // clear the tx queue
180 oo.mutexTxQueue.Unlock()
181 oo.mutexRxSchedMap.Lock()
182 for k := range oo.rxSchedulerMap {
183 delete(oo.rxSchedulerMap, k) //clear the scheduler map
184 }
185 oo.mutexRxSchedMap.Unlock()
186 oo.mutexHpTid.Lock()
187 oo.hpTid = 0x8000 //reset the high prio transactionId
188 oo.mutexHpTid.Unlock()
189 oo.mutexTid.Lock()
190 oo.tid = 1 //reset the low prio transactionId
191 oo.mutexTid.Unlock()
192 //reset control values
193 oo.uploadSequNo = 0
194 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000195 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000196 //reset the stats counter - which might be topic of discussion ...
197 oo.txFrames = 0
198 oo.txOnuFrames = 0
199 oo.rxFrames = 0
200 oo.rxOnuFrames = 0
201 oo.rxOnuDiscards = 0
202
203 return nil
204}
205
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000206// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530207func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000208 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000209 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530210 switch omciMsg.MessageType {
211 case omci.AlarmNotificationType:
212 data := OmciMessage{
213 OmciMsg: omciMsg,
214 OmciPacket: packet,
215 }
216 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
217 return nil
218 default:
219 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
220 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000221 /*
222 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
223 rxOnuFrames++
224
225 switch msgType {
226 case AlarmNotification:
227 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000228 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000229 // python code was:
230 //if msg_type == EntityOperations.AlarmNotification.value:
231 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
232 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
233 //
234 return errors.New("RxAlarmNotification unimplemented")
235 }
236 case AttributeValueChange:
237 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000238 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000239 // python code was:
240 //elif msg_type == EntityOperations.AttributeValueChange.value:
241 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
242 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
243 //
244 return errors.New("RxAttributeValueChange unimplemented")
245 }
246 case TestResult:
247 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000248 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000249 // python code was:
250 //elif msg_type == EntityOperations.TestResult.value:
251 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
252 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
253 //
254 return errors.New("RxTestResult unimplemented")
255 }
256 default:
257 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000258 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000259 rxOnuDiscards++
260 return errors.New("RxOnuMsgType unimplemented")
261 }
262 }
263 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000264}
265
mpagenko80622a52021-02-09 16:53:23 +0000266func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
267 //assuming omci message content is hex coded!
268 // with restricted output of 16bytes would be ...rxMsg[:16]
269 logger.Debugw(ctx, "omci-message-received:", log.Fields{
270 "RxOmciMessage": hex.EncodeToString(rxMsg),
271 "device-id": oo.deviceID})
272}
273
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000274// Rx handler for onu messages
275// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530276func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000277 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000278 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
279 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000280 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000281 trailerLenData := rxMsg[42:44]
282 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000283 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000284 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
285 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
286 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
287 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
288 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
289 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
290 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
291 }
292 }
293 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
294 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
295 // (an extendedFormat message could be destroyed this way!)
296 // extend/overwrite with trailer
297 trailer := make([]byte, 8)
298 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
299 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
300 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
301 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
302 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
303 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
304 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000305 }
306 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000307 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
308 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000309 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200310 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000311 }
312
313 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
314 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000315 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000316 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200317 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000318 }
319 omciLayer := packet.Layer(omci.LayerTypeOMCI)
320 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000321 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000322 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200323 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000324 }
325 omciMsg, ok := omciLayer.(*omci.OMCI)
326 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000327 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000328 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200329 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000330 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000331 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000332 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700333 // TestResult is asynchronous indication that carries the same TID as the TestResponse.
334 // We expect to find the TID in the oo.rxSchedulerMap
335 if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000336 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000337 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000338 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000339 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530340 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000341 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000342 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200343 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000344 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200345 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530346 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000347 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530348 oo.mutexRxSchedMap.Lock()
349 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
350 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000351 if rxCallbackEntry.framePrint {
352 oo.printRxMessage(ctx, rxMsg)
353 }
Himani Chawla4d908332020-08-31 12:30:20 +0530354 //disadvantage of decoupling: error verification made difficult, but anyway the question is
355 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000356 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000357 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000358 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
359 }
mpagenkoc8bba412021-01-15 15:38:44 +0000360
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700361 // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message,
362 // so do not clean up the TransactionID in that case.
363 if omciMsg.MessageType != omci.TestResponseType {
364 // having posted the response the request is regarded as 'done'
365 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
366 }
Himani Chawla4d908332020-08-31 12:30:20 +0530367 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000368 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000369 }
mpagenko80622a52021-02-09 16:53:23 +0000370 oo.mutexRxSchedMap.Unlock()
371 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
372 oo.printRxMessage(ctx, rxMsg)
373 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000374
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000375 /* py code was:
376 Receive and OMCI message from the proxy channel to the OLT.
377
378 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
379 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
380 """
381 if not self.enabled:
382 return
383
384 try:
385 now = arrow.utcnow()
386 d = None
387
388 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
389 # save the current value of the entity_id_to_class_map, then
390 # replace it with our custom one before decode, and then finally
391 # restore it later. Tried other ways but really made the code messy.
392 saved_me_map = omci_entities.entity_id_to_class_map
393 omci_entities.entity_id_to_class_map = self._me_map
394
395 try:
396 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000397 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000398 except KeyError as e:
399 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000400 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000401 rx_frame = self._decode_unknown_me(msg)
402 self._rx_unknown_me += 1
403
404 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000405 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000406 return
407
408 finally:
409 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
410
411 rx_tid = rx_frame.fields['transaction_id']
412 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000413 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000414 # Filter the Test Result frame and route through receive onu
415 # message method.
416 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000417 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000418 return self._receive_onu_message(rx_frame)
419
420 # Previously unreachable if this is the very first round-trip Rx or we
421 # have been running consecutive errors
422 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000423 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000424 self.reactor.callLater(0, self._publish_connectivity_event, True)
425
426 self._rx_frames += 1
427 self._consecutive_errors = 0
428
429 try:
430 high_priority = self._tid_is_high_priority(rx_tid)
431 index = self._get_priority_index(high_priority)
432
433 # (timestamp, defer, frame, timeout, retry, delayedCall)
434 last_tx_tuple = self._tx_request[index]
435
436 if last_tx_tuple is None or \
437 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
438 # Possible late Rx on a message that timed-out
439 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000440 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000441 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
442 self._rx_unknown_tid += 1
443 self._rx_late += 1
444 return
445
446 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
447 if dc is not None and not dc.cancelled and not dc.called:
448 dc.cancel()
449
450 _secs = self._update_rx_tx_stats(now, ts)
451
452 # Late arrival already serviced by a timeout?
453 if d.called:
454 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000455 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000456 return
457
458 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000459 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000460 if d is not None:
461 return d.errback(failure.Failure(e))
462 return
463
464 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000465 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000466 tx_tid = tx_frame.fields['transaction_id'])
467 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
468
469 # begin success callback chain (will cancel timeout and queue next Tx message)
470 self._rx_response[index] = rx_frame
471 d.callback(rx_frame)
472
473 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000474 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000475 */
476}
477
Himani Chawla6d2ae152020-09-02 13:11:20 +0530478/*
479func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530480 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530481 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000482}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530483*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000484
Girish Gowdra6afb56a2021-04-27 17:47:57 -0700485// ReleaseTid releases OMCI transaction identifier from rxSchedulerMap
486func (oo *omciCC) ReleaseTid(ctx context.Context, tid uint16) {
487 logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid})
488 delete(oo.rxSchedulerMap, tid)
489}
490
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000491//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530492func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
493 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000494
dbainbri4d3a0dc2020-12-02 00:33:42 +0000495 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000496 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
497 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000498 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
mpagenko80622a52021-02-09 16:53:23 +0000499 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000500 oo.mutexRxSchedMap.Unlock()
501
502 //just use a simple list for starting - might need some more effort, especially for multi source write access
503 omciTxRequest := omciTransferStructure{
504 txFrame,
505 timeout,
506 retry,
507 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000508 printFrame,
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000509 receiveCallbackPair,
510 nil,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000511 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000512 oo.mutexMonReq.Lock()
513 defer oo.mutexMonReq.Unlock()
514 if _, exist := oo.monitoredRequests[receiveCallbackPair.cbKey]; !exist {
515 go oo.processRequestMonitoring(ctx, omciTxRequest)
516 return nil
517 }
518 logger.Errorw(ctx, "A message with this tid is processed already!",
519 log.Fields{"tid": receiveCallbackPair.cbKey, "device-id": oo.deviceID})
520 return fmt.Errorf("message with tid is processed already %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000521}
522
523//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530524func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000525 // return errors.New("sendNextRequest unimplemented")
526
527 // just try to get something transferred !!
528 // avoid accessing the txQueue from parallel send requests
529 // block parallel omci send requests at least until SendIAP is 'committed'
530 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
531 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000532 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000533 for oo.txQueue.Len() > 0 {
534 queueElement := oo.txQueue.Front() // First element
535 omciTxRequest := queueElement.Value.(omciTransferStructure)
536 /* compare olt device handler code:
537 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000538 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000539 var deviceType string
540 var deviceID string
541 var proxyDeviceID string
542
543 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
544
545 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
546
dbainbri4d3a0dc2020-12-02 00:33:42 +0000547 logger.Debugw(ctx,"omci indication for a device not in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000548 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
549 kwargs := make(map[string]interface{})
550 kwargs["onu_id"] = omciInd.OnuId
551 kwargs["parent_port_no"] = ponPort
552
dbainbri4d3a0dc2020-12-02 00:33:42 +0000553 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000555 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000556 return
557 }
558 deviceType = onuDevice.Type
559 deviceID = onuDevice.Id
560 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
561 //if not exist in cache, then add to cache.
562 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
563 } else {
564 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000565 logger.Debugw(ctx,"omci indication for a device in cache.", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000566 deviceType = onuInCache.(*OnuDevice).deviceType
567 deviceID = onuInCache.(*OnuDevice).deviceID
568 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
569 }
570 */
571 /* and compare onu_adapter py code:
572 omci_msg = InterAdapterOmciMessage(
573 message=bytes(frame),
574 proxy_address=self._proxy_address,
575 connect_status=self._device.connect_status)
576
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000577 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000578
579 yield self._adapter_proxy.send_inter_adapter_message(
580 msg=omci_msg,
581 type=InterAdapterMessageType.OMCI_REQUEST,
582 from_adapter=self._device.type,
583 to_adapter=self._proxy_address.device_type,
584 to_device_id=self._device_id,
585 proxy_device_id=self._proxy_address.device_id
586 )
587 */
588 device, err := oo.coreProxy.GetDevice(ctx,
589 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
590 if err != nil || device == nil {
591 /*TODO: needs to handle error scenarios */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000592 logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000593 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200594 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000595 }
596
mpagenko80622a52021-02-09 16:53:23 +0000597 if omciTxRequest.withFramePrint {
598 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
599 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
600 "device-id": oo.deviceID,
601 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
602 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
603 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000605 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000606 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800607 //fromTopic,toType,toDevId, ProxyDevId
608 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000609 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000610 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000611 return sendErr
612 }
613 oo.txQueue.Remove(queueElement) // Dequeue
614 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000615 return nil
616}
617
Himani Chawla6d2ae152020-09-02 13:11:20 +0530618func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 var next uint16
620 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000621 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000622 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530623 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000624 if oo.hpTid < 0x8000 {
625 oo.hpTid = 0x8000
626 }
mpagenko900ee4b2020-10-12 11:56:34 +0000627 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000628 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000629 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000630 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530631 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000632 if oo.tid >= 0x8000 {
633 oo.tid = 1
634 }
mpagenko900ee4b2020-10-12 11:56:34 +0000635 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000636 }
637 return next
638}
639
640// ###################################################################################
641// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000642func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000643 omciLayer := &omci.OMCI{
644 TransactionID: tid,
645 MessageType: msgType,
646 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000647 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000648}
649
dbainbri4d3a0dc2020-12-02 00:33:42 +0000650func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000651 var options gopacket.SerializeOptions
652 options.FixLengths = true
653
654 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530655 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000656 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000657 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000658 return nil, err
659 }
660 return buffer.Bytes(), nil
661}
662
Himani Chawla4d908332020-08-31 12:30:20 +0530663/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000664func hexEncode(omciPkt []byte) ([]byte, error) {
665 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
666 hex.Encode(dst, omciPkt)
667 return dst, nil
668}
Himani Chawla4d908332020-08-31 12:30:20 +0530669*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000670
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000671//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000672func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000673
dbainbri4d3a0dc2020-12-02 00:33:42 +0000674 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000675 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000676
677 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000678 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000679 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200680 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000681 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000682 oo.mutexMonReq.RLock()
683 if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist {
684 oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true
685 } else {
686 logger.Infow(ctx, "reqMon: map entry does not exist!",
687 log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID})
688 }
689 oo.mutexMonReq.RUnlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000690
691 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
692 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000693 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000694 Type: OMCI,
695 Data: OmciMessage{
696 OmciMsg: omciMsg,
697 OmciPacket: packet,
698 },
699 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000700 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000701 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000702
703 return nil
704}
705
Himani Chawla6d2ae152020-09-02 13:11:20 +0530706func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000707
dbainbri4d3a0dc2020-12-02 00:33:42 +0000708 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000709 request := &omci.MibResetRequest{
710 MeBasePacket: omci.MeBasePacket{
711 EntityClass: me.OnuDataClassID,
712 },
713 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530714 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000715 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000716 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000717 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000718 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000719 return err
720 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530721 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000722 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000723 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000724 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000725 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000726}
727
Himani Chawla6d2ae152020-09-02 13:11:20 +0530728func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000729 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300730 request := &omci.RebootRequest{
731 MeBasePacket: omci.MeBasePacket{
732 EntityClass: me.OnuGClassID,
733 },
734 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530735 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000736 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300737 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000738 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000739 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300740 return err
741 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530742 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300743 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000744 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300745 }
746
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000747 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300748 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000749 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000750 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300751 return err
752 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000753 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000755 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200756 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300757 return err
758 }
759 return nil
760}
761
Himani Chawla6d2ae152020-09-02 13:11:20 +0530762func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000763 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000764 request := &omci.MibUploadRequest{
765 MeBasePacket: omci.MeBasePacket{
766 EntityClass: me.OnuDataClassID,
767 },
768 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530769 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000770 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000771 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000772 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000773 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000774 return err
775 }
776 oo.uploadSequNo = 0
777 oo.uploadNoOfCmds = 0
778
Himani Chawla6d2ae152020-09-02 13:11:20 +0530779 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000780 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000781 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000782 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000783 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000784}
785
Himani Chawla6d2ae152020-09-02 13:11:20 +0530786func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000787 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000788 request := &omci.MibUploadNextRequest{
789 MeBasePacket: omci.MeBasePacket{
790 EntityClass: me.OnuDataClassID,
791 },
792 CommandSequenceNumber: oo.uploadSequNo,
793 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530794 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000795 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000796 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000797 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000798 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000799 return err
800 }
801 oo.uploadSequNo++
802
Himani Chawla6d2ae152020-09-02 13:11:20 +0530803 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000804 cbKey: tid,
805 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
806 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
807 // compare also software upgrade download section handling
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000808 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000809 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000810 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000811}
812
Himani Chawlad3dac422021-03-13 02:31:31 +0530813func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
814 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
815 request := &omci.GetAllAlarmsRequest{
816 MeBasePacket: omci.MeBasePacket{
817 EntityClass: me.OnuDataClassID,
818 },
819 AlarmRetrievalMode: byte(alarmRetreivalMode),
820 }
821 tid := oo.getNextTid(highPrio)
822 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
823 if err != nil {
824 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
825 "Err": err, "device-id": oo.deviceID})
826 return err
827 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000828 oo.pBaseDeviceHandler.pAlarmMgr.ResetAlarmUploadCounters()
Himani Chawlad3dac422021-03-13 02:31:31 +0530829
830 omciRxCallbackPair := callbackPair{
831 cbKey: tid,
832 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
833 oo.receiveOmciResponse, true},
834 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000835 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530836}
837
838func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000839 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.GetAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530840 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
841 "alarmUploadSeqNo": alarmUploadSeqNo})
842 request := &omci.GetAllAlarmsNextRequest{
843 MeBasePacket: omci.MeBasePacket{
844 EntityClass: me.OnuDataClassID,
845 },
846 CommandSequenceNumber: alarmUploadSeqNo,
847 }
848 tid := oo.getNextTid(highPrio)
849 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
850 if err != nil {
851 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
852 "Err": err, "device-id": oo.deviceID})
853 return err
854 }
Holger Hildebrandt0da7e6f2021-05-12 13:08:43 +0000855 oo.pBaseDeviceHandler.pAlarmMgr.IncrementAlarmUploadSeqNo()
Himani Chawlad3dac422021-03-13 02:31:31 +0530856
857 omciRxCallbackPair := callbackPair{
858 cbKey: tid,
859 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
860 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000861 return oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Himani Chawlad3dac422021-03-13 02:31:31 +0530862}
863
ozgecanetsiab36ed572021-04-01 10:38:48 +0300864func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530865 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000866 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000867 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000868
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000869 meParams := me.ParamData{
870 EntityID: galEthernetEID,
871 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
872 }
873 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
874 if omciErr.GetError() == nil {
875 //all setByCreate parameters already set, no default option required ...
876 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
877 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000878 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000879 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300880 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000881 }
882
dbainbri4d3a0dc2020-12-02 00:33:42 +0000883 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000884 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000885 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000886 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300887 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000888 }
889
Himani Chawla6d2ae152020-09-02 13:11:20 +0530890 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000891 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000892 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000893 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000894 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000895 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000896 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000897 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300898 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000899 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000900 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300901 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000902 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000903 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000904 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300905 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000906}
907
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000908// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
ozgecanetsiab36ed572021-04-01 10:38:48 +0300909func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530910 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000911 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000912 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000913
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000914 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
915 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000916 // By now we just use fix values to fire - this is anyway what the python adapter does
917 // read ONU-2G from DB ???? //TODO!!!
918 meParams := me.ParamData{
919 EntityID: 0,
920 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
921 }
922 meInstance, omciErr := me.NewOnu2G(meParams)
923 if omciErr.GetError() == nil {
924 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
925 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000926 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000927 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300928 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000929 }
930
dbainbri4d3a0dc2020-12-02 00:33:42 +0000931 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000932 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000933 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000934 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300935 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000936 }
937
Himani Chawla6d2ae152020-09-02 13:11:20 +0530938 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000939 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000940 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000941 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000942 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000943 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000944 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000945 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300946 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000947 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000948 logger.Debug(ctx, "send ONU2-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +0300949 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000950 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000951 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000952 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300953 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000954}
955
Himani Chawla6d2ae152020-09-02 13:11:20 +0530956func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +0300957 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +0530958 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530959 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000960 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000961 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000962
963 meParams := me.ParamData{
964 EntityID: instID,
965 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300966 "Priority": 0x8000,
967 "MaxAge": 20 * 256, //20s
968 "HelloTime": 2 * 256, //2s
969 "ForwardDelay": 15 * 256, //15s
970 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000971 },
972 }
973
974 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
975 if omciErr.GetError() == nil {
976 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
977 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
978 omci.TransactionID(tid), omci.AddDefaults(true))
979 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000980 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000981 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300982 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000983 }
984
dbainbri4d3a0dc2020-12-02 00:33:42 +0000985 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000986 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000987 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000988 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +0300989 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000990 }
991
Himani Chawla6d2ae152020-09-02 13:11:20 +0530992 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000993 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000994 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000995 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +0000996 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000997 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000998 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000999 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001000 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001001 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001002 logger.Debug(ctx, "send MBSP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001003 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001004 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001005 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001006 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001007 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001008}
1009
Himani Chawla6d2ae152020-09-02 13:11:20 +05301010func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001011 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301012 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +05301013 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +00001014 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001015 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001016
1017 meParams := me.ParamData{
1018 EntityID: instID,
1019 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +05301020 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
1021 "PortNum": aPUniPort.macBpNo,
1022 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +05301023 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001024 },
1025 }
1026 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1027 if omciErr.GetError() == nil {
1028 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1029 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1030 omci.TransactionID(tid), omci.AddDefaults(true))
1031 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001032 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001033 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001034 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001035 }
1036
dbainbri4d3a0dc2020-12-02 00:33:42 +00001037 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001038 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001039 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001040 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001041 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001042 }
1043
Himani Chawla6d2ae152020-09-02 13:11:20 +05301044 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001045 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001046 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001047 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001048 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001049 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001050 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001051 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001052 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001053 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001054 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001055 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001056 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001057 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001058 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001059 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001060}
1061
Himani Chawla6d2ae152020-09-02 13:11:20 +05301062func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001063 aPUniPort *onuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301064 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001065 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301066 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001067 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001068 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001069
1070 // compare python adapter code WA VOL-1311: this is not done here!
1071 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1072 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1073 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301074 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001075 assType = uint8(10) // for VEIP
1076 }
1077 meParams := me.ParamData{
1078 EntityID: instID,
1079 Attributes: me.AttributeValueMap{
1080 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301081 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001082 },
1083 }
1084 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1085 if omciErr.GetError() == nil {
1086 //all setByCreate parameters already set, no default option required ...
1087 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1088 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001089 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001090 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001091 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001092 }
1093
dbainbri4d3a0dc2020-12-02 00:33:42 +00001094 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001095 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001096 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001097 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001098 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001099 }
1100
Himani Chawla6d2ae152020-09-02 13:11:20 +05301101 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001102 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001103 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001104 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001105 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001106 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001107 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001108 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001109 return nil, err
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001110 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001111 logger.Debug(ctx, "send EVTOCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001112 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001113 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001114 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001115 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001116 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001117}
1118
Himani Chawla6d2ae152020-09-02 13:11:20 +05301119func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001120 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301121 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001122 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001123 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001124
1125 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1126 meParams := me.ParamData{
1127 EntityID: 0,
1128 Attributes: requestedAttributes,
1129 }
1130 meInstance, omciErr := me.NewOnuG(meParams)
1131 if omciErr.GetError() == nil {
1132 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1133 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001134 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001135 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001136 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001137 }
1138
dbainbri4d3a0dc2020-12-02 00:33:42 +00001139 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001140 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001141 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001142 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001143 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001144 }
1145
Himani Chawla6d2ae152020-09-02 13:11:20 +05301146 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001147 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001148 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001149 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001150 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001151 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001152 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001153 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001154 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001155 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001156 logger.Debug(ctx, "send ONU-G-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001157 return meInstance, nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001158 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001159 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001160 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001161 return nil, omciErr.GetError()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001162}
1163
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001164func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001165 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001166 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001167 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001168 "SequNo": strconv.FormatInt(int64(tid), 16)})
1169
1170 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1171 meParams := me.ParamData{
1172 EntityID: aInstNo,
1173 Attributes: requestedAttributes,
1174 }
1175 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1176 if omciErr.GetError() == nil {
1177 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1178 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001179 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001180 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001181 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001182 }
1183
dbainbri4d3a0dc2020-12-02 00:33:42 +00001184 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001185 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001186 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001187 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001188 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001189 }
1190
1191 omciRxCallbackPair := callbackPair{
1192 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001193 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001194 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001195 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001196 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001197 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001198 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001199 return nil, err
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001200 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001201 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001202 return meInstance, nil
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001203 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001204 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001205 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001206 return nil, omciErr.GetError()
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001207}
1208
1209/* UniG obsolete by now, left here in case it should be needed once again
1210 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301211func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001212 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301213 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001214 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001215 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001216
1217 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1218 meParams := me.ParamData{
1219 EntityID: aInstNo,
1220 Attributes: requestedAttributes,
1221 }
1222 meInstance, omciErr := me.NewUniG(meParams)
1223 if omciErr.GetError() == nil {
1224 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1225 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001226 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001227 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001228 return nil
1229 }
1230
1231 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1232 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001233 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001234 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001235 return nil
1236 }
1237
Himani Chawla6d2ae152020-09-02 13:11:20 +05301238 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001239 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001240 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001241 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001242 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001243 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001245 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001246 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001247 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001248 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001249 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001251 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001252 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001253 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001254}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001255*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001256
Himani Chawla6d2ae152020-09-02 13:11:20 +05301257func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001258 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301259 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001260 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001261 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001262
1263 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1264 meParams := me.ParamData{
1265 EntityID: aInstNo,
1266 Attributes: requestedAttributes,
1267 }
1268 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1269 if omciErr.GetError() == nil {
1270 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1271 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001272 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001273 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001274 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001275 }
1276
dbainbri4d3a0dc2020-12-02 00:33:42 +00001277 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001278 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001279 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001280 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001281 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001282 }
1283
Himani Chawla6d2ae152020-09-02 13:11:20 +05301284 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001285 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001286 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001287 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001288 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001289 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001291 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001292 return nil, err
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001293 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001294 logger.Debug(ctx, "send VEIP-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001295 return meInstance, nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001296 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001297 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001298 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001299 return nil, omciErr.GetError()
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001300}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001301
Himani Chawla6d2ae152020-09-02 13:11:20 +05301302func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001303 timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001304
Himani Chawla6d2ae152020-09-02 13:11:20 +05301305 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001306 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001307 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001308
1309 meParams := me.ParamData{
1310 EntityID: entityID,
1311 Attributes: requestedAttributes,
1312 }
1313 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1314 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301315 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001316 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1317 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001318 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 +03001319 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001320 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001321 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001322 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001323 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001324 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001325 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301326 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001327 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001328 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001329 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001330 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001331 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001332 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001333 return nil, err
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001334 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001335 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001336 return meInstance, nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001337 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001338 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001339 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001340}
1341
Himani Chawla6d2ae152020-09-02 13:11:20 +05301342func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001343 aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301344 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001345 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001346 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1347
1348 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001349 EntityID: aInstID,
1350 Attributes: me.AttributeValueMap{
1351 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1352 "TpPointer": 0xFFFF,
1353 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1354 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1355 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1356 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1357 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1358 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1359 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1360 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1361 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001362 }
1363 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1364 if omciErr.GetError() == nil {
1365 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1366 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1367 omci.TransactionID(tid), omci.AddDefaults(true))
1368 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001369 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001370 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001371 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001372 }
1373
dbainbri4d3a0dc2020-12-02 00:33:42 +00001374 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001375 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001376 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001377 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001378 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001379 }
1380
Himani Chawla6d2ae152020-09-02 13:11:20 +05301381 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001382 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001383 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001384 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001385 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001386 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001387 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001388 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001389 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001390 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001391 logger.Debug(ctx, "send .1pMapper-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001392 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001394 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001395 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001396 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001397}
1398
Himani Chawla6d2ae152020-09-02 13:11:20 +05301399func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001400 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301401 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001402 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001403 "SequNo": strconv.FormatInt(int64(tid), 16),
1404 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1405
1406 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1407 if omciErr.GetError() == nil {
1408 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1409 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1410 omci.TransactionID(tid), omci.AddDefaults(true))
1411 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001412 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001413 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001414 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001415 }
1416
dbainbri4d3a0dc2020-12-02 00:33:42 +00001417 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001418 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001419 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001420 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001421 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001422 }
1423
Himani Chawla6d2ae152020-09-02 13:11:20 +05301424 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001426 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001427 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001428 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001429 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001431 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001432 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001433 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001434 logger.Debug(ctx, "send MBPCD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001435 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001436 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001437 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001438 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001439 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001440}
1441
Himani Chawla6d2ae152020-09-02 13:11:20 +05301442func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001443 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301444 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001445 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001446 "SequNo": strconv.FormatInt(int64(tid), 16),
1447 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1448
1449 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1450 if omciErr.GetError() == nil {
1451 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1452 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1453 omci.TransactionID(tid), omci.AddDefaults(true))
1454 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001455 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001456 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001457 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001458 }
1459
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001461 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001462 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001463 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001464 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001465 }
1466
Himani Chawla6d2ae152020-09-02 13:11:20 +05301467 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001468 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001469 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001470 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001471 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001472 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001473 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001474 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001475 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001476 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001477 logger.Debug(ctx, "send GemNCTP-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001478 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001479 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001480 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001481 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001482 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001483}
1484
Himani Chawla6d2ae152020-09-02 13:11:20 +05301485func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001486 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301487 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001488 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001489 "SequNo": strconv.FormatInt(int64(tid), 16),
1490 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1491
1492 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1493 if omciErr.GetError() == nil {
1494 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1495 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1496 omci.TransactionID(tid))
1497 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001498 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001499 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001500 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 }
1502
dbainbri4d3a0dc2020-12-02 00:33:42 +00001503 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001504 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001505 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001506 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001507 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001508 }
1509
Himani Chawla6d2ae152020-09-02 13:11:20 +05301510 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001511 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001512 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001513 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001514 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001515 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001516 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001517 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001518 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001519 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001520 logger.Debug(ctx, "send GemIwTp-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001521 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001522 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001523 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001524 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001525 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001526}
1527
Himani Chawla6d2ae152020-09-02 13:11:20 +05301528func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001529 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301530 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001531 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001532 "SequNo": strconv.FormatInt(int64(tid), 16),
1533 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1534
1535 meInstance, omciErr := me.NewTCont(params[0])
1536 if omciErr.GetError() == nil {
1537 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1538 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001539 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001540 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001541 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001542 }
1543
dbainbri4d3a0dc2020-12-02 00:33:42 +00001544 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001545 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001546 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001547 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001548 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001549 }
1550
Himani Chawla6d2ae152020-09-02 13:11:20 +05301551 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001552 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001553 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001554 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001555 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001556 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001557 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001558 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001559 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001560 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001561 logger.Debug(ctx, "send TCont-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001562 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001563 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001564 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001565 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001566 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001567}
1568
Himani Chawla6d2ae152020-09-02 13:11:20 +05301569func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001570 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301571 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001572 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001573 "SequNo": strconv.FormatInt(int64(tid), 16),
1574 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1575
1576 meInstance, omciErr := me.NewPriorityQueue(params[0])
1577 if omciErr.GetError() == nil {
1578 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1579 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001580 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001581 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001582 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001583 }
1584
dbainbri4d3a0dc2020-12-02 00:33:42 +00001585 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001586 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001587 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001588 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001589 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001590 }
1591
Himani Chawla6d2ae152020-09-02 13:11:20 +05301592 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001593 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001594 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001595 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001596 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001597 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001598 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001599 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001600 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001601 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001602 logger.Debug(ctx, "send PrioQueue-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001603 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001604 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001605 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001606 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001607 return nil, omciErr.GetError()
mpagenko3dbcdd22020-07-22 07:38:45 +00001608}
1609
Himani Chawla6d2ae152020-09-02 13:11:20 +05301610func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001611 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301612 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001613 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001614 "SequNo": strconv.FormatInt(int64(tid), 16),
1615 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1616
1617 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1618 if omciErr.GetError() == nil {
1619 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1620 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001621 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001622 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001623 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001624 }
1625
dbainbri4d3a0dc2020-12-02 00:33:42 +00001626 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001627 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001628 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001629 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001630 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001631 }
1632
Himani Chawla6d2ae152020-09-02 13:11:20 +05301633 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001634 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001635 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001636 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001637 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001638 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001639 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001640 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001641 return nil, err
mpagenko3dbcdd22020-07-22 07:38:45 +00001642 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001643 logger.Debug(ctx, "send 1PMapper-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001644 return meInstance, nil
mpagenko3dbcdd22020-07-22 07:38:45 +00001645 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001646 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001647 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001648 return nil, omciErr.GetError()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001649}
mpagenkodff5dda2020-08-28 11:52:01 +00001650
Himani Chawla6d2ae152020-09-02 13:11:20 +05301651func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001652 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301653 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001654 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001655 "SequNo": strconv.FormatInt(int64(tid), 16),
1656 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1657
1658 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1659 if omciErr.GetError() == nil {
1660 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1661 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1662 omci.TransactionID(tid))
1663 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001664 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001665 "Err": err, "device-id": oo.deviceID})
1666 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1667 // return (dual format) error code that can be used at caller for immediate error treatment
1668 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001669 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001670 }
1671
dbainbri4d3a0dc2020-12-02 00:33:42 +00001672 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001673 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001674 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001675 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001676 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001677 }
1678
Himani Chawla6d2ae152020-09-02 13:11:20 +05301679 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001680 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001681 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001682 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001683 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001684 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001685 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001686 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001687 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001688 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001689 logger.Debug(ctx, "send VTFD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001690 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001691 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001692 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001693 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001694 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001695}
1696
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001697// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001698func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001699 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001700 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001701 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001702 "SequNo": strconv.FormatInt(int64(tid), 16),
1703 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1704
1705 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1706 if omciErr.GetError() == nil {
1707 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1708 omci.TransactionID(tid))
1709 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001710 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001711 "Err": err, "device-id": oo.deviceID})
1712 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1713 // return (dual format) error code that can be used at caller for immediate error treatment
1714 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001715 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001716 }
1717
dbainbri4d3a0dc2020-12-02 00:33:42 +00001718 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001719 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001720 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001721 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001722 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001723 }
1724
1725 omciRxCallbackPair := callbackPair{
1726 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001727 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001728 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001729 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001730 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001731 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001732 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001733 return nil, err
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001734 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001735 logger.Debug(ctx, "send VTFD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001736 return meInstance, nil
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001737 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001738 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001739 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001740 return nil, omciErr.GetError()
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001741}
1742
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001743func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001744 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001745 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001746 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001747 "SequNo": strconv.FormatInt(int64(tid), 16),
1748 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1749
1750 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1751 if omciErr.GetError() == nil {
1752 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1753 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001754 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001755 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001756 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001757 }
1758
dbainbri4d3a0dc2020-12-02 00:33:42 +00001759 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001760 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001761 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001762 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001763 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001764 }
1765
1766 omciRxCallbackPair := callbackPair{
1767 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001768 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001769 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001770 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001771 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001772 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001773 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001774 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001775 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001776 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001777 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001778 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001779 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001780 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001781 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001782}
1783
Himani Chawla6d2ae152020-09-02 13:11:20 +05301784func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001785 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301786 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001787 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001788 "SequNo": strconv.FormatInt(int64(tid), 16),
1789 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1790
1791 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1792 if omciErr.GetError() == nil {
1793 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1794 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001795 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001796 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001797 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001798 }
1799
dbainbri4d3a0dc2020-12-02 00:33:42 +00001800 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001801 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001802 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001803 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001804 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001805 }
1806
Himani Chawla6d2ae152020-09-02 13:11:20 +05301807 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001808 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001809 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001810 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001811 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001812 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001813 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001814 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001815 return nil, err
mpagenkodff5dda2020-08-28 11:52:01 +00001816 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001817 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001818 return meInstance, nil
mpagenkodff5dda2020-08-28 11:52:01 +00001819 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001820 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001821 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001822 return nil, omciErr.GetError()
mpagenkodff5dda2020-08-28 11:52:01 +00001823}
mpagenko01e726e2020-10-23 09:45:29 +00001824
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001825func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001826 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001827 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001828 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001829 "SequNo": strconv.FormatInt(int64(tid), 16),
1830 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1831
1832 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1833 if omciErr.GetError() == nil {
1834 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1835 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001836 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001837 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001838 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001839 }
1840
dbainbri4d3a0dc2020-12-02 00:33:42 +00001841 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001842 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001843 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001844 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001845 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001846 }
1847
1848 omciRxCallbackPair := callbackPair{
1849 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001850 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001851 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001852 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001853 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001854 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001855 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001856 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001857 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001858 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001859 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001860 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001861 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001862 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001863 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001864}
1865
mpagenko01e726e2020-10-23 09:45:29 +00001866func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001867 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko01e726e2020-10-23 09:45:29 +00001868 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001869 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001870 "SequNo": strconv.FormatInt(int64(tid), 16),
1871 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1872
1873 meParams := me.ParamData{EntityID: aInstID}
1874 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1875 if omciErr.GetError() == nil {
1876 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1877 omci.TransactionID(tid))
1878 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001879 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001880 "Err": err, "device-id": oo.deviceID})
1881 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1882 // return (dual format) error code that can be used at caller for immediate error treatment
1883 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03001884 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001885 }
1886
dbainbri4d3a0dc2020-12-02 00:33:42 +00001887 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001888 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001889 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001890 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001891 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001892 }
1893
1894 omciRxCallbackPair := callbackPair{
1895 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001896 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001897 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001898 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko01e726e2020-10-23 09:45:29 +00001899 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001900 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001901 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001902 return nil, err
mpagenko01e726e2020-10-23 09:45:29 +00001903 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001904 logger.Debug(ctx, "send VTFD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001905 return meInstance, nil
mpagenko01e726e2020-10-23 09:45:29 +00001906 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001907 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001908 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001909 return nil, omciErr.GetError()
mpagenko01e726e2020-10-23 09:45:29 +00001910}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001911
ozgecanetsiab6441962021-03-10 10:58:48 +03001912// nolint: unused
1913func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001914 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001915 tid := oo.getNextTid(highPrio)
1916 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1917 "SequNo": strconv.FormatInt(int64(tid), 16),
1918 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1919 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1920 if omciErr.GetError() == nil {
1921 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1922 if err != nil {
1923 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001924 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001925 }
1926 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1927 if err != nil {
1928 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001929 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001930 }
1931 omciRxCallbackPair := callbackPair{
1932 cbKey: tid,
1933 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1934 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001935 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001936 if err != nil {
1937 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001938 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001939 }
1940 logger.Debug(ctx, "send TD-Create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001941 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001942 }
1943 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001944 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001945}
1946
1947// nolint: unused
1948func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001949 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001950 tid := oo.getNextTid(highPrio)
1951 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1952 "SequNo": strconv.FormatInt(int64(tid), 16),
1953 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1954
1955 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1956 if omciErr.GetError() == nil {
1957 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1958 if err != nil {
1959 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001960 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001961 }
1962 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1963 if err != nil {
1964 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001965 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001966 }
1967 omciRxCallbackPair := callbackPair{
1968 cbKey: tid,
1969 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1970 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00001971 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03001972 if err != nil {
1973 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001974 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001975 }
1976 logger.Debug(ctx, "send TD-Set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03001977 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03001978 }
1979 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001980 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03001981
1982}
1983
1984// nolint: unused
1985func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03001986 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
ozgecanetsiab6441962021-03-10 10:58:48 +03001987 tid := oo.getNextTid(highPrio)
1988 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1989 "SequNo": strconv.FormatInt(int64(tid), 16),
1990 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1991
1992 meParams := me.ParamData{EntityID: aInstID}
1993 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1994 if omciErr.GetError() == nil {
1995 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1996 if err != nil {
1997 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03001998 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03001999 }
2000 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2001 if err != nil {
2002 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002003 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002004 }
2005 omciRxCallbackPair := callbackPair{
2006 cbKey: tid,
2007 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2008 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002009 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab6441962021-03-10 10:58:48 +03002010 if err != nil {
2011 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002012 return nil, err
ozgecanetsiab6441962021-03-10 10:58:48 +03002013 }
2014 logger.Debug(ctx, "send TD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002015 return meInstance, nil
ozgecanetsiab6441962021-03-10 10:58:48 +03002016 }
2017 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002018 return nil, omciErr.GetError()
ozgecanetsiab6441962021-03-10 10:58:48 +03002019
2020}
2021
mpagenko8b07c1b2020-11-26 10:36:31 +00002022func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002023 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002024 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002025 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002026 "SequNo": strconv.FormatInt(int64(tid), 16),
2027 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2028
2029 meParams := me.ParamData{EntityID: aInstID}
2030 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2031 if omciErr.GetError() == nil {
2032 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2033 omci.TransactionID(tid))
2034 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002035 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002036 "Err": err, "device-id": oo.deviceID})
2037 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2038 // return (dual format) error code that can be used at caller for immediate error treatment
2039 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002040 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002041 }
2042
dbainbri4d3a0dc2020-12-02 00:33:42 +00002043 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002044 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002045 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002046 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002047 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002048 }
2049
2050 omciRxCallbackPair := callbackPair{
2051 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002052 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002053 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002054 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002055 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002056 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002057 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002058 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002059 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002060 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002061 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002062 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002063 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002064 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002065 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002066}
2067
2068func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002069 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002070 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002071 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002072 "SequNo": strconv.FormatInt(int64(tid), 16),
2073 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2074
2075 meParams := me.ParamData{EntityID: aInstID}
2076 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2077 if omciErr.GetError() == nil {
2078 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2079 omci.TransactionID(tid))
2080 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002081 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002082 "Err": err, "device-id": oo.deviceID})
2083 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2084 // return (dual format) error code that can be used at caller for immediate error treatment
2085 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002086 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002087 }
2088
dbainbri4d3a0dc2020-12-02 00:33:42 +00002089 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002090 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002091 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002092 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002093 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002094 }
2095
2096 omciRxCallbackPair := callbackPair{
2097 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002098 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002099 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002100 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002101 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002102 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002103 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002104 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002105 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002106 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002107 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002108 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002109 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002110 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002111 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002112}
2113
2114func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002115 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002116 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002117 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002118 "SequNo": strconv.FormatInt(int64(tid), 16),
2119 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2120
2121 meParams := me.ParamData{EntityID: aInstID}
2122 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2123 if omciErr.GetError() == nil {
2124 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2125 omci.TransactionID(tid))
2126 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002127 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002128 "Err": err, "device-id": oo.deviceID})
2129 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2130 // return (dual format) error code that can be used at caller for immediate error treatment
2131 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002132 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002133 }
2134
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002136 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002137 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002138 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002139 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002140 }
2141
2142 omciRxCallbackPair := callbackPair{
2143 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002144 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002145 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002146 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002147 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002148 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002149 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002150 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002151 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002152 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002153 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002154 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002155 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002156 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002157 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002158}
2159
2160func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002161 rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) {
mpagenko8b07c1b2020-11-26 10:36:31 +00002162 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002163 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002164 "SequNo": strconv.FormatInt(int64(tid), 16),
2165 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2166
2167 meParams := me.ParamData{EntityID: aInstID}
2168 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2169 if omciErr.GetError() == nil {
2170 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2171 omci.TransactionID(tid))
2172 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002173 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002174 "Err": err, "device-id": oo.deviceID})
2175 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2176 // return (dual format) error code that can be used at caller for immediate error treatment
2177 // (relevant to all used sendXX() methods and their error conditions)
ozgecanetsiab36ed572021-04-01 10:38:48 +03002178 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002179 }
2180
dbainbri4d3a0dc2020-12-02 00:33:42 +00002181 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002182 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002183 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002184 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002185 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002186 }
2187
2188 omciRxCallbackPair := callbackPair{
2189 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002190 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002191 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002192 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko8b07c1b2020-11-26 10:36:31 +00002193 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002194 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002195 "Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002196 return nil, err
mpagenko8b07c1b2020-11-26 10:36:31 +00002197 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002198 logger.Debug(ctx, "send MBPCD-Delete-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002199 return meInstance, nil
mpagenko8b07c1b2020-11-26 10:36:31 +00002200 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002201 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002202 "Err": omciErr.GetError(), "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002203 return nil, omciErr.GetError()
mpagenko8b07c1b2020-11-26 10:36:31 +00002204}
2205
ozgecanetsia422dbf32020-10-28 14:07:19 +03002206func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002207 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002208 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002209 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002210 "SequNo": strconv.FormatInt(int64(tid), 16),
2211 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2212
2213 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2214 if omciErr.GetError() == nil {
2215 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2216 omci.AddDefaults(true))
2217 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002218 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002219 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002220 }
2221
dbainbri4d3a0dc2020-12-02 00:33:42 +00002222 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002223 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002224 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002225 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002226 }
2227
2228 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002229 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002230 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002231 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002232 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002233 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002234 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002235 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002236 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002237 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002238 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002239 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002240 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002241 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002242}
2243
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002244func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002245 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002246 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002247 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002248 "SequNo": strconv.FormatInt(int64(tid), 16),
2249 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2250
2251 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2252 if omciErr.GetError() == nil {
2253 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2254 omci.AddDefaults(true))
2255 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002256 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002257 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002258 }
2259
dbainbri4d3a0dc2020-12-02 00:33:42 +00002260 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002261 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002262 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002263 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002264 }
2265
2266 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002267 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002268 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002269 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002270 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002271 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002272 return nil, err
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002273 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002274 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002275 return meInstance, nil
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002276 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002277 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002278 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002279 return nil, omciErr.GetError()
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002280}
2281
ozgecanetsia422dbf32020-10-28 14:07:19 +03002282func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002283 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002284 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002285 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002286 "SequNo": strconv.FormatInt(int64(tid), 16),
2287 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2288
2289 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2290 if omciErr.GetError() == nil {
2291 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2292 omci.AddDefaults(true))
2293 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002294 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002295 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002296 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002297 }
2298
dbainbri4d3a0dc2020-12-02 00:33:42 +00002299 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002300 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002301 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002302 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002303 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002304 }
2305
2306 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002307 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002308 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002309 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002310 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002311 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002312 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002313 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002314 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002315 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002316 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002317 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002318 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002319 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002320 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002321}
2322
2323func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002324 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002325 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002326 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002327 "SequNo": strconv.FormatInt(int64(tid), 16),
2328 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2329
2330 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2331 if omciErr.GetError() == nil {
2332 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2333 omci.AddDefaults(true))
2334 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002335 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002336 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002337 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002338 }
2339
dbainbri4d3a0dc2020-12-02 00:33:42 +00002340 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002341 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002342 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002343 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002344 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002345 }
2346
2347 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002348 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002349 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002350 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002351 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002352 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002353 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002354 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002355 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002356 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002357 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002358 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002359 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002360 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002361 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002362}
2363
2364func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002365 rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) {
ozgecanetsia422dbf32020-10-28 14:07:19 +03002366 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002367 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002368 "SequNo": strconv.FormatInt(int64(tid), 16),
2369 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2370
2371 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2372 if omciErr.GetError() == nil {
2373 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2374 omci.AddDefaults(true))
2375 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002376 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002377 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002378 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002379 }
2380
dbainbri4d3a0dc2020-12-02 00:33:42 +00002381 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002382 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002383 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002384 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002385 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002386 }
2387
2388 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002389 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002390 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002391 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002392 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002393 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002394 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002395 return nil, err
ozgecanetsia422dbf32020-10-28 14:07:19 +03002396 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002397 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsiab36ed572021-04-01 10:38:48 +03002398 return meInstance, nil
ozgecanetsia422dbf32020-10-28 14:07:19 +03002399 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002400 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002401 "device-id": oo.deviceID})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002402 return nil, omciErr.GetError()
ozgecanetsia422dbf32020-10-28 14:07:19 +03002403}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002404
Girish Gowdrae0140f02021-02-02 16:55:09 -08002405func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2406 tid := oo.getNextTid(highPrio)
2407 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2408 "SequNo": strconv.FormatInt(int64(tid), 16)})
2409
2410 omciLayer := &omci.OMCI{
2411 TransactionID: tid,
2412 MessageType: omci.SynchronizeTimeRequestType,
2413 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2414 // Length: 0x28, // Optional, defaults to 40 octets
2415 }
2416 utcTime := time.Now().UTC()
2417 request := &omci.SynchronizeTimeRequest{
2418 MeBasePacket: omci.MeBasePacket{
2419 EntityClass: me.OnuGClassID,
2420 // Default Instance ID is 0
2421 },
2422 Year: uint16(utcTime.Year()),
2423 Month: uint8(utcTime.Month()),
2424 Day: uint8(utcTime.Day()),
2425 Hour: uint8(utcTime.Hour()),
2426 Minute: uint8(utcTime.Minute()),
2427 Second: uint8(utcTime.Second()),
2428 }
2429
2430 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2431 if err != nil {
2432 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2433 "device-id": oo.deviceID})
2434 return err
2435 }
2436
2437 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002438 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002439 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002440 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002441 if err != nil {
2442 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2443 "device-id": oo.deviceID})
2444 return err
2445 }
2446 logger.Debug(ctx, "send synchronize time request done")
2447 return nil
2448}
2449
2450func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002451 upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002452 tid := oo.getNextTid(highPrio)
2453 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2454 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2455 meParam := me.ParamData{EntityID: entityID}
2456 var meInstance *me.ManagedEntity
2457 var omciErr me.OmciErrors
2458 if upstream {
2459 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2460 } else {
2461 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2462 }
2463 if omciErr.GetError() == nil {
2464 var omciLayer *omci.OMCI
2465 var msgLayer gopacket.SerializableLayer
2466 var err error
2467 if create {
2468 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2469 omci.AddDefaults(true))
2470 } else {
2471 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2472 omci.AddDefaults(true))
2473 }
2474 if err != nil {
2475 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2476 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002477 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002478 }
2479
2480 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2481 if err != nil {
2482 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2483 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002484 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002485 }
2486
2487 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002488 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002489 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002490 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002491 if err != nil {
2492 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2493 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002494 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002495 }
2496 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2497 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002498 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002499 }
2500 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2501 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 +03002502 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002503}
2504
2505func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002506 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdrae0140f02021-02-02 16:55:09 -08002507 tid := oo.getNextTid(highPrio)
2508 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2509 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2510 meParam := me.ParamData{EntityID: entityID}
2511 var meInstance *me.ManagedEntity
2512 var omciErr me.OmciErrors
2513 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2514
2515 if omciErr.GetError() == nil {
2516 var omciLayer *omci.OMCI
2517 var msgLayer gopacket.SerializableLayer
2518 var err error
2519 if create {
2520 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2521 omci.AddDefaults(true))
2522 } else {
2523 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2524 omci.AddDefaults(true))
2525 }
2526 if err != nil {
2527 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2528 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002529 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002530 }
2531
2532 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2533 if err != nil {
2534 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2535 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002536 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002537 }
2538
2539 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002540 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002541 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002542 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdrae0140f02021-02-02 16:55:09 -08002543 if err != nil {
2544 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2545 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002546 return nil, err
Girish Gowdrae0140f02021-02-02 16:55:09 -08002547 }
2548 logger.Debugw(ctx, "send ethernet uni history data ME done",
2549 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002550 return meInstance, nil
Girish Gowdrae0140f02021-02-02 16:55:09 -08002551 }
2552 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2553 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002554 return nil, omciErr.GetError()
Girish Gowdrae0140f02021-02-02 16:55:09 -08002555}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002556
2557func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002558 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002559 tid := oo.getNextTid(highPrio)
2560 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2561 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2562 meParam := me.ParamData{EntityID: entityID}
2563 var meInstance *me.ManagedEntity
2564 var omciErr me.OmciErrors
2565 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2566
2567 if omciErr.GetError() == nil {
2568 var omciLayer *omci.OMCI
2569 var msgLayer gopacket.SerializableLayer
2570 var err error
2571 if create {
2572 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2573 omci.AddDefaults(true))
2574 } else {
2575 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2576 omci.AddDefaults(true))
2577 }
2578 if err != nil {
2579 logger.Errorw(ctx, "Cannot encode fec history data ME",
2580 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002581 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002582 }
2583
2584 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2585 if err != nil {
2586 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2587 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002588 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002589 }
2590
2591 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002592 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002593 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002594 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002595 if err != nil {
2596 logger.Errorw(ctx, "Cannot send fec history data ME",
2597 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002598 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002599 }
2600 logger.Debugw(ctx, "send fec history data ME done",
2601 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002602 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002603 }
2604 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2605 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002606 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002607}
2608
2609func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
ozgecanetsiab36ed572021-04-01 10:38:48 +03002610 create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) {
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002611 tid := oo.getNextTid(highPrio)
2612 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2613 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2614 meParam := me.ParamData{EntityID: entityID}
2615 var meInstance *me.ManagedEntity
2616 var omciErr me.OmciErrors
2617 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2618
2619 if omciErr.GetError() == nil {
2620 var omciLayer *omci.OMCI
2621 var msgLayer gopacket.SerializableLayer
2622 var err error
2623 if create {
2624 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2625 omci.AddDefaults(true))
2626 } else {
2627 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2628 omci.AddDefaults(true))
2629 }
2630 if err != nil {
2631 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2632 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002633 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002634 }
2635
2636 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2637 if err != nil {
2638 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2639 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002640 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002641 }
2642
2643 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002644 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002645 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002646 err = oo.send(ctx, pkt, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002647 if err != nil {
2648 logger.Errorw(ctx, "Cannot send gemport history data ME",
2649 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002650 return nil, err
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002651 }
2652 logger.Debugw(ctx, "send gemport history data ME done",
2653 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002654 return meInstance, nil
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002655 }
2656 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2657 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
ozgecanetsiab36ed572021-04-01 10:38:48 +03002658 return nil, omciErr.GetError()
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002659}
2660
mpagenko80622a52021-02-09 16:53:23 +00002661func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2662 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2663 tid := oo.getNextTid(highPrio)
2664 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2665 "SequNo": strconv.FormatInt(int64(tid), 16),
2666 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2667
2668 omciLayer := &omci.OMCI{
2669 TransactionID: tid,
2670 MessageType: omci.StartSoftwareDownloadRequestType,
2671 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2672 // Length: 0x28, // Optional, defaults to 40 octets
2673 }
2674 request := &omci.StartSoftwareDownloadRequest{
2675 MeBasePacket: omci.MeBasePacket{
2676 EntityClass: me.SoftwareImageClassID,
2677 EntityInstance: aImageMeID, //inactive image
2678 },
2679 WindowSize: aDownloadWindowSize,
2680 ImageSize: aFileLen,
2681 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2682 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2683 }
2684
2685 var options gopacket.SerializeOptions
2686 options.FixLengths = true
2687 buffer := gopacket.NewSerializeBuffer()
2688 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2689 if err != nil {
2690 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2691 "device-id": oo.deviceID})
2692 return err
2693 }
2694 outgoingPacket := buffer.Bytes()
2695
2696 omciRxCallbackPair := callbackPair{cbKey: tid,
2697 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2698 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002699 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002700 if err != nil {
2701 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2702 "device-id": oo.deviceID})
2703 return err
2704 }
2705 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002706 return nil
2707}
2708
2709func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool,
2710 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2711 tid := oo.getNextTid(highPrio)
2712 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2713 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002714 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002715
2716 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2717 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002718 msgType := omci.DownloadSectionRequestType
2719 if aAckRequest > 0 {
2720 msgType = omci.DownloadSectionRequestWithResponseType
2721 }
mpagenko80622a52021-02-09 16:53:23 +00002722 omciLayer := &omci.OMCI{
2723 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002724 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002725 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2726 // Length: 0x28, // Optional, defaults to 40 octets
2727 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002728 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002729 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002730 request := &omci.DownloadSectionRequest{
2731 MeBasePacket: omci.MeBasePacket{
2732 EntityClass: me.SoftwareImageClassID,
2733 EntityInstance: aImageMeID, //inactive image
2734 },
2735 SectionNumber: aDownloadSectionNo,
2736 SectionData: localSectionData,
2737 }
2738
2739 var options gopacket.SerializeOptions
2740 options.FixLengths = true
2741 buffer := gopacket.NewSerializeBuffer()
2742 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2743 if err != nil {
2744 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2745 "device-id": oo.deviceID})
2746 return err
2747 }
2748 outgoingPacket := buffer.Bytes()
2749
mpagenko15ff4a52021-03-02 10:09:20 +00002750 //for initial debug purpose overrule the requested print state for some frames
2751 printFrame := aPrint
2752 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2753 printFrame = true
2754 }
2755
mpagenko80622a52021-02-09 16:53:23 +00002756 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002757 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002758 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002759 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002760 if err != nil {
2761 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2762 "device-id": oo.deviceID})
2763 return err
2764 }
2765 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002766 return nil
2767}
2768
2769func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2770 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2771 tid := oo.getNextTid(highPrio)
2772 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2773 "SequNo": strconv.FormatInt(int64(tid), 16),
2774 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2775
mpagenko15ff4a52021-03-02 10:09:20 +00002776 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002777 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002778 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002779 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2780 // Length: 0x28, // Optional, defaults to 40 octets
2781 }
mpagenko15ff4a52021-03-02 10:09:20 +00002782 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002783 MeBasePacket: omci.MeBasePacket{
2784 EntityClass: me.SoftwareImageClassID,
2785 EntityInstance: aImageMeID, //inactive image
2786 },
mpagenko15ff4a52021-03-02 10:09:20 +00002787 CRC32: aImageCrc,
2788 ImageSize: aFileLen,
2789 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2790 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002791 }
mpagenko15ff4a52021-03-02 10:09:20 +00002792
2793 var options gopacket.SerializeOptions
2794 options.FixLengths = true
2795 buffer := gopacket.NewSerializeBuffer()
2796 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2797 if err != nil {
2798 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002799 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002800 return err
mpagenko80622a52021-02-09 16:53:23 +00002801 }
mpagenko15ff4a52021-03-02 10:09:20 +00002802 outgoingPacket := buffer.Bytes()
2803
2804 omciRxCallbackPair := callbackPair{cbKey: tid,
2805 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2806 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002807 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002808 if err != nil {
2809 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2810 "device-id": oo.deviceID})
2811 return err
2812 }
2813 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002814 return nil
2815}
2816
2817func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2818 rxChan chan Message, aImageMeID uint16) error {
2819 tid := oo.getNextTid(highPrio)
2820 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2821 "SequNo": strconv.FormatInt(int64(tid), 16),
2822 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2823
2824 omciLayer := &omci.OMCI{
2825 TransactionID: tid,
2826 MessageType: omci.ActivateSoftwareRequestType,
2827 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2828 // Length: 0x28, // Optional, defaults to 40 octets
2829 }
2830 request := &omci.ActivateSoftwareRequest{
2831 MeBasePacket: omci.MeBasePacket{
2832 EntityClass: me.SoftwareImageClassID,
2833 EntityInstance: aImageMeID, //inactive image
2834 },
2835 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2836 }
2837
2838 var options gopacket.SerializeOptions
2839 options.FixLengths = true
2840 buffer := gopacket.NewSerializeBuffer()
2841 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2842 if err != nil {
2843 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2844 "device-id": oo.deviceID})
2845 return err
2846 }
2847 outgoingPacket := buffer.Bytes()
2848
2849 omciRxCallbackPair := callbackPair{cbKey: tid,
2850 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2851 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002852 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko80622a52021-02-09 16:53:23 +00002853 if err != nil {
2854 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2855 "device-id": oo.deviceID})
2856 return err
2857 }
2858 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002859 return nil
2860}
mpagenko80622a52021-02-09 16:53:23 +00002861
mpagenko15ff4a52021-03-02 10:09:20 +00002862func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2863 rxChan chan Message, aImageMeID uint16) error {
2864 tid := oo.getNextTid(highPrio)
2865 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2866 "SequNo": strconv.FormatInt(int64(tid), 16),
2867 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2868
2869 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002870 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002871 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002872 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2873 // Length: 0x28, // Optional, defaults to 40 octets
2874 }
mpagenko15ff4a52021-03-02 10:09:20 +00002875 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002876 MeBasePacket: omci.MeBasePacket{
2877 EntityClass: me.SoftwareImageClassID,
2878 EntityInstance: aImageMeID, //inactive image
2879 },
mpagenko80622a52021-02-09 16:53:23 +00002880 }
mpagenko15ff4a52021-03-02 10:09:20 +00002881
2882 var options gopacket.SerializeOptions
2883 options.FixLengths = true
2884 buffer := gopacket.NewSerializeBuffer()
2885 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2886 if err != nil {
2887 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002888 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002889 return err
mpagenko80622a52021-02-09 16:53:23 +00002890 }
mpagenko15ff4a52021-03-02 10:09:20 +00002891 outgoingPacket := buffer.Bytes()
2892
2893 omciRxCallbackPair := callbackPair{cbKey: tid,
2894 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2895 }
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002896 err = oo.send(ctx, outgoingPacket, timeout, cDefaultRetries, highPrio, omciRxCallbackPair)
mpagenko15ff4a52021-03-02 10:09:20 +00002897 if err != nil {
2898 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2899 "device-id": oo.deviceID})
2900 return err
2901 }
2902 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002903 return nil
2904}
2905
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002906func (oo *omciCC) sendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error {
2907 tid := oo.getNextTid(highPrio)
2908 logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID,
2909 "SequNo": strconv.FormatInt(int64(tid), 16),
2910 "InstId": strconv.FormatInt(int64(instdID), 16)})
2911 omciLayer := &omci.OMCI{
2912 TransactionID: tid,
2913 MessageType: omci.TestRequestType,
2914 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2915 // Length: 0x28, // Optional, defaults to 40 octets
2916 }
2917
2918 var request *omci.OpticalLineSupervisionTestRequest
2919 switch classID {
2920 case aniGClassID:
2921 request = &omci.OpticalLineSupervisionTestRequest{
2922 MeBasePacket: omci.MeBasePacket{
2923 EntityClass: classID,
2924 EntityInstance: instdID,
2925 },
2926 SelectTest: uint8(7), // self test
2927 GeneralPurposeBuffer: uint16(0),
2928 VendorSpecificParameters: uint16(0),
2929 }
2930 default:
2931 logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID})
2932 return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID)
2933 }
2934 // Test serialization back to former string
2935 var options gopacket.SerializeOptions
2936 options.FixLengths = true
2937
2938 buffer := gopacket.NewSerializeBuffer()
2939 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2940 if err != nil {
2941 logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err,
2942 "device-id": oo.deviceID})
2943 return err
2944 }
2945 outgoingPacket := buffer.Bytes()
2946
2947 omciRxCallbackPair := callbackPair{cbKey: tid,
2948 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2949 }
2950 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2951 if err != nil {
2952 logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err,
2953 "device-id": oo.deviceID})
2954 return err
2955 }
2956 logger.Debug(ctx, "send self test request done")
2957 return nil
2958}
2959
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002960func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002961 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002962 if v == omciMsg.MessageType {
Girish Gowdra6afb56a2021-04-27 17:47:57 -07002963 nextLayer, _ := omci.MsgTypeToNextLayer(v, false)
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002964 msgLayer := (*packet).Layer(nextLayer)
2965 switch nextLayer {
2966 case omci.LayerTypeCreateResponse:
2967 if msgLayer.(*omci.CreateResponse).Result == me.Success {
2968 return true
2969 }
2970 case omci.LayerTypeDeleteResponse:
2971 if msgLayer.(*omci.DeleteResponse).Result == me.Success {
2972 return true
2973 }
2974 case omci.LayerTypeSetResponse:
2975 if msgLayer.(*omci.SetResponse).Result == me.Success {
2976 return true
2977 }
2978 case omci.LayerTypeStartSoftwareDownloadResponse:
2979 if msgLayer.(*omci.StartSoftwareDownloadResponse).Result == me.Success {
2980 return true
2981 }
2982 case omci.LayerTypeEndSoftwareDownloadResponse:
2983 if msgLayer.(*omci.EndSoftwareDownloadResponse).Result == me.Success {
2984 return true
2985 }
2986 case omci.LayerTypeActivateSoftwareResponse:
2987 if msgLayer.(*omci.ActivateSoftwareResponse).Result == me.Success {
2988 return true
2989 }
2990 case omci.LayerTypeCommitSoftwareResponse:
2991 if msgLayer.(*omci.CommitSoftwareResponse).Result == me.Success {
2992 return true
2993 }
2994 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002995 }
2996 }
2997 return false
2998}
Holger Hildebrandt366ef192021-05-05 11:07:44 +00002999
3000func (oo *omciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest omciTransferStructure) {
3001
3002 chSuccess := make(chan bool)
3003 aOmciTxRequest.chSuccess = chSuccess
3004
3005 tid := aOmciTxRequest.cbPair.cbKey
3006 timeout := aOmciTxRequest.timeout
3007 retries := aOmciTxRequest.retries
3008
3009 oo.mutexMonReq.Lock()
3010 oo.monitoredRequests[tid] = aOmciTxRequest
3011 oo.mutexMonReq.Unlock()
3012
3013 retryCounter := 0
3014loop:
3015 for retryCounter <= retries {
3016
3017 oo.mutexTxQueue.Lock()
3018 oo.txQueue.PushBack(aOmciTxRequest) // enqueue
3019 oo.mutexTxQueue.Unlock()
3020
3021 go oo.sendNextRequest(ctx)
3022
3023 select {
3024 case success := <-chSuccess:
3025 if success {
3026 logger.Debugw(ctx, "reqMon: response received in time",
3027 log.Fields{"tid": tid, "device-id": oo.deviceID})
3028 } else {
3029 logger.Debugw(ctx, "reqMon: wait for response aborted",
3030 log.Fields{"tid": tid, "device-id": oo.deviceID})
3031 }
3032 break loop
3033 case <-time.After(time.Duration(timeout) * time.Second):
3034 if retryCounter == retries {
3035 logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached!",
3036 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3037 break loop
3038 } else {
3039 logger.Infow(ctx, "reqMon: timeout waiting for response - retry",
3040 log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID})
3041 }
3042 }
3043 retryCounter++
3044 }
3045 oo.mutexMonReq.Lock()
3046 delete(oo.monitoredRequests, tid)
3047 oo.mutexMonReq.Unlock()
3048}
3049
3050//CancelRequestMonitoring terminates monitoring of outstanding omci requests
3051func (oo *omciCC) CancelRequestMonitoring() {
3052 oo.mutexMonReq.RLock()
3053 for k := range oo.monitoredRequests {
3054 oo.monitoredRequests[k].chSuccess <- false
3055 }
3056 oo.mutexMonReq.RUnlock()
3057}
3058
3059//GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum
3060//time consumed for retry processing of a particular OMCI-request
3061func (oo *omciCC) GetMaxOmciTimeoutWithRetries() time.Duration {
3062 return time.Duration((cDefaultRetries+1)*oo.pOnuDeviceEntry.pOpenOnuAc.omciTimeout + 1)
3063}