blob: 24d6ea13d52878e006c82c039ee6e1ba63390336 [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
mpagenko02cf1b22021-03-12 17:30:30 +000045// ### global test related tag #####
46const cbSwUpgradeRespSim = false
47
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000048// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053049
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
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000162 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530163 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000164
165 return &omciCC
166}
167
mpagenko900ee4b2020-10-12 11:56:34 +0000168//stop stops/resets the omciCC
169func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000170 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000171 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
172 oo.mutexTxQueue.Lock()
173 oo.txQueue.Init() // clear the tx queue
174 oo.mutexTxQueue.Unlock()
175 oo.mutexRxSchedMap.Lock()
176 for k := range oo.rxSchedulerMap {
177 delete(oo.rxSchedulerMap, k) //clear the scheduler map
178 }
179 oo.mutexRxSchedMap.Unlock()
180 oo.mutexHpTid.Lock()
181 oo.hpTid = 0x8000 //reset the high prio transactionId
182 oo.mutexHpTid.Unlock()
183 oo.mutexTid.Lock()
184 oo.tid = 1 //reset the low prio transactionId
185 oo.mutexTid.Unlock()
186 //reset control values
187 oo.uploadSequNo = 0
188 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000189 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000190 //reset the stats counter - which might be topic of discussion ...
191 oo.txFrames = 0
192 oo.txOnuFrames = 0
193 oo.rxFrames = 0
194 oo.rxOnuFrames = 0
195 oo.rxOnuDiscards = 0
196
197 return nil
198}
199
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000200// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530201func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000202 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000203 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530204 switch omciMsg.MessageType {
205 case omci.AlarmNotificationType:
206 data := OmciMessage{
207 OmciMsg: omciMsg,
208 OmciPacket: packet,
209 }
210 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
211 return nil
212 default:
213 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
214 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000215 /*
216 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
217 rxOnuFrames++
218
219 switch msgType {
220 case AlarmNotification:
221 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000222 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000223 // python code was:
224 //if msg_type == EntityOperations.AlarmNotification.value:
225 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
226 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
227 //
228 return errors.New("RxAlarmNotification unimplemented")
229 }
230 case AttributeValueChange:
231 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000232 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000233 // python code was:
234 //elif msg_type == EntityOperations.AttributeValueChange.value:
235 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
236 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
237 //
238 return errors.New("RxAttributeValueChange unimplemented")
239 }
240 case TestResult:
241 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000242 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000243 // python code was:
244 //elif msg_type == EntityOperations.TestResult.value:
245 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
246 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
247 //
248 return errors.New("RxTestResult unimplemented")
249 }
250 default:
251 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000252 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000253 rxOnuDiscards++
254 return errors.New("RxOnuMsgType unimplemented")
255 }
256 }
257 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000258}
259
mpagenko80622a52021-02-09 16:53:23 +0000260func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
261 //assuming omci message content is hex coded!
262 // with restricted output of 16bytes would be ...rxMsg[:16]
263 logger.Debugw(ctx, "omci-message-received:", log.Fields{
264 "RxOmciMessage": hex.EncodeToString(rxMsg),
265 "device-id": oo.deviceID})
266}
267
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000268// Rx handler for onu messages
269// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530270func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000271 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000272 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
273 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000274 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000275 trailerLenData := rxMsg[42:44]
276 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000277 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000278 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
279 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
280 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
281 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
282 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
283 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
284 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
285 }
286 }
287 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
288 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
289 // (an extendedFormat message could be destroyed this way!)
290 // extend/overwrite with trailer
291 trailer := make([]byte, 8)
292 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
293 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
294 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
295 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
296 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
297 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
298 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000299 }
300 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000301 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
302 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000303 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200304 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000305 }
306
307 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
308 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000309 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000310 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200311 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000312 }
313 omciLayer := packet.Layer(omci.LayerTypeOMCI)
314 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000315 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000316 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200317 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000318 }
319 omciMsg, ok := omciLayer.(*omci.OMCI)
320 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000321 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000322 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200323 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000324 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000325 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000326 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000327 if byte(omciMsg.MessageType)&me.AK == 0 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000328 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000329 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000330 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000331 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530332 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000333 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000334 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200335 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000336 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200337 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530338
339 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000340 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530341 oo.mutexRxSchedMap.Lock()
342 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
343 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000344 if rxCallbackEntry.framePrint {
345 oo.printRxMessage(ctx, rxMsg)
346 }
Himani Chawla4d908332020-08-31 12:30:20 +0530347 //disadvantage of decoupling: error verification made difficult, but anyway the question is
348 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000349 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000350 if isResponseWithMibDataSync(omciMsg.MessageType) {
351 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
352 }
mpagenkoc8bba412021-01-15 15:38:44 +0000353
Himani Chawla4d908332020-08-31 12:30:20 +0530354 // having posted the response the request is regarded as 'done'
355 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
356 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000357 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000358 }
mpagenko80622a52021-02-09 16:53:23 +0000359 oo.mutexRxSchedMap.Unlock()
360 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
361 oo.printRxMessage(ctx, rxMsg)
362 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000363
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000364 /* py code was:
365 Receive and OMCI message from the proxy channel to the OLT.
366
367 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
368 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
369 """
370 if not self.enabled:
371 return
372
373 try:
374 now = arrow.utcnow()
375 d = None
376
377 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
378 # save the current value of the entity_id_to_class_map, then
379 # replace it with our custom one before decode, and then finally
380 # restore it later. Tried other ways but really made the code messy.
381 saved_me_map = omci_entities.entity_id_to_class_map
382 omci_entities.entity_id_to_class_map = self._me_map
383
384 try:
385 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000386 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000387 except KeyError as e:
388 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000389 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000390 rx_frame = self._decode_unknown_me(msg)
391 self._rx_unknown_me += 1
392
393 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000394 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000395 return
396
397 finally:
398 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
399
400 rx_tid = rx_frame.fields['transaction_id']
401 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000402 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000403 # Filter the Test Result frame and route through receive onu
404 # message method.
405 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000406 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000407 return self._receive_onu_message(rx_frame)
408
409 # Previously unreachable if this is the very first round-trip Rx or we
410 # have been running consecutive errors
411 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000412 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000413 self.reactor.callLater(0, self._publish_connectivity_event, True)
414
415 self._rx_frames += 1
416 self._consecutive_errors = 0
417
418 try:
419 high_priority = self._tid_is_high_priority(rx_tid)
420 index = self._get_priority_index(high_priority)
421
422 # (timestamp, defer, frame, timeout, retry, delayedCall)
423 last_tx_tuple = self._tx_request[index]
424
425 if last_tx_tuple is None or \
426 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
427 # Possible late Rx on a message that timed-out
428 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000429 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000430 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
431 self._rx_unknown_tid += 1
432 self._rx_late += 1
433 return
434
435 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
436 if dc is not None and not dc.cancelled and not dc.called:
437 dc.cancel()
438
439 _secs = self._update_rx_tx_stats(now, ts)
440
441 # Late arrival already serviced by a timeout?
442 if d.called:
443 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000444 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000445 return
446
447 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000448 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000449 if d is not None:
450 return d.errback(failure.Failure(e))
451 return
452
453 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000454 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000455 tx_tid = tx_frame.fields['transaction_id'])
456 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
457
458 # begin success callback chain (will cancel timeout and queue next Tx message)
459 self._rx_response[index] = rx_frame
460 d.callback(rx_frame)
461
462 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000463 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000464 */
465}
466
Himani Chawla6d2ae152020-09-02 13:11:20 +0530467/*
468func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530469 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530470 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000471}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530472*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000473
474//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530475func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
476 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000477
dbainbri4d3a0dc2020-12-02 00:33:42 +0000478 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000479 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
480 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000481 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
mpagenko80622a52021-02-09 16:53:23 +0000482 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000483 oo.mutexRxSchedMap.Unlock()
484
485 //just use a simple list for starting - might need some more effort, especially for multi source write access
486 omciTxRequest := omciTransferStructure{
487 txFrame,
488 timeout,
489 retry,
490 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000491 printFrame,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000492 }
493 oo.mutexTxQueue.Lock()
494 oo.txQueue.PushBack(omciTxRequest) // enqueue
495 oo.mutexTxQueue.Unlock()
496
497 // for first test just bypass and send directly:
498 go oo.sendNextRequest(ctx)
499 return nil
500}
501
502//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530503func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000504 // return errors.New("sendNextRequest unimplemented")
505
506 // just try to get something transferred !!
507 // avoid accessing the txQueue from parallel send requests
508 // block parallel omci send requests at least until SendIAP is 'committed'
509 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
510 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000511 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000512 for oo.txQueue.Len() > 0 {
513 queueElement := oo.txQueue.Front() // First element
514 omciTxRequest := queueElement.Value.(omciTransferStructure)
515 /* compare olt device handler code:
516 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000517 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000518 var deviceType string
519 var deviceID string
520 var proxyDeviceID string
521
522 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
523
524 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
525
dbainbri4d3a0dc2020-12-02 00:33:42 +0000526 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 +0000527 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
528 kwargs := make(map[string]interface{})
529 kwargs["onu_id"] = omciInd.OnuId
530 kwargs["parent_port_no"] = ponPort
531
dbainbri4d3a0dc2020-12-02 00:33:42 +0000532 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000533 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000534 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000535 return
536 }
537 deviceType = onuDevice.Type
538 deviceID = onuDevice.Id
539 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
540 //if not exist in cache, then add to cache.
541 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
542 } else {
543 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000544 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 +0000545 deviceType = onuInCache.(*OnuDevice).deviceType
546 deviceID = onuInCache.(*OnuDevice).deviceID
547 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
548 }
549 */
550 /* and compare onu_adapter py code:
551 omci_msg = InterAdapterOmciMessage(
552 message=bytes(frame),
553 proxy_address=self._proxy_address,
554 connect_status=self._device.connect_status)
555
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000556 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000557
558 yield self._adapter_proxy.send_inter_adapter_message(
559 msg=omci_msg,
560 type=InterAdapterMessageType.OMCI_REQUEST,
561 from_adapter=self._device.type,
562 to_adapter=self._proxy_address.device_type,
563 to_device_id=self._device_id,
564 proxy_device_id=self._proxy_address.device_id
565 )
566 */
567 device, err := oo.coreProxy.GetDevice(ctx,
568 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
569 if err != nil || device == nil {
570 /*TODO: needs to handle error scenarios */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000571 logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000572 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200573 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000574 }
575
mpagenko80622a52021-02-09 16:53:23 +0000576 if omciTxRequest.withFramePrint {
577 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
578 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
579 "device-id": oo.deviceID,
580 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
581 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
582 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000583 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000584 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000585 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800586 //fromTopic,toType,toDevId, ProxyDevId
587 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000588 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000589 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000590 return sendErr
591 }
592 oo.txQueue.Remove(queueElement) // Dequeue
593 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000594 return nil
595}
596
Himani Chawla6d2ae152020-09-02 13:11:20 +0530597func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000598 var next uint16
599 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000600 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000601 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530602 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000603 if oo.hpTid < 0x8000 {
604 oo.hpTid = 0x8000
605 }
mpagenko900ee4b2020-10-12 11:56:34 +0000606 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000607 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000608 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000609 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530610 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000611 if oo.tid >= 0x8000 {
612 oo.tid = 1
613 }
mpagenko900ee4b2020-10-12 11:56:34 +0000614 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000615 }
616 return next
617}
618
619// ###################################################################################
620// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000621func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000622 omciLayer := &omci.OMCI{
623 TransactionID: tid,
624 MessageType: msgType,
625 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000626 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000627}
628
dbainbri4d3a0dc2020-12-02 00:33:42 +0000629func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000630 var options gopacket.SerializeOptions
631 options.FixLengths = true
632
633 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530634 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000635 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000636 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000637 return nil, err
638 }
639 return buffer.Bytes(), nil
640}
641
Himani Chawla4d908332020-08-31 12:30:20 +0530642/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000643func hexEncode(omciPkt []byte) ([]byte, error) {
644 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
645 hex.Encode(dst, omciPkt)
646 return dst, nil
647}
Himani Chawla4d908332020-08-31 12:30:20 +0530648*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000649
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000650//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000651func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000652
dbainbri4d3a0dc2020-12-02 00:33:42 +0000653 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000654 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000655
656 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000657 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000658 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200659 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000660 }
661
662 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
663 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000664 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000665 Type: OMCI,
666 Data: OmciMessage{
667 OmciMsg: omciMsg,
668 OmciPacket: packet,
669 },
670 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000671 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000672 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000673
674 return nil
675}
676
Himani Chawla6d2ae152020-09-02 13:11:20 +0530677func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000678
dbainbri4d3a0dc2020-12-02 00:33:42 +0000679 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000680 request := &omci.MibResetRequest{
681 MeBasePacket: omci.MeBasePacket{
682 EntityClass: me.OnuDataClassID,
683 },
684 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530685 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000686 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000687 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000688 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000689 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000690 return err
691 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530692 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000693 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000694 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000695 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530696 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000697}
698
Himani Chawla6d2ae152020-09-02 13:11:20 +0530699func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000700 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300701 request := &omci.RebootRequest{
702 MeBasePacket: omci.MeBasePacket{
703 EntityClass: me.OnuGClassID,
704 },
705 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530706 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000707 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300708 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000709 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000710 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300711 return err
712 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530713 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300714 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000715 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300716 }
717
Himani Chawla6d2ae152020-09-02 13:11:20 +0530718 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300719 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000720 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000721 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300722 return err
723 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000724 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300725 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000726 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200727 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300728 return err
729 }
730 return nil
731}
732
Himani Chawla6d2ae152020-09-02 13:11:20 +0530733func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000734 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000735 request := &omci.MibUploadRequest{
736 MeBasePacket: omci.MeBasePacket{
737 EntityClass: me.OnuDataClassID,
738 },
739 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530740 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000741 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000742 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000743 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000744 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000745 return err
746 }
747 oo.uploadSequNo = 0
748 oo.uploadNoOfCmds = 0
749
Himani Chawla6d2ae152020-09-02 13:11:20 +0530750 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000751 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000752 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000753 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530754 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000755}
756
Himani Chawla6d2ae152020-09-02 13:11:20 +0530757func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000758 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000759 request := &omci.MibUploadNextRequest{
760 MeBasePacket: omci.MeBasePacket{
761 EntityClass: me.OnuDataClassID,
762 },
763 CommandSequenceNumber: oo.uploadSequNo,
764 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530765 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000766 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000767 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000768 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000769 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000770 return err
771 }
772 oo.uploadSequNo++
773
Himani Chawla6d2ae152020-09-02 13:11:20 +0530774 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000775 cbKey: tid,
776 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
777 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
778 // compare also software upgrade download section handling
779 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, false},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000780 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530781 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000782}
783
Himani Chawlad3dac422021-03-13 02:31:31 +0530784func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
785 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
786 request := &omci.GetAllAlarmsRequest{
787 MeBasePacket: omci.MeBasePacket{
788 EntityClass: me.OnuDataClassID,
789 },
790 AlarmRetrievalMode: byte(alarmRetreivalMode),
791 }
792 tid := oo.getNextTid(highPrio)
793 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
794 if err != nil {
795 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
796 "Err": err, "device-id": oo.deviceID})
797 return err
798 }
799 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo = 0
800 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadNoOfCmds = 0
801
802 omciRxCallbackPair := callbackPair{
803 cbKey: tid,
804 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
805 oo.receiveOmciResponse, true},
806 }
807 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
808}
809
810func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
811 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo
812 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
813 "alarmUploadSeqNo": alarmUploadSeqNo})
814 request := &omci.GetAllAlarmsNextRequest{
815 MeBasePacket: omci.MeBasePacket{
816 EntityClass: me.OnuDataClassID,
817 },
818 CommandSequenceNumber: alarmUploadSeqNo,
819 }
820 tid := oo.getNextTid(highPrio)
821 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
822 if err != nil {
823 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
824 "Err": err, "device-id": oo.deviceID})
825 return err
826 }
827 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo++
828
829 omciRxCallbackPair := callbackPair{
830 cbKey: tid,
831 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
832 }
833 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
834}
835
Himani Chawla6d2ae152020-09-02 13:11:20 +0530836func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
837 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000838 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000839 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000840
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000841 meParams := me.ParamData{
842 EntityID: galEthernetEID,
843 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
844 }
845 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
846 if omciErr.GetError() == nil {
847 //all setByCreate parameters already set, no default option required ...
848 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
849 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000850 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000851 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000852 return nil
853 }
854
dbainbri4d3a0dc2020-12-02 00:33:42 +0000855 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000856 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000857 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000858 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000859 return nil
860 }
861
Himani Chawla6d2ae152020-09-02 13:11:20 +0530862 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000863 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000864 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000865 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530866 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000867 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000868 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000869 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000870 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000871 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000872 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000873 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000874 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000875 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000876 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000877 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000878}
879
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000880// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530881func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
882 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000883 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000884 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000885
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000886 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
887 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000888 // By now we just use fix values to fire - this is anyway what the python adapter does
889 // read ONU-2G from DB ???? //TODO!!!
890 meParams := me.ParamData{
891 EntityID: 0,
892 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
893 }
894 meInstance, omciErr := me.NewOnu2G(meParams)
895 if omciErr.GetError() == nil {
896 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
897 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000898 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000899 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000900 return nil
901 }
902
dbainbri4d3a0dc2020-12-02 00:33:42 +0000903 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000904 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000905 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000906 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907 return nil
908 }
909
Himani Chawla6d2ae152020-09-02 13:11:20 +0530910 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000911 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000912 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000913 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530914 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000915 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000916 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000917 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000918 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000919 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000920 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000921 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000922 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000923 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000924 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000925 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000926}
927
Himani Chawla6d2ae152020-09-02 13:11:20 +0530928func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
929 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
930 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530931 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000932 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000933 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000934
935 meParams := me.ParamData{
936 EntityID: instID,
937 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300938 "Priority": 0x8000,
939 "MaxAge": 20 * 256, //20s
940 "HelloTime": 2 * 256, //2s
941 "ForwardDelay": 15 * 256, //15s
942 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000943 },
944 }
945
946 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
947 if omciErr.GetError() == nil {
948 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
949 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
950 omci.TransactionID(tid), omci.AddDefaults(true))
951 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000952 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000953 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000954 return nil
955 }
956
dbainbri4d3a0dc2020-12-02 00:33:42 +0000957 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000958 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000959 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000960 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000961 return nil
962 }
963
Himani Chawla6d2ae152020-09-02 13:11:20 +0530964 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000965 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000966 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000967 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530968 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000969 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000970 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000971 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000972 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000973 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000974 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000975 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000976 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000977 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000978 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000979 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000980}
981
Himani Chawla6d2ae152020-09-02 13:11:20 +0530982func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
983 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
984 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530985 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000986 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000987 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000988
989 meParams := me.ParamData{
990 EntityID: instID,
991 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530992 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
993 "PortNum": aPUniPort.macBpNo,
994 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530995 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000996 },
997 }
998 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
999 if omciErr.GetError() == nil {
1000 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1001 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1002 omci.TransactionID(tid), omci.AddDefaults(true))
1003 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001004 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001005 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001006 return nil
1007 }
1008
dbainbri4d3a0dc2020-12-02 00:33:42 +00001009 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001010 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001011 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001012 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001013 return nil
1014 }
1015
Himani Chawla6d2ae152020-09-02 13:11:20 +05301016 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001017 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001018 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001019 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301020 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001021 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001022 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001023 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001024 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001025 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001026 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001027 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001028 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001029 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001030 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001031 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001032}
1033
Himani Chawla6d2ae152020-09-02 13:11:20 +05301034func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
1035 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
1036 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001037 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301038 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001039 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001040 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001041
1042 // compare python adapter code WA VOL-1311: this is not done here!
1043 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1044 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1045 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301046 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001047 assType = uint8(10) // for VEIP
1048 }
1049 meParams := me.ParamData{
1050 EntityID: instID,
1051 Attributes: me.AttributeValueMap{
1052 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301053 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001054 },
1055 }
1056 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1057 if omciErr.GetError() == nil {
1058 //all setByCreate parameters already set, no default option required ...
1059 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1060 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001061 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001062 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001063 return nil
1064 }
1065
dbainbri4d3a0dc2020-12-02 00:33:42 +00001066 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001067 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001068 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001069 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001070 return nil
1071 }
1072
Himani Chawla6d2ae152020-09-02 13:11:20 +05301073 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001074 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001075 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001076 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301077 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001078 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001079 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001080 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001081 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001082 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001083 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001084 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001085 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001086 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001087 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001088 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001089}
1090
Himani Chawla6d2ae152020-09-02 13:11:20 +05301091func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001092 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301093 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001094 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001095 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001096
1097 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1098 meParams := me.ParamData{
1099 EntityID: 0,
1100 Attributes: requestedAttributes,
1101 }
1102 meInstance, omciErr := me.NewOnuG(meParams)
1103 if omciErr.GetError() == nil {
1104 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1105 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001106 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001107 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001108 return nil
1109 }
1110
dbainbri4d3a0dc2020-12-02 00:33:42 +00001111 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001112 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001113 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001114 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001115 return nil
1116 }
1117
Himani Chawla6d2ae152020-09-02 13:11:20 +05301118 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001119 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001120 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001121 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301122 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001123 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001124 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001125 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001126 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001127 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001129 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001130 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001131 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001132 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001133 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001134}
1135
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001136func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1137 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1138 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001139 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001140 "SequNo": strconv.FormatInt(int64(tid), 16)})
1141
1142 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1143 meParams := me.ParamData{
1144 EntityID: aInstNo,
1145 Attributes: requestedAttributes,
1146 }
1147 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1148 if omciErr.GetError() == nil {
1149 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1150 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001151 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001152 "Err": err, "device-id": oo.deviceID})
1153 return nil
1154 }
1155
dbainbri4d3a0dc2020-12-02 00:33:42 +00001156 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001157 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001158 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001159 "Err": err, "device-id": oo.deviceID})
1160 return nil
1161 }
1162
1163 omciRxCallbackPair := callbackPair{
1164 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001165 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001166 }
1167 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1168 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001169 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001170 "Err": err, "device-id": oo.deviceID})
1171 return nil
1172 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001173 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001174 return meInstance
1175 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001176 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001177 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1178 return nil
1179}
1180
1181/* UniG obsolete by now, left here in case it should be needed once again
1182 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301183func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001184 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301185 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001186 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001187 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001188
1189 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1190 meParams := me.ParamData{
1191 EntityID: aInstNo,
1192 Attributes: requestedAttributes,
1193 }
1194 meInstance, omciErr := me.NewUniG(meParams)
1195 if omciErr.GetError() == nil {
1196 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1197 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001198 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001199 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001200 return nil
1201 }
1202
1203 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1204 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001205 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001206 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001207 return nil
1208 }
1209
Himani Chawla6d2ae152020-09-02 13:11:20 +05301210 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001211 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001212 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001213 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301214 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001215 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001216 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001217 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001218 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001219 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001221 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001222 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001223 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001224 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001225 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001226}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001227*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001228
Himani Chawla6d2ae152020-09-02 13:11:20 +05301229func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001230 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301231 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001232 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001233 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001234
1235 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1236 meParams := me.ParamData{
1237 EntityID: aInstNo,
1238 Attributes: requestedAttributes,
1239 }
1240 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1241 if omciErr.GetError() == nil {
1242 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1243 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001244 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001245 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001246 return nil
1247 }
1248
dbainbri4d3a0dc2020-12-02 00:33:42 +00001249 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001251 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001252 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001253 return nil
1254 }
1255
Himani Chawla6d2ae152020-09-02 13:11:20 +05301256 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001257 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001258 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001259 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301260 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001261 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001262 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001263 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001264 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001265 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001267 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001268 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001269 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001270 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001271 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001272}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001273
Himani Chawla6d2ae152020-09-02 13:11:20 +05301274func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001275 timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001276
Himani Chawla6d2ae152020-09-02 13:11:20 +05301277 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001278 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001279 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001280
1281 meParams := me.ParamData{
1282 EntityID: entityID,
1283 Attributes: requestedAttributes,
1284 }
1285 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1286 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301287 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001288 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1289 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 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 +00001291 return nil
1292 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001293 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001294 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001295 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001296 return nil
1297 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301298 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001299 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001300 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001301 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301302 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001303 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001304 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 +00001305 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001306 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001307 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001308 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001309 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001310 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001311 return nil
1312}
1313
Himani Chawla6d2ae152020-09-02 13:11:20 +05301314func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001315 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301316 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001317 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001318 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1319
1320 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001321 EntityID: aInstID,
1322 Attributes: me.AttributeValueMap{
1323 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1324 "TpPointer": 0xFFFF,
1325 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1326 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1327 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1328 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1329 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1330 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1331 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1332 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1333 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001334 }
1335 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1336 if omciErr.GetError() == nil {
1337 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1338 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1339 omci.TransactionID(tid), omci.AddDefaults(true))
1340 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001341 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001342 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001343 return nil
1344 }
1345
dbainbri4d3a0dc2020-12-02 00:33:42 +00001346 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001347 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001348 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001349 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001350 return nil
1351 }
1352
Himani Chawla6d2ae152020-09-02 13:11:20 +05301353 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001354 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001355 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001356 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301357 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001358 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001359 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001360 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001361 return nil
1362 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001363 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001364 return meInstance
1365 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001366 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001367 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001368 return nil
1369}
1370
Himani Chawla6d2ae152020-09-02 13:11:20 +05301371func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001372 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301373 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001374 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001375 "SequNo": strconv.FormatInt(int64(tid), 16),
1376 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1377
1378 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1379 if omciErr.GetError() == nil {
1380 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1381 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1382 omci.TransactionID(tid), omci.AddDefaults(true))
1383 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001384 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001385 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001386 return nil
1387 }
1388
dbainbri4d3a0dc2020-12-02 00:33:42 +00001389 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001390 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001391 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001392 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001393 return nil
1394 }
1395
Himani Chawla6d2ae152020-09-02 13:11:20 +05301396 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001397 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001398 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001399 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301400 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001401 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001402 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001403 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001404 return nil
1405 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001406 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001407 return meInstance
1408 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001409 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001410 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001411 return nil
1412}
1413
Himani Chawla6d2ae152020-09-02 13:11:20 +05301414func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001415 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301416 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001417 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001418 "SequNo": strconv.FormatInt(int64(tid), 16),
1419 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1420
1421 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1422 if omciErr.GetError() == nil {
1423 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1424 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1425 omci.TransactionID(tid), omci.AddDefaults(true))
1426 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001427 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001428 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001429 return nil
1430 }
1431
dbainbri4d3a0dc2020-12-02 00:33:42 +00001432 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001433 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001434 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001435 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001436 return nil
1437 }
1438
Himani Chawla6d2ae152020-09-02 13:11:20 +05301439 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001440 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001441 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001442 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301443 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001444 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001445 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001446 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001447 return nil
1448 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001449 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001450 return meInstance
1451 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001452 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001453 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001454 return nil
1455}
1456
Himani Chawla6d2ae152020-09-02 13:11:20 +05301457func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001458 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301459 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001460 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001461 "SequNo": strconv.FormatInt(int64(tid), 16),
1462 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1463
1464 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1465 if omciErr.GetError() == nil {
1466 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1467 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1468 omci.TransactionID(tid))
1469 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001470 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001471 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001472 return nil
1473 }
1474
dbainbri4d3a0dc2020-12-02 00:33:42 +00001475 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001476 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001477 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001478 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001479 return nil
1480 }
1481
Himani Chawla6d2ae152020-09-02 13:11:20 +05301482 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001483 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001484 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001485 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301486 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001487 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001488 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001489 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001490 return nil
1491 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001492 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001493 return meInstance
1494 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001495 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001496 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001497 return nil
1498}
1499
Himani Chawla6d2ae152020-09-02 13:11:20 +05301500func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301502 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001503 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001504 "SequNo": strconv.FormatInt(int64(tid), 16),
1505 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1506
1507 meInstance, omciErr := me.NewTCont(params[0])
1508 if omciErr.GetError() == nil {
1509 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1510 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001511 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001512 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001513 return nil
1514 }
1515
dbainbri4d3a0dc2020-12-02 00:33:42 +00001516 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001517 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001518 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001519 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001520 return nil
1521 }
1522
Himani Chawla6d2ae152020-09-02 13:11:20 +05301523 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001524 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001525 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001526 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301527 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001528 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001529 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001530 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001531 return nil
1532 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001533 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001534 return meInstance
1535 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001536 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001537 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001538 return nil
1539}
1540
Himani Chawla6d2ae152020-09-02 13:11:20 +05301541func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001542 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301543 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001544 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001545 "SequNo": strconv.FormatInt(int64(tid), 16),
1546 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1547
1548 meInstance, omciErr := me.NewPriorityQueue(params[0])
1549 if omciErr.GetError() == nil {
1550 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1551 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001552 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001553 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001554 return nil
1555 }
1556
dbainbri4d3a0dc2020-12-02 00:33:42 +00001557 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001558 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001559 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001560 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001561 return nil
1562 }
1563
Himani Chawla6d2ae152020-09-02 13:11:20 +05301564 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001565 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001566 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001567 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301568 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001569 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001570 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001571 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001572 return nil
1573 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001574 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001575 return meInstance
1576 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001577 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001578 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001579 return nil
1580}
1581
Himani Chawla6d2ae152020-09-02 13:11:20 +05301582func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001583 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301584 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001585 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001586 "SequNo": strconv.FormatInt(int64(tid), 16),
1587 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1588
1589 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1590 if omciErr.GetError() == nil {
1591 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1592 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001593 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001594 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001595 return nil
1596 }
1597
dbainbri4d3a0dc2020-12-02 00:33:42 +00001598 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001599 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001600 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001601 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001602 return nil
1603 }
1604
Himani Chawla6d2ae152020-09-02 13:11:20 +05301605 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001606 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001607 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001608 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301609 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001610 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001611 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001612 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001613 return nil
1614 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001615 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001616 return meInstance
1617 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001618 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001619 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001620 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001621}
mpagenkodff5dda2020-08-28 11:52:01 +00001622
Himani Chawla6d2ae152020-09-02 13:11:20 +05301623func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001624 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301625 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001626 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001627 "SequNo": strconv.FormatInt(int64(tid), 16),
1628 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1629
1630 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1631 if omciErr.GetError() == nil {
1632 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1633 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1634 omci.TransactionID(tid))
1635 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001636 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001637 "Err": err, "device-id": oo.deviceID})
1638 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1639 // return (dual format) error code that can be used at caller for immediate error treatment
1640 // (relevant to all used sendXX() methods and their error conditions)
1641 return nil
1642 }
1643
dbainbri4d3a0dc2020-12-02 00:33:42 +00001644 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001645 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001646 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001647 "Err": err, "device-id": oo.deviceID})
1648 return nil
1649 }
1650
Himani Chawla6d2ae152020-09-02 13:11:20 +05301651 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001652 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001653 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001654 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301655 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001656 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001657 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001658 "Err": err, "device-id": oo.deviceID})
1659 return nil
1660 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001662 return meInstance
1663 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001664 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001665 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1666 return nil
1667}
1668
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001669// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001670func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1671 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1672 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001673 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001674 "SequNo": strconv.FormatInt(int64(tid), 16),
1675 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1676
1677 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1678 if omciErr.GetError() == nil {
1679 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1680 omci.TransactionID(tid))
1681 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001682 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001683 "Err": err, "device-id": oo.deviceID})
1684 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1685 // return (dual format) error code that can be used at caller for immediate error treatment
1686 // (relevant to all used sendXX() methods and their error conditions)
1687 return nil
1688 }
1689
dbainbri4d3a0dc2020-12-02 00:33:42 +00001690 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001691 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001692 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001693 "Err": err, "device-id": oo.deviceID})
1694 return nil
1695 }
1696
1697 omciRxCallbackPair := callbackPair{
1698 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001699 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001700 }
1701 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1702 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001703 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001704 "Err": err, "device-id": oo.deviceID})
1705 return nil
1706 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001707 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001708 return meInstance
1709 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001710 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001711 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1712 return nil
1713}
1714
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001715func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1716 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1717 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001718 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001719 "SequNo": strconv.FormatInt(int64(tid), 16),
1720 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1721
1722 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1723 if omciErr.GetError() == nil {
1724 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1725 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001726 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001727 "Err": err, "device-id": oo.deviceID})
1728 return nil
1729 }
1730
dbainbri4d3a0dc2020-12-02 00:33:42 +00001731 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001732 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001733 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001734 "Err": err, "device-id": oo.deviceID})
1735 return nil
1736 }
1737
1738 omciRxCallbackPair := callbackPair{
1739 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001740 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001741 }
1742 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1743 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001744 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001745 "Err": err, "device-id": oo.deviceID})
1746 return nil
1747 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001748 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001749 return meInstance
1750 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001751 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001752 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1753 return nil
1754}
1755
Himani Chawla6d2ae152020-09-02 13:11:20 +05301756func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001757 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301758 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001759 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001760 "SequNo": strconv.FormatInt(int64(tid), 16),
1761 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1762
1763 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1764 if omciErr.GetError() == nil {
1765 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1766 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001767 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001768 "Err": err, "device-id": oo.deviceID})
1769 return nil
1770 }
1771
dbainbri4d3a0dc2020-12-02 00:33:42 +00001772 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001773 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001774 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001775 "Err": err, "device-id": oo.deviceID})
1776 return nil
1777 }
1778
Himani Chawla6d2ae152020-09-02 13:11:20 +05301779 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001780 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001781 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001782 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301783 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001784 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001785 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001786 "Err": err, "device-id": oo.deviceID})
1787 return nil
1788 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001789 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001790 return meInstance
1791 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001792 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001793 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1794 return nil
1795}
mpagenko01e726e2020-10-23 09:45:29 +00001796
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001797func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1798 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1799 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001800 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001801 "SequNo": strconv.FormatInt(int64(tid), 16),
1802 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1803
1804 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1805 if omciErr.GetError() == nil {
1806 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1807 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001808 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001809 "Err": err, "device-id": oo.deviceID})
1810 return nil
1811 }
1812
dbainbri4d3a0dc2020-12-02 00:33:42 +00001813 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001814 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001815 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001816 "Err": err, "device-id": oo.deviceID})
1817 return nil
1818 }
1819
1820 omciRxCallbackPair := callbackPair{
1821 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001822 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001823 }
1824 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1825 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001826 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001827 "Err": err, "device-id": oo.deviceID})
1828 return nil
1829 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001830 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001831 return meInstance
1832 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001833 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001834 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1835 return nil
1836}
1837
mpagenko01e726e2020-10-23 09:45:29 +00001838func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1839 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1840 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001841 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001842 "SequNo": strconv.FormatInt(int64(tid), 16),
1843 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1844
1845 meParams := me.ParamData{EntityID: aInstID}
1846 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1847 if omciErr.GetError() == nil {
1848 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1849 omci.TransactionID(tid))
1850 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001851 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001852 "Err": err, "device-id": oo.deviceID})
1853 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1854 // return (dual format) error code that can be used at caller for immediate error treatment
1855 // (relevant to all used sendXX() methods and their error conditions)
1856 return nil
1857 }
1858
dbainbri4d3a0dc2020-12-02 00:33:42 +00001859 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001860 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001861 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001862 "Err": err, "device-id": oo.deviceID})
1863 return nil
1864 }
1865
1866 omciRxCallbackPair := callbackPair{
1867 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001868 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001869 }
1870 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1871 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001872 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001873 "Err": err, "device-id": oo.deviceID})
1874 return nil
1875 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001876 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001877 return meInstance
1878 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001879 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001880 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1881 return nil
1882}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001883
ozgecanetsiab6441962021-03-10 10:58:48 +03001884// nolint: unused
1885func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
1886 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1887 tid := oo.getNextTid(highPrio)
1888 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1889 "SequNo": strconv.FormatInt(int64(tid), 16),
1890 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1891 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1892 if omciErr.GetError() == nil {
1893 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1894 if err != nil {
1895 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
1896 return nil
1897 }
1898 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1899 if err != nil {
1900 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
1901 return nil
1902 }
1903 omciRxCallbackPair := callbackPair{
1904 cbKey: tid,
1905 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1906 }
1907 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1908 if err != nil {
1909 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
1910 return nil
1911 }
1912 logger.Debug(ctx, "send TD-Create-msg done")
1913 return meInstance
1914 }
1915 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1916 return nil
1917}
1918
1919// nolint: unused
1920func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
1921 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1922 tid := oo.getNextTid(highPrio)
1923 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1924 "SequNo": strconv.FormatInt(int64(tid), 16),
1925 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1926
1927 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1928 if omciErr.GetError() == nil {
1929 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1930 if err != nil {
1931 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
1932 return nil
1933 }
1934 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1935 if err != nil {
1936 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
1937 return nil
1938 }
1939 omciRxCallbackPair := callbackPair{
1940 cbKey: tid,
1941 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1942 }
1943 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1944 if err != nil {
1945 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
1946 return nil
1947 }
1948 logger.Debug(ctx, "send TD-Set-msg done")
1949 return meInstance
1950 }
1951 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1952 return nil
1953
1954}
1955
1956// nolint: unused
1957func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
1958 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1959 tid := oo.getNextTid(highPrio)
1960 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1961 "SequNo": strconv.FormatInt(int64(tid), 16),
1962 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1963
1964 meParams := me.ParamData{EntityID: aInstID}
1965 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1966 if omciErr.GetError() == nil {
1967 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1968 if err != nil {
1969 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1970 return nil
1971 }
1972 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1973 if err != nil {
1974 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1975 return nil
1976 }
1977 omciRxCallbackPair := callbackPair{
1978 cbKey: tid,
1979 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1980 }
1981 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1982 if err != nil {
1983 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1984 return nil
1985 }
1986 logger.Debug(ctx, "send TD-Delete-msg done")
1987 return meInstance
1988 }
1989 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1990 return nil
1991
1992}
1993
mpagenko8b07c1b2020-11-26 10:36:31 +00001994func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1995 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1996 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001997 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001998 "SequNo": strconv.FormatInt(int64(tid), 16),
1999 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2000
2001 meParams := me.ParamData{EntityID: aInstID}
2002 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2003 if omciErr.GetError() == nil {
2004 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2005 omci.TransactionID(tid))
2006 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002007 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002008 "Err": err, "device-id": oo.deviceID})
2009 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2010 // return (dual format) error code that can be used at caller for immediate error treatment
2011 // (relevant to all used sendXX() methods and their error conditions)
2012 return nil
2013 }
2014
dbainbri4d3a0dc2020-12-02 00:33:42 +00002015 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002016 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002017 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002018 "Err": err, "device-id": oo.deviceID})
2019 return nil
2020 }
2021
2022 omciRxCallbackPair := callbackPair{
2023 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002024 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002025 }
2026 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2027 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002028 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002029 "Err": err, "device-id": oo.deviceID})
2030 return nil
2031 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002032 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002033 return meInstance
2034 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002035 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002036 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2037 return nil
2038}
2039
2040func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
2041 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2042 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002043 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002044 "SequNo": strconv.FormatInt(int64(tid), 16),
2045 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2046
2047 meParams := me.ParamData{EntityID: aInstID}
2048 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2049 if omciErr.GetError() == nil {
2050 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2051 omci.TransactionID(tid))
2052 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002053 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002054 "Err": err, "device-id": oo.deviceID})
2055 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2056 // return (dual format) error code that can be used at caller for immediate error treatment
2057 // (relevant to all used sendXX() methods and their error conditions)
2058 return nil
2059 }
2060
dbainbri4d3a0dc2020-12-02 00:33:42 +00002061 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002062 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002063 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002064 "Err": err, "device-id": oo.deviceID})
2065 return nil
2066 }
2067
2068 omciRxCallbackPair := callbackPair{
2069 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002070 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002071 }
2072 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2073 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002074 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002075 "Err": err, "device-id": oo.deviceID})
2076 return nil
2077 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002078 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002079 return meInstance
2080 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002081 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002082 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2083 return nil
2084}
2085
2086func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
2087 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2088 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002089 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002090 "SequNo": strconv.FormatInt(int64(tid), 16),
2091 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2092
2093 meParams := me.ParamData{EntityID: aInstID}
2094 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2095 if omciErr.GetError() == nil {
2096 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2097 omci.TransactionID(tid))
2098 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002099 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002100 "Err": err, "device-id": oo.deviceID})
2101 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2102 // return (dual format) error code that can be used at caller for immediate error treatment
2103 // (relevant to all used sendXX() methods and their error conditions)
2104 return nil
2105 }
2106
dbainbri4d3a0dc2020-12-02 00:33:42 +00002107 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002108 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002109 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002110 "Err": err, "device-id": oo.deviceID})
2111 return nil
2112 }
2113
2114 omciRxCallbackPair := callbackPair{
2115 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002116 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002117 }
2118 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2119 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002120 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002121 "Err": err, "device-id": oo.deviceID})
2122 return nil
2123 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002124 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002125 return meInstance
2126 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002127 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002128 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2129 return nil
2130}
2131
2132func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
2133 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2134 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002135 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002136 "SequNo": strconv.FormatInt(int64(tid), 16),
2137 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2138
2139 meParams := me.ParamData{EntityID: aInstID}
2140 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2141 if omciErr.GetError() == nil {
2142 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2143 omci.TransactionID(tid))
2144 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002145 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002146 "Err": err, "device-id": oo.deviceID})
2147 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2148 // return (dual format) error code that can be used at caller for immediate error treatment
2149 // (relevant to all used sendXX() methods and their error conditions)
2150 return nil
2151 }
2152
dbainbri4d3a0dc2020-12-02 00:33:42 +00002153 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002154 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002155 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002156 "Err": err, "device-id": oo.deviceID})
2157 return nil
2158 }
2159
2160 omciRxCallbackPair := callbackPair{
2161 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002162 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002163 }
2164 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2165 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002166 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002167 "Err": err, "device-id": oo.deviceID})
2168 return nil
2169 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002170 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002171 return meInstance
2172 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002173 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002174 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2175 return nil
2176}
2177
ozgecanetsia422dbf32020-10-28 14:07:19 +03002178func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2179 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2180 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002181 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002182 "SequNo": strconv.FormatInt(int64(tid), 16),
2183 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2184
2185 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2186 if omciErr.GetError() == nil {
2187 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2188 omci.AddDefaults(true))
2189 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002190 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002191 return nil
2192 }
2193
dbainbri4d3a0dc2020-12-02 00:33:42 +00002194 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002195 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002196 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002197 return nil
2198 }
2199
2200 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002201 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002202 }
2203 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2204 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002205 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002206 return nil
2207 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002208 logger.Debug(ctx, "send MulticastGEMIWTP-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 MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002212 "device-id": oo.deviceID})
2213 return nil
2214}
2215
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002216func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2217 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2218 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002219 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002220 "SequNo": strconv.FormatInt(int64(tid), 16),
2221 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2222
2223 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2224 if omciErr.GetError() == nil {
2225 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2226 omci.AddDefaults(true))
2227 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002228 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002229 return nil
2230 }
2231
dbainbri4d3a0dc2020-12-02 00:33:42 +00002232 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002233 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002235 return nil
2236 }
2237
2238 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002239 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002240 }
2241 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2242 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002243 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002244 return nil
2245 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002246 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002247 return meInstance
2248 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002249 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002250 "device-id": oo.deviceID})
2251 return nil
2252}
2253
ozgecanetsia422dbf32020-10-28 14:07:19 +03002254func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2255 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2256 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002257 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002258 "SequNo": strconv.FormatInt(int64(tid), 16),
2259 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2260
2261 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2262 if omciErr.GetError() == nil {
2263 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2264 omci.AddDefaults(true))
2265 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002266 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002267 "device-id": oo.deviceID})
2268 return nil
2269 }
2270
dbainbri4d3a0dc2020-12-02 00:33:42 +00002271 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002272 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002273 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002274 "device-id": oo.deviceID})
2275 return nil
2276 }
2277
2278 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002279 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002280 }
2281 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2282 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002283 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002284 "device-id": oo.deviceID})
2285 return nil
2286 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002287 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002288 return meInstance
2289 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002290 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002291 "device-id": oo.deviceID})
2292 return nil
2293}
2294
2295func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2296 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2297 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002298 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002299 "SequNo": strconv.FormatInt(int64(tid), 16),
2300 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2301
2302 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2303 if omciErr.GetError() == nil {
2304 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2305 omci.AddDefaults(true))
2306 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002307 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002308 "device-id": oo.deviceID})
2309 return nil
2310 }
2311
dbainbri4d3a0dc2020-12-02 00:33:42 +00002312 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002313 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002314 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002315 "device-id": oo.deviceID})
2316 return nil
2317 }
2318
2319 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002320 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002321 }
2322 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2323 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002324 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002325 "device-id": oo.deviceID})
2326 return nil
2327 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002328 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002329 return meInstance
2330 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002331 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002332 "device-id": oo.deviceID})
2333 return nil
2334}
2335
2336func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2337 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2338 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002339 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002340 "SequNo": strconv.FormatInt(int64(tid), 16),
2341 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2342
2343 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2344 if omciErr.GetError() == nil {
2345 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2346 omci.AddDefaults(true))
2347 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002348 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002349 "device-id": oo.deviceID})
2350 return nil
2351 }
2352
dbainbri4d3a0dc2020-12-02 00:33:42 +00002353 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002354 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002355 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002356 "device-id": oo.deviceID})
2357 return nil
2358 }
2359
2360 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002361 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002362 }
2363 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2364 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002365 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002366 "device-id": oo.deviceID})
2367 return nil
2368 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002369 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002370 return meInstance
2371 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002372 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002373 "device-id": oo.deviceID})
2374 return nil
2375}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002376
Girish Gowdrae0140f02021-02-02 16:55:09 -08002377func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2378 tid := oo.getNextTid(highPrio)
2379 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2380 "SequNo": strconv.FormatInt(int64(tid), 16)})
2381
2382 omciLayer := &omci.OMCI{
2383 TransactionID: tid,
2384 MessageType: omci.SynchronizeTimeRequestType,
2385 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2386 // Length: 0x28, // Optional, defaults to 40 octets
2387 }
2388 utcTime := time.Now().UTC()
2389 request := &omci.SynchronizeTimeRequest{
2390 MeBasePacket: omci.MeBasePacket{
2391 EntityClass: me.OnuGClassID,
2392 // Default Instance ID is 0
2393 },
2394 Year: uint16(utcTime.Year()),
2395 Month: uint8(utcTime.Month()),
2396 Day: uint8(utcTime.Day()),
2397 Hour: uint8(utcTime.Hour()),
2398 Minute: uint8(utcTime.Minute()),
2399 Second: uint8(utcTime.Second()),
2400 }
2401
2402 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2403 if err != nil {
2404 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2405 "device-id": oo.deviceID})
2406 return err
2407 }
2408
2409 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002410 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002411 }
2412 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2413 if err != nil {
2414 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2415 "device-id": oo.deviceID})
2416 return err
2417 }
2418 logger.Debug(ctx, "send synchronize time request done")
2419 return nil
2420}
2421
2422func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
2423 upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2424 tid := oo.getNextTid(highPrio)
2425 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2426 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2427 meParam := me.ParamData{EntityID: entityID}
2428 var meInstance *me.ManagedEntity
2429 var omciErr me.OmciErrors
2430 if upstream {
2431 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2432 } else {
2433 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2434 }
2435 if omciErr.GetError() == nil {
2436 var omciLayer *omci.OMCI
2437 var msgLayer gopacket.SerializableLayer
2438 var err error
2439 if create {
2440 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2441 omci.AddDefaults(true))
2442 } else {
2443 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2444 omci.AddDefaults(true))
2445 }
2446 if err != nil {
2447 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2448 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2449 return nil
2450 }
2451
2452 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2453 if err != nil {
2454 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2455 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2456 return nil
2457 }
2458
2459 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002460 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002461 }
2462 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2463 if err != nil {
2464 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2465 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2466 return nil
2467 }
2468 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2469 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2470 return meInstance
2471 }
2472 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2473 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2474 return nil
2475}
2476
2477func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
2478 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2479 tid := oo.getNextTid(highPrio)
2480 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2481 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2482 meParam := me.ParamData{EntityID: entityID}
2483 var meInstance *me.ManagedEntity
2484 var omciErr me.OmciErrors
2485 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2486
2487 if omciErr.GetError() == nil {
2488 var omciLayer *omci.OMCI
2489 var msgLayer gopacket.SerializableLayer
2490 var err error
2491 if create {
2492 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2493 omci.AddDefaults(true))
2494 } else {
2495 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2496 omci.AddDefaults(true))
2497 }
2498 if err != nil {
2499 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2500 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2501 return nil
2502 }
2503
2504 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2505 if err != nil {
2506 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2507 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2508 return nil
2509 }
2510
2511 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002512 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002513 }
2514 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2515 if err != nil {
2516 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2517 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2518 return nil
2519 }
2520 logger.Debugw(ctx, "send ethernet uni history data ME done",
2521 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2522 return meInstance
2523 }
2524 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2525 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2526 return nil
2527}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002528
2529func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
2530 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2531 tid := oo.getNextTid(highPrio)
2532 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2533 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2534 meParam := me.ParamData{EntityID: entityID}
2535 var meInstance *me.ManagedEntity
2536 var omciErr me.OmciErrors
2537 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2538
2539 if omciErr.GetError() == nil {
2540 var omciLayer *omci.OMCI
2541 var msgLayer gopacket.SerializableLayer
2542 var err error
2543 if create {
2544 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2545 omci.AddDefaults(true))
2546 } else {
2547 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2548 omci.AddDefaults(true))
2549 }
2550 if err != nil {
2551 logger.Errorw(ctx, "Cannot encode fec history data ME",
2552 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2553 return nil
2554 }
2555
2556 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2557 if err != nil {
2558 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2559 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2560 return nil
2561 }
2562
2563 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002564 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002565 }
2566 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2567 if err != nil {
2568 logger.Errorw(ctx, "Cannot send fec history data ME",
2569 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2570 return nil
2571 }
2572 logger.Debugw(ctx, "send fec history data ME done",
2573 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2574 return meInstance
2575 }
2576 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2577 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2578 return nil
2579}
2580
2581func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
2582 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2583 tid := oo.getNextTid(highPrio)
2584 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2585 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2586 meParam := me.ParamData{EntityID: entityID}
2587 var meInstance *me.ManagedEntity
2588 var omciErr me.OmciErrors
2589 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2590
2591 if omciErr.GetError() == nil {
2592 var omciLayer *omci.OMCI
2593 var msgLayer gopacket.SerializableLayer
2594 var err error
2595 if create {
2596 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2597 omci.AddDefaults(true))
2598 } else {
2599 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2600 omci.AddDefaults(true))
2601 }
2602 if err != nil {
2603 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2604 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2605 return nil
2606 }
2607
2608 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2609 if err != nil {
2610 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2611 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2612 return nil
2613 }
2614
2615 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002616 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002617 }
2618 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2619 if err != nil {
2620 logger.Errorw(ctx, "Cannot send gemport history data ME",
2621 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2622 return nil
2623 }
2624 logger.Debugw(ctx, "send gemport history data ME done",
2625 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2626 return meInstance
2627 }
2628 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2629 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2630 return nil
2631}
2632
mpagenko80622a52021-02-09 16:53:23 +00002633func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2634 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2635 tid := oo.getNextTid(highPrio)
2636 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2637 "SequNo": strconv.FormatInt(int64(tid), 16),
2638 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2639
2640 omciLayer := &omci.OMCI{
2641 TransactionID: tid,
2642 MessageType: omci.StartSoftwareDownloadRequestType,
2643 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2644 // Length: 0x28, // Optional, defaults to 40 octets
2645 }
2646 request := &omci.StartSoftwareDownloadRequest{
2647 MeBasePacket: omci.MeBasePacket{
2648 EntityClass: me.SoftwareImageClassID,
2649 EntityInstance: aImageMeID, //inactive image
2650 },
2651 WindowSize: aDownloadWindowSize,
2652 ImageSize: aFileLen,
2653 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2654 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2655 }
2656
2657 var options gopacket.SerializeOptions
2658 options.FixLengths = true
2659 buffer := gopacket.NewSerializeBuffer()
2660 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2661 if err != nil {
2662 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2663 "device-id": oo.deviceID})
2664 return err
2665 }
2666 outgoingPacket := buffer.Bytes()
2667
2668 omciRxCallbackPair := callbackPair{cbKey: tid,
2669 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2670 }
2671 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2672 if err != nil {
2673 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2674 "device-id": oo.deviceID})
2675 return err
2676 }
2677 logger.Debug(ctx, "send StartSwDlRequest done")
2678
mpagenko02cf1b22021-03-12 17:30:30 +00002679 if cbSwUpgradeRespSim == true {
2680 go func() {
2681 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2682 time.Sleep(time.Millisecond * 50) //give some response time
2683 respOmciLayer := &omci.OMCI{
2684 TransactionID: tid,
2685 MessageType: omci.StartSoftwareDownloadResponseType,
2686 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2687 // Length: 0x28, // Optional, defaults to 40 octets
2688 }
2689 response := &omci.StartSoftwareDownloadResponse{
2690 MeBasePacket: omci.MeBasePacket{
2691 EntityClass: me.SoftwareImageClassID,
2692 EntityInstance: aImageMeID, //inactive image
2693 },
2694 Result: 0,
2695 WindowSize: aDownloadWindowSize,
2696 NumberOfInstances: 0, //seems at the moment I can only generate 0 instances, using 1 here panics as MeResult can not be set below
2697 //MeResults: cannot set here: downloadResults type not exported from omci-lib!
2698 }
2699 var respOptions gopacket.SerializeOptions
2700 respOptions.FixLengths = true
2701 respBuffer := gopacket.NewSerializeBuffer()
2702 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2703 if respErr != nil {
2704 logger.Errorw(ctx, "Cannot serialize StartSwDlResponse", log.Fields{"Err": respErr,
2705 "device-id": oo.deviceID})
2706 return
2707 }
2708 respPacket := respBuffer.Bytes()
2709 logger.Debugw(ctx, "simulate StartSwDlResponse", log.Fields{"device-id": oo.deviceID,
2710 "SequNo": strconv.FormatInt(int64(tid), 16),
2711 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2712 "windowSize": aDownloadWindowSize})
2713 go func(oo *omciCC) {
2714 _ = oo.receiveMessage(ctx, respPacket)
2715 }(oo)
2716 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2717 }()
2718 }
mpagenko80622a52021-02-09 16:53:23 +00002719 return nil
2720}
2721
2722func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool,
2723 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2724 tid := oo.getNextTid(highPrio)
2725 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2726 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002727 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002728
2729 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2730 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002731 msgType := omci.DownloadSectionRequestType
2732 if aAckRequest > 0 {
2733 msgType = omci.DownloadSectionRequestWithResponseType
2734 }
mpagenko80622a52021-02-09 16:53:23 +00002735 omciLayer := &omci.OMCI{
2736 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002737 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002738 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2739 // Length: 0x28, // Optional, defaults to 40 octets
2740 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002741 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002742 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002743 request := &omci.DownloadSectionRequest{
2744 MeBasePacket: omci.MeBasePacket{
2745 EntityClass: me.SoftwareImageClassID,
2746 EntityInstance: aImageMeID, //inactive image
2747 },
2748 SectionNumber: aDownloadSectionNo,
2749 SectionData: localSectionData,
2750 }
2751
2752 var options gopacket.SerializeOptions
2753 options.FixLengths = true
2754 buffer := gopacket.NewSerializeBuffer()
2755 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2756 if err != nil {
2757 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2758 "device-id": oo.deviceID})
2759 return err
2760 }
2761 outgoingPacket := buffer.Bytes()
2762
mpagenko15ff4a52021-03-02 10:09:20 +00002763 //for initial debug purpose overrule the requested print state for some frames
2764 printFrame := aPrint
2765 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2766 printFrame = true
2767 }
2768
mpagenko80622a52021-02-09 16:53:23 +00002769 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002770 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002771 }
2772 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2773 if err != nil {
2774 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2775 "device-id": oo.deviceID})
2776 return err
2777 }
2778 logger.Debug(ctx, "send DlSectionRequest done")
2779
mpagenko02cf1b22021-03-12 17:30:30 +00002780 if cbSwUpgradeRespSim == true {
2781 go func() {
2782 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2783 if aAckRequest > 0 {
2784 time.Sleep(time.Millisecond * 50) //give some response time
2785 respOmciLayer := &omci.OMCI{
2786 TransactionID: tid,
2787 MessageType: omci.DownloadSectionResponseType,
2788 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2789 // Length: 0x28, // Optional, defaults to 40 octets
2790 }
2791 response := &omci.DownloadSectionResponse{
2792 MeBasePacket: omci.MeBasePacket{
2793 EntityClass: me.SoftwareImageClassID,
2794 EntityInstance: aImageMeID, //inactive image
2795 },
2796 Result: 0,
2797 SectionNumber: aDownloadSectionNo,
2798 }
2799 var respOptions gopacket.SerializeOptions
2800 respOptions.FixLengths = true
2801 respBuffer := gopacket.NewSerializeBuffer()
2802 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2803 if respErr != nil {
2804 logger.Errorw(ctx, "Cannot serialize DlSectionResponse", log.Fields{"Err": respErr,
2805 "device-id": oo.deviceID})
2806 return
2807 }
2808 respPacket := respBuffer.Bytes()
2809 if aPrint {
2810 logger.Debugw(ctx, "simulate DlSectionResponse", log.Fields{"device-id": oo.deviceID,
2811 "SequNo": strconv.FormatInt(int64(tid), 16),
2812 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2813 "packet": hex.EncodeToString(respPacket)})
2814 } else {
2815 logger.Debugw(ctx, "simulate DlSectionResponse", log.Fields{"device-id": oo.deviceID,
2816 "SequNo": strconv.FormatInt(int64(tid), 16),
2817 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2818 }
2819 go func(oo *omciCC) {
2820 _ = oo.receiveMessage(ctx, respPacket)
2821 }(oo)
mpagenko15ff4a52021-03-02 10:09:20 +00002822 }
mpagenko02cf1b22021-03-12 17:30:30 +00002823 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2824 }()
2825 }
mpagenko80622a52021-02-09 16:53:23 +00002826 return nil
2827}
2828
2829func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2830 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2831 tid := oo.getNextTid(highPrio)
2832 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2833 "SequNo": strconv.FormatInt(int64(tid), 16),
2834 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2835
mpagenko15ff4a52021-03-02 10:09:20 +00002836 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002837 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002838 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002839 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2840 // Length: 0x28, // Optional, defaults to 40 octets
2841 }
mpagenko15ff4a52021-03-02 10:09:20 +00002842 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002843 MeBasePacket: omci.MeBasePacket{
2844 EntityClass: me.SoftwareImageClassID,
2845 EntityInstance: aImageMeID, //inactive image
2846 },
mpagenko15ff4a52021-03-02 10:09:20 +00002847 CRC32: aImageCrc,
2848 ImageSize: aFileLen,
2849 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2850 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002851 }
mpagenko15ff4a52021-03-02 10:09:20 +00002852
2853 var options gopacket.SerializeOptions
2854 options.FixLengths = true
2855 buffer := gopacket.NewSerializeBuffer()
2856 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2857 if err != nil {
2858 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002859 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002860 return err
mpagenko80622a52021-02-09 16:53:23 +00002861 }
mpagenko15ff4a52021-03-02 10:09:20 +00002862 outgoingPacket := buffer.Bytes()
2863
2864 omciRxCallbackPair := callbackPair{cbKey: tid,
2865 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2866 }
2867 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2868 if err != nil {
2869 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2870 "device-id": oo.deviceID})
2871 return err
2872 }
2873 logger.Debug(ctx, "send EndSwDlRequest done")
2874
mpagenko02cf1b22021-03-12 17:30:30 +00002875 if cbSwUpgradeRespSim == true {
2876 go func() {
2877 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2878 time.Sleep(time.Millisecond * 50) //give some response time
2879 respOmciLayer := &omci.OMCI{
2880 TransactionID: tid,
2881 MessageType: omci.EndSoftwareDownloadResponseType,
2882 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2883 // Length: 0x28, // Optional, defaults to 40 octets
2884 }
2885 response := &omci.EndSoftwareDownloadResponse{
2886 MeBasePacket: omci.MeBasePacket{
2887 EntityClass: me.SoftwareImageClassID,
2888 EntityInstance: aImageMeID, //inactive image
2889 },
2890 Result: 0, //simulate done, option would be busy
2891 NumberOfInstances: 0, //basic ONU-G instance
2892 }
2893 var respOptions gopacket.SerializeOptions
2894 respOptions.FixLengths = true
2895 respBuffer := gopacket.NewSerializeBuffer()
2896 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2897 if respErr != nil {
2898 logger.Errorw(ctx, "Cannot serialize EndSwDlResponse", log.Fields{"Err": respErr,
2899 "device-id": oo.deviceID})
2900 return
2901 }
2902 respPacket := respBuffer.Bytes()
2903 logger.Debugw(ctx, "simulate EndSwDlResponse", log.Fields{"device-id": oo.deviceID,
2904 "SequNo": strconv.FormatInt(int64(tid), 16),
2905 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2906 "result": 0})
2907 go func(oo *omciCC) {
2908 _ = oo.receiveMessage(ctx, respPacket)
2909 }(oo)
2910 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2911 }()
2912 }
mpagenko80622a52021-02-09 16:53:23 +00002913 return nil
2914}
2915
2916func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2917 rxChan chan Message, aImageMeID uint16) error {
2918 tid := oo.getNextTid(highPrio)
2919 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2920 "SequNo": strconv.FormatInt(int64(tid), 16),
2921 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2922
2923 omciLayer := &omci.OMCI{
2924 TransactionID: tid,
2925 MessageType: omci.ActivateSoftwareRequestType,
2926 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2927 // Length: 0x28, // Optional, defaults to 40 octets
2928 }
2929 request := &omci.ActivateSoftwareRequest{
2930 MeBasePacket: omci.MeBasePacket{
2931 EntityClass: me.SoftwareImageClassID,
2932 EntityInstance: aImageMeID, //inactive image
2933 },
2934 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2935 }
2936
2937 var options gopacket.SerializeOptions
2938 options.FixLengths = true
2939 buffer := gopacket.NewSerializeBuffer()
2940 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2941 if err != nil {
2942 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2943 "device-id": oo.deviceID})
2944 return err
2945 }
2946 outgoingPacket := buffer.Bytes()
2947
2948 omciRxCallbackPair := callbackPair{cbKey: tid,
2949 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2950 }
2951 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2952 if err != nil {
2953 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2954 "device-id": oo.deviceID})
2955 return err
2956 }
2957 logger.Debug(ctx, "send ActivateSwRequest done")
2958
mpagenko02cf1b22021-03-12 17:30:30 +00002959 if cbSwUpgradeRespSim == true {
2960 go func() {
2961 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
2962 time.Sleep(time.Millisecond * 50) //give some response time
mpagenko80622a52021-02-09 16:53:23 +00002963
mpagenko02cf1b22021-03-12 17:30:30 +00002964 respOmciLayer := &omci.OMCI{
2965 TransactionID: tid,
2966 MessageType: omci.ActivateSoftwareResponseType,
2967 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2968 // Length: 0x28, // Optional, defaults to 40 octets
2969 }
2970 response := &omci.ActivateSoftwareResponse{
2971 MeBasePacket: omci.MeBasePacket{
2972 EntityClass: me.SoftwareImageClassID,
2973 EntityInstance: aImageMeID, //inactive image
2974 },
2975 Result: 0, //simulate done, option would be busy
2976 }
2977 var respOptions gopacket.SerializeOptions
2978 respOptions.FixLengths = true
2979 respBuffer := gopacket.NewSerializeBuffer()
2980 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
2981 if respErr != nil {
2982 logger.Errorw(ctx, "Cannot serialize ActivateSwResponse", log.Fields{"Err": respErr,
2983 "device-id": oo.deviceID})
2984 return
2985 }
2986 respPacket := respBuffer.Bytes()
2987 logger.Debugw(ctx, "simulate ActivateSwResponse", log.Fields{"device-id": oo.deviceID,
2988 "SequNo": strconv.FormatInt(int64(tid), 16),
2989 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
2990 "result": 0})
2991 go func(oo *omciCC) {
2992 _ = oo.receiveMessage(ctx, respPacket)
2993 }(oo)
2994 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
2995 }()
2996 }
mpagenko15ff4a52021-03-02 10:09:20 +00002997 return nil
2998}
mpagenko80622a52021-02-09 16:53:23 +00002999
mpagenko15ff4a52021-03-02 10:09:20 +00003000func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
3001 rxChan chan Message, aImageMeID uint16) error {
3002 tid := oo.getNextTid(highPrio)
3003 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
3004 "SequNo": strconv.FormatInt(int64(tid), 16),
3005 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
3006
3007 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00003008 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00003009 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00003010 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3011 // Length: 0x28, // Optional, defaults to 40 octets
3012 }
mpagenko15ff4a52021-03-02 10:09:20 +00003013 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00003014 MeBasePacket: omci.MeBasePacket{
3015 EntityClass: me.SoftwareImageClassID,
3016 EntityInstance: aImageMeID, //inactive image
3017 },
mpagenko80622a52021-02-09 16:53:23 +00003018 }
mpagenko15ff4a52021-03-02 10:09:20 +00003019
3020 var options gopacket.SerializeOptions
3021 options.FixLengths = true
3022 buffer := gopacket.NewSerializeBuffer()
3023 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
3024 if err != nil {
3025 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00003026 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00003027 return err
mpagenko80622a52021-02-09 16:53:23 +00003028 }
mpagenko15ff4a52021-03-02 10:09:20 +00003029 outgoingPacket := buffer.Bytes()
3030
3031 omciRxCallbackPair := callbackPair{cbKey: tid,
3032 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
3033 }
3034 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
3035 if err != nil {
3036 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
3037 "device-id": oo.deviceID})
3038 return err
3039 }
3040 logger.Debug(ctx, "send CommitSwRequest done")
3041
mpagenko02cf1b22021-03-12 17:30:30 +00003042 if cbSwUpgradeRespSim == true {
3043 go func() {
3044 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** start *****
3045 time.Sleep(time.Millisecond * 50) //give some response time
3046 respOmciLayer := &omci.OMCI{
3047 TransactionID: tid,
3048 MessageType: omci.CommitSoftwareResponseType,
3049 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
3050 // Length: 0x28, // Optional, defaults to 40 octets
3051 }
3052 response := &omci.CommitSoftwareResponse{
3053 MeBasePacket: omci.MeBasePacket{
3054 EntityClass: me.SoftwareImageClassID,
3055 EntityInstance: aImageMeID, //inactive image
3056 },
3057 //TODO: Not yet supported by omci-lib Result: 0, //simulate done
3058 }
3059 var respOptions gopacket.SerializeOptions
3060 respOptions.FixLengths = true
3061 respBuffer := gopacket.NewSerializeBuffer()
3062 respErr := gopacket.SerializeLayers(respBuffer, respOptions, respOmciLayer, response)
3063 if respErr != nil {
3064 logger.Errorw(ctx, "Cannot serialize CommitSwResponse", log.Fields{"Err": respErr,
3065 "device-id": oo.deviceID})
3066 return
3067 }
3068 respPacket := respBuffer.Bytes()
3069 logger.Debugw(ctx, "simulate CommitSwResponse", log.Fields{"device-id": oo.deviceID,
3070 "SequNo": strconv.FormatInt(int64(tid), 16),
3071 "InstId": strconv.FormatInt(int64(aImageMeID), 16),
3072 "result": 0})
3073 go func(oo *omciCC) {
3074 _ = oo.receiveMessage(ctx, respPacket)
3075 }(oo)
3076 //**** test simulation - as long as BBSIM does not support ONU SW upgrade *** stop *****
3077 }()
3078 }
mpagenko80622a52021-02-09 16:53:23 +00003079 return nil
3080}
3081
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00003082func isResponseWithMibDataSync(msgType omci.MessageType) bool {
3083 for _, v := range responsesWithMibDataSync {
3084 if v == msgType {
3085 return true
3086 }
3087 }
3088 return false
3089}