blob: 47767965532310b0eae29c8195e765d249d4a07f [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
Andrea Campanella6515c582020-10-05 11:25:00 +020025 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000027 "sync"
mpagenko80622a52021-02-09 16:53:23 +000028 "time" //by now for testing
Holger Hildebrandtfa074992020-03-27 15:42:06 +000029
30 "github.com/google/gopacket"
31 // TODO!!! Some references could be resolved auto, but some need specific context ....
32 gp "github.com/google/gopacket"
33
34 "github.com/opencord/omci-lib-go"
35 me "github.com/opencord/omci-lib-go/generated"
dbainbri4d3a0dc2020-12-02 00:33:42 +000036 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
39 "github.com/opencord/voltha-lib-go/v4/pkg/log"
40 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
41 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
42 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000043)
44
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000045// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053046
47//ConstDefaultOmciTimeout - Default OMCI Timeout
Holger Hildebrandtfa074992020-03-27 15:42:06 +000048const ConstDefaultOmciTimeout = 10 // ( 3 ?) Seconds
49
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000050const galEthernetEID = uint16(1)
51const maxGemPayloadSize = uint16(48)
52const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053053
54//const defaultTPID = uint16(0x8100)
55//const broadComDefaultVID = uint16(4091)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000056const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
57const ieeeMapperServiceProfileEID = uint16(0x8001)
58const macBridgePortAniEID = uint16(0x2102)
59
mpagenko8b07c1b2020-11-26 10:36:31 +000060const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
61
mpagenkoc8bba412021-01-15 15:38:44 +000062const cOmciBaseMessageTrailerLen = 40
63
64// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
65type tOmciReceiveError uint8
66
67const (
68 // cOmciMessageReceiveNoError - default start state
69 cOmciMessageReceiveNoError tOmciReceiveError = iota
70 // Error indication wrong trailer length within the message
71 cOmciMessageReceiveErrorTrailerLen
72 // Error indication missing trailer within the message
73 cOmciMessageReceiveErrorMissTrailer
74)
75
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000076// ### OMCI related definitions - end
77
Himani Chawla6d2ae152020-09-02 13:11:20 +053078//callbackPairEntry to be used for OMCI send/receive correlation
79type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000080 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000081 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
mpagenko80622a52021-02-09 16:53:23 +000082 framePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000083}
84
Himani Chawla6d2ae152020-09-02 13:11:20 +053085//callbackPair to be used for ReceiveCallback init
86type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000087 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053088 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000089}
90
91type omciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000092 txFrame []byte
93 timeout int
94 retry int
95 highPrio bool
96 withFramePrint bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000097}
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
mpagenko80622a52021-02-09 16:53:23 +0000261func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
262 //assuming omci message content is hex coded!
263 // with restricted output of 16bytes would be ...rxMsg[:16]
264 logger.Debugw(ctx, "omci-message-received:", log.Fields{
265 "RxOmciMessage": hex.EncodeToString(rxMsg),
266 "device-id": oo.deviceID})
267}
268
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000269// Rx handler for onu messages
270// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530271func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000272 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000273 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
274 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000275 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000276 trailerLenData := rxMsg[42:44]
277 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000278 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000279 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
280 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
281 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
282 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
283 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
284 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
285 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
286 }
287 }
288 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
289 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
290 // (an extendedFormat message could be destroyed this way!)
291 // extend/overwrite with trailer
292 trailer := make([]byte, 8)
293 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
294 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
295 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
296 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
297 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
298 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
299 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000300 }
301 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000302 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
303 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000304 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200305 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000306 }
307
308 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
309 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000310 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000311 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200312 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000313 }
314 omciLayer := packet.Layer(omci.LayerTypeOMCI)
315 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000316 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000317 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200318 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000319 }
320 omciMsg, ok := omciLayer.(*omci.OMCI)
321 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000322 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000323 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200324 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000325 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000326 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000327 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000328 if byte(omciMsg.MessageType)&me.AK == 0 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000329 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000330 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000331 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000332 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530333 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000334 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000335 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200336 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000337 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200338 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530339
340 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000341 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530342 oo.mutexRxSchedMap.Lock()
343 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
344 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000345 if rxCallbackEntry.framePrint {
346 oo.printRxMessage(ctx, rxMsg)
347 }
Himani Chawla4d908332020-08-31 12:30:20 +0530348 //disadvantage of decoupling: error verification made difficult, but anyway the question is
349 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000350 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000351 if isResponseWithMibDataSync(omciMsg.MessageType) {
352 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
353 }
mpagenkoc8bba412021-01-15 15:38:44 +0000354
Himani Chawla4d908332020-08-31 12:30:20 +0530355 // having posted the response the request is regarded as 'done'
356 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
357 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000358 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000359 }
mpagenko80622a52021-02-09 16:53:23 +0000360 oo.mutexRxSchedMap.Unlock()
361 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
362 oo.printRxMessage(ctx, rxMsg)
363 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000364
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000365 /* py code was:
366 Receive and OMCI message from the proxy channel to the OLT.
367
368 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
369 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
370 """
371 if not self.enabled:
372 return
373
374 try:
375 now = arrow.utcnow()
376 d = None
377
378 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
379 # save the current value of the entity_id_to_class_map, then
380 # replace it with our custom one before decode, and then finally
381 # restore it later. Tried other ways but really made the code messy.
382 saved_me_map = omci_entities.entity_id_to_class_map
383 omci_entities.entity_id_to_class_map = self._me_map
384
385 try:
386 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000387 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000388 except KeyError as e:
389 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000390 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000391 rx_frame = self._decode_unknown_me(msg)
392 self._rx_unknown_me += 1
393
394 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000395 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000396 return
397
398 finally:
399 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
400
401 rx_tid = rx_frame.fields['transaction_id']
402 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000403 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000404 # Filter the Test Result frame and route through receive onu
405 # message method.
406 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000407 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000408 return self._receive_onu_message(rx_frame)
409
410 # Previously unreachable if this is the very first round-trip Rx or we
411 # have been running consecutive errors
412 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000413 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000414 self.reactor.callLater(0, self._publish_connectivity_event, True)
415
416 self._rx_frames += 1
417 self._consecutive_errors = 0
418
419 try:
420 high_priority = self._tid_is_high_priority(rx_tid)
421 index = self._get_priority_index(high_priority)
422
423 # (timestamp, defer, frame, timeout, retry, delayedCall)
424 last_tx_tuple = self._tx_request[index]
425
426 if last_tx_tuple is None or \
427 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
428 # Possible late Rx on a message that timed-out
429 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000430 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000431 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
432 self._rx_unknown_tid += 1
433 self._rx_late += 1
434 return
435
436 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
437 if dc is not None and not dc.cancelled and not dc.called:
438 dc.cancel()
439
440 _secs = self._update_rx_tx_stats(now, ts)
441
442 # Late arrival already serviced by a timeout?
443 if d.called:
444 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000445 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000446 return
447
448 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000449 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000450 if d is not None:
451 return d.errback(failure.Failure(e))
452 return
453
454 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000455 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000456 tx_tid = tx_frame.fields['transaction_id'])
457 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
458
459 # begin success callback chain (will cancel timeout and queue next Tx message)
460 self._rx_response[index] = rx_frame
461 d.callback(rx_frame)
462
463 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000464 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000465 */
466}
467
Himani Chawla6d2ae152020-09-02 13:11:20 +0530468/*
469func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530470 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530471 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000472}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530473*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000474
475//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530476func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
477 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000478
dbainbri4d3a0dc2020-12-02 00:33:42 +0000479 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000480 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
481 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000482 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
mpagenko80622a52021-02-09 16:53:23 +0000483 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000484 oo.mutexRxSchedMap.Unlock()
485
486 //just use a simple list for starting - might need some more effort, especially for multi source write access
487 omciTxRequest := omciTransferStructure{
488 txFrame,
489 timeout,
490 retry,
491 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000492 printFrame,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000493 }
494 oo.mutexTxQueue.Lock()
495 oo.txQueue.PushBack(omciTxRequest) // enqueue
496 oo.mutexTxQueue.Unlock()
497
498 // for first test just bypass and send directly:
499 go oo.sendNextRequest(ctx)
500 return nil
501}
502
503//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530504func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000505 // return errors.New("sendNextRequest unimplemented")
506
507 // just try to get something transferred !!
508 // avoid accessing the txQueue from parallel send requests
509 // block parallel omci send requests at least until SendIAP is 'committed'
510 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
511 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000512 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000513 for oo.txQueue.Len() > 0 {
514 queueElement := oo.txQueue.Front() // First element
515 omciTxRequest := queueElement.Value.(omciTransferStructure)
516 /* compare olt device handler code:
517 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000518 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000519 var deviceType string
520 var deviceID string
521 var proxyDeviceID string
522
523 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
524
525 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
526
dbainbri4d3a0dc2020-12-02 00:33:42 +0000527 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 +0000528 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
529 kwargs := make(map[string]interface{})
530 kwargs["onu_id"] = omciInd.OnuId
531 kwargs["parent_port_no"] = ponPort
532
dbainbri4d3a0dc2020-12-02 00:33:42 +0000533 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000534 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000535 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000536 return
537 }
538 deviceType = onuDevice.Type
539 deviceID = onuDevice.Id
540 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
541 //if not exist in cache, then add to cache.
542 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
543 } else {
544 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000545 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 +0000546 deviceType = onuInCache.(*OnuDevice).deviceType
547 deviceID = onuInCache.(*OnuDevice).deviceID
548 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
549 }
550 */
551 /* and compare onu_adapter py code:
552 omci_msg = InterAdapterOmciMessage(
553 message=bytes(frame),
554 proxy_address=self._proxy_address,
555 connect_status=self._device.connect_status)
556
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000557 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000558
559 yield self._adapter_proxy.send_inter_adapter_message(
560 msg=omci_msg,
561 type=InterAdapterMessageType.OMCI_REQUEST,
562 from_adapter=self._device.type,
563 to_adapter=self._proxy_address.device_type,
564 to_device_id=self._device_id,
565 proxy_device_id=self._proxy_address.device_id
566 )
567 */
568 device, err := oo.coreProxy.GetDevice(ctx,
569 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
570 if err != nil || device == nil {
571 /*TODO: needs to handle error scenarios */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000572 logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000573 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200574 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000575 }
576
mpagenko80622a52021-02-09 16:53:23 +0000577 if omciTxRequest.withFramePrint {
578 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
579 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
580 "device-id": oo.deviceID,
581 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
582 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
583 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000584 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000585 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000586 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800587 //fromTopic,toType,toDevId, ProxyDevId
588 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000589 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000590 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000591 return sendErr
592 }
593 oo.txQueue.Remove(queueElement) // Dequeue
594 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000595 return nil
596}
597
Himani Chawla6d2ae152020-09-02 13:11:20 +0530598func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000599 var next uint16
600 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000601 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000602 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530603 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 if oo.hpTid < 0x8000 {
605 oo.hpTid = 0x8000
606 }
mpagenko900ee4b2020-10-12 11:56:34 +0000607 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000608 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000609 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000610 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530611 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000612 if oo.tid >= 0x8000 {
613 oo.tid = 1
614 }
mpagenko900ee4b2020-10-12 11:56:34 +0000615 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000616 }
617 return next
618}
619
620// ###################################################################################
621// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000622func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000623 omciLayer := &omci.OMCI{
624 TransactionID: tid,
625 MessageType: msgType,
626 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000627 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000628}
629
dbainbri4d3a0dc2020-12-02 00:33:42 +0000630func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000631 var options gopacket.SerializeOptions
632 options.FixLengths = true
633
634 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530635 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000636 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000637 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000638 return nil, err
639 }
640 return buffer.Bytes(), nil
641}
642
Himani Chawla4d908332020-08-31 12:30:20 +0530643/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000644func hexEncode(omciPkt []byte) ([]byte, error) {
645 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
646 hex.Encode(dst, omciPkt)
647 return dst, nil
648}
Himani Chawla4d908332020-08-31 12:30:20 +0530649*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000650
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000651//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000652func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000653
dbainbri4d3a0dc2020-12-02 00:33:42 +0000654 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000655 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000656
657 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000658 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000659 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200660 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000661 }
662
663 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
664 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000665 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000666 Type: OMCI,
667 Data: OmciMessage{
668 OmciMsg: omciMsg,
669 OmciPacket: packet,
670 },
671 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000672 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000673 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000674
675 return nil
676}
677
Himani Chawla6d2ae152020-09-02 13:11:20 +0530678func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000679
dbainbri4d3a0dc2020-12-02 00:33:42 +0000680 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000681 request := &omci.MibResetRequest{
682 MeBasePacket: omci.MeBasePacket{
683 EntityClass: me.OnuDataClassID,
684 },
685 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530686 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000687 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000688 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000689 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000690 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000691 return err
692 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530693 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000694 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000695 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000696 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530697 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000698}
699
Himani Chawla6d2ae152020-09-02 13:11:20 +0530700func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000701 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300702 request := &omci.RebootRequest{
703 MeBasePacket: omci.MeBasePacket{
704 EntityClass: me.OnuGClassID,
705 },
706 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530707 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000708 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300709 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000710 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000711 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300712 return err
713 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530714 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300715 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000716 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300717 }
718
Himani Chawla6d2ae152020-09-02 13:11:20 +0530719 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300720 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000721 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000722 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300723 return err
724 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000725 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300726 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000727 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200728 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300729 return err
730 }
731 return nil
732}
733
Himani Chawla6d2ae152020-09-02 13:11:20 +0530734func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000735 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000736 request := &omci.MibUploadRequest{
737 MeBasePacket: omci.MeBasePacket{
738 EntityClass: me.OnuDataClassID,
739 },
740 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530741 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000742 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000743 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000744 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000745 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000746 return err
747 }
748 oo.uploadSequNo = 0
749 oo.uploadNoOfCmds = 0
750
Himani Chawla6d2ae152020-09-02 13:11:20 +0530751 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000752 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000753 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000754 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530755 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000756}
757
Himani Chawla6d2ae152020-09-02 13:11:20 +0530758func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000759 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000760 request := &omci.MibUploadNextRequest{
761 MeBasePacket: omci.MeBasePacket{
762 EntityClass: me.OnuDataClassID,
763 },
764 CommandSequenceNumber: oo.uploadSequNo,
765 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530766 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000767 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000768 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000769 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000770 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000771 return err
772 }
773 oo.uploadSequNo++
774
Himani Chawla6d2ae152020-09-02 13:11:20 +0530775 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000776 cbKey: tid,
777 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
778 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
779 // compare also software upgrade download section handling
780 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, false},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000781 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530782 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000783}
784
Himani Chawla6d2ae152020-09-02 13:11:20 +0530785func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
786 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000787 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000788 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000789
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000790 meParams := me.ParamData{
791 EntityID: galEthernetEID,
792 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
793 }
794 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
795 if omciErr.GetError() == nil {
796 //all setByCreate parameters already set, no default option required ...
797 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
798 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000799 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000800 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000801 return nil
802 }
803
dbainbri4d3a0dc2020-12-02 00:33:42 +0000804 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000805 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000806 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000807 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000808 return nil
809 }
810
Himani Chawla6d2ae152020-09-02 13:11:20 +0530811 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000812 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000813 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000814 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530815 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000816 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000817 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000818 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000819 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000820 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000821 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000822 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000823 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000824 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000825 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000826 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000827}
828
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000829// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530830func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
831 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000832 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000833 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000834
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000835 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
836 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000837 // By now we just use fix values to fire - this is anyway what the python adapter does
838 // read ONU-2G from DB ???? //TODO!!!
839 meParams := me.ParamData{
840 EntityID: 0,
841 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
842 }
843 meInstance, omciErr := me.NewOnu2G(meParams)
844 if omciErr.GetError() == nil {
845 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
846 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000847 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000848 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000849 return nil
850 }
851
dbainbri4d3a0dc2020-12-02 00:33:42 +0000852 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000853 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000854 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000855 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000856 return nil
857 }
858
Himani Chawla6d2ae152020-09-02 13:11:20 +0530859 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000860 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000861 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000862 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530863 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000864 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000865 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000866 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000867 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000868 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000869 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000870 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000871 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000872 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000873 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000874 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000875}
876
Himani Chawla6d2ae152020-09-02 13:11:20 +0530877func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
878 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
879 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530880 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000881 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000882 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000883
884 meParams := me.ParamData{
885 EntityID: instID,
886 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300887 "Priority": 0x8000,
888 "MaxAge": 20 * 256, //20s
889 "HelloTime": 2 * 256, //2s
890 "ForwardDelay": 15 * 256, //15s
891 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000892 },
893 }
894
895 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
896 if omciErr.GetError() == nil {
897 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
898 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
899 omci.TransactionID(tid), omci.AddDefaults(true))
900 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000901 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000902 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000903 return nil
904 }
905
dbainbri4d3a0dc2020-12-02 00:33:42 +0000906 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000908 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000909 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000910 return nil
911 }
912
Himani Chawla6d2ae152020-09-02 13:11:20 +0530913 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000914 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000915 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000916 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530917 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000918 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000919 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000920 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000921 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000922 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000923 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000924 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000925 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000926 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000927 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000928 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000929}
930
Himani Chawla6d2ae152020-09-02 13:11:20 +0530931func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
932 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
933 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530934 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000935 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000936 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000937
938 meParams := me.ParamData{
939 EntityID: instID,
940 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530941 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
942 "PortNum": aPUniPort.macBpNo,
943 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530944 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000945 },
946 }
947 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
948 if omciErr.GetError() == nil {
949 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
950 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
951 omci.TransactionID(tid), omci.AddDefaults(true))
952 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000953 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000954 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000955 return nil
956 }
957
dbainbri4d3a0dc2020-12-02 00:33:42 +0000958 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000959 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000960 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000961 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000962 return nil
963 }
964
Himani Chawla6d2ae152020-09-02 13:11:20 +0530965 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000966 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000967 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000968 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530969 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000970 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000971 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000972 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000973 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000974 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000975 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000976 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000977 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000978 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000979 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000980 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000981}
982
Himani Chawla6d2ae152020-09-02 13:11:20 +0530983func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
984 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
985 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000986 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +0530987 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000988 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000989 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000990
991 // compare python adapter code WA VOL-1311: this is not done here!
992 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
993 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
994 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +0530995 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000996 assType = uint8(10) // for VEIP
997 }
998 meParams := me.ParamData{
999 EntityID: instID,
1000 Attributes: me.AttributeValueMap{
1001 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301002 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001003 },
1004 }
1005 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1006 if omciErr.GetError() == nil {
1007 //all setByCreate parameters already set, no default option required ...
1008 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1009 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001010 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001011 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001012 return nil
1013 }
1014
dbainbri4d3a0dc2020-12-02 00:33:42 +00001015 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001016 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001017 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001018 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001019 return nil
1020 }
1021
Himani Chawla6d2ae152020-09-02 13:11:20 +05301022 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001023 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001024 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001025 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301026 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001027 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001028 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001029 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001030 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001031 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001032 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001033 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001034 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001035 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001036 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001037 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001038}
1039
Himani Chawla6d2ae152020-09-02 13:11:20 +05301040func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001041 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301042 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001043 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001044 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001045
1046 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1047 meParams := me.ParamData{
1048 EntityID: 0,
1049 Attributes: requestedAttributes,
1050 }
1051 meInstance, omciErr := me.NewOnuG(meParams)
1052 if omciErr.GetError() == nil {
1053 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1054 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001055 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001056 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001057 return nil
1058 }
1059
dbainbri4d3a0dc2020-12-02 00:33:42 +00001060 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001061 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001062 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001063 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001064 return nil
1065 }
1066
Himani Chawla6d2ae152020-09-02 13:11:20 +05301067 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001068 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001069 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001070 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301071 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001072 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001073 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001074 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001075 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001076 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001077 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001078 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001079 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001080 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001081 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001082 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001083}
1084
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001085func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1086 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1087 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001088 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001089 "SequNo": strconv.FormatInt(int64(tid), 16)})
1090
1091 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1092 meParams := me.ParamData{
1093 EntityID: aInstNo,
1094 Attributes: requestedAttributes,
1095 }
1096 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1097 if omciErr.GetError() == nil {
1098 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1099 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001100 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001101 "Err": err, "device-id": oo.deviceID})
1102 return nil
1103 }
1104
dbainbri4d3a0dc2020-12-02 00:33:42 +00001105 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001106 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001107 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001108 "Err": err, "device-id": oo.deviceID})
1109 return nil
1110 }
1111
1112 omciRxCallbackPair := callbackPair{
1113 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001114 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001115 }
1116 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1117 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001118 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001119 "Err": err, "device-id": oo.deviceID})
1120 return nil
1121 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001122 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001123 return meInstance
1124 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001125 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001126 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1127 return nil
1128}
1129
1130/* UniG obsolete by now, left here in case it should be needed once again
1131 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301132func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001133 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301134 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001135 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001136 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001137
1138 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1139 meParams := me.ParamData{
1140 EntityID: aInstNo,
1141 Attributes: requestedAttributes,
1142 }
1143 meInstance, omciErr := me.NewUniG(meParams)
1144 if omciErr.GetError() == nil {
1145 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1146 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001147 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001148 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001149 return nil
1150 }
1151
1152 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1153 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001154 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001155 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001156 return nil
1157 }
1158
Himani Chawla6d2ae152020-09-02 13:11:20 +05301159 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001160 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001161 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001162 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301163 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001164 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001165 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001166 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001167 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001168 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001169 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001170 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001171 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001172 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001173 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001174 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001175}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001176*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001177
Himani Chawla6d2ae152020-09-02 13:11:20 +05301178func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001179 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301180 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001181 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001182 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001183
1184 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1185 meParams := me.ParamData{
1186 EntityID: aInstNo,
1187 Attributes: requestedAttributes,
1188 }
1189 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1190 if omciErr.GetError() == nil {
1191 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1192 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001193 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001194 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001195 return nil
1196 }
1197
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001199 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001200 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001201 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001202 return nil
1203 }
1204
Himani Chawla6d2ae152020-09-02 13:11:20 +05301205 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001206 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001207 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001208 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301209 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001210 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001211 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001212 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001213 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001214 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001215 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001216 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001217 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001218 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001219 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001220 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001221}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001222
Himani Chawla6d2ae152020-09-02 13:11:20 +05301223func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001224 timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001225
Himani Chawla6d2ae152020-09-02 13:11:20 +05301226 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001227 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001228 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001229
1230 meParams := me.ParamData{
1231 EntityID: entityID,
1232 Attributes: requestedAttributes,
1233 }
1234 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1235 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301236 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001237 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1238 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001239 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 +00001240 return nil
1241 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001242 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001243 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001245 return nil
1246 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301247 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001248 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001249 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001250 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301251 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001252 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001253 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 +00001254 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001255 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001256 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001257 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001258 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001259 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001260 return nil
1261}
1262
Himani Chawla6d2ae152020-09-02 13:11:20 +05301263func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001264 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301265 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001267 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1268
1269 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001270 EntityID: aInstID,
1271 Attributes: me.AttributeValueMap{
1272 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1273 "TpPointer": 0xFFFF,
1274 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1275 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1276 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1277 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1278 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1279 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1280 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1281 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1282 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001283 }
1284 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1285 if omciErr.GetError() == nil {
1286 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1287 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1288 omci.TransactionID(tid), omci.AddDefaults(true))
1289 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001291 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001292 return nil
1293 }
1294
dbainbri4d3a0dc2020-12-02 00:33:42 +00001295 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001296 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001297 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001298 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001299 return nil
1300 }
1301
Himani Chawla6d2ae152020-09-02 13:11:20 +05301302 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001303 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001304 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001305 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301306 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001307 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001308 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001309 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001310 return nil
1311 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001312 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001313 return meInstance
1314 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001315 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001316 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001317 return nil
1318}
1319
Himani Chawla6d2ae152020-09-02 13:11:20 +05301320func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001321 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301322 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001323 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001324 "SequNo": strconv.FormatInt(int64(tid), 16),
1325 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1326
1327 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1328 if omciErr.GetError() == nil {
1329 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1330 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1331 omci.TransactionID(tid), omci.AddDefaults(true))
1332 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001333 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001334 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001335 return nil
1336 }
1337
dbainbri4d3a0dc2020-12-02 00:33:42 +00001338 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001339 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001340 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001341 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001342 return nil
1343 }
1344
Himani Chawla6d2ae152020-09-02 13:11:20 +05301345 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001346 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001347 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001348 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301349 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001350 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001351 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001352 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001353 return nil
1354 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001355 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001356 return meInstance
1357 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001358 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001359 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001360 return nil
1361}
1362
Himani Chawla6d2ae152020-09-02 13:11:20 +05301363func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001364 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301365 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001366 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001367 "SequNo": strconv.FormatInt(int64(tid), 16),
1368 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1369
1370 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1371 if omciErr.GetError() == nil {
1372 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1373 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1374 omci.TransactionID(tid), omci.AddDefaults(true))
1375 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001376 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001377 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 return nil
1379 }
1380
dbainbri4d3a0dc2020-12-02 00:33:42 +00001381 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001382 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001383 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001384 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001385 return nil
1386 }
1387
Himani Chawla6d2ae152020-09-02 13:11:20 +05301388 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001389 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001390 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001391 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301392 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001393 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001394 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001395 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001396 return nil
1397 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001398 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001399 return meInstance
1400 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001401 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001402 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001403 return nil
1404}
1405
Himani Chawla6d2ae152020-09-02 13:11:20 +05301406func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001407 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301408 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001409 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001410 "SequNo": strconv.FormatInt(int64(tid), 16),
1411 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1412
1413 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1414 if omciErr.GetError() == nil {
1415 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1416 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1417 omci.TransactionID(tid))
1418 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001419 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001420 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 return nil
1422 }
1423
dbainbri4d3a0dc2020-12-02 00:33:42 +00001424 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001425 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001426 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001427 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001428 return nil
1429 }
1430
Himani Chawla6d2ae152020-09-02 13:11:20 +05301431 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001432 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001433 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001434 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301435 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001436 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001437 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001438 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001439 return nil
1440 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001441 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001442 return meInstance
1443 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001444 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001445 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001446 return nil
1447}
1448
Himani Chawla6d2ae152020-09-02 13:11:20 +05301449func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001450 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301451 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001452 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001453 "SequNo": strconv.FormatInt(int64(tid), 16),
1454 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1455
1456 meInstance, omciErr := me.NewTCont(params[0])
1457 if omciErr.GetError() == nil {
1458 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1459 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001461 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001462 return nil
1463 }
1464
dbainbri4d3a0dc2020-12-02 00:33:42 +00001465 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001466 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001467 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001468 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001469 return nil
1470 }
1471
Himani Chawla6d2ae152020-09-02 13:11:20 +05301472 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001473 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001474 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001475 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301476 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001477 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001478 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001479 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001480 return nil
1481 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001482 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001483 return meInstance
1484 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001485 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001486 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001487 return nil
1488}
1489
Himani Chawla6d2ae152020-09-02 13:11:20 +05301490func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001491 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301492 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001493 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001494 "SequNo": strconv.FormatInt(int64(tid), 16),
1495 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1496
1497 meInstance, omciErr := me.NewPriorityQueue(params[0])
1498 if omciErr.GetError() == nil {
1499 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1500 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001501 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001502 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001503 return nil
1504 }
1505
dbainbri4d3a0dc2020-12-02 00:33:42 +00001506 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001507 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001508 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001509 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001510 return nil
1511 }
1512
Himani Chawla6d2ae152020-09-02 13:11:20 +05301513 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001514 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001515 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301517 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001518 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001519 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001520 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001521 return nil
1522 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001523 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001524 return meInstance
1525 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001526 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001527 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001528 return nil
1529}
1530
Himani Chawla6d2ae152020-09-02 13:11:20 +05301531func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001532 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301533 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001534 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001535 "SequNo": strconv.FormatInt(int64(tid), 16),
1536 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1537
1538 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1539 if omciErr.GetError() == nil {
1540 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1541 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001542 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001543 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001544 return nil
1545 }
1546
dbainbri4d3a0dc2020-12-02 00:33:42 +00001547 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001548 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001549 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001550 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001551 return nil
1552 }
1553
Himani Chawla6d2ae152020-09-02 13:11:20 +05301554 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001555 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001556 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001557 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301558 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001559 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001560 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001561 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001562 return nil
1563 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001564 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001565 return meInstance
1566 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001567 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001568 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001569 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001570}
mpagenkodff5dda2020-08-28 11:52:01 +00001571
Himani Chawla6d2ae152020-09-02 13:11:20 +05301572func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001573 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301574 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001575 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001576 "SequNo": strconv.FormatInt(int64(tid), 16),
1577 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1578
1579 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1580 if omciErr.GetError() == nil {
1581 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1582 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1583 omci.TransactionID(tid))
1584 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001585 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001586 "Err": err, "device-id": oo.deviceID})
1587 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1588 // return (dual format) error code that can be used at caller for immediate error treatment
1589 // (relevant to all used sendXX() methods and their error conditions)
1590 return nil
1591 }
1592
dbainbri4d3a0dc2020-12-02 00:33:42 +00001593 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001594 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001595 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001596 "Err": err, "device-id": oo.deviceID})
1597 return nil
1598 }
1599
Himani Chawla6d2ae152020-09-02 13:11:20 +05301600 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001601 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001602 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001603 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301604 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001605 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001606 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001607 "Err": err, "device-id": oo.deviceID})
1608 return nil
1609 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001610 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001611 return meInstance
1612 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001613 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001614 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1615 return nil
1616}
1617
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001618// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001619func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1620 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1621 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001622 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001623 "SequNo": strconv.FormatInt(int64(tid), 16),
1624 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1625
1626 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1627 if omciErr.GetError() == nil {
1628 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1629 omci.TransactionID(tid))
1630 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001631 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001632 "Err": err, "device-id": oo.deviceID})
1633 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1634 // return (dual format) error code that can be used at caller for immediate error treatment
1635 // (relevant to all used sendXX() methods and their error conditions)
1636 return nil
1637 }
1638
dbainbri4d3a0dc2020-12-02 00:33:42 +00001639 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001640 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001641 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001642 "Err": err, "device-id": oo.deviceID})
1643 return nil
1644 }
1645
1646 omciRxCallbackPair := callbackPair{
1647 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001648 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001649 }
1650 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1651 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001652 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001653 "Err": err, "device-id": oo.deviceID})
1654 return nil
1655 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001656 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001657 return meInstance
1658 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001659 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001660 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1661 return nil
1662}
1663
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001664func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1665 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1666 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001667 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001668 "SequNo": strconv.FormatInt(int64(tid), 16),
1669 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1670
1671 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1672 if omciErr.GetError() == nil {
1673 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1674 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001675 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001676 "Err": err, "device-id": oo.deviceID})
1677 return nil
1678 }
1679
dbainbri4d3a0dc2020-12-02 00:33:42 +00001680 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001681 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001682 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001683 "Err": err, "device-id": oo.deviceID})
1684 return nil
1685 }
1686
1687 omciRxCallbackPair := callbackPair{
1688 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001689 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001690 }
1691 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1692 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001693 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001694 "Err": err, "device-id": oo.deviceID})
1695 return nil
1696 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001697 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001698 return meInstance
1699 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001700 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001701 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1702 return nil
1703}
1704
Himani Chawla6d2ae152020-09-02 13:11:20 +05301705func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001706 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301707 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001708 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001709 "SequNo": strconv.FormatInt(int64(tid), 16),
1710 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1711
1712 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1713 if omciErr.GetError() == nil {
1714 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1715 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001716 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001717 "Err": err, "device-id": oo.deviceID})
1718 return nil
1719 }
1720
dbainbri4d3a0dc2020-12-02 00:33:42 +00001721 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001722 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001723 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001724 "Err": err, "device-id": oo.deviceID})
1725 return nil
1726 }
1727
Himani Chawla6d2ae152020-09-02 13:11:20 +05301728 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001729 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001730 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001731 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301732 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001733 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001734 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001735 "Err": err, "device-id": oo.deviceID})
1736 return nil
1737 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001738 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001739 return meInstance
1740 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001741 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001742 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1743 return nil
1744}
mpagenko01e726e2020-10-23 09:45:29 +00001745
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001746func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1747 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1748 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001749 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001750 "SequNo": strconv.FormatInt(int64(tid), 16),
1751 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1752
1753 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1754 if omciErr.GetError() == nil {
1755 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1756 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001757 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001758 "Err": err, "device-id": oo.deviceID})
1759 return nil
1760 }
1761
dbainbri4d3a0dc2020-12-02 00:33:42 +00001762 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001763 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001764 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001765 "Err": err, "device-id": oo.deviceID})
1766 return nil
1767 }
1768
1769 omciRxCallbackPair := callbackPair{
1770 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001771 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001772 }
1773 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1774 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001775 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001776 "Err": err, "device-id": oo.deviceID})
1777 return nil
1778 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001779 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001780 return meInstance
1781 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001782 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001783 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1784 return nil
1785}
1786
mpagenko01e726e2020-10-23 09:45:29 +00001787func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1788 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1789 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001790 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001791 "SequNo": strconv.FormatInt(int64(tid), 16),
1792 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1793
1794 meParams := me.ParamData{EntityID: aInstID}
1795 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1796 if omciErr.GetError() == nil {
1797 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1798 omci.TransactionID(tid))
1799 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001800 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001801 "Err": err, "device-id": oo.deviceID})
1802 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1803 // return (dual format) error code that can be used at caller for immediate error treatment
1804 // (relevant to all used sendXX() methods and their error conditions)
1805 return nil
1806 }
1807
dbainbri4d3a0dc2020-12-02 00:33:42 +00001808 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001809 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001810 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001811 "Err": err, "device-id": oo.deviceID})
1812 return nil
1813 }
1814
1815 omciRxCallbackPair := callbackPair{
1816 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001817 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001818 }
1819 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1820 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001821 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001822 "Err": err, "device-id": oo.deviceID})
1823 return nil
1824 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001825 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001826 return meInstance
1827 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001828 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001829 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1830 return nil
1831}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001832
mpagenko8b07c1b2020-11-26 10:36:31 +00001833func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1834 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1835 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001836 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001837 "SequNo": strconv.FormatInt(int64(tid), 16),
1838 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1839
1840 meParams := me.ParamData{EntityID: aInstID}
1841 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
1842 if omciErr.GetError() == nil {
1843 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1844 omci.TransactionID(tid))
1845 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001846 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001847 "Err": err, "device-id": oo.deviceID})
1848 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1849 // return (dual format) error code that can be used at caller for immediate error treatment
1850 // (relevant to all used sendXX() methods and their error conditions)
1851 return nil
1852 }
1853
dbainbri4d3a0dc2020-12-02 00:33:42 +00001854 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001855 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001856 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001857 "Err": err, "device-id": oo.deviceID})
1858 return nil
1859 }
1860
1861 omciRxCallbackPair := callbackPair{
1862 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001863 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00001864 }
1865 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1866 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001867 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001868 "Err": err, "device-id": oo.deviceID})
1869 return nil
1870 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001871 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001872 return meInstance
1873 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001874 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001875 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1876 return nil
1877}
1878
1879func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
1880 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1881 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001882 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001883 "SequNo": strconv.FormatInt(int64(tid), 16),
1884 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1885
1886 meParams := me.ParamData{EntityID: aInstID}
1887 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
1888 if omciErr.GetError() == nil {
1889 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1890 omci.TransactionID(tid))
1891 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001892 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001893 "Err": err, "device-id": oo.deviceID})
1894 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1895 // return (dual format) error code that can be used at caller for immediate error treatment
1896 // (relevant to all used sendXX() methods and their error conditions)
1897 return nil
1898 }
1899
dbainbri4d3a0dc2020-12-02 00:33:42 +00001900 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001901 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001902 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001903 "Err": err, "device-id": oo.deviceID})
1904 return nil
1905 }
1906
1907 omciRxCallbackPair := callbackPair{
1908 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001909 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00001910 }
1911 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1912 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001913 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001914 "Err": err, "device-id": oo.deviceID})
1915 return nil
1916 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001917 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001918 return meInstance
1919 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001920 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001921 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1922 return nil
1923}
1924
1925func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
1926 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1927 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001928 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001929 "SequNo": strconv.FormatInt(int64(tid), 16),
1930 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1931
1932 meParams := me.ParamData{EntityID: aInstID}
1933 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1934 if omciErr.GetError() == nil {
1935 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1936 omci.TransactionID(tid))
1937 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001938 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001939 "Err": err, "device-id": oo.deviceID})
1940 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1941 // return (dual format) error code that can be used at caller for immediate error treatment
1942 // (relevant to all used sendXX() methods and their error conditions)
1943 return nil
1944 }
1945
dbainbri4d3a0dc2020-12-02 00:33:42 +00001946 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001947 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001948 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001949 "Err": err, "device-id": oo.deviceID})
1950 return nil
1951 }
1952
1953 omciRxCallbackPair := callbackPair{
1954 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001955 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00001956 }
1957 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1958 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001959 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001960 "Err": err, "device-id": oo.deviceID})
1961 return nil
1962 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001963 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00001964 return meInstance
1965 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001966 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001967 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1968 return nil
1969}
1970
1971func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
1972 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1973 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001974 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001975 "SequNo": strconv.FormatInt(int64(tid), 16),
1976 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1977
1978 meParams := me.ParamData{EntityID: aInstID}
1979 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
1980 if omciErr.GetError() == nil {
1981 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1982 omci.TransactionID(tid))
1983 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001984 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001985 "Err": err, "device-id": oo.deviceID})
1986 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1987 // return (dual format) error code that can be used at caller for immediate error treatment
1988 // (relevant to all used sendXX() methods and their error conditions)
1989 return nil
1990 }
1991
dbainbri4d3a0dc2020-12-02 00:33:42 +00001992 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00001993 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001994 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001995 "Err": err, "device-id": oo.deviceID})
1996 return nil
1997 }
1998
1999 omciRxCallbackPair := callbackPair{
2000 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002001 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002002 }
2003 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2004 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002005 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002006 "Err": err, "device-id": oo.deviceID})
2007 return nil
2008 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002009 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002010 return meInstance
2011 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002012 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002013 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2014 return nil
2015}
2016
ozgecanetsia422dbf32020-10-28 14:07:19 +03002017func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2018 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2019 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002020 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002021 "SequNo": strconv.FormatInt(int64(tid), 16),
2022 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2023
2024 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2025 if omciErr.GetError() == nil {
2026 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2027 omci.AddDefaults(true))
2028 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002030 return nil
2031 }
2032
dbainbri4d3a0dc2020-12-02 00:33:42 +00002033 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002034 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002035 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002036 return nil
2037 }
2038
2039 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002040 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002041 }
2042 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2043 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002044 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002045 return nil
2046 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002047 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002048 return meInstance
2049 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002050 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002051 "device-id": oo.deviceID})
2052 return nil
2053}
2054
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002055func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2056 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2057 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002058 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002059 "SequNo": strconv.FormatInt(int64(tid), 16),
2060 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2061
2062 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2063 if omciErr.GetError() == nil {
2064 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2065 omci.AddDefaults(true))
2066 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002067 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002068 return nil
2069 }
2070
dbainbri4d3a0dc2020-12-02 00:33:42 +00002071 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002072 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002073 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002074 return nil
2075 }
2076
2077 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002078 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002079 }
2080 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2081 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002082 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002083 return nil
2084 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002085 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002086 return meInstance
2087 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002088 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002089 "device-id": oo.deviceID})
2090 return nil
2091}
2092
ozgecanetsia422dbf32020-10-28 14:07:19 +03002093func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2094 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2095 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002096 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002097 "SequNo": strconv.FormatInt(int64(tid), 16),
2098 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2099
2100 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2101 if omciErr.GetError() == nil {
2102 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2103 omci.AddDefaults(true))
2104 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002105 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002106 "device-id": oo.deviceID})
2107 return nil
2108 }
2109
dbainbri4d3a0dc2020-12-02 00:33:42 +00002110 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002111 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002112 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002113 "device-id": oo.deviceID})
2114 return nil
2115 }
2116
2117 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002118 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002119 }
2120 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2121 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002122 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002123 "device-id": oo.deviceID})
2124 return nil
2125 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002126 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002127 return meInstance
2128 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002129 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002130 "device-id": oo.deviceID})
2131 return nil
2132}
2133
2134func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2135 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2136 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002137 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002138 "SequNo": strconv.FormatInt(int64(tid), 16),
2139 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2140
2141 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2142 if omciErr.GetError() == nil {
2143 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2144 omci.AddDefaults(true))
2145 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002146 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002147 "device-id": oo.deviceID})
2148 return nil
2149 }
2150
dbainbri4d3a0dc2020-12-02 00:33:42 +00002151 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002152 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002153 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002154 "device-id": oo.deviceID})
2155 return nil
2156 }
2157
2158 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002159 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002160 }
2161 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2162 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002163 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002164 "device-id": oo.deviceID})
2165 return nil
2166 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002167 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002168 return meInstance
2169 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002170 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002171 "device-id": oo.deviceID})
2172 return nil
2173}
2174
2175func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2176 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2177 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002178 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002179 "SequNo": strconv.FormatInt(int64(tid), 16),
2180 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2181
2182 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2183 if omciErr.GetError() == nil {
2184 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2185 omci.AddDefaults(true))
2186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002187 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002188 "device-id": oo.deviceID})
2189 return nil
2190 }
2191
dbainbri4d3a0dc2020-12-02 00:33:42 +00002192 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002193 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002194 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002195 "device-id": oo.deviceID})
2196 return nil
2197 }
2198
2199 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002200 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002201 }
2202 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2203 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002204 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002205 "device-id": oo.deviceID})
2206 return nil
2207 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002208 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002209 return meInstance
2210 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002211 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002212 "device-id": oo.deviceID})
2213 return nil
2214}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002215
Girish Gowdrae0140f02021-02-02 16:55:09 -08002216func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2217 tid := oo.getNextTid(highPrio)
2218 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2219 "SequNo": strconv.FormatInt(int64(tid), 16)})
2220
2221 omciLayer := &omci.OMCI{
2222 TransactionID: tid,
2223 MessageType: omci.SynchronizeTimeRequestType,
2224 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2225 // Length: 0x28, // Optional, defaults to 40 octets
2226 }
2227 utcTime := time.Now().UTC()
2228 request := &omci.SynchronizeTimeRequest{
2229 MeBasePacket: omci.MeBasePacket{
2230 EntityClass: me.OnuGClassID,
2231 // Default Instance ID is 0
2232 },
2233 Year: uint16(utcTime.Year()),
2234 Month: uint8(utcTime.Month()),
2235 Day: uint8(utcTime.Day()),
2236 Hour: uint8(utcTime.Hour()),
2237 Minute: uint8(utcTime.Minute()),
2238 Second: uint8(utcTime.Second()),
2239 }
2240
2241 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2242 if err != nil {
2243 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2244 "device-id": oo.deviceID})
2245 return err
2246 }
2247
2248 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002249 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002250 }
2251 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2252 if err != nil {
2253 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2254 "device-id": oo.deviceID})
2255 return err
2256 }
2257 logger.Debug(ctx, "send synchronize time request done")
2258 return nil
2259}
2260
2261func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
2262 upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2263 tid := oo.getNextTid(highPrio)
2264 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2265 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2266 meParam := me.ParamData{EntityID: entityID}
2267 var meInstance *me.ManagedEntity
2268 var omciErr me.OmciErrors
2269 if upstream {
2270 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2271 } else {
2272 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2273 }
2274 if omciErr.GetError() == nil {
2275 var omciLayer *omci.OMCI
2276 var msgLayer gopacket.SerializableLayer
2277 var err error
2278 if create {
2279 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2280 omci.AddDefaults(true))
2281 } else {
2282 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2283 omci.AddDefaults(true))
2284 }
2285 if err != nil {
2286 logger.Errorw(ctx, "Cannot encode 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
2291 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2292 if err != nil {
2293 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2294 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2295 return nil
2296 }
2297
2298 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002299 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002300 }
2301 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2302 if err != nil {
2303 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2304 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2305 return nil
2306 }
2307 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2308 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2309 return meInstance
2310 }
2311 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2312 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2313 return nil
2314}
2315
2316func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
2317 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2318 tid := oo.getNextTid(highPrio)
2319 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2320 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2321 meParam := me.ParamData{EntityID: entityID}
2322 var meInstance *me.ManagedEntity
2323 var omciErr me.OmciErrors
2324 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2325
2326 if omciErr.GetError() == nil {
2327 var omciLayer *omci.OMCI
2328 var msgLayer gopacket.SerializableLayer
2329 var err error
2330 if create {
2331 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2332 omci.AddDefaults(true))
2333 } else {
2334 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2335 omci.AddDefaults(true))
2336 }
2337 if err != nil {
2338 logger.Errorw(ctx, "Cannot encode 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
2343 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2344 if err != nil {
2345 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2346 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2347 return nil
2348 }
2349
2350 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002351 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002352 }
2353 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2354 if err != nil {
2355 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2356 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2357 return nil
2358 }
2359 logger.Debugw(ctx, "send ethernet uni history data ME done",
2360 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2361 return meInstance
2362 }
2363 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2364 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2365 return nil
2366}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002367
2368func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
2369 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2370 tid := oo.getNextTid(highPrio)
2371 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2372 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2373 meParam := me.ParamData{EntityID: entityID}
2374 var meInstance *me.ManagedEntity
2375 var omciErr me.OmciErrors
2376 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2377
2378 if omciErr.GetError() == nil {
2379 var omciLayer *omci.OMCI
2380 var msgLayer gopacket.SerializableLayer
2381 var err error
2382 if create {
2383 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2384 omci.AddDefaults(true))
2385 } else {
2386 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2387 omci.AddDefaults(true))
2388 }
2389 if err != nil {
2390 logger.Errorw(ctx, "Cannot encode fec history data ME",
2391 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2392 return nil
2393 }
2394
2395 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2396 if err != nil {
2397 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2398 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2399 return nil
2400 }
2401
2402 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002403 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002404 }
2405 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2406 if err != nil {
2407 logger.Errorw(ctx, "Cannot send fec history data ME",
2408 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2409 return nil
2410 }
2411 logger.Debugw(ctx, "send fec history data ME done",
2412 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2413 return meInstance
2414 }
2415 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2416 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2417 return nil
2418}
2419
2420func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
2421 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2422 tid := oo.getNextTid(highPrio)
2423 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2424 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2425 meParam := me.ParamData{EntityID: entityID}
2426 var meInstance *me.ManagedEntity
2427 var omciErr me.OmciErrors
2428 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2429
2430 if omciErr.GetError() == nil {
2431 var omciLayer *omci.OMCI
2432 var msgLayer gopacket.SerializableLayer
2433 var err error
2434 if create {
2435 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2436 omci.AddDefaults(true))
2437 } else {
2438 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2439 omci.AddDefaults(true))
2440 }
2441 if err != nil {
2442 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2443 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2444 return nil
2445 }
2446
2447 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2448 if err != nil {
2449 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2450 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2451 return nil
2452 }
2453
2454 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002455 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002456 }
2457 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2458 if err != nil {
2459 logger.Errorw(ctx, "Cannot send gemport history data ME",
2460 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2461 return nil
2462 }
2463 logger.Debugw(ctx, "send gemport history data ME done",
2464 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2465 return meInstance
2466 }
2467 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2468 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2469 return nil
2470}
2471
mpagenko80622a52021-02-09 16:53:23 +00002472func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2473 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2474 tid := oo.getNextTid(highPrio)
2475 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2476 "SequNo": strconv.FormatInt(int64(tid), 16),
2477 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2478
2479 omciLayer := &omci.OMCI{
2480 TransactionID: tid,
2481 MessageType: omci.StartSoftwareDownloadRequestType,
2482 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2483 // Length: 0x28, // Optional, defaults to 40 octets
2484 }
2485 request := &omci.StartSoftwareDownloadRequest{
2486 MeBasePacket: omci.MeBasePacket{
2487 EntityClass: me.SoftwareImageClassID,
2488 EntityInstance: aImageMeID, //inactive image
2489 },
2490 WindowSize: aDownloadWindowSize,
2491 ImageSize: aFileLen,
2492 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2493 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2494 }
2495
2496 var options gopacket.SerializeOptions
2497 options.FixLengths = true
2498 buffer := gopacket.NewSerializeBuffer()
2499 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2500 if err != nil {
2501 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2502 "device-id": oo.deviceID})
2503 return err
2504 }
2505 outgoingPacket := buffer.Bytes()
2506
2507 omciRxCallbackPair := callbackPair{cbKey: tid,
2508 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2509 }
2510 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2511 if err != nil {
2512 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2513 "device-id": oo.deviceID})
2514 return err
2515 }
2516 logger.Debug(ctx, "send StartSwDlRequest done")
2517
2518 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2519 time.Sleep(time.Millisecond * 200) //give some response time
2520 respOmciLayer := &omci.OMCI{
2521 TransactionID: tid,
2522 MessageType: omci.StartSoftwareDownloadResponseType,
2523 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2524 // Length: 0x28, // Optional, defaults to 40 octets
2525 }
2526 response := &omci.StartSoftwareDownloadResponse{
2527 MeBasePacket: omci.MeBasePacket{
2528 EntityClass: me.SoftwareImageClassID,
2529 EntityInstance: aImageMeID, //inactive image
2530 },
2531 Result: 0,
2532 WindowSize: aDownloadWindowSize,
2533 NumberOfInstances: 0, //seems at the moment I can only generate 0 instances, using 1 here panics as MeResult can not be set below
2534 //MeResults: cannot set here: downloadResults type not exported from omci-lib!
2535 }
2536 var respOptions gopacket.SerializeOptions
2537 respOptions.FixLengths = true
2538 respBuffer := gopacket.NewSerializeBuffer()
2539 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2540 if respErr != nil {
2541 logger.Errorw(ctx, "Cannot serialize StartSwDlResponse", log.Fields{"Err": respErr,
2542 "device-id": oo.deviceID})
2543 return respErr
2544 }
2545 respPacket := respBuffer.Bytes()
2546 logger.Debugw(ctx, "simulate StartSwDlResponse", log.Fields{"device-id": oo.deviceID,
2547 "SequNo": strconv.FormatInt(int64(tid), 16),
2548 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2549 "windowSize": aDownloadWindowSize})
2550 go func(oo *omciCC) {
2551 _ = oo.receiveMessage(ctx, respPacket)
2552 }(oo)
2553 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2554 return nil
2555}
2556
2557func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool,
2558 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2559 tid := oo.getNextTid(highPrio)
2560 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2561 "SequNo": strconv.FormatInt(int64(tid), 16),
2562 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2563
2564 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2565 // by now just try to send it as defined by omci-lib
2566 omciLayer := &omci.OMCI{
2567 TransactionID: tid,
2568 MessageType: omci.DownloadSectionRequestType,
2569 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2570 // Length: 0x28, // Optional, defaults to 40 octets
2571 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002572 var localSectionData [31]byte
mpagenko80622a52021-02-09 16:53:23 +00002573 copy(localSectionData[:], aSection)
2574 request := &omci.DownloadSectionRequest{
2575 MeBasePacket: omci.MeBasePacket{
2576 EntityClass: me.SoftwareImageClassID,
2577 EntityInstance: aImageMeID, //inactive image
2578 },
2579 SectionNumber: aDownloadSectionNo,
2580 SectionData: localSectionData,
2581 }
2582
2583 var options gopacket.SerializeOptions
2584 options.FixLengths = true
2585 buffer := gopacket.NewSerializeBuffer()
2586 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2587 if err != nil {
2588 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2589 "device-id": oo.deviceID})
2590 return err
2591 }
2592 outgoingPacket := buffer.Bytes()
2593
2594 omciRxCallbackPair := callbackPair{cbKey: tid,
2595 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, aPrint},
2596 }
2597 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2598 if err != nil {
2599 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2600 "device-id": oo.deviceID})
2601 return err
2602 }
2603 logger.Debug(ctx, "send DlSectionRequest done")
2604
2605 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2606 if aAckRequest > 0 {
2607 time.Sleep(time.Millisecond * 200) //give some response time
2608 respOmciLayer := &omci.OMCI{
2609 TransactionID: tid,
2610 MessageType: omci.DownloadSectionResponseType,
2611 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2612 // Length: 0x28, // Optional, defaults to 40 octets
2613 }
2614 response := &omci.DownloadSectionResponse{
2615 MeBasePacket: omci.MeBasePacket{
2616 EntityClass: me.SoftwareImageClassID,
2617 EntityInstance: aImageMeID, //inactive image
2618 },
2619 Result: 0,
2620 SectionNumber: aDownloadSectionNo,
2621 }
2622 var respOptions gopacket.SerializeOptions
2623 respOptions.FixLengths = true
2624 respBuffer := gopacket.NewSerializeBuffer()
2625 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2626 if respErr != nil {
2627 logger.Errorw(ctx, "Cannot serialize DlSectionResponse", log.Fields{"Err": respErr,
2628 "device-id": oo.deviceID})
2629 return err
2630 }
2631 respPacket := respBuffer.Bytes()
2632 if aPrint {
2633 logger.Debugw(ctx, "simulate DlSectionResponse", log.Fields{"device-id": oo.deviceID,
2634 "SequNo": strconv.FormatInt(int64(tid), 16),
2635 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2636 "packet": hex.EncodeToString(respPacket)})
2637 } else {
2638 logger.Debugw(ctx, "simulate DlSectionResponse", log.Fields{"device-id": oo.deviceID,
2639 "SequNo": strconv.FormatInt(int64(tid), 16),
2640 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2641 }
2642 go func(oo *omciCC) {
2643 _ = oo.receiveMessage(ctx, respPacket)
2644 }(oo)
2645 }
2646 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2647 return nil
2648}
2649
2650func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2651 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2652 tid := oo.getNextTid(highPrio)
2653 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2654 "SequNo": strconv.FormatInt(int64(tid), 16),
2655 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2656
2657 //**** test simulation - as long as omci-lib serialize for this type is not corrected - just bypass sending *** start *****
2658 /*
2659 omciLayer := &omci.OMCI{
2660 TransactionID: tid,
2661 MessageType: omci.EndSoftwareDownloadRequestType,
2662 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2663 // Length: 0x28, // Optional, defaults to 40 octets
2664 }
2665 request := &omci.EndSoftwareDownloadRequest{
2666 MeBasePacket: omci.MeBasePacket{
2667 EntityClass: me.SoftwareImageClassID,
2668 EntityInstance: aImageMeID, //inactive image
2669 },
2670 CRC32: aImageCrc,
2671 ImageSize: aFileLen,
2672 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2673 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
2674 }
2675
2676 var options gopacket.SerializeOptions
2677 options.FixLengths = true
2678 buffer := gopacket.NewSerializeBuffer()
2679 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2680 if err != nil {
2681 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
2682 "device-id": oo.deviceID})
2683 return err
2684 }
2685 outgoingPacket := buffer.Bytes()
2686
2687 omciRxCallbackPair := callbackPair{cbKey: tid,
2688 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2689 }
2690 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2691 if err != nil {
2692 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2693 "device-id": oo.deviceID})
2694 return err
2695 }
2696 */
2697 //**** test simulation - as long as omci-lib serialize for this type is not corrected - just bypass sending *** end *****
2698 logger.Debug(ctx, "send EndSwDlRequest done")
2699
2700 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2701 //callback code necessary here only as long as sending the request is not possible
2702 omciRxCallbackPair := callbackPair{cbKey: tid,
2703 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2704 }
2705 oo.mutexRxSchedMap.Lock()
2706 oo.rxSchedulerMap[omciRxCallbackPair.cbKey] = omciRxCallbackPair.cbEntry
2707 oo.mutexRxSchedMap.Unlock()
2708 //callback code necessary here only as long as sending the request is not possible
2709
2710 time.Sleep(time.Millisecond * 200) //give some response time
2711 respOmciLayer := &omci.OMCI{
2712 TransactionID: tid,
2713 MessageType: omci.EndSoftwareDownloadResponseType,
2714 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2715 // Length: 0x28, // Optional, defaults to 40 octets
2716 }
2717 response := &omci.EndSoftwareDownloadResponse{
2718 MeBasePacket: omci.MeBasePacket{
2719 EntityClass: me.SoftwareImageClassID,
2720 EntityInstance: aImageMeID, //inactive image
2721 },
2722 Result: 0, //simulate done, option would be busy
2723 NumberOfInstances: 0, //seems at the moment I can only generate 0 instances, using 1 here panics as MeResult can not be set below
2724 //MeResults: cannot set here: downloadResults type not exported from omci-lib!
2725 }
2726 var respOptions gopacket.SerializeOptions
2727 respOptions.FixLengths = true
2728 respBuffer := gopacket.NewSerializeBuffer()
2729 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2730 if respErr != nil {
2731 logger.Errorw(ctx, "Cannot serialize EndSwDlResponse", log.Fields{"Err": respErr,
2732 "device-id": oo.deviceID})
2733 return respErr
2734 }
2735 respPacket := respBuffer.Bytes()
2736 logger.Debugw(ctx, "simulate EndSwDlResponse", log.Fields{"device-id": oo.deviceID,
2737 "SequNo": strconv.FormatInt(int64(tid), 16),
2738 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2739 "result": 0})
2740 go func(oo *omciCC) {
2741 _ = oo.receiveMessage(ctx, respPacket)
2742 }(oo)
2743 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2744 return nil
2745}
2746
2747func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2748 rxChan chan Message, aImageMeID uint16) error {
2749 tid := oo.getNextTid(highPrio)
2750 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2751 "SequNo": strconv.FormatInt(int64(tid), 16),
2752 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2753
2754 omciLayer := &omci.OMCI{
2755 TransactionID: tid,
2756 MessageType: omci.ActivateSoftwareRequestType,
2757 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2758 // Length: 0x28, // Optional, defaults to 40 octets
2759 }
2760 request := &omci.ActivateSoftwareRequest{
2761 MeBasePacket: omci.MeBasePacket{
2762 EntityClass: me.SoftwareImageClassID,
2763 EntityInstance: aImageMeID, //inactive image
2764 },
2765 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2766 }
2767
2768 var options gopacket.SerializeOptions
2769 options.FixLengths = true
2770 buffer := gopacket.NewSerializeBuffer()
2771 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2772 if err != nil {
2773 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2774 "device-id": oo.deviceID})
2775 return err
2776 }
2777 outgoingPacket := buffer.Bytes()
2778
2779 omciRxCallbackPair := callbackPair{cbKey: tid,
2780 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2781 }
2782 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2783 if err != nil {
2784 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2785 "device-id": oo.deviceID})
2786 return err
2787 }
2788 logger.Debug(ctx, "send ActivateSwRequest done")
2789
2790 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2791
2792 time.Sleep(time.Millisecond * 50) //give some response time
2793
2794 respOmciLayer := &omci.OMCI{
2795 TransactionID: tid,
2796 MessageType: omci.ActivateSoftwareResponseType,
2797 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2798 // Length: 0x28, // Optional, defaults to 40 octets
2799 }
2800 response := &omci.ActivateSoftwareResponse{
2801 MeBasePacket: omci.MeBasePacket{
2802 EntityClass: me.SoftwareImageClassID,
2803 EntityInstance: aImageMeID, //inactive image
2804 },
2805 Result: 0, //simulate done, option would be busy
2806 }
2807 var respOptions gopacket.SerializeOptions
2808 respOptions.FixLengths = true
2809 respBuffer := gopacket.NewSerializeBuffer()
2810 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2811 if respErr != nil {
2812 logger.Errorw(ctx, "Cannot serialize ActivateSwResponse", log.Fields{"Err": respErr,
2813 "device-id": oo.deviceID})
2814 return respErr
2815 }
2816 respPacket := respBuffer.Bytes()
2817 logger.Debugw(ctx, "simulate ActivateSwResponse", log.Fields{"device-id": oo.deviceID,
2818 "SequNo": strconv.FormatInt(int64(tid), 16),
2819 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2820 "result": 0})
2821 go func(oo *omciCC) {
2822 _ = oo.receiveMessage(ctx, respPacket)
2823 }(oo)
2824 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2825 return nil
2826}
2827
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002828func isResponseWithMibDataSync(msgType omci.MessageType) bool {
2829 for _, v := range responsesWithMibDataSync {
2830 if v == msgType {
2831 return true
2832 }
2833 }
2834 return false
2835}