blob: dbdaa93d41d275e1e0c495f19a7f875074b92e2d [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"
Girish Gowdrae0140f02021-02-02 16:55:09 -080028 "time"
mpagenkodff5dda2020-08-28 11:52:01 +000029
Holger Hildebrandtfa074992020-03-27 15:42:06 +000030 //"time"
31
32 "github.com/google/gopacket"
33 // TODO!!! Some references could be resolved auto, but some need specific context ....
34 gp "github.com/google/gopacket"
35
36 "github.com/opencord/omci-lib-go"
37 me "github.com/opencord/omci-lib-go/generated"
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000039
dbainbri4d3a0dc2020-12-02 00:33:42 +000040 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
41 "github.com/opencord/voltha-lib-go/v4/pkg/log"
42 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
43 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
44 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000045)
46
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053048
49//ConstDefaultOmciTimeout - Default OMCI Timeout
Holger Hildebrandtfa074992020-03-27 15:42:06 +000050const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds
51
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000052const galEthernetEID = uint16(1)
53const maxGemPayloadSize = uint16(48)
54const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053055
56//const defaultTPID = uint16(0x8100)
57//const broadComDefaultVID = uint16(4091)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000058const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
59const ieeeMapperServiceProfileEID = uint16(0x8001)
60const macBridgePortAniEID = uint16(0x2102)
61
mpagenko8b07c1b2020-11-26 10:36:31 +000062const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
63
mpagenkoc8bba412021-01-15 15:38:44 +000064const cOmciBaseMessageTrailerLen = 40
65
66// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
67type tOmciReceiveError uint8
68
69const (
70 // cOmciMessageReceiveNoError - default start state
71 cOmciMessageReceiveNoError tOmciReceiveError = iota
72 // Error indication wrong trailer length within the message
73 cOmciMessageReceiveErrorTrailerLen
74 // Error indication missing trailer within the message
75 cOmciMessageReceiveErrorMissTrailer
76)
77
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000078// ### OMCI related definitions - end
79
Himani Chawla6d2ae152020-09-02 13:11:20 +053080//callbackPairEntry to be used for OMCI send/receive correlation
81type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000082 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000083 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000084}
85
Himani Chawla6d2ae152020-09-02 13:11:20 +053086//callbackPair to be used for ReceiveCallback init
87type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000088 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053089 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000090}
91
92type omciTransferStructure struct {
93 txFrame []byte
94 timeout int
95 retry int
96 highPrio bool
97}
98
Himani Chawla6d2ae152020-09-02 13:11:20 +053099//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
100type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000101 enabled bool
102 pOnuDeviceEntry *OnuDeviceEntry
103 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +0530104 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000105 coreProxy adapterif.CoreProxy
106 adapterProxy adapterif.AdapterProxy
107 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000108 rxOmciFrameError tOmciReceiveError
109
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000110 txFrames, txOnuFrames uint32
111 rxFrames, rxOnuFrames, rxOnuDiscards uint32
112
113 // OMCI params
114 mutexTid sync.Mutex
115 tid uint16
116 mutexHpTid sync.Mutex
117 hpTid uint16
118 uploadSequNo uint16
119 uploadNoOfCmds uint16
120
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000121 mutexTxQueue sync.Mutex
122 txQueue *list.List
123 mutexRxSchedMap sync.Mutex
Himani Chawla6d2ae152020-09-02 13:11:20 +0530124 rxSchedulerMap map[uint16]callbackPairEntry
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000125 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000126}
127
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000128var responsesWithMibDataSync = []omci.MessageType{
129 omci.CreateResponseType,
130 omci.DeleteResponseType,
131 omci.SetResponseType,
132 omci.StartSoftwareDownloadResponseType,
133 omci.EndSoftwareDownloadResponseType,
134 omci.ActivateSoftwareResponseType,
135 omci.CommitSoftwareResponseType,
136}
137
Himani Chawla6d2ae152020-09-02 13:11:20 +0530138//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000139//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530140func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
141 deviceID string, deviceHandler *deviceHandler,
142 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000143 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530144 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000145 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530146 omciCC.pOnuDeviceEntry = onuDeviceEntry
147 omciCC.deviceID = deviceID
148 omciCC.pBaseDeviceHandler = deviceHandler
149 omciCC.coreProxy = coreProxy
150 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000151 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000152 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000153 omciCC.txFrames = 0
154 omciCC.txOnuFrames = 0
155 omciCC.rxFrames = 0
156 omciCC.rxOnuFrames = 0
157 omciCC.rxOnuDiscards = 0
158 omciCC.tid = 0x1
159 omciCC.hpTid = 0x8000
160 omciCC.uploadSequNo = 0
161 omciCC.uploadNoOfCmds = 0
162
163 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530164 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000165
166 return &omciCC
167}
168
mpagenko900ee4b2020-10-12 11:56:34 +0000169//stop stops/resets the omciCC
170func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000171 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000172 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
173 oo.mutexTxQueue.Lock()
174 oo.txQueue.Init() // clear the tx queue
175 oo.mutexTxQueue.Unlock()
176 oo.mutexRxSchedMap.Lock()
177 for k := range oo.rxSchedulerMap {
178 delete(oo.rxSchedulerMap, k) //clear the scheduler map
179 }
180 oo.mutexRxSchedMap.Unlock()
181 oo.mutexHpTid.Lock()
182 oo.hpTid = 0x8000 //reset the high prio transactionId
183 oo.mutexHpTid.Unlock()
184 oo.mutexTid.Lock()
185 oo.tid = 1 //reset the low prio transactionId
186 oo.mutexTid.Unlock()
187 //reset control values
188 oo.uploadSequNo = 0
189 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000190 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000191 //reset the stats counter - which might be topic of discussion ...
192 oo.txFrames = 0
193 oo.txOnuFrames = 0
194 oo.rxFrames = 0
195 oo.rxOnuFrames = 0
196 oo.rxOnuDiscards = 0
197
198 return nil
199}
200
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000201// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530202func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000203 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000204 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530205 switch omciMsg.MessageType {
206 case omci.AlarmNotificationType:
207 data := OmciMessage{
208 OmciMsg: omciMsg,
209 OmciPacket: packet,
210 }
211 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
212 return nil
213 default:
214 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
215 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000216 /*
217 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
218 rxOnuFrames++
219
220 switch msgType {
221 case AlarmNotification:
222 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000223 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000224 // python code was:
225 //if msg_type == EntityOperations.AlarmNotification.value:
226 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
227 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
228 //
229 return errors.New("RxAlarmNotification unimplemented")
230 }
231 case AttributeValueChange:
232 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000233 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000234 // python code was:
235 //elif msg_type == EntityOperations.AttributeValueChange.value:
236 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
237 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
238 //
239 return errors.New("RxAttributeValueChange unimplemented")
240 }
241 case TestResult:
242 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000243 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000244 // python code was:
245 //elif msg_type == EntityOperations.TestResult.value:
246 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
247 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
248 //
249 return errors.New("RxTestResult unimplemented")
250 }
251 default:
252 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000253 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000254 rxOnuDiscards++
255 return errors.New("RxOnuMsgType unimplemented")
256 }
257 }
258 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000259}
260
261// Rx handler for onu messages
262// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530263func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000264 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000265 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
266 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000267 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000268 trailerLenData := rxMsg[42:44]
269 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000270 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000271 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
272 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
273 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
274 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
275 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
276 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
277 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
278 }
279 }
280 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
281 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
282 // (an extendedFormat message could be destroyed this way!)
283 // extend/overwrite with trailer
284 trailer := make([]byte, 8)
285 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
286 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
287 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
288 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
289 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
290 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
291 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000292 }
293 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000294 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
295 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200296 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000297 }
298
299 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
300 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000301 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200302 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000303 }
304 omciLayer := packet.Layer(omci.LayerTypeOMCI)
305 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000306 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200307 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000308 }
309 omciMsg, ok := omciLayer.(*omci.OMCI)
310 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000311 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200312 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000313 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000314 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000315 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000316 if byte(omciMsg.MessageType)&me.AK == 0 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000317 // Not a response
dbainbri4d3a0dc2020-12-02 00:33:42 +0000318 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000319 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530320 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000321 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000322 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200323 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000324 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200325 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530326
327 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000328 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530329 oo.mutexRxSchedMap.Lock()
330 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
331 if ok && rxCallbackEntry.cbFunction != nil {
332 //disadvantage of decoupling: error verification made difficult, but anyway the question is
333 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000334 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000335 if isResponseWithMibDataSync(omciMsg.MessageType) {
336 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
337 }
mpagenkoc8bba412021-01-15 15:38:44 +0000338
Himani Chawla4d908332020-08-31 12:30:20 +0530339 // having posted the response the request is regarded as 'done'
340 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
341 oo.mutexRxSchedMap.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000342 } else {
Himani Chawla4d908332020-08-31 12:30:20 +0530343 oo.mutexRxSchedMap.Unlock()
Matteo Scandolo20ca10c2021-01-21 14:35:45 -0800344 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID, "omciMsg": omciMsg, "transCorrId": omciMsg.TransactionID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200345 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000346 }
347
348 return nil
349 /* py code was:
350 Receive and OMCI message from the proxy channel to the OLT.
351
352 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
353 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
354 """
355 if not self.enabled:
356 return
357
358 try:
359 now = arrow.utcnow()
360 d = None
361
362 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
363 # save the current value of the entity_id_to_class_map, then
364 # replace it with our custom one before decode, and then finally
365 # restore it later. Tried other ways but really made the code messy.
366 saved_me_map = omci_entities.entity_id_to_class_map
367 omci_entities.entity_id_to_class_map = self._me_map
368
369 try:
370 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000371 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000372 except KeyError as e:
373 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000374 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000375 rx_frame = self._decode_unknown_me(msg)
376 self._rx_unknown_me += 1
377
378 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000379 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000380 return
381
382 finally:
383 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
384
385 rx_tid = rx_frame.fields['transaction_id']
386 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000387 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000388 # Filter the Test Result frame and route through receive onu
389 # message method.
390 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000391 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000392 return self._receive_onu_message(rx_frame)
393
394 # Previously unreachable if this is the very first round-trip Rx or we
395 # have been running consecutive errors
396 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000397 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000398 self.reactor.callLater(0, self._publish_connectivity_event, True)
399
400 self._rx_frames += 1
401 self._consecutive_errors = 0
402
403 try:
404 high_priority = self._tid_is_high_priority(rx_tid)
405 index = self._get_priority_index(high_priority)
406
407 # (timestamp, defer, frame, timeout, retry, delayedCall)
408 last_tx_tuple = self._tx_request[index]
409
410 if last_tx_tuple is None or \
411 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
412 # Possible late Rx on a message that timed-out
413 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000414 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000415 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
416 self._rx_unknown_tid += 1
417 self._rx_late += 1
418 return
419
420 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
421 if dc is not None and not dc.cancelled and not dc.called:
422 dc.cancel()
423
424 _secs = self._update_rx_tx_stats(now, ts)
425
426 # Late arrival already serviced by a timeout?
427 if d.called:
428 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000429 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000430 return
431
432 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000433 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000434 if d is not None:
435 return d.errback(failure.Failure(e))
436 return
437
438 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000439 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000440 tx_tid = tx_frame.fields['transaction_id'])
441 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
442
443 # begin success callback chain (will cancel timeout and queue next Tx message)
444 self._rx_response[index] = rx_frame
445 d.callback(rx_frame)
446
447 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000448 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000449 */
450}
451
Himani Chawla6d2ae152020-09-02 13:11:20 +0530452/*
453func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530454 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530455 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000456}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530457*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000458
459//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530460func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
461 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000462
dbainbri4d3a0dc2020-12-02 00:33:42 +0000463 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000464 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
465 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000466 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000467 oo.mutexRxSchedMap.Unlock()
468
469 //just use a simple list for starting - might need some more effort, especially for multi source write access
470 omciTxRequest := omciTransferStructure{
471 txFrame,
472 timeout,
473 retry,
474 highPrio,
475 }
476 oo.mutexTxQueue.Lock()
477 oo.txQueue.PushBack(omciTxRequest) // enqueue
478 oo.mutexTxQueue.Unlock()
479
480 // for first test just bypass and send directly:
481 go oo.sendNextRequest(ctx)
482 return nil
483}
484
485//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530486func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000487 // return errors.New("sendNextRequest unimplemented")
488
489 // just try to get something transferred !!
490 // avoid accessing the txQueue from parallel send requests
491 // block parallel omci send requests at least until SendIAP is 'committed'
492 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
493 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000494 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000495 for oo.txQueue.Len() > 0 {
496 queueElement := oo.txQueue.Front() // First element
497 omciTxRequest := queueElement.Value.(omciTransferStructure)
498 /* compare olt device handler code:
499 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000500 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000501 var deviceType string
502 var deviceID string
503 var proxyDeviceID string
504
505 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
506
507 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
508
dbainbri4d3a0dc2020-12-02 00:33:42 +0000509 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 +0000510 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
511 kwargs := make(map[string]interface{})
512 kwargs["onu_id"] = omciInd.OnuId
513 kwargs["parent_port_no"] = ponPort
514
dbainbri4d3a0dc2020-12-02 00:33:42 +0000515 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000517 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000518 return
519 }
520 deviceType = onuDevice.Type
521 deviceID = onuDevice.Id
522 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
523 //if not exist in cache, then add to cache.
524 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
525 } else {
526 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000527 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 +0000528 deviceType = onuInCache.(*OnuDevice).deviceType
529 deviceID = onuInCache.(*OnuDevice).deviceID
530 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
531 }
532 */
533 /* and compare onu_adapter py code:
534 omci_msg = InterAdapterOmciMessage(
535 message=bytes(frame),
536 proxy_address=self._proxy_address,
537 connect_status=self._device.connect_status)
538
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000539 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000540
541 yield self._adapter_proxy.send_inter_adapter_message(
542 msg=omci_msg,
543 type=InterAdapterMessageType.OMCI_REQUEST,
544 from_adapter=self._device.type,
545 to_adapter=self._proxy_address.device_type,
546 to_device_id=self._device_id,
547 proxy_device_id=self._proxy_address.device_id
548 )
549 */
550 device, err := oo.coreProxy.GetDevice(ctx,
551 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
552 if err != nil || device == nil {
553 /*TODO: needs to handle error scenarios */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000554 logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000555 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200556 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000557 }
558
dbainbri4d3a0dc2020-12-02 00:33:42 +0000559 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +0000560 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
561 "device-id": oo.deviceID,
562 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
563 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000564
565 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000566 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000567 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800568 //fromTopic,toType,toDevId, ProxyDevId
569 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000570 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000571 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000572 return sendErr
573 }
574 oo.txQueue.Remove(queueElement) // Dequeue
575 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000576 return nil
577}
578
Himani Chawla6d2ae152020-09-02 13:11:20 +0530579func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000580 var next uint16
581 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000582 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000583 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530584 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000585 if oo.hpTid < 0x8000 {
586 oo.hpTid = 0x8000
587 }
mpagenko900ee4b2020-10-12 11:56:34 +0000588 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000589 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000590 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000591 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530592 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000593 if oo.tid >= 0x8000 {
594 oo.tid = 1
595 }
mpagenko900ee4b2020-10-12 11:56:34 +0000596 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000597 }
598 return next
599}
600
601// ###################################################################################
602// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000603func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 omciLayer := &omci.OMCI{
605 TransactionID: tid,
606 MessageType: msgType,
607 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000608 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000609}
610
dbainbri4d3a0dc2020-12-02 00:33:42 +0000611func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000612 var options gopacket.SerializeOptions
613 options.FixLengths = true
614
615 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530616 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000617 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000618 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 return nil, err
620 }
621 return buffer.Bytes(), nil
622}
623
Himani Chawla4d908332020-08-31 12:30:20 +0530624/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000625func hexEncode(omciPkt []byte) ([]byte, error) {
626 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
627 hex.Encode(dst, omciPkt)
628 return dst, nil
629}
Himani Chawla4d908332020-08-31 12:30:20 +0530630*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000631
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000632//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000633func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000634
dbainbri4d3a0dc2020-12-02 00:33:42 +0000635 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000636 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000637
638 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000639 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000640 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200641 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000642 }
643
644 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
645 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000646 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000647 Type: OMCI,
648 Data: OmciMessage{
649 OmciMsg: omciMsg,
650 OmciPacket: packet,
651 },
652 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000653 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000654 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000655
656 return nil
657}
658
Himani Chawla6d2ae152020-09-02 13:11:20 +0530659func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000660
dbainbri4d3a0dc2020-12-02 00:33:42 +0000661 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662 request := &omci.MibResetRequest{
663 MeBasePacket: omci.MeBasePacket{
664 EntityClass: me.OnuDataClassID,
665 },
666 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530667 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000668 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000669 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000670 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000671 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000672 return err
673 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530674 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000675 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530676 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000677 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530678 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000679}
680
Himani Chawla6d2ae152020-09-02 13:11:20 +0530681func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000682 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300683 request := &omci.RebootRequest{
684 MeBasePacket: omci.MeBasePacket{
685 EntityClass: me.OnuGClassID,
686 },
687 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530688 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000689 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300690 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000691 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000692 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300693 return err
694 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530695 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300696 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530697 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300698 }
699
Himani Chawla6d2ae152020-09-02 13:11:20 +0530700 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300701 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000702 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000703 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300704 return err
705 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300707 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000708 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200709 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300710 return err
711 }
712 return nil
713}
714
Himani Chawla6d2ae152020-09-02 13:11:20 +0530715func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000716 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000717 request := &omci.MibUploadRequest{
718 MeBasePacket: omci.MeBasePacket{
719 EntityClass: me.OnuDataClassID,
720 },
721 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530722 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000723 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000724 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000725 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000726 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000727 return err
728 }
729 oo.uploadSequNo = 0
730 oo.uploadNoOfCmds = 0
731
Himani Chawla6d2ae152020-09-02 13:11:20 +0530732 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000733 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530734 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000735 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530736 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000737}
738
Himani Chawla6d2ae152020-09-02 13:11:20 +0530739func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000740 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000741 request := &omci.MibUploadNextRequest{
742 MeBasePacket: omci.MeBasePacket{
743 EntityClass: me.OnuDataClassID,
744 },
745 CommandSequenceNumber: oo.uploadSequNo,
746 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530747 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000748 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000749 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000750 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000751 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000752 return err
753 }
754 oo.uploadSequNo++
755
Himani Chawla6d2ae152020-09-02 13:11:20 +0530756 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000757 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530758 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000759 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530760 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000761}
762
Himani Chawla6d2ae152020-09-02 13:11:20 +0530763func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
764 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000765 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000766 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000767
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000768 meParams := me.ParamData{
769 EntityID: galEthernetEID,
770 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
771 }
772 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
773 if omciErr.GetError() == nil {
774 //all setByCreate parameters already set, no default option required ...
775 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
776 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000777 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000778 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000779 return nil
780 }
781
dbainbri4d3a0dc2020-12-02 00:33:42 +0000782 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000783 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000784 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000785 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000786 return nil
787 }
788
Himani Chawla6d2ae152020-09-02 13:11:20 +0530789 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000790 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530791 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000792 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530793 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000794 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000795 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000796 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000797 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000798 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000799 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000800 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000801 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000802 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000803 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000804 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000805}
806
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000807// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530808func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
809 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000810 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000811 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000812
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000813 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
814 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000815 // By now we just use fix values to fire - this is anyway what the python adapter does
816 // read ONU-2G from DB ???? //TODO!!!
817 meParams := me.ParamData{
818 EntityID: 0,
819 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
820 }
821 meInstance, omciErr := me.NewOnu2G(meParams)
822 if omciErr.GetError() == nil {
823 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
824 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000825 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000826 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000827 return nil
828 }
829
dbainbri4d3a0dc2020-12-02 00:33:42 +0000830 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000831 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000832 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000833 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000834 return nil
835 }
836
Himani Chawla6d2ae152020-09-02 13:11:20 +0530837 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000838 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530839 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000840 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530841 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000842 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000843 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000844 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000845 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000846 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000847 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000848 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000849 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000850 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000851 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000852 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000853}
854
Himani Chawla6d2ae152020-09-02 13:11:20 +0530855func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
856 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
857 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530858 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000859 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000860 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000861
862 meParams := me.ParamData{
863 EntityID: instID,
864 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300865 "Priority": 0x8000,
866 "MaxAge": 20 * 256, //20s
867 "HelloTime": 2 * 256, //2s
868 "ForwardDelay": 15 * 256, //15s
869 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000870 },
871 }
872
873 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
874 if omciErr.GetError() == nil {
875 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
876 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
877 omci.TransactionID(tid), omci.AddDefaults(true))
878 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000879 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000880 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000881 return nil
882 }
883
dbainbri4d3a0dc2020-12-02 00:33:42 +0000884 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000885 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000886 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000887 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000888 return nil
889 }
890
Himani Chawla6d2ae152020-09-02 13:11:20 +0530891 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000892 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530893 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000894 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530895 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000896 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000897 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000898 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000899 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000900 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000901 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000902 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000903 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000904 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000905 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000906 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907}
908
Himani Chawla6d2ae152020-09-02 13:11:20 +0530909func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
910 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
911 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530912 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000913 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000914 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000915
916 meParams := me.ParamData{
917 EntityID: instID,
918 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530919 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
920 "PortNum": aPUniPort.macBpNo,
921 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530922 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000923 },
924 }
925 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
926 if omciErr.GetError() == nil {
927 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
928 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
929 omci.TransactionID(tid), omci.AddDefaults(true))
930 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000931 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000932 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000933 return nil
934 }
935
dbainbri4d3a0dc2020-12-02 00:33:42 +0000936 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000937 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000938 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000939 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000940 return nil
941 }
942
Himani Chawla6d2ae152020-09-02 13:11:20 +0530943 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000944 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +0530945 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000946 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530947 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000948 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000949 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000950 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000951 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000952 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000953 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000954 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000955 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000956 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000957 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000958 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000959}
960
Himani Chawla6d2ae152020-09-02 13:11:20 +0530961func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
962 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
963 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000964 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +0530965 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000966 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000967 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000968
969 // compare python adapter code WA VOL-1311: this is not done here!
970 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
971 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
972 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +0530973 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000974 assType = uint8(10) // for VEIP
975 }
976 meParams := me.ParamData{
977 EntityID: instID,
978 Attributes: me.AttributeValueMap{
979 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +0530980 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000981 },
982 }
983 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
984 if omciErr.GetError() == nil {
985 //all setByCreate parameters already set, no default option required ...
986 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
987 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000988 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000989 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000990 return nil
991 }
992
dbainbri4d3a0dc2020-12-02 00:33:42 +0000993 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000994 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000995 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000996 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000997 return nil
998 }
999
Himani Chawla6d2ae152020-09-02 13:11:20 +05301000 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001001 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301002 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001003 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301004 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001005 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001006 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001007 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001008 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001009 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001010 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001011 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001012 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001013 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001014 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001015 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001016}
1017
Himani Chawla6d2ae152020-09-02 13:11:20 +05301018func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001019 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301020 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001021 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001022 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001023
1024 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1025 meParams := me.ParamData{
1026 EntityID: 0,
1027 Attributes: requestedAttributes,
1028 }
1029 meInstance, omciErr := me.NewOnuG(meParams)
1030 if omciErr.GetError() == nil {
1031 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1032 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001033 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001034 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001035 return nil
1036 }
1037
dbainbri4d3a0dc2020-12-02 00:33:42 +00001038 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001039 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001040 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001041 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001042 return nil
1043 }
1044
Himani Chawla6d2ae152020-09-02 13:11:20 +05301045 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001046 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301047 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001048 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301049 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001050 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001051 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001052 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001053 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001054 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001055 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001056 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001057 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001058 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001059 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001060 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001061}
1062
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001063func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1064 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1065 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001066 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001067 "SequNo": strconv.FormatInt(int64(tid), 16)})
1068
1069 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1070 meParams := me.ParamData{
1071 EntityID: aInstNo,
1072 Attributes: requestedAttributes,
1073 }
1074 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1075 if omciErr.GetError() == nil {
1076 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1077 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001078 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001079 "Err": err, "device-id": oo.deviceID})
1080 return nil
1081 }
1082
dbainbri4d3a0dc2020-12-02 00:33:42 +00001083 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001084 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001085 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001086 "Err": err, "device-id": oo.deviceID})
1087 return nil
1088 }
1089
1090 omciRxCallbackPair := callbackPair{
1091 cbKey: tid,
1092 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1093 }
1094 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1095 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001096 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001097 "Err": err, "device-id": oo.deviceID})
1098 return nil
1099 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001100 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001101 return meInstance
1102 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001103 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001104 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1105 return nil
1106}
1107
1108/* UniG obsolete by now, left here in case it should be needed once again
1109 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301110func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001111 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301112 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001113 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001114 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001115
1116 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1117 meParams := me.ParamData{
1118 EntityID: aInstNo,
1119 Attributes: requestedAttributes,
1120 }
1121 meInstance, omciErr := me.NewUniG(meParams)
1122 if omciErr.GetError() == nil {
1123 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1124 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001125 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001126 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001127 return nil
1128 }
1129
1130 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1131 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001132 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001133 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001134 return nil
1135 }
1136
Himani Chawla6d2ae152020-09-02 13:11:20 +05301137 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001138 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301139 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001140 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301141 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001142 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001143 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001144 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001145 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001146 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001147 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001148 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001149 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001150 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001151 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001152 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001153}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001154*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001155
Himani Chawla6d2ae152020-09-02 13:11:20 +05301156func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001157 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301158 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001159 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001160 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001161
1162 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1163 meParams := me.ParamData{
1164 EntityID: aInstNo,
1165 Attributes: requestedAttributes,
1166 }
1167 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1168 if omciErr.GetError() == nil {
1169 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1170 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001171 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001172 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001173 return nil
1174 }
1175
dbainbri4d3a0dc2020-12-02 00:33:42 +00001176 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001177 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001178 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001179 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001180 return nil
1181 }
1182
Himani Chawla6d2ae152020-09-02 13:11:20 +05301183 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001184 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301185 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001186 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301187 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001188 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001189 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001190 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001191 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001192 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001193 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001194 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001195 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001196 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001197 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001198 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001199}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001200
Himani Chawla6d2ae152020-09-02 13:11:20 +05301201func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001202 timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001203
Himani Chawla6d2ae152020-09-02 13:11:20 +05301204 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001205 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001206 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001207
1208 meParams := me.ParamData{
1209 EntityID: entityID,
1210 Attributes: requestedAttributes,
1211 }
1212 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1213 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301214 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001215 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1216 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001217 logger.Errorf(ctx, "Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001218 return nil
1219 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001221 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001222 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001223 return nil
1224 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301225 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001226 cbKey: tid,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001227 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001228 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301229 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001230 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001231 logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001232 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001233 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001234 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001235 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001236 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001237 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001238 return nil
1239}
1240
Himani Chawla6d2ae152020-09-02 13:11:20 +05301241func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001242 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301243 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001245 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1246
1247 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001248 EntityID: aInstID,
1249 Attributes: me.AttributeValueMap{
1250 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1251 "TpPointer": 0xFFFF,
1252 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1253 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1254 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1255 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1256 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1257 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1258 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1259 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1260 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001261 }
1262 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1263 if omciErr.GetError() == nil {
1264 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1265 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1266 omci.TransactionID(tid), omci.AddDefaults(true))
1267 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001268 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001269 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001270 return nil
1271 }
1272
dbainbri4d3a0dc2020-12-02 00:33:42 +00001273 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001274 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001276 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001277 return nil
1278 }
1279
Himani Chawla6d2ae152020-09-02 13:11:20 +05301280 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001281 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301282 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001283 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301284 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001285 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001286 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001287 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001288 return nil
1289 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001291 return meInstance
1292 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001293 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001294 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001295 return nil
1296}
1297
Himani Chawla6d2ae152020-09-02 13:11:20 +05301298func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001299 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301300 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001301 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001302 "SequNo": strconv.FormatInt(int64(tid), 16),
1303 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1304
1305 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1306 if omciErr.GetError() == nil {
1307 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1308 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1309 omci.TransactionID(tid), omci.AddDefaults(true))
1310 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001311 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001312 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001313 return nil
1314 }
1315
dbainbri4d3a0dc2020-12-02 00:33:42 +00001316 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001317 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001318 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001319 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001320 return nil
1321 }
1322
Himani Chawla6d2ae152020-09-02 13:11:20 +05301323 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001324 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301325 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001326 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301327 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001328 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001329 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001330 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001331 return nil
1332 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001333 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001334 return meInstance
1335 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001336 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001337 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001338 return nil
1339}
1340
Himani Chawla6d2ae152020-09-02 13:11:20 +05301341func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001342 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301343 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001344 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001345 "SequNo": strconv.FormatInt(int64(tid), 16),
1346 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1347
1348 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1349 if omciErr.GetError() == nil {
1350 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1351 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1352 omci.TransactionID(tid), omci.AddDefaults(true))
1353 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001354 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001355 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001356 return nil
1357 }
1358
dbainbri4d3a0dc2020-12-02 00:33:42 +00001359 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001360 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001361 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001362 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001363 return nil
1364 }
1365
Himani Chawla6d2ae152020-09-02 13:11:20 +05301366 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001367 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301368 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001369 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301370 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001371 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001372 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001373 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001374 return nil
1375 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001376 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001377 return meInstance
1378 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001379 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001380 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001381 return nil
1382}
1383
Himani Chawla6d2ae152020-09-02 13:11:20 +05301384func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001385 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301386 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001387 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001388 "SequNo": strconv.FormatInt(int64(tid), 16),
1389 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1390
1391 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1392 if omciErr.GetError() == nil {
1393 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1394 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1395 omci.TransactionID(tid))
1396 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001397 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001398 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001399 return nil
1400 }
1401
dbainbri4d3a0dc2020-12-02 00:33:42 +00001402 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001403 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001404 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001405 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001406 return nil
1407 }
1408
Himani Chawla6d2ae152020-09-02 13:11:20 +05301409 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001410 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301411 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001412 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301413 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001414 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001416 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001417 return nil
1418 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001419 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001420 return meInstance
1421 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001422 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001423 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001424 return nil
1425}
1426
Himani Chawla6d2ae152020-09-02 13:11:20 +05301427func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001428 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301429 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001430 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001431 "SequNo": strconv.FormatInt(int64(tid), 16),
1432 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1433
1434 meInstance, omciErr := me.NewTCont(params[0])
1435 if omciErr.GetError() == nil {
1436 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1437 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001438 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001439 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001440 return nil
1441 }
1442
dbainbri4d3a0dc2020-12-02 00:33:42 +00001443 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001444 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001445 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001446 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001447 return nil
1448 }
1449
Himani Chawla6d2ae152020-09-02 13:11:20 +05301450 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001451 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301452 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001453 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301454 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001455 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001456 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001457 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001458 return nil
1459 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001461 return meInstance
1462 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001463 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001464 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001465 return nil
1466}
1467
Himani Chawla6d2ae152020-09-02 13:11:20 +05301468func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001469 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301470 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001471 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001472 "SequNo": strconv.FormatInt(int64(tid), 16),
1473 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1474
1475 meInstance, omciErr := me.NewPriorityQueue(params[0])
1476 if omciErr.GetError() == nil {
1477 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1478 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001479 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001480 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001481 return nil
1482 }
1483
dbainbri4d3a0dc2020-12-02 00:33:42 +00001484 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001485 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001486 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001487 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001488 return nil
1489 }
1490
Himani Chawla6d2ae152020-09-02 13:11:20 +05301491 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001492 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301493 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001494 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301495 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001496 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001497 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001498 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001499 return nil
1500 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001501 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001502 return meInstance
1503 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001504 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001505 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001506 return nil
1507}
1508
Himani Chawla6d2ae152020-09-02 13:11:20 +05301509func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001510 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301511 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001512 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001513 "SequNo": strconv.FormatInt(int64(tid), 16),
1514 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1515
1516 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1517 if omciErr.GetError() == nil {
1518 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1519 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001520 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001521 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001522 return nil
1523 }
1524
dbainbri4d3a0dc2020-12-02 00:33:42 +00001525 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001526 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001527 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001528 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001529 return nil
1530 }
1531
Himani Chawla6d2ae152020-09-02 13:11:20 +05301532 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001533 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301534 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenko3dbcdd22020-07-22 07:38:45 +00001535 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301536 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001537 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001538 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001539 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001540 return nil
1541 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001542 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001543 return meInstance
1544 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001545 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001546 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001547 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001548}
mpagenkodff5dda2020-08-28 11:52:01 +00001549
Himani Chawla6d2ae152020-09-02 13:11:20 +05301550func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001551 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301552 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001553 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001554 "SequNo": strconv.FormatInt(int64(tid), 16),
1555 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1556
1557 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1558 if omciErr.GetError() == nil {
1559 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1560 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1561 omci.TransactionID(tid))
1562 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001563 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001564 "Err": err, "device-id": oo.deviceID})
1565 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1566 // return (dual format) error code that can be used at caller for immediate error treatment
1567 // (relevant to all used sendXX() methods and their error conditions)
1568 return nil
1569 }
1570
dbainbri4d3a0dc2020-12-02 00:33:42 +00001571 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001572 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001573 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001574 "Err": err, "device-id": oo.deviceID})
1575 return nil
1576 }
1577
Himani Chawla6d2ae152020-09-02 13:11:20 +05301578 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001579 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301580 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001581 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301582 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001583 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001584 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001585 "Err": err, "device-id": oo.deviceID})
1586 return nil
1587 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001588 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001589 return meInstance
1590 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001591 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001592 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1593 return nil
1594}
1595
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001596// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001597func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1598 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1599 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001600 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001601 "SequNo": strconv.FormatInt(int64(tid), 16),
1602 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1603
1604 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1605 if omciErr.GetError() == nil {
1606 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1607 omci.TransactionID(tid))
1608 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001609 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001610 "Err": err, "device-id": oo.deviceID})
1611 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1612 // return (dual format) error code that can be used at caller for immediate error treatment
1613 // (relevant to all used sendXX() methods and their error conditions)
1614 return nil
1615 }
1616
dbainbri4d3a0dc2020-12-02 00:33:42 +00001617 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001618 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001619 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001620 "Err": err, "device-id": oo.deviceID})
1621 return nil
1622 }
1623
1624 omciRxCallbackPair := callbackPair{
1625 cbKey: tid,
1626 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1627 }
1628 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1629 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001630 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001631 "Err": err, "device-id": oo.deviceID})
1632 return nil
1633 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001634 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001635 return meInstance
1636 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001637 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001638 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1639 return nil
1640}
1641
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001642func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1643 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1644 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001645 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001646 "SequNo": strconv.FormatInt(int64(tid), 16),
1647 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1648
1649 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1650 if omciErr.GetError() == nil {
1651 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1652 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001653 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001654 "Err": err, "device-id": oo.deviceID})
1655 return nil
1656 }
1657
dbainbri4d3a0dc2020-12-02 00:33:42 +00001658 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001659 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001660 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001661 "Err": err, "device-id": oo.deviceID})
1662 return nil
1663 }
1664
1665 omciRxCallbackPair := callbackPair{
1666 cbKey: tid,
1667 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1668 }
1669 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1670 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001671 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001672 "Err": err, "device-id": oo.deviceID})
1673 return nil
1674 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001675 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001676 return meInstance
1677 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001678 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001679 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1680 return nil
1681}
1682
Himani Chawla6d2ae152020-09-02 13:11:20 +05301683func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001684 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301685 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001686 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001687 "SequNo": strconv.FormatInt(int64(tid), 16),
1688 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1689
1690 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1691 if omciErr.GetError() == nil {
1692 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1693 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001694 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001695 "Err": err, "device-id": oo.deviceID})
1696 return nil
1697 }
1698
dbainbri4d3a0dc2020-12-02 00:33:42 +00001699 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001700 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001701 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001702 "Err": err, "device-id": oo.deviceID})
1703 return nil
1704 }
1705
Himani Chawla6d2ae152020-09-02 13:11:20 +05301706 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001707 cbKey: tid,
Himani Chawla6d2ae152020-09-02 13:11:20 +05301708 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
mpagenkodff5dda2020-08-28 11:52:01 +00001709 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301710 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001711 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001712 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001713 "Err": err, "device-id": oo.deviceID})
1714 return nil
1715 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001716 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001717 return meInstance
1718 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001719 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001720 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1721 return nil
1722}
mpagenko01e726e2020-10-23 09:45:29 +00001723
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001724func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1725 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1726 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001727 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001728 "SequNo": strconv.FormatInt(int64(tid), 16),
1729 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1730
1731 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1732 if omciErr.GetError() == nil {
1733 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1734 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001735 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001736 "Err": err, "device-id": oo.deviceID})
1737 return nil
1738 }
1739
dbainbri4d3a0dc2020-12-02 00:33:42 +00001740 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001741 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001742 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001743 "Err": err, "device-id": oo.deviceID})
1744 return nil
1745 }
1746
1747 omciRxCallbackPair := callbackPair{
1748 cbKey: tid,
1749 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1750 }
1751 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1752 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001753 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001754 "Err": err, "device-id": oo.deviceID})
1755 return nil
1756 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001757 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001758 return meInstance
1759 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001760 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001761 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1762 return nil
1763}
1764
mpagenko01e726e2020-10-23 09:45:29 +00001765func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1766 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1767 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001768 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001769 "SequNo": strconv.FormatInt(int64(tid), 16),
1770 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1771
1772 meParams := me.ParamData{EntityID: aInstID}
1773 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1774 if omciErr.GetError() == nil {
1775 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1776 omci.TransactionID(tid))
1777 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001778 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001779 "Err": err, "device-id": oo.deviceID})
1780 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1781 // return (dual format) error code that can be used at caller for immediate error treatment
1782 // (relevant to all used sendXX() methods and their error conditions)
1783 return nil
1784 }
1785
dbainbri4d3a0dc2020-12-02 00:33:42 +00001786 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001787 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001788 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001789 "Err": err, "device-id": oo.deviceID})
1790 return nil
1791 }
1792
1793 omciRxCallbackPair := callbackPair{
1794 cbKey: tid,
1795 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1796 }
1797 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1798 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001799 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001800 "Err": err, "device-id": oo.deviceID})
1801 return nil
1802 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001803 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001804 return meInstance
1805 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001806 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001807 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1808 return nil
1809}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001810
mpagenko8b07c1b2020-11-26 10:36:31 +00001811func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1812 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1813 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001815 "SequNo": strconv.FormatInt(int64(tid), 16),
1816 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1817
1818 meParams := me.ParamData{EntityID: aInstID}
1819 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
1820 if omciErr.GetError() == nil {
1821 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1822 omci.TransactionID(tid))
1823 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001824 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001825 "Err": err, "device-id": oo.deviceID})
1826 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1827 // return (dual format) error code that can be used at caller for immediate error treatment
1828 // (relevant to all used sendXX() methods and their error conditions)
1829 return nil
1830 }
1831
dbainbri4d3a0dc2020-12-02 00:33:42 +00001832 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001833 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001834 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001835 "Err": err, "device-id": oo.deviceID})
1836 return nil
1837 }
1838
1839 omciRxCallbackPair := callbackPair{
1840 cbKey: tid,
1841 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1842 }
1843 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1844 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001845 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001846 "Err": err, "device-id": oo.deviceID})
1847 return nil
1848 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001849 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001850 return meInstance
1851 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001852 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001853 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1854 return nil
1855}
1856
1857func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
1858 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1859 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001860 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001861 "SequNo": strconv.FormatInt(int64(tid), 16),
1862 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1863
1864 meParams := me.ParamData{EntityID: aInstID}
1865 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
1866 if omciErr.GetError() == nil {
1867 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1868 omci.TransactionID(tid))
1869 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001870 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001871 "Err": err, "device-id": oo.deviceID})
1872 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1873 // return (dual format) error code that can be used at caller for immediate error treatment
1874 // (relevant to all used sendXX() methods and their error conditions)
1875 return nil
1876 }
1877
dbainbri4d3a0dc2020-12-02 00:33:42 +00001878 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001879 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001880 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001881 "Err": err, "device-id": oo.deviceID})
1882 return nil
1883 }
1884
1885 omciRxCallbackPair := callbackPair{
1886 cbKey: tid,
1887 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1888 }
1889 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1890 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001891 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001892 "Err": err, "device-id": oo.deviceID})
1893 return nil
1894 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001895 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001896 return meInstance
1897 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001898 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001899 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1900 return nil
1901}
1902
1903func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
1904 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1905 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001906 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001907 "SequNo": strconv.FormatInt(int64(tid), 16),
1908 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1909
1910 meParams := me.ParamData{EntityID: aInstID}
1911 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1912 if omciErr.GetError() == nil {
1913 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1914 omci.TransactionID(tid))
1915 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001916 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001917 "Err": err, "device-id": oo.deviceID})
1918 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1919 // return (dual format) error code that can be used at caller for immediate error treatment
1920 // (relevant to all used sendXX() methods and their error conditions)
1921 return nil
1922 }
1923
dbainbri4d3a0dc2020-12-02 00:33:42 +00001924 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001925 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001926 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001927 "Err": err, "device-id": oo.deviceID})
1928 return nil
1929 }
1930
1931 omciRxCallbackPair := callbackPair{
1932 cbKey: tid,
1933 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1934 }
1935 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1936 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001937 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001938 "Err": err, "device-id": oo.deviceID})
1939 return nil
1940 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001941 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001942 return meInstance
1943 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001944 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001945 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1946 return nil
1947}
1948
1949func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
1950 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1951 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001952 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001953 "SequNo": strconv.FormatInt(int64(tid), 16),
1954 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1955
1956 meParams := me.ParamData{EntityID: aInstID}
1957 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1958 if omciErr.GetError() == nil {
1959 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1960 omci.TransactionID(tid))
1961 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001962 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001963 "Err": err, "device-id": oo.deviceID})
1964 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1965 // return (dual format) error code that can be used at caller for immediate error treatment
1966 // (relevant to all used sendXX() methods and their error conditions)
1967 return nil
1968 }
1969
dbainbri4d3a0dc2020-12-02 00:33:42 +00001970 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001971 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001972 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001973 "Err": err, "device-id": oo.deviceID})
1974 return nil
1975 }
1976
1977 omciRxCallbackPair := callbackPair{
1978 cbKey: tid,
1979 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
1980 }
1981 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1982 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001983 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001984 "Err": err, "device-id": oo.deviceID})
1985 return nil
1986 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001987 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001988 return meInstance
1989 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001990 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001991 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1992 return nil
1993}
1994
mpagenkofc4f56e2020-11-04 17:17:49 +00001995// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03001996func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
1997 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1998 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001999 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002000 "SequNo": strconv.FormatInt(int64(tid), 16),
2001 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2002
2003 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2004 if omciErr.GetError() == nil {
2005 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2006 omci.AddDefaults(true))
2007 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002008 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002009 return nil
2010 }
2011
dbainbri4d3a0dc2020-12-02 00:33:42 +00002012 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002013 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002014 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002015 return nil
2016 }
2017
2018 omciRxCallbackPair := callbackPair{cbKey: tid,
2019 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2020 }
2021 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2022 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002023 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002024 return nil
2025 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002026 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002027 return meInstance
2028 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002030 "device-id": oo.deviceID})
2031 return nil
2032}
2033
mpagenkofc4f56e2020-11-04 17:17:49 +00002034// nolint: unused
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002035func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2036 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2037 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002038 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002039 "SequNo": strconv.FormatInt(int64(tid), 16),
2040 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2041
2042 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2043 if omciErr.GetError() == nil {
2044 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2045 omci.AddDefaults(true))
2046 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002047 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002048 return nil
2049 }
2050
dbainbri4d3a0dc2020-12-02 00:33:42 +00002051 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002052 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002053 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002054 return nil
2055 }
2056
2057 omciRxCallbackPair := callbackPair{cbKey: tid,
2058 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2059 }
2060 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2061 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002062 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002063 return nil
2064 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002065 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002066 return meInstance
2067 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002068 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002069 "device-id": oo.deviceID})
2070 return nil
2071}
2072
2073// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002074func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2075 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2076 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002077 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002078 "SequNo": strconv.FormatInt(int64(tid), 16),
2079 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2080
2081 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2082 if omciErr.GetError() == nil {
2083 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2084 omci.AddDefaults(true))
2085 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002086 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002087 "device-id": oo.deviceID})
2088 return nil
2089 }
2090
dbainbri4d3a0dc2020-12-02 00:33:42 +00002091 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002092 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002093 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002094 "device-id": oo.deviceID})
2095 return nil
2096 }
2097
2098 omciRxCallbackPair := callbackPair{cbKey: tid,
2099 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2100 }
2101 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2102 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002103 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002104 "device-id": oo.deviceID})
2105 return nil
2106 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002107 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002108 return meInstance
2109 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002110 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002111 "device-id": oo.deviceID})
2112 return nil
2113}
2114
mpagenkofc4f56e2020-11-04 17:17:49 +00002115// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002116func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2117 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2118 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002119 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002120 "SequNo": strconv.FormatInt(int64(tid), 16),
2121 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2122
2123 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2124 if omciErr.GetError() == nil {
2125 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2126 omci.AddDefaults(true))
2127 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002128 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002129 "device-id": oo.deviceID})
2130 return nil
2131 }
2132
dbainbri4d3a0dc2020-12-02 00:33:42 +00002133 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002134 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002136 "device-id": oo.deviceID})
2137 return nil
2138 }
2139
2140 omciRxCallbackPair := callbackPair{cbKey: tid,
2141 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2142 }
2143 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2144 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002145 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002146 "device-id": oo.deviceID})
2147 return nil
2148 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002149 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002150 return meInstance
2151 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002152 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002153 "device-id": oo.deviceID})
2154 return nil
2155}
2156
mpagenkofc4f56e2020-11-04 17:17:49 +00002157// nolint: unused
ozgecanetsia422dbf32020-10-28 14:07:19 +03002158func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2159 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2160 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002161 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002162 "SequNo": strconv.FormatInt(int64(tid), 16),
2163 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2164
2165 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2166 if omciErr.GetError() == nil {
2167 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2168 omci.AddDefaults(true))
2169 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002170 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002171 "device-id": oo.deviceID})
2172 return nil
2173 }
2174
dbainbri4d3a0dc2020-12-02 00:33:42 +00002175 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002176 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002177 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002178 "device-id": oo.deviceID})
2179 return nil
2180 }
2181
2182 omciRxCallbackPair := callbackPair{cbKey: tid,
2183 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2184 }
2185 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002187 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002188 "device-id": oo.deviceID})
2189 return nil
2190 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002191 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002192 return meInstance
2193 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002194 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002195 "device-id": oo.deviceID})
2196 return nil
2197}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002198
Girish Gowdrae0140f02021-02-02 16:55:09 -08002199func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2200 tid := oo.getNextTid(highPrio)
2201 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2202 "SequNo": strconv.FormatInt(int64(tid), 16)})
2203
2204 omciLayer := &omci.OMCI{
2205 TransactionID: tid,
2206 MessageType: omci.SynchronizeTimeRequestType,
2207 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2208 // Length: 0x28, // Optional, defaults to 40 octets
2209 }
2210 utcTime := time.Now().UTC()
2211 request := &omci.SynchronizeTimeRequest{
2212 MeBasePacket: omci.MeBasePacket{
2213 EntityClass: me.OnuGClassID,
2214 // Default Instance ID is 0
2215 },
2216 Year: uint16(utcTime.Year()),
2217 Month: uint8(utcTime.Month()),
2218 Day: uint8(utcTime.Day()),
2219 Hour: uint8(utcTime.Hour()),
2220 Minute: uint8(utcTime.Minute()),
2221 Second: uint8(utcTime.Second()),
2222 }
2223
2224 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2225 if err != nil {
2226 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2227 "device-id": oo.deviceID})
2228 return err
2229 }
2230
2231 omciRxCallbackPair := callbackPair{cbKey: tid,
2232 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2233 }
2234 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2235 if err != nil {
2236 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2237 "device-id": oo.deviceID})
2238 return err
2239 }
2240 logger.Debug(ctx, "send synchronize time request done")
2241 return nil
2242}
2243
2244func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
2245 upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2246 tid := oo.getNextTid(highPrio)
2247 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2248 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2249 meParam := me.ParamData{EntityID: entityID}
2250 var meInstance *me.ManagedEntity
2251 var omciErr me.OmciErrors
2252 if upstream {
2253 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2254 } else {
2255 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2256 }
2257 if omciErr.GetError() == nil {
2258 var omciLayer *omci.OMCI
2259 var msgLayer gopacket.SerializableLayer
2260 var err error
2261 if create {
2262 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2263 omci.AddDefaults(true))
2264 } else {
2265 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2266 omci.AddDefaults(true))
2267 }
2268 if err != nil {
2269 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2270 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2271 return nil
2272 }
2273
2274 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2275 if err != nil {
2276 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2277 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2278 return nil
2279 }
2280
2281 omciRxCallbackPair := callbackPair{cbKey: tid,
2282 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2283 }
2284 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2285 if err != nil {
2286 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2287 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2288 return nil
2289 }
2290 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2291 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2292 return meInstance
2293 }
2294 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2295 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2296 return nil
2297}
2298
2299func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
2300 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2301 tid := oo.getNextTid(highPrio)
2302 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2303 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2304 meParam := me.ParamData{EntityID: entityID}
2305 var meInstance *me.ManagedEntity
2306 var omciErr me.OmciErrors
2307 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2308
2309 if omciErr.GetError() == nil {
2310 var omciLayer *omci.OMCI
2311 var msgLayer gopacket.SerializableLayer
2312 var err error
2313 if create {
2314 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2315 omci.AddDefaults(true))
2316 } else {
2317 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2318 omci.AddDefaults(true))
2319 }
2320 if err != nil {
2321 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2322 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2323 return nil
2324 }
2325
2326 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2327 if err != nil {
2328 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2329 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2330 return nil
2331 }
2332
2333 omciRxCallbackPair := callbackPair{cbKey: tid,
2334 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse},
2335 }
2336 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2337 if err != nil {
2338 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2339 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2340 return nil
2341 }
2342 logger.Debugw(ctx, "send ethernet uni history data ME done",
2343 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2344 return meInstance
2345 }
2346 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2347 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2348 return nil
2349}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002350func isResponseWithMibDataSync(msgType omci.MessageType) bool {
2351 for _, v := range responsesWithMibDataSync {
2352 if v == msgType {
2353 return true
2354 }
2355 }
2356 return false
2357}