blob: 1c58250bb31594f1bddb40b854d78e5af939bebe [file] [log] [blame]
Holger Hildebrandtfa074992020-03-27 15:42:06 +00001/*
2 * Copyright 2020-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +000017//Package adaptercoreonu provides the utility for onu devices, flows and statistics
18package adaptercoreonu
Holger Hildebrandtfa074992020-03-27 15:42:06 +000019
20import (
21 "container/list"
22 "context"
23 "encoding/binary"
24 "encoding/hex"
Andrea Campanella6515c582020-10-05 11:25:00 +020025 "fmt"
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000026 "strconv"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000027 "sync"
mpagenko80622a52021-02-09 16:53:23 +000028 "time" //by now for testing
Holger Hildebrandtfa074992020-03-27 15:42:06 +000029
30 "github.com/google/gopacket"
31 // TODO!!! Some references could be resolved auto, but some need specific context ....
32 gp "github.com/google/gopacket"
33
34 "github.com/opencord/omci-lib-go"
35 me "github.com/opencord/omci-lib-go/generated"
dbainbri4d3a0dc2020-12-02 00:33:42 +000036 "github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000037
dbainbri4d3a0dc2020-12-02 00:33:42 +000038 //"github.com/opencord/voltha-lib-go/v4/pkg/kafka"
39 "github.com/opencord/voltha-lib-go/v4/pkg/log"
40 ic "github.com/opencord/voltha-protos/v4/go/inter_container"
41 //"github.com/opencord/voltha-protos/v4/go/openflow_13"
42 //"github.com/opencord/voltha-protos/v4/go/voltha"
Holger Hildebrandtfa074992020-03-27 15:42:06 +000043)
44
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000045// ### OMCI related definitions - retrieved from Python adapter code/trace ####
Himani Chawla6d2ae152020-09-02 13:11:20 +053046
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000047const galEthernetEID = uint16(1)
48const maxGemPayloadSize = uint16(48)
49const connectivityModeValue = uint8(5)
Himani Chawla4d908332020-08-31 12:30:20 +053050
51//const defaultTPID = uint16(0x8100)
52//const broadComDefaultVID = uint16(4091)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000053const macBridgeServiceProfileEID = uint16(0x201) // TODO: most all these need better definition or tuning
54const ieeeMapperServiceProfileEID = uint16(0x8001)
55const macBridgePortAniEID = uint16(0x2102)
56
mpagenko8b07c1b2020-11-26 10:36:31 +000057const unusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems
58
mpagenkoc8bba412021-01-15 15:38:44 +000059const cOmciBaseMessageTrailerLen = 40
60
61// tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format)
62type tOmciReceiveError uint8
63
64const (
65 // cOmciMessageReceiveNoError - default start state
66 cOmciMessageReceiveNoError tOmciReceiveError = iota
67 // Error indication wrong trailer length within the message
68 cOmciMessageReceiveErrorTrailerLen
69 // Error indication missing trailer within the message
70 cOmciMessageReceiveErrorMissTrailer
71)
72
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +000073// ### OMCI related definitions - end
74
Himani Chawla6d2ae152020-09-02 13:11:20 +053075//callbackPairEntry to be used for OMCI send/receive correlation
76type callbackPairEntry struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000077 cbRespChannel chan Message
dbainbri4d3a0dc2020-12-02 00:33:42 +000078 cbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error
mpagenko80622a52021-02-09 16:53:23 +000079 framePrint bool //true for printing
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000080}
81
Himani Chawla6d2ae152020-09-02 13:11:20 +053082//callbackPair to be used for ReceiveCallback init
83type callbackPair struct {
Holger Hildebrandtccd390c2020-05-29 13:49:04 +000084 cbKey uint16
Himani Chawla6d2ae152020-09-02 13:11:20 +053085 cbEntry callbackPairEntry
Holger Hildebrandtfa074992020-03-27 15:42:06 +000086}
87
88type omciTransferStructure struct {
mpagenko80622a52021-02-09 16:53:23 +000089 txFrame []byte
90 timeout int
91 retry int
92 highPrio bool
93 withFramePrint bool
Holger Hildebrandtfa074992020-03-27 15:42:06 +000094}
95
Himani Chawla6d2ae152020-09-02 13:11:20 +053096//omciCC structure holds information needed for OMCI communication (to/from OLT Adapter)
97type omciCC struct {
Holger Hildebrandtfa074992020-03-27 15:42:06 +000098 enabled bool
99 pOnuDeviceEntry *OnuDeviceEntry
100 deviceID string
Himani Chawla6d2ae152020-09-02 13:11:20 +0530101 pBaseDeviceHandler *deviceHandler
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000102 coreProxy adapterif.CoreProxy
103 adapterProxy adapterif.AdapterProxy
104 supportExtMsg bool
mpagenkoc8bba412021-01-15 15:38:44 +0000105 rxOmciFrameError tOmciReceiveError
106
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000107 txFrames, txOnuFrames uint32
108 rxFrames, rxOnuFrames, rxOnuDiscards uint32
109
110 // OMCI params
111 mutexTid sync.Mutex
112 tid uint16
113 mutexHpTid sync.Mutex
114 hpTid uint16
115 uploadSequNo uint16
116 uploadNoOfCmds uint16
117
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000118 mutexTxQueue sync.Mutex
119 txQueue *list.List
120 mutexRxSchedMap sync.Mutex
Himani Chawla6d2ae152020-09-02 13:11:20 +0530121 rxSchedulerMap map[uint16]callbackPairEntry
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000122 pLastTxMeInstance *me.ManagedEntity
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000123}
124
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000125var responsesWithMibDataSync = []omci.MessageType{
126 omci.CreateResponseType,
127 omci.DeleteResponseType,
128 omci.SetResponseType,
129 omci.StartSoftwareDownloadResponseType,
130 omci.EndSoftwareDownloadResponseType,
131 omci.ActivateSoftwareResponseType,
132 omci.CommitSoftwareResponseType,
133}
134
Himani Chawla6d2ae152020-09-02 13:11:20 +0530135//newOmciCC constructor returns a new instance of a OmciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000136//mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!)
Himani Chawla6d2ae152020-09-02 13:11:20 +0530137func newOmciCC(ctx context.Context, onuDeviceEntry *OnuDeviceEntry,
138 deviceID string, deviceHandler *deviceHandler,
139 coreProxy adapterif.CoreProxy, adapterProxy adapterif.AdapterProxy) *omciCC {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000140 logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID})
Himani Chawla6d2ae152020-09-02 13:11:20 +0530141 var omciCC omciCC
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000142 omciCC.enabled = false
Himani Chawla4d908332020-08-31 12:30:20 +0530143 omciCC.pOnuDeviceEntry = onuDeviceEntry
144 omciCC.deviceID = deviceID
145 omciCC.pBaseDeviceHandler = deviceHandler
146 omciCC.coreProxy = coreProxy
147 omciCC.adapterProxy = adapterProxy
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000148 omciCC.supportExtMsg = false
mpagenkoc8bba412021-01-15 15:38:44 +0000149 omciCC.rxOmciFrameError = cOmciMessageReceiveNoError
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000150 omciCC.txFrames = 0
151 omciCC.txOnuFrames = 0
152 omciCC.rxFrames = 0
153 omciCC.rxOnuFrames = 0
154 omciCC.rxOnuDiscards = 0
155 omciCC.tid = 0x1
156 omciCC.hpTid = 0x8000
157 omciCC.uploadSequNo = 0
158 omciCC.uploadNoOfCmds = 0
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000159 omciCC.txQueue = list.New()
Himani Chawla6d2ae152020-09-02 13:11:20 +0530160 omciCC.rxSchedulerMap = make(map[uint16]callbackPairEntry)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000161
162 return &omciCC
163}
164
mpagenko900ee4b2020-10-12 11:56:34 +0000165//stop stops/resets the omciCC
166func (oo *omciCC) stop(ctx context.Context) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000167 logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID})
mpagenko900ee4b2020-10-12 11:56:34 +0000168 //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests
169 oo.mutexTxQueue.Lock()
170 oo.txQueue.Init() // clear the tx queue
171 oo.mutexTxQueue.Unlock()
172 oo.mutexRxSchedMap.Lock()
173 for k := range oo.rxSchedulerMap {
174 delete(oo.rxSchedulerMap, k) //clear the scheduler map
175 }
176 oo.mutexRxSchedMap.Unlock()
177 oo.mutexHpTid.Lock()
178 oo.hpTid = 0x8000 //reset the high prio transactionId
179 oo.mutexHpTid.Unlock()
180 oo.mutexTid.Lock()
181 oo.tid = 1 //reset the low prio transactionId
182 oo.mutexTid.Unlock()
183 //reset control values
184 oo.uploadSequNo = 0
185 oo.uploadNoOfCmds = 0
mpagenkoc8bba412021-01-15 15:38:44 +0000186 oo.rxOmciFrameError = cOmciMessageReceiveNoError
mpagenko900ee4b2020-10-12 11:56:34 +0000187 //reset the stats counter - which might be topic of discussion ...
188 oo.txFrames = 0
189 oo.txOnuFrames = 0
190 oo.rxFrames = 0
191 oo.rxOnuFrames = 0
192 oo.rxOnuDiscards = 0
193
194 return nil
195}
196
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000197// Rx handler for omci messages
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530198func (oo *omciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000199 logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000200 "payload": hex.EncodeToString(omciMsg.Payload)})
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530201 switch omciMsg.MessageType {
202 case omci.AlarmNotificationType:
203 data := OmciMessage{
204 OmciMsg: omciMsg,
205 OmciPacket: packet,
206 }
207 go oo.pBaseDeviceHandler.pAlarmMgr.handleOmciAlarmNotificationMessage(ctx, data)
208 return nil
209 default:
210 return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String())
211 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000212 /*
213 msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue
214 rxOnuFrames++
215
216 switch msgType {
217 case AlarmNotification:
218 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000219 logger.Info("Unhandled: received-onu-alarm-message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000220 // python code was:
221 //if msg_type == EntityOperations.AlarmNotification.value:
222 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification)
223 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
224 //
225 return errors.New("RxAlarmNotification unimplemented")
226 }
227 case AttributeValueChange:
228 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000229 logger.Info("Unhandled: received-attribute-value-change")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000230 // python code was:
231 //elif msg_type == EntityOperations.AttributeValueChange.value:
232 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification)
233 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
234 //
235 return errors.New("RxAttributeValueChange unimplemented")
236 }
237 case TestResult:
238 {
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000239 logger.Info("Unhandled: received-test-result")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000240 // python code was:
241 //elif msg_type == EntityOperations.TestResult.value:
242 // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result)
243 // self.reactor.callLater(0, self.event_bus.publish, topic, msg)
244 //
245 return errors.New("RxTestResult unimplemented")
246 }
247 default:
248 {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000249 logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000250 rxOnuDiscards++
251 return errors.New("RxOnuMsgType unimplemented")
252 }
253 }
254 */
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000255}
256
mpagenko80622a52021-02-09 16:53:23 +0000257func (oo *omciCC) printRxMessage(ctx context.Context, rxMsg []byte) {
258 //assuming omci message content is hex coded!
259 // with restricted output of 16bytes would be ...rxMsg[:16]
260 logger.Debugw(ctx, "omci-message-received:", log.Fields{
261 "RxOmciMessage": hex.EncodeToString(rxMsg),
262 "device-id": oo.deviceID})
263}
264
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000265// Rx handler for onu messages
266// e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ...
Himani Chawla6d2ae152020-09-02 13:11:20 +0530267func (oo *omciCC) receiveMessage(ctx context.Context, rxMsg []byte) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000268 //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000269 if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len
270 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
mpagenkoc8bba412021-01-15 15:38:44 +0000271 // (an extendedFormat message could be destroyed this way!)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000272 trailerLenData := rxMsg[42:44]
273 trailerLen := binary.BigEndian.Uint16(trailerLenData)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000274 //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen})
mpagenkoc8bba412021-01-15 15:38:44 +0000275 if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect
276 binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen)
277 if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen {
278 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
279 logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected",
280 log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID})
281 oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen
282 }
283 }
284 } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all!
285 // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!!
286 // (an extendedFormat message could be destroyed this way!)
287 // extend/overwrite with trailer
288 trailer := make([]byte, 8)
289 binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length
290 rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...)
291 if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer {
292 //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries
293 logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)",
294 log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID})
295 oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000296 }
297 } else {
mpagenkoc8bba412021-01-15 15:38:44 +0000298 logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort",
299 log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000300 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200301 return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000302 }
303
304 packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy)
305 if packet == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000306 logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000307 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200308 return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000309 }
310 omciLayer := packet.Layer(omci.LayerTypeOMCI)
311 if omciLayer == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000312 logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000313 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200314 return fmt.Errorf("could not decode omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000315 }
316 omciMsg, ok := omciLayer.(*omci.OMCI)
317 if !ok {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000318 logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID})
mpagenko80622a52021-02-09 16:53:23 +0000319 oo.printRxMessage(ctx, rxMsg)
Andrea Campanella6515c582020-10-05 11:25:00 +0200320 return fmt.Errorf("could not assign omci layer %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000321 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000322 logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType,
mpagenko3dbcdd22020-07-22 07:38:45 +0000323 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier})
Holger Hildebrandt2fb70892020-10-28 11:53:18 +0000324 if byte(omciMsg.MessageType)&me.AK == 0 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000325 // Not a response
mpagenko80622a52021-02-09 16:53:23 +0000326 oo.printRxMessage(ctx, rxMsg)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000327 logger.Debug(ctx, "RxMsg is no Omci Response Message")
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000328 if omciMsg.TransactionID == 0 {
Himani Chawlaac1f5ad2021-02-04 21:21:54 +0530329 return oo.receiveOnuMessage(ctx, omciMsg, &packet)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000330 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000331 logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages",
Andrea Campanella6515c582020-10-05 11:25:00 +0200332 log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload),
mpagenko8b07c1b2020-11-26 10:36:31 +0000333 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200334 return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID)
Himani Chawla4d908332020-08-31 12:30:20 +0530335
336 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000337 //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester")
Himani Chawla4d908332020-08-31 12:30:20 +0530338 oo.mutexRxSchedMap.Lock()
339 rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID]
340 if ok && rxCallbackEntry.cbFunction != nil {
mpagenko80622a52021-02-09 16:53:23 +0000341 if rxCallbackEntry.framePrint {
342 oo.printRxMessage(ctx, rxMsg)
343 }
Himani Chawla4d908332020-08-31 12:30:20 +0530344 //disadvantage of decoupling: error verification made difficult, but anyway the question is
345 // how to react on erroneous frame reception, maybe can simply be ignored
dbainbri4d3a0dc2020-12-02 00:33:42 +0000346 go rxCallbackEntry.cbFunction(ctx, omciMsg, &packet, rxCallbackEntry.cbRespChannel)
Holger Hildebrandt3124e302021-03-23 12:47:03 +0000347 if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +0000348 oo.pOnuDeviceEntry.incrementMibDataSync(ctx)
349 }
mpagenkoc8bba412021-01-15 15:38:44 +0000350
Himani Chawla4d908332020-08-31 12:30:20 +0530351 // having posted the response the request is regarded as 'done'
352 delete(oo.rxSchedulerMap, omciMsg.TransactionID)
353 oo.mutexRxSchedMap.Unlock()
mpagenko80622a52021-02-09 16:53:23 +0000354 return nil
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000355 }
mpagenko80622a52021-02-09 16:53:23 +0000356 oo.mutexRxSchedMap.Unlock()
357 logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID})
358 oo.printRxMessage(ctx, rxMsg)
359 return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000360
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000361 /* py code was:
362 Receive and OMCI message from the proxy channel to the OLT.
363
364 Call this from your ONU Adapter on a new OMCI Rx on the proxy channel
365 :param msg: (str) OMCI binary message (used as input to Scapy packet decoder)
366 """
367 if not self.enabled:
368 return
369
370 try:
371 now = arrow.utcnow()
372 d = None
373
374 # NOTE: Since we may need to do an independent ME map on a per-ONU basis
375 # save the current value of the entity_id_to_class_map, then
376 # replace it with our custom one before decode, and then finally
377 # restore it later. Tried other ways but really made the code messy.
378 saved_me_map = omci_entities.entity_id_to_class_map
379 omci_entities.entity_id_to_class_map = self._me_map
380
381 try:
382 rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg)
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000383 self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000384 except KeyError as e:
385 # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000386 self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000387 rx_frame = self._decode_unknown_me(msg)
388 self._rx_unknown_me += 1
389
390 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000391 self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000392 return
393
394 finally:
395 omci_entities.entity_id_to_class_map = saved_me_map # Always restore it.
396
397 rx_tid = rx_frame.fields['transaction_id']
398 msg_type = rx_frame.fields['message_type']
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000399 self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000400 # Filter the Test Result frame and route through receive onu
401 # message method.
402 if rx_tid == 0 or msg_type == EntityOperations.TestResult.value:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000403 self.logger.debug('Receive ONU message', rx_tid=0)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000404 return self._receive_onu_message(rx_frame)
405
406 # Previously unreachable if this is the very first round-trip Rx or we
407 # have been running consecutive errors
408 if self._rx_frames == 0 or self._consecutive_errors != 0:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000409 self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000410 self.reactor.callLater(0, self._publish_connectivity_event, True)
411
412 self._rx_frames += 1
413 self._consecutive_errors = 0
414
415 try:
416 high_priority = self._tid_is_high_priority(rx_tid)
417 index = self._get_priority_index(high_priority)
418
419 # (timestamp, defer, frame, timeout, retry, delayedCall)
420 last_tx_tuple = self._tx_request[index]
421
422 if last_tx_tuple is None or \
423 last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid:
424 # Possible late Rx on a message that timed-out
425 if last_tx_tuple:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000426 self.logger.debug('Unknown message', rx_tid=rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000427 tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id'))
428 self._rx_unknown_tid += 1
429 self._rx_late += 1
430 return
431
432 ts, d, tx_frame, timeout, retry, dc = last_tx_tuple
433 if dc is not None and not dc.cancelled and not dc.called:
434 dc.cancel()
435
436 _secs = self._update_rx_tx_stats(now, ts)
437
438 # Late arrival already serviced by a timeout?
439 if d.called:
440 self._rx_late += 1
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000441 self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000442 return
443
444 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000445 self.logger.exception('frame-match', msg=hexlify(msg), e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000446 if d is not None:
447 return d.errback(failure.Failure(e))
448 return
449
450 # Publish Rx event to listeners in a different task
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000451 self.logger.debug('Publish rx event', rx_tid = rx_tid,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000452 tx_tid = tx_frame.fields['transaction_id'])
453 reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame)
454
455 # begin success callback chain (will cancel timeout and queue next Tx message)
456 self._rx_response[index] = rx_frame
457 d.callback(rx_frame)
458
459 except Exception as e:
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000460 self.logger.exception('rx-msg', e=e)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000461 */
462}
463
Himani Chawla6d2ae152020-09-02 13:11:20 +0530464/*
465func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error {
Himani Chawla4d908332020-08-31 12:30:20 +0530466 return errors.New("publishRxResponseFrame unimplemented")
Himani Chawla6d2ae152020-09-02 13:11:20 +0530467 //def _publish_rx_frame(self, tx_frame, rx_frame):
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000468}
Himani Chawla6d2ae152020-09-02 13:11:20 +0530469*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000470
471//Queue the OMCI Frame for a transmit to the ONU via the proxy_channel
Himani Chawla6d2ae152020-09-02 13:11:20 +0530472func (oo *omciCC) send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool,
473 receiveCallbackPair callbackPair) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000474
dbainbri4d3a0dc2020-12-02 00:33:42 +0000475 logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.cbKey})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000476 // it could be checked, if the callback keay is already registered - but simply overwrite may be acceptable ...
477 oo.mutexRxSchedMap.Lock()
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000478 oo.rxSchedulerMap[receiveCallbackPair.cbKey] = receiveCallbackPair.cbEntry
mpagenko80622a52021-02-09 16:53:23 +0000479 printFrame := receiveCallbackPair.cbEntry.framePrint //printFrame true means debug print of frame is requested
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000480 oo.mutexRxSchedMap.Unlock()
481
482 //just use a simple list for starting - might need some more effort, especially for multi source write access
483 omciTxRequest := omciTransferStructure{
484 txFrame,
485 timeout,
486 retry,
487 highPrio,
mpagenko80622a52021-02-09 16:53:23 +0000488 printFrame,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000489 }
490 oo.mutexTxQueue.Lock()
491 oo.txQueue.PushBack(omciTxRequest) // enqueue
492 oo.mutexTxQueue.Unlock()
493
494 // for first test just bypass and send directly:
495 go oo.sendNextRequest(ctx)
496 return nil
497}
498
499//Pull next tx request and send it
Himani Chawla6d2ae152020-09-02 13:11:20 +0530500func (oo *omciCC) sendNextRequest(ctx context.Context) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000501 // return errors.New("sendNextRequest unimplemented")
502
503 // just try to get something transferred !!
504 // avoid accessing the txQueue from parallel send requests
505 // block parallel omci send requests at least until SendIAP is 'committed'
506 // that should be feasible for an onu instance as on OMCI anyway window size 1 is assumed
507 oo.mutexTxQueue.Lock()
mpagenkodff5dda2020-08-28 11:52:01 +0000508 defer oo.mutexTxQueue.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000509 for oo.txQueue.Len() > 0 {
510 queueElement := oo.txQueue.Front() // First element
511 omciTxRequest := queueElement.Value.(omciTransferStructure)
512 /* compare olt device handler code:
513 func (dh *DeviceHandler) omciIndication(omciInd *oop.OmciIndication) {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000514 logger.Debugw(ctx,"omci indication", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000515 var deviceType string
516 var deviceID string
517 var proxyDeviceID string
518
519 onuKey := dh.formOnuKey(omciInd.IntfId, omciInd.OnuId)
520
521 if onuInCache, ok := dh.onus.Load(onuKey); !ok {
522
dbainbri4d3a0dc2020-12-02 00:33:42 +0000523 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 +0000524 ponPort := IntfIDToPortNo(omciInd.GetIntfId(), voltha.Port_PON_OLT)
525 kwargs := make(map[string]interface{})
526 kwargs["onu_id"] = omciInd.OnuId
527 kwargs["parent_port_no"] = ponPort
528
dbainbri4d3a0dc2020-12-02 00:33:42 +0000529 onuDevice, err := dh.coreProxy.GetChildDevice(log.WithSpanFromContext(context.TODO(), ctx), dh.device.Id, kwargs)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000530 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000531 logger.Errorw(ctx,"onu not found", log.Fields{"intfID": omciInd.IntfId, "onuID": omciInd.OnuId, "error": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000532 return
533 }
534 deviceType = onuDevice.Type
535 deviceID = onuDevice.Id
536 proxyDeviceID = onuDevice.ProxyAddress.DeviceId
537 //if not exist in cache, then add to cache.
538 dh.onus.Store(onuKey, NewOnuDevice(deviceID, deviceType, onuDevice.SerialNumber, omciInd.OnuId, omciInd.IntfId, proxyDeviceID))
539 } else {
540 //found in cache
dbainbri4d3a0dc2020-12-02 00:33:42 +0000541 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 +0000542 deviceType = onuInCache.(*OnuDevice).deviceType
543 deviceID = onuInCache.(*OnuDevice).deviceID
544 proxyDeviceID = onuInCache.(*OnuDevice).proxyDeviceID
545 }
546 */
547 /* and compare onu_adapter py code:
548 omci_msg = InterAdapterOmciMessage(
549 message=bytes(frame),
550 proxy_address=self._proxy_address,
551 connect_status=self._device.connect_status)
552
Holger Hildebrandt0f9b88d2020-04-20 13:33:25 +0000553 self.logger.debug('sent-omci-msg', tid=tx_tid, omci_msg=hexlify(bytes(frame)))
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000554
555 yield self._adapter_proxy.send_inter_adapter_message(
556 msg=omci_msg,
557 type=InterAdapterMessageType.OMCI_REQUEST,
558 from_adapter=self._device.type,
559 to_adapter=self._proxy_address.device_type,
560 to_device_id=self._device_id,
561 proxy_device_id=self._proxy_address.device_id
562 )
563 */
mpagenko80622a52021-02-09 16:53:23 +0000564 if omciTxRequest.withFramePrint {
565 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
566 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
567 "device-id": oo.deviceID,
568 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
569 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
570 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000571 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000572 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000573 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800574 //fromTopic,toType,toDevId, ProxyDevId
575 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000576 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000577 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000578 return sendErr
579 }
580 oo.txQueue.Remove(queueElement) // Dequeue
581 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000582 return nil
583}
584
Himani Chawla6d2ae152020-09-02 13:11:20 +0530585func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000586 var next uint16
587 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000588 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000589 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530590 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000591 if oo.hpTid < 0x8000 {
592 oo.hpTid = 0x8000
593 }
mpagenko900ee4b2020-10-12 11:56:34 +0000594 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000595 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000596 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000597 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530598 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000599 if oo.tid >= 0x8000 {
600 oo.tid = 1
601 }
mpagenko900ee4b2020-10-12 11:56:34 +0000602 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000603 }
604 return next
605}
606
607// ###################################################################################
608// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000609func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000610 omciLayer := &omci.OMCI{
611 TransactionID: tid,
612 MessageType: msgType,
613 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000614 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000615}
616
dbainbri4d3a0dc2020-12-02 00:33:42 +0000617func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000618 var options gopacket.SerializeOptions
619 options.FixLengths = true
620
621 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530622 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000623 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000624 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000625 return nil, err
626 }
627 return buffer.Bytes(), nil
628}
629
Himani Chawla4d908332020-08-31 12:30:20 +0530630/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000631func hexEncode(omciPkt []byte) ([]byte, error) {
632 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
633 hex.Encode(dst, omciPkt)
634 return dst, nil
635}
Himani Chawla4d908332020-08-31 12:30:20 +0530636*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000637
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000638//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000639func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000640
dbainbri4d3a0dc2020-12-02 00:33:42 +0000641 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000642 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000643
644 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000645 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000646 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200647 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000648 }
649
650 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
651 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000652 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000653 Type: OMCI,
654 Data: OmciMessage{
655 OmciMsg: omciMsg,
656 OmciPacket: packet,
657 },
658 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000659 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000660 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000661
662 return nil
663}
664
Himani Chawla6d2ae152020-09-02 13:11:20 +0530665func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000666
dbainbri4d3a0dc2020-12-02 00:33:42 +0000667 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000668 request := &omci.MibResetRequest{
669 MeBasePacket: omci.MeBasePacket{
670 EntityClass: me.OnuDataClassID,
671 },
672 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530673 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000674 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000675 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000676 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000677 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000678 return err
679 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530680 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000681 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000682 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000683 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530684 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000685}
686
Himani Chawla6d2ae152020-09-02 13:11:20 +0530687func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000688 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300689 request := &omci.RebootRequest{
690 MeBasePacket: omci.MeBasePacket{
691 EntityClass: me.OnuGClassID,
692 },
693 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530694 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000695 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300696 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000697 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000698 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300699 return err
700 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530701 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300702 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000703 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300704 }
705
Himani Chawla6d2ae152020-09-02 13:11:20 +0530706 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300707 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000708 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000709 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300710 return err
711 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000712 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300713 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000714 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200715 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300716 return err
717 }
718 return nil
719}
720
Himani Chawla6d2ae152020-09-02 13:11:20 +0530721func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000722 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000723 request := &omci.MibUploadRequest{
724 MeBasePacket: omci.MeBasePacket{
725 EntityClass: me.OnuDataClassID,
726 },
727 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530728 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000729 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000730 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000731 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000732 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000733 return err
734 }
735 oo.uploadSequNo = 0
736 oo.uploadNoOfCmds = 0
737
Himani Chawla6d2ae152020-09-02 13:11:20 +0530738 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000739 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000740 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000741 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530742 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000743}
744
Himani Chawla6d2ae152020-09-02 13:11:20 +0530745func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000746 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000747 request := &omci.MibUploadNextRequest{
748 MeBasePacket: omci.MeBasePacket{
749 EntityClass: me.OnuDataClassID,
750 },
751 CommandSequenceNumber: oo.uploadSequNo,
752 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530753 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000754 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000755 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000756 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000757 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000758 return err
759 }
760 oo.uploadSequNo++
761
Himani Chawla6d2ae152020-09-02 13:11:20 +0530762 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000763 cbKey: tid,
764 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
765 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
766 // compare also software upgrade download section handling
767 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, false},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000768 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530769 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000770}
771
Himani Chawlad3dac422021-03-13 02:31:31 +0530772func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
773 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
774 request := &omci.GetAllAlarmsRequest{
775 MeBasePacket: omci.MeBasePacket{
776 EntityClass: me.OnuDataClassID,
777 },
778 AlarmRetrievalMode: byte(alarmRetreivalMode),
779 }
780 tid := oo.getNextTid(highPrio)
781 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
782 if err != nil {
783 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
784 "Err": err, "device-id": oo.deviceID})
785 return err
786 }
787 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo = 0
788 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadNoOfCmds = 0
789
790 omciRxCallbackPair := callbackPair{
791 cbKey: tid,
792 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
793 oo.receiveOmciResponse, true},
794 }
795 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
796}
797
798func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
799 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo
800 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
801 "alarmUploadSeqNo": alarmUploadSeqNo})
802 request := &omci.GetAllAlarmsNextRequest{
803 MeBasePacket: omci.MeBasePacket{
804 EntityClass: me.OnuDataClassID,
805 },
806 CommandSequenceNumber: alarmUploadSeqNo,
807 }
808 tid := oo.getNextTid(highPrio)
809 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
810 if err != nil {
811 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
812 "Err": err, "device-id": oo.deviceID})
813 return err
814 }
815 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo++
816
817 omciRxCallbackPair := callbackPair{
818 cbKey: tid,
819 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
820 }
821 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
822}
823
Himani Chawla6d2ae152020-09-02 13:11:20 +0530824func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
825 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000826 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000827 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000828
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000829 meParams := me.ParamData{
830 EntityID: galEthernetEID,
831 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
832 }
833 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
834 if omciErr.GetError() == nil {
835 //all setByCreate parameters already set, no default option required ...
836 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
837 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000838 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000839 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000840 return nil
841 }
842
dbainbri4d3a0dc2020-12-02 00:33:42 +0000843 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000844 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000845 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000846 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000847 return nil
848 }
849
Himani Chawla6d2ae152020-09-02 13:11:20 +0530850 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000851 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000852 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000853 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530854 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000855 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000856 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000857 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000858 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000859 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000860 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000861 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000862 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000863 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000864 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000865 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000866}
867
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000868// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530869func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
870 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000871 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000872 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000873
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000874 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
875 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000876 // By now we just use fix values to fire - this is anyway what the python adapter does
877 // read ONU-2G from DB ???? //TODO!!!
878 meParams := me.ParamData{
879 EntityID: 0,
880 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
881 }
882 meInstance, omciErr := me.NewOnu2G(meParams)
883 if omciErr.GetError() == nil {
884 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
885 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000886 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000887 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000888 return nil
889 }
890
dbainbri4d3a0dc2020-12-02 00:33:42 +0000891 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000892 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000893 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000894 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000895 return nil
896 }
897
Himani Chawla6d2ae152020-09-02 13:11:20 +0530898 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000899 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000900 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000901 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530902 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000903 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000904 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000905 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000906 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000907 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000908 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000909 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000910 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000911 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000912 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000913 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000914}
915
Himani Chawla6d2ae152020-09-02 13:11:20 +0530916func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
917 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
918 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530919 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000920 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000921 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000922
923 meParams := me.ParamData{
924 EntityID: instID,
925 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300926 "Priority": 0x8000,
927 "MaxAge": 20 * 256, //20s
928 "HelloTime": 2 * 256, //2s
929 "ForwardDelay": 15 * 256, //15s
930 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000931 },
932 }
933
934 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
935 if omciErr.GetError() == nil {
936 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
937 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
938 omci.TransactionID(tid), omci.AddDefaults(true))
939 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000940 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000941 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000942 return nil
943 }
944
dbainbri4d3a0dc2020-12-02 00:33:42 +0000945 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000946 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000947 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000948 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000949 return nil
950 }
951
Himani Chawla6d2ae152020-09-02 13:11:20 +0530952 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000953 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000954 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000955 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530956 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000957 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000958 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000959 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000960 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000961 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000962 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000963 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000964 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000965 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000966 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000967 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000968}
969
Himani Chawla6d2ae152020-09-02 13:11:20 +0530970func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
971 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
972 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530973 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000974 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000975 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000976
977 meParams := me.ParamData{
978 EntityID: instID,
979 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530980 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
981 "PortNum": aPUniPort.macBpNo,
982 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530983 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000984 },
985 }
986 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
987 if omciErr.GetError() == nil {
988 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
989 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
990 omci.TransactionID(tid), omci.AddDefaults(true))
991 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000992 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000993 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000994 return nil
995 }
996
dbainbri4d3a0dc2020-12-02 00:33:42 +0000997 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000998 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000999 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001000 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001001 return nil
1002 }
1003
Himani Chawla6d2ae152020-09-02 13:11:20 +05301004 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001005 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001006 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001007 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301008 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001009 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001010 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001011 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001012 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001013 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001014 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001015 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001016 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001017 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001018 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001019 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001020}
1021
Himani Chawla6d2ae152020-09-02 13:11:20 +05301022func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
1023 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
1024 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001025 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301026 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001027 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001028 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001029
1030 // compare python adapter code WA VOL-1311: this is not done here!
1031 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1032 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1033 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301034 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001035 assType = uint8(10) // for VEIP
1036 }
1037 meParams := me.ParamData{
1038 EntityID: instID,
1039 Attributes: me.AttributeValueMap{
1040 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301041 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001042 },
1043 }
1044 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1045 if omciErr.GetError() == nil {
1046 //all setByCreate parameters already set, no default option required ...
1047 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1048 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001049 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001050 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001051 return nil
1052 }
1053
dbainbri4d3a0dc2020-12-02 00:33:42 +00001054 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001055 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001056 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001057 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001058 return nil
1059 }
1060
Himani Chawla6d2ae152020-09-02 13:11:20 +05301061 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001062 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001063 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001064 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301065 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001066 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001067 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001068 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001069 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001070 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001071 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001072 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001073 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001074 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001075 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001076 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001077}
1078
Himani Chawla6d2ae152020-09-02 13:11:20 +05301079func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001080 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301081 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001082 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001083 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001084
1085 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1086 meParams := me.ParamData{
1087 EntityID: 0,
1088 Attributes: requestedAttributes,
1089 }
1090 meInstance, omciErr := me.NewOnuG(meParams)
1091 if omciErr.GetError() == nil {
1092 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1093 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001094 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001095 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001096 return nil
1097 }
1098
dbainbri4d3a0dc2020-12-02 00:33:42 +00001099 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001100 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001101 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001102 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001103 return nil
1104 }
1105
Himani Chawla6d2ae152020-09-02 13:11:20 +05301106 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001107 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001108 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001109 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301110 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001111 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001112 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001113 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001114 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001115 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001116 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001117 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001118 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001119 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001120 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001121 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001122}
1123
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001124func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1125 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1126 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001127 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001128 "SequNo": strconv.FormatInt(int64(tid), 16)})
1129
1130 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1131 meParams := me.ParamData{
1132 EntityID: aInstNo,
1133 Attributes: requestedAttributes,
1134 }
1135 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1136 if omciErr.GetError() == nil {
1137 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1138 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001139 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001140 "Err": err, "device-id": oo.deviceID})
1141 return nil
1142 }
1143
dbainbri4d3a0dc2020-12-02 00:33:42 +00001144 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001145 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001146 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001147 "Err": err, "device-id": oo.deviceID})
1148 return nil
1149 }
1150
1151 omciRxCallbackPair := callbackPair{
1152 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001153 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001154 }
1155 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1156 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001157 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001158 "Err": err, "device-id": oo.deviceID})
1159 return nil
1160 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001161 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001162 return meInstance
1163 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001164 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001165 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1166 return nil
1167}
1168
1169/* UniG obsolete by now, left here in case it should be needed once again
1170 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301171func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001172 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301173 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001174 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001175 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001176
1177 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1178 meParams := me.ParamData{
1179 EntityID: aInstNo,
1180 Attributes: requestedAttributes,
1181 }
1182 meInstance, omciErr := me.NewUniG(meParams)
1183 if omciErr.GetError() == nil {
1184 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1185 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001186 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001187 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001188 return nil
1189 }
1190
1191 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1192 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001193 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001194 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001195 return nil
1196 }
1197
Himani Chawla6d2ae152020-09-02 13:11:20 +05301198 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001199 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001200 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001201 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301202 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001203 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001204 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001205 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001206 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001207 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001208 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001209 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001210 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001211 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001212 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001213 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001214}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001215*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001216
Himani Chawla6d2ae152020-09-02 13:11:20 +05301217func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001218 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301219 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001221 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001222
1223 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1224 meParams := me.ParamData{
1225 EntityID: aInstNo,
1226 Attributes: requestedAttributes,
1227 }
1228 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1229 if omciErr.GetError() == nil {
1230 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1231 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001232 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001233 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001234 return nil
1235 }
1236
dbainbri4d3a0dc2020-12-02 00:33:42 +00001237 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001238 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001239 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001240 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001241 return nil
1242 }
1243
Himani Chawla6d2ae152020-09-02 13:11:20 +05301244 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001245 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001246 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001247 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301248 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001249 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001250 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001251 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001252 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001253 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001254 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001255 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001256 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001257 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001258 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001259 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001260}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001261
Himani Chawla6d2ae152020-09-02 13:11:20 +05301262func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001263 timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001264
Himani Chawla6d2ae152020-09-02 13:11:20 +05301265 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001267 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001268
1269 meParams := me.ParamData{
1270 EntityID: entityID,
1271 Attributes: requestedAttributes,
1272 }
1273 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1274 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301275 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001276 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1277 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001278 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 +00001279 return nil
1280 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001281 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001282 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001283 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001284 return nil
1285 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301286 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001287 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001288 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001289 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301290 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001291 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001292 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 +00001293 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001294 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001295 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001296 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001297 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001298 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001299 return nil
1300}
1301
Himani Chawla6d2ae152020-09-02 13:11:20 +05301302func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001303 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301304 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001305 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001306 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1307
1308 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001309 EntityID: aInstID,
1310 Attributes: me.AttributeValueMap{
1311 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1312 "TpPointer": 0xFFFF,
1313 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1314 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1315 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1316 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1317 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1318 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1319 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1320 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1321 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001322 }
1323 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1324 if omciErr.GetError() == nil {
1325 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1326 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1327 omci.TransactionID(tid), omci.AddDefaults(true))
1328 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001329 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001330 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001331 return nil
1332 }
1333
dbainbri4d3a0dc2020-12-02 00:33:42 +00001334 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001335 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001336 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001337 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001338 return nil
1339 }
1340
Himani Chawla6d2ae152020-09-02 13:11:20 +05301341 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001342 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001343 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001344 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301345 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001346 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001347 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001348 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001349 return nil
1350 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001351 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001352 return meInstance
1353 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001354 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001355 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001356 return nil
1357}
1358
Himani Chawla6d2ae152020-09-02 13:11:20 +05301359func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001360 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301361 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001362 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001363 "SequNo": strconv.FormatInt(int64(tid), 16),
1364 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1365
1366 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1367 if omciErr.GetError() == nil {
1368 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1369 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1370 omci.TransactionID(tid), omci.AddDefaults(true))
1371 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001372 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001373 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001374 return nil
1375 }
1376
dbainbri4d3a0dc2020-12-02 00:33:42 +00001377 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001378 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001379 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001380 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001381 return nil
1382 }
1383
Himani Chawla6d2ae152020-09-02 13:11:20 +05301384 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001385 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001386 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001387 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301388 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001389 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001390 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001391 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001392 return nil
1393 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001394 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001395 return meInstance
1396 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001397 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001398 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001399 return nil
1400}
1401
Himani Chawla6d2ae152020-09-02 13:11:20 +05301402func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001403 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301404 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001405 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001406 "SequNo": strconv.FormatInt(int64(tid), 16),
1407 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1408
1409 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1410 if omciErr.GetError() == nil {
1411 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1412 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1413 omci.TransactionID(tid), omci.AddDefaults(true))
1414 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001415 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001416 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001417 return nil
1418 }
1419
dbainbri4d3a0dc2020-12-02 00:33:42 +00001420 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001421 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001422 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001423 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001424 return nil
1425 }
1426
Himani Chawla6d2ae152020-09-02 13:11:20 +05301427 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001428 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001429 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001430 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301431 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001432 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001433 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001434 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001435 return nil
1436 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001437 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001438 return meInstance
1439 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001440 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001441 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001442 return nil
1443}
1444
Himani Chawla6d2ae152020-09-02 13:11:20 +05301445func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001446 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301447 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001448 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001449 "SequNo": strconv.FormatInt(int64(tid), 16),
1450 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1451
1452 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1453 if omciErr.GetError() == nil {
1454 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1455 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1456 omci.TransactionID(tid))
1457 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001458 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001459 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001460 return nil
1461 }
1462
dbainbri4d3a0dc2020-12-02 00:33:42 +00001463 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001464 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001465 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001466 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001467 return nil
1468 }
1469
Himani Chawla6d2ae152020-09-02 13:11:20 +05301470 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001471 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001472 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001473 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301474 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001475 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001476 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001477 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001478 return nil
1479 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001480 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001481 return meInstance
1482 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001483 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001484 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001485 return nil
1486}
1487
Himani Chawla6d2ae152020-09-02 13:11:20 +05301488func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001489 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301490 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001491 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001492 "SequNo": strconv.FormatInt(int64(tid), 16),
1493 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1494
1495 meInstance, omciErr := me.NewTCont(params[0])
1496 if omciErr.GetError() == nil {
1497 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1498 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001499 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001500 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 return nil
1502 }
1503
dbainbri4d3a0dc2020-12-02 00:33:42 +00001504 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001505 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001506 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001507 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001508 return nil
1509 }
1510
Himani Chawla6d2ae152020-09-02 13:11:20 +05301511 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001512 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001513 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001514 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301515 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001516 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001517 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001518 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001519 return nil
1520 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001521 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001522 return meInstance
1523 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001524 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001525 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001526 return nil
1527}
1528
Himani Chawla6d2ae152020-09-02 13:11:20 +05301529func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001530 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301531 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001532 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001533 "SequNo": strconv.FormatInt(int64(tid), 16),
1534 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1535
1536 meInstance, omciErr := me.NewPriorityQueue(params[0])
1537 if omciErr.GetError() == nil {
1538 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1539 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001540 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001541 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001542 return nil
1543 }
1544
dbainbri4d3a0dc2020-12-02 00:33:42 +00001545 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001546 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001547 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001548 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001549 return nil
1550 }
1551
Himani Chawla6d2ae152020-09-02 13:11:20 +05301552 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001553 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001554 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001555 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301556 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001557 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001558 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001559 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001560 return nil
1561 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001562 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001563 return meInstance
1564 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001565 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001566 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001567 return nil
1568}
1569
Himani Chawla6d2ae152020-09-02 13:11:20 +05301570func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001571 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301572 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001573 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001574 "SequNo": strconv.FormatInt(int64(tid), 16),
1575 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1576
1577 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1578 if omciErr.GetError() == nil {
1579 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1580 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001581 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001582 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001583 return nil
1584 }
1585
dbainbri4d3a0dc2020-12-02 00:33:42 +00001586 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001587 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001588 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001589 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001590 return nil
1591 }
1592
Himani Chawla6d2ae152020-09-02 13:11:20 +05301593 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001594 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001595 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001596 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301597 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001598 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001599 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001600 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001601 return nil
1602 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001603 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001604 return meInstance
1605 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001606 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001607 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001608 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001609}
mpagenkodff5dda2020-08-28 11:52:01 +00001610
Himani Chawla6d2ae152020-09-02 13:11:20 +05301611func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001612 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301613 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001614 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001615 "SequNo": strconv.FormatInt(int64(tid), 16),
1616 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1617
1618 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1619 if omciErr.GetError() == nil {
1620 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1621 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1622 omci.TransactionID(tid))
1623 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001624 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001625 "Err": err, "device-id": oo.deviceID})
1626 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1627 // return (dual format) error code that can be used at caller for immediate error treatment
1628 // (relevant to all used sendXX() methods and their error conditions)
1629 return nil
1630 }
1631
dbainbri4d3a0dc2020-12-02 00:33:42 +00001632 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001633 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001634 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001635 "Err": err, "device-id": oo.deviceID})
1636 return nil
1637 }
1638
Himani Chawla6d2ae152020-09-02 13:11:20 +05301639 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001640 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001641 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001642 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301643 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001644 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001645 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001646 "Err": err, "device-id": oo.deviceID})
1647 return nil
1648 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001649 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001650 return meInstance
1651 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001652 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001653 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1654 return nil
1655}
1656
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001657// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001658func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1659 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1660 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001662 "SequNo": strconv.FormatInt(int64(tid), 16),
1663 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1664
1665 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1666 if omciErr.GetError() == nil {
1667 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1668 omci.TransactionID(tid))
1669 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001670 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001671 "Err": err, "device-id": oo.deviceID})
1672 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1673 // return (dual format) error code that can be used at caller for immediate error treatment
1674 // (relevant to all used sendXX() methods and their error conditions)
1675 return nil
1676 }
1677
dbainbri4d3a0dc2020-12-02 00:33:42 +00001678 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001679 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001680 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001681 "Err": err, "device-id": oo.deviceID})
1682 return nil
1683 }
1684
1685 omciRxCallbackPair := callbackPair{
1686 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001687 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001688 }
1689 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1690 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001691 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001692 "Err": err, "device-id": oo.deviceID})
1693 return nil
1694 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001695 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001696 return meInstance
1697 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001698 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001699 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1700 return nil
1701}
1702
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001703func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1704 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1705 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001706 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001707 "SequNo": strconv.FormatInt(int64(tid), 16),
1708 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1709
1710 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1711 if omciErr.GetError() == nil {
1712 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1713 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001714 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001715 "Err": err, "device-id": oo.deviceID})
1716 return nil
1717 }
1718
dbainbri4d3a0dc2020-12-02 00:33:42 +00001719 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001720 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001721 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001722 "Err": err, "device-id": oo.deviceID})
1723 return nil
1724 }
1725
1726 omciRxCallbackPair := callbackPair{
1727 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001728 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001729 }
1730 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1731 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001732 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001733 "Err": err, "device-id": oo.deviceID})
1734 return nil
1735 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001736 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001737 return meInstance
1738 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001739 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001740 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1741 return nil
1742}
1743
Himani Chawla6d2ae152020-09-02 13:11:20 +05301744func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001745 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301746 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001747 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001748 "SequNo": strconv.FormatInt(int64(tid), 16),
1749 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1750
1751 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1752 if omciErr.GetError() == nil {
1753 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1754 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001755 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001756 "Err": err, "device-id": oo.deviceID})
1757 return nil
1758 }
1759
dbainbri4d3a0dc2020-12-02 00:33:42 +00001760 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001761 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001762 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001763 "Err": err, "device-id": oo.deviceID})
1764 return nil
1765 }
1766
Himani Chawla6d2ae152020-09-02 13:11:20 +05301767 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001768 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001769 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001770 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301771 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001772 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001773 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001774 "Err": err, "device-id": oo.deviceID})
1775 return nil
1776 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001777 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001778 return meInstance
1779 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001780 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001781 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1782 return nil
1783}
mpagenko01e726e2020-10-23 09:45:29 +00001784
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001785func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1786 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1787 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001788 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001789 "SequNo": strconv.FormatInt(int64(tid), 16),
1790 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1791
1792 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1793 if omciErr.GetError() == nil {
1794 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1795 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001796 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001797 "Err": err, "device-id": oo.deviceID})
1798 return nil
1799 }
1800
dbainbri4d3a0dc2020-12-02 00:33:42 +00001801 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001802 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001803 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001804 "Err": err, "device-id": oo.deviceID})
1805 return nil
1806 }
1807
1808 omciRxCallbackPair := callbackPair{
1809 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001810 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001811 }
1812 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1813 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001814 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001815 "Err": err, "device-id": oo.deviceID})
1816 return nil
1817 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001818 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001819 return meInstance
1820 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001821 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001822 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1823 return nil
1824}
1825
mpagenko01e726e2020-10-23 09:45:29 +00001826func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1827 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1828 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001829 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001830 "SequNo": strconv.FormatInt(int64(tid), 16),
1831 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1832
1833 meParams := me.ParamData{EntityID: aInstID}
1834 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1835 if omciErr.GetError() == nil {
1836 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1837 omci.TransactionID(tid))
1838 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001839 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001840 "Err": err, "device-id": oo.deviceID})
1841 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1842 // return (dual format) error code that can be used at caller for immediate error treatment
1843 // (relevant to all used sendXX() methods and their error conditions)
1844 return nil
1845 }
1846
dbainbri4d3a0dc2020-12-02 00:33:42 +00001847 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001848 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001849 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001850 "Err": err, "device-id": oo.deviceID})
1851 return nil
1852 }
1853
1854 omciRxCallbackPair := callbackPair{
1855 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001856 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001857 }
1858 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1859 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001860 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001861 "Err": err, "device-id": oo.deviceID})
1862 return nil
1863 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001864 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001865 return meInstance
1866 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001867 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001868 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1869 return nil
1870}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001871
ozgecanetsiab6441962021-03-10 10:58:48 +03001872// nolint: unused
1873func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
1874 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1875 tid := oo.getNextTid(highPrio)
1876 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1877 "SequNo": strconv.FormatInt(int64(tid), 16),
1878 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1879 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1880 if omciErr.GetError() == nil {
1881 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1882 if err != nil {
1883 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
1884 return nil
1885 }
1886 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1887 if err != nil {
1888 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
1889 return nil
1890 }
1891 omciRxCallbackPair := callbackPair{
1892 cbKey: tid,
1893 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1894 }
1895 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1896 if err != nil {
1897 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
1898 return nil
1899 }
1900 logger.Debug(ctx, "send TD-Create-msg done")
1901 return meInstance
1902 }
1903 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1904 return nil
1905}
1906
1907// nolint: unused
1908func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
1909 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1910 tid := oo.getNextTid(highPrio)
1911 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1912 "SequNo": strconv.FormatInt(int64(tid), 16),
1913 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1914
1915 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1916 if omciErr.GetError() == nil {
1917 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1918 if err != nil {
1919 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
1920 return nil
1921 }
1922 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1923 if err != nil {
1924 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
1925 return nil
1926 }
1927 omciRxCallbackPair := callbackPair{
1928 cbKey: tid,
1929 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1930 }
1931 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1932 if err != nil {
1933 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
1934 return nil
1935 }
1936 logger.Debug(ctx, "send TD-Set-msg done")
1937 return meInstance
1938 }
1939 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1940 return nil
1941
1942}
1943
1944// nolint: unused
1945func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
1946 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1947 tid := oo.getNextTid(highPrio)
1948 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1949 "SequNo": strconv.FormatInt(int64(tid), 16),
1950 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1951
1952 meParams := me.ParamData{EntityID: aInstID}
1953 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1954 if omciErr.GetError() == nil {
1955 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1956 if err != nil {
1957 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1958 return nil
1959 }
1960 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1961 if err != nil {
1962 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1963 return nil
1964 }
1965 omciRxCallbackPair := callbackPair{
1966 cbKey: tid,
1967 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1968 }
1969 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1970 if err != nil {
1971 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1972 return nil
1973 }
1974 logger.Debug(ctx, "send TD-Delete-msg done")
1975 return meInstance
1976 }
1977 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1978 return nil
1979
1980}
1981
mpagenko8b07c1b2020-11-26 10:36:31 +00001982func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1983 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1984 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001985 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001986 "SequNo": strconv.FormatInt(int64(tid), 16),
1987 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1988
1989 meParams := me.ParamData{EntityID: aInstID}
1990 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
1991 if omciErr.GetError() == nil {
1992 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1993 omci.TransactionID(tid))
1994 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001995 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00001996 "Err": err, "device-id": oo.deviceID})
1997 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1998 // return (dual format) error code that can be used at caller for immediate error treatment
1999 // (relevant to all used sendXX() methods and their error conditions)
2000 return nil
2001 }
2002
dbainbri4d3a0dc2020-12-02 00:33:42 +00002003 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002004 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002005 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002006 "Err": err, "device-id": oo.deviceID})
2007 return nil
2008 }
2009
2010 omciRxCallbackPair := callbackPair{
2011 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002012 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002013 }
2014 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2015 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002016 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002017 "Err": err, "device-id": oo.deviceID})
2018 return nil
2019 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002020 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002021 return meInstance
2022 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002023 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002024 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2025 return nil
2026}
2027
2028func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
2029 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2030 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002031 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002032 "SequNo": strconv.FormatInt(int64(tid), 16),
2033 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2034
2035 meParams := me.ParamData{EntityID: aInstID}
2036 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2037 if omciErr.GetError() == nil {
2038 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2039 omci.TransactionID(tid))
2040 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002041 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002042 "Err": err, "device-id": oo.deviceID})
2043 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2044 // return (dual format) error code that can be used at caller for immediate error treatment
2045 // (relevant to all used sendXX() methods and their error conditions)
2046 return nil
2047 }
2048
dbainbri4d3a0dc2020-12-02 00:33:42 +00002049 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002050 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002051 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002052 "Err": err, "device-id": oo.deviceID})
2053 return nil
2054 }
2055
2056 omciRxCallbackPair := callbackPair{
2057 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002058 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002059 }
2060 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2061 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002062 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002063 "Err": err, "device-id": oo.deviceID})
2064 return nil
2065 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002066 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002067 return meInstance
2068 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002069 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002070 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2071 return nil
2072}
2073
2074func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
2075 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2076 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002077 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002078 "SequNo": strconv.FormatInt(int64(tid), 16),
2079 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2080
2081 meParams := me.ParamData{EntityID: aInstID}
2082 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2083 if omciErr.GetError() == nil {
2084 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2085 omci.TransactionID(tid))
2086 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002087 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002088 "Err": err, "device-id": oo.deviceID})
2089 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2090 // return (dual format) error code that can be used at caller for immediate error treatment
2091 // (relevant to all used sendXX() methods and their error conditions)
2092 return nil
2093 }
2094
dbainbri4d3a0dc2020-12-02 00:33:42 +00002095 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002096 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002097 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002098 "Err": err, "device-id": oo.deviceID})
2099 return nil
2100 }
2101
2102 omciRxCallbackPair := callbackPair{
2103 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002104 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002105 }
2106 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2107 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002108 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002109 "Err": err, "device-id": oo.deviceID})
2110 return nil
2111 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002112 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002113 return meInstance
2114 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002115 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002116 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2117 return nil
2118}
2119
2120func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
2121 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2122 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002123 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002124 "SequNo": strconv.FormatInt(int64(tid), 16),
2125 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2126
2127 meParams := me.ParamData{EntityID: aInstID}
2128 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2129 if omciErr.GetError() == nil {
2130 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2131 omci.TransactionID(tid))
2132 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002133 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002134 "Err": err, "device-id": oo.deviceID})
2135 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2136 // return (dual format) error code that can be used at caller for immediate error treatment
2137 // (relevant to all used sendXX() methods and their error conditions)
2138 return nil
2139 }
2140
dbainbri4d3a0dc2020-12-02 00:33:42 +00002141 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002142 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002143 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002144 "Err": err, "device-id": oo.deviceID})
2145 return nil
2146 }
2147
2148 omciRxCallbackPair := callbackPair{
2149 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002150 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002151 }
2152 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2153 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002154 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002155 "Err": err, "device-id": oo.deviceID})
2156 return nil
2157 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002158 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002159 return meInstance
2160 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002161 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002162 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2163 return nil
2164}
2165
ozgecanetsia422dbf32020-10-28 14:07:19 +03002166func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2167 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2168 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002169 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002170 "SequNo": strconv.FormatInt(int64(tid), 16),
2171 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2172
2173 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2174 if omciErr.GetError() == nil {
2175 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2176 omci.AddDefaults(true))
2177 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002178 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002179 return nil
2180 }
2181
dbainbri4d3a0dc2020-12-02 00:33:42 +00002182 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002183 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002184 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002185 return nil
2186 }
2187
2188 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002189 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002190 }
2191 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2192 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002193 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002194 return nil
2195 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002196 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002197 return meInstance
2198 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002199 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002200 "device-id": oo.deviceID})
2201 return nil
2202}
2203
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002204func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2205 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2206 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002207 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002208 "SequNo": strconv.FormatInt(int64(tid), 16),
2209 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2210
2211 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2212 if omciErr.GetError() == nil {
2213 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2214 omci.AddDefaults(true))
2215 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002216 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002217 return nil
2218 }
2219
dbainbri4d3a0dc2020-12-02 00:33:42 +00002220 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002221 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002222 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002223 return nil
2224 }
2225
2226 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002227 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002228 }
2229 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2230 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002231 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002232 return nil
2233 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002234 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002235 return meInstance
2236 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002237 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002238 "device-id": oo.deviceID})
2239 return nil
2240}
2241
ozgecanetsia422dbf32020-10-28 14:07:19 +03002242func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2243 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2244 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002245 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002246 "SequNo": strconv.FormatInt(int64(tid), 16),
2247 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2248
2249 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2250 if omciErr.GetError() == nil {
2251 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2252 omci.AddDefaults(true))
2253 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002254 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002255 "device-id": oo.deviceID})
2256 return nil
2257 }
2258
dbainbri4d3a0dc2020-12-02 00:33:42 +00002259 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002260 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002261 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002262 "device-id": oo.deviceID})
2263 return nil
2264 }
2265
2266 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002267 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002268 }
2269 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2270 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002271 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002272 "device-id": oo.deviceID})
2273 return nil
2274 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002275 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002276 return meInstance
2277 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002278 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002279 "device-id": oo.deviceID})
2280 return nil
2281}
2282
2283func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2284 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2285 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002286 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002287 "SequNo": strconv.FormatInt(int64(tid), 16),
2288 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2289
2290 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2291 if omciErr.GetError() == nil {
2292 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2293 omci.AddDefaults(true))
2294 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002295 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002296 "device-id": oo.deviceID})
2297 return nil
2298 }
2299
dbainbri4d3a0dc2020-12-02 00:33:42 +00002300 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002301 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002302 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002303 "device-id": oo.deviceID})
2304 return nil
2305 }
2306
2307 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002308 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002309 }
2310 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2311 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002312 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002313 "device-id": oo.deviceID})
2314 return nil
2315 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002316 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002317 return meInstance
2318 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002319 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002320 "device-id": oo.deviceID})
2321 return nil
2322}
2323
2324func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2325 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2326 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002327 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002328 "SequNo": strconv.FormatInt(int64(tid), 16),
2329 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2330
2331 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2332 if omciErr.GetError() == nil {
2333 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2334 omci.AddDefaults(true))
2335 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002337 "device-id": oo.deviceID})
2338 return nil
2339 }
2340
dbainbri4d3a0dc2020-12-02 00:33:42 +00002341 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002342 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002343 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002344 "device-id": oo.deviceID})
2345 return nil
2346 }
2347
2348 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002349 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002350 }
2351 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2352 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002353 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002354 "device-id": oo.deviceID})
2355 return nil
2356 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002357 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002358 return meInstance
2359 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002360 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002361 "device-id": oo.deviceID})
2362 return nil
2363}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002364
Girish Gowdrae0140f02021-02-02 16:55:09 -08002365func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2366 tid := oo.getNextTid(highPrio)
2367 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2368 "SequNo": strconv.FormatInt(int64(tid), 16)})
2369
2370 omciLayer := &omci.OMCI{
2371 TransactionID: tid,
2372 MessageType: omci.SynchronizeTimeRequestType,
2373 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2374 // Length: 0x28, // Optional, defaults to 40 octets
2375 }
2376 utcTime := time.Now().UTC()
2377 request := &omci.SynchronizeTimeRequest{
2378 MeBasePacket: omci.MeBasePacket{
2379 EntityClass: me.OnuGClassID,
2380 // Default Instance ID is 0
2381 },
2382 Year: uint16(utcTime.Year()),
2383 Month: uint8(utcTime.Month()),
2384 Day: uint8(utcTime.Day()),
2385 Hour: uint8(utcTime.Hour()),
2386 Minute: uint8(utcTime.Minute()),
2387 Second: uint8(utcTime.Second()),
2388 }
2389
2390 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2391 if err != nil {
2392 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2393 "device-id": oo.deviceID})
2394 return err
2395 }
2396
2397 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002398 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002399 }
2400 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2401 if err != nil {
2402 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2403 "device-id": oo.deviceID})
2404 return err
2405 }
2406 logger.Debug(ctx, "send synchronize time request done")
2407 return nil
2408}
2409
2410func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
2411 upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2412 tid := oo.getNextTid(highPrio)
2413 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2414 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2415 meParam := me.ParamData{EntityID: entityID}
2416 var meInstance *me.ManagedEntity
2417 var omciErr me.OmciErrors
2418 if upstream {
2419 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2420 } else {
2421 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2422 }
2423 if omciErr.GetError() == nil {
2424 var omciLayer *omci.OMCI
2425 var msgLayer gopacket.SerializableLayer
2426 var err error
2427 if create {
2428 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2429 omci.AddDefaults(true))
2430 } else {
2431 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2432 omci.AddDefaults(true))
2433 }
2434 if err != nil {
2435 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2436 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2437 return nil
2438 }
2439
2440 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2441 if err != nil {
2442 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2443 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2444 return nil
2445 }
2446
2447 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002448 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002449 }
2450 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2451 if err != nil {
2452 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2453 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2454 return nil
2455 }
2456 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2457 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2458 return meInstance
2459 }
2460 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2461 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2462 return nil
2463}
2464
2465func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
2466 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2467 tid := oo.getNextTid(highPrio)
2468 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2469 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2470 meParam := me.ParamData{EntityID: entityID}
2471 var meInstance *me.ManagedEntity
2472 var omciErr me.OmciErrors
2473 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2474
2475 if omciErr.GetError() == nil {
2476 var omciLayer *omci.OMCI
2477 var msgLayer gopacket.SerializableLayer
2478 var err error
2479 if create {
2480 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2481 omci.AddDefaults(true))
2482 } else {
2483 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2484 omci.AddDefaults(true))
2485 }
2486 if err != nil {
2487 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2488 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2489 return nil
2490 }
2491
2492 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2493 if err != nil {
2494 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2495 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2496 return nil
2497 }
2498
2499 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002500 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002501 }
2502 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2503 if err != nil {
2504 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2505 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2506 return nil
2507 }
2508 logger.Debugw(ctx, "send ethernet uni history data ME done",
2509 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2510 return meInstance
2511 }
2512 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2513 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2514 return nil
2515}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002516
2517func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
2518 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2519 tid := oo.getNextTid(highPrio)
2520 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2521 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2522 meParam := me.ParamData{EntityID: entityID}
2523 var meInstance *me.ManagedEntity
2524 var omciErr me.OmciErrors
2525 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2526
2527 if omciErr.GetError() == nil {
2528 var omciLayer *omci.OMCI
2529 var msgLayer gopacket.SerializableLayer
2530 var err error
2531 if create {
2532 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2533 omci.AddDefaults(true))
2534 } else {
2535 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2536 omci.AddDefaults(true))
2537 }
2538 if err != nil {
2539 logger.Errorw(ctx, "Cannot encode fec history data ME",
2540 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2541 return nil
2542 }
2543
2544 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2545 if err != nil {
2546 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2547 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2548 return nil
2549 }
2550
2551 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002552 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002553 }
2554 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2555 if err != nil {
2556 logger.Errorw(ctx, "Cannot send fec history data ME",
2557 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2558 return nil
2559 }
2560 logger.Debugw(ctx, "send fec history data ME done",
2561 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2562 return meInstance
2563 }
2564 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2565 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2566 return nil
2567}
2568
2569func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
2570 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2571 tid := oo.getNextTid(highPrio)
2572 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2573 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2574 meParam := me.ParamData{EntityID: entityID}
2575 var meInstance *me.ManagedEntity
2576 var omciErr me.OmciErrors
2577 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2578
2579 if omciErr.GetError() == nil {
2580 var omciLayer *omci.OMCI
2581 var msgLayer gopacket.SerializableLayer
2582 var err error
2583 if create {
2584 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2585 omci.AddDefaults(true))
2586 } else {
2587 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2588 omci.AddDefaults(true))
2589 }
2590 if err != nil {
2591 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2592 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2593 return nil
2594 }
2595
2596 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2597 if err != nil {
2598 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2599 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2600 return nil
2601 }
2602
2603 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002604 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002605 }
2606 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2607 if err != nil {
2608 logger.Errorw(ctx, "Cannot send gemport history data ME",
2609 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2610 return nil
2611 }
2612 logger.Debugw(ctx, "send gemport history data ME done",
2613 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2614 return meInstance
2615 }
2616 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2617 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2618 return nil
2619}
2620
mpagenko80622a52021-02-09 16:53:23 +00002621func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2622 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2623 tid := oo.getNextTid(highPrio)
2624 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2625 "SequNo": strconv.FormatInt(int64(tid), 16),
2626 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2627
2628 omciLayer := &omci.OMCI{
2629 TransactionID: tid,
2630 MessageType: omci.StartSoftwareDownloadRequestType,
2631 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2632 // Length: 0x28, // Optional, defaults to 40 octets
2633 }
2634 request := &omci.StartSoftwareDownloadRequest{
2635 MeBasePacket: omci.MeBasePacket{
2636 EntityClass: me.SoftwareImageClassID,
2637 EntityInstance: aImageMeID, //inactive image
2638 },
2639 WindowSize: aDownloadWindowSize,
2640 ImageSize: aFileLen,
2641 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2642 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2643 }
2644
2645 var options gopacket.SerializeOptions
2646 options.FixLengths = true
2647 buffer := gopacket.NewSerializeBuffer()
2648 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2649 if err != nil {
2650 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2651 "device-id": oo.deviceID})
2652 return err
2653 }
2654 outgoingPacket := buffer.Bytes()
2655
2656 omciRxCallbackPair := callbackPair{cbKey: tid,
2657 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2658 }
2659 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2660 if err != nil {
2661 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2662 "device-id": oo.deviceID})
2663 return err
2664 }
2665 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002666 return nil
2667}
2668
2669func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool,
2670 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2671 tid := oo.getNextTid(highPrio)
2672 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2673 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002674 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002675
2676 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2677 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002678 msgType := omci.DownloadSectionRequestType
2679 if aAckRequest > 0 {
2680 msgType = omci.DownloadSectionRequestWithResponseType
2681 }
mpagenko80622a52021-02-09 16:53:23 +00002682 omciLayer := &omci.OMCI{
2683 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002684 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002685 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2686 // Length: 0x28, // Optional, defaults to 40 octets
2687 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002688 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002689 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002690 request := &omci.DownloadSectionRequest{
2691 MeBasePacket: omci.MeBasePacket{
2692 EntityClass: me.SoftwareImageClassID,
2693 EntityInstance: aImageMeID, //inactive image
2694 },
2695 SectionNumber: aDownloadSectionNo,
2696 SectionData: localSectionData,
2697 }
2698
2699 var options gopacket.SerializeOptions
2700 options.FixLengths = true
2701 buffer := gopacket.NewSerializeBuffer()
2702 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2703 if err != nil {
2704 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2705 "device-id": oo.deviceID})
2706 return err
2707 }
2708 outgoingPacket := buffer.Bytes()
2709
mpagenko15ff4a52021-03-02 10:09:20 +00002710 //for initial debug purpose overrule the requested print state for some frames
2711 printFrame := aPrint
2712 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2713 printFrame = true
2714 }
2715
mpagenko80622a52021-02-09 16:53:23 +00002716 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002717 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002718 }
2719 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2720 if err != nil {
2721 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2722 "device-id": oo.deviceID})
2723 return err
2724 }
2725 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002726 return nil
2727}
2728
2729func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2730 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2731 tid := oo.getNextTid(highPrio)
2732 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2733 "SequNo": strconv.FormatInt(int64(tid), 16),
2734 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2735
mpagenko15ff4a52021-03-02 10:09:20 +00002736 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002737 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002738 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002739 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2740 // Length: 0x28, // Optional, defaults to 40 octets
2741 }
mpagenko15ff4a52021-03-02 10:09:20 +00002742 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002743 MeBasePacket: omci.MeBasePacket{
2744 EntityClass: me.SoftwareImageClassID,
2745 EntityInstance: aImageMeID, //inactive image
2746 },
mpagenko15ff4a52021-03-02 10:09:20 +00002747 CRC32: aImageCrc,
2748 ImageSize: aFileLen,
2749 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2750 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002751 }
mpagenko15ff4a52021-03-02 10:09:20 +00002752
2753 var options gopacket.SerializeOptions
2754 options.FixLengths = true
2755 buffer := gopacket.NewSerializeBuffer()
2756 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2757 if err != nil {
2758 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002759 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002760 return err
mpagenko80622a52021-02-09 16:53:23 +00002761 }
mpagenko15ff4a52021-03-02 10:09:20 +00002762 outgoingPacket := buffer.Bytes()
2763
2764 omciRxCallbackPair := callbackPair{cbKey: tid,
2765 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2766 }
2767 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2768 if err != nil {
2769 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2770 "device-id": oo.deviceID})
2771 return err
2772 }
2773 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002774 return nil
2775}
2776
2777func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2778 rxChan chan Message, aImageMeID uint16) error {
2779 tid := oo.getNextTid(highPrio)
2780 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2781 "SequNo": strconv.FormatInt(int64(tid), 16),
2782 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2783
2784 omciLayer := &omci.OMCI{
2785 TransactionID: tid,
2786 MessageType: omci.ActivateSoftwareRequestType,
2787 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2788 // Length: 0x28, // Optional, defaults to 40 octets
2789 }
2790 request := &omci.ActivateSoftwareRequest{
2791 MeBasePacket: omci.MeBasePacket{
2792 EntityClass: me.SoftwareImageClassID,
2793 EntityInstance: aImageMeID, //inactive image
2794 },
2795 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2796 }
2797
2798 var options gopacket.SerializeOptions
2799 options.FixLengths = true
2800 buffer := gopacket.NewSerializeBuffer()
2801 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2802 if err != nil {
2803 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2804 "device-id": oo.deviceID})
2805 return err
2806 }
2807 outgoingPacket := buffer.Bytes()
2808
2809 omciRxCallbackPair := callbackPair{cbKey: tid,
2810 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2811 }
2812 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2813 if err != nil {
2814 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2815 "device-id": oo.deviceID})
2816 return err
2817 }
2818 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002819 return nil
2820}
mpagenko80622a52021-02-09 16:53:23 +00002821
mpagenko15ff4a52021-03-02 10:09:20 +00002822func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2823 rxChan chan Message, aImageMeID uint16) error {
2824 tid := oo.getNextTid(highPrio)
2825 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2826 "SequNo": strconv.FormatInt(int64(tid), 16),
2827 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2828
2829 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002830 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002831 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002832 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2833 // Length: 0x28, // Optional, defaults to 40 octets
2834 }
mpagenko15ff4a52021-03-02 10:09:20 +00002835 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002836 MeBasePacket: omci.MeBasePacket{
2837 EntityClass: me.SoftwareImageClassID,
2838 EntityInstance: aImageMeID, //inactive image
2839 },
mpagenko80622a52021-02-09 16:53:23 +00002840 }
mpagenko15ff4a52021-03-02 10:09:20 +00002841
2842 var options gopacket.SerializeOptions
2843 options.FixLengths = true
2844 buffer := gopacket.NewSerializeBuffer()
2845 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2846 if err != nil {
2847 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002848 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002849 return err
mpagenko80622a52021-02-09 16:53:23 +00002850 }
mpagenko15ff4a52021-03-02 10:09:20 +00002851 outgoingPacket := buffer.Bytes()
2852
2853 omciRxCallbackPair := callbackPair{cbKey: tid,
2854 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2855 }
2856 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2857 if err != nil {
2858 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2859 "device-id": oo.deviceID})
2860 return err
2861 }
2862 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002863 return nil
2864}
2865
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002866func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002867 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002868 if v == omciMsg.MessageType {
2869 nextLayer, _ := omci.MsgTypeToNextLayer(v)
2870 msgLayer := (*packet).Layer(nextLayer)
2871 switch nextLayer {
2872 case omci.LayerTypeCreateResponse:
2873 if msgLayer.(*omci.CreateResponse).Result == me.Success {
2874 return true
2875 }
2876 case omci.LayerTypeDeleteResponse:
2877 if msgLayer.(*omci.DeleteResponse).Result == me.Success {
2878 return true
2879 }
2880 case omci.LayerTypeSetResponse:
2881 if msgLayer.(*omci.SetResponse).Result == me.Success {
2882 return true
2883 }
2884 case omci.LayerTypeStartSoftwareDownloadResponse:
2885 if msgLayer.(*omci.StartSoftwareDownloadResponse).Result == me.Success {
2886 return true
2887 }
2888 case omci.LayerTypeEndSoftwareDownloadResponse:
2889 if msgLayer.(*omci.EndSoftwareDownloadResponse).Result == me.Success {
2890 return true
2891 }
2892 case omci.LayerTypeActivateSoftwareResponse:
2893 if msgLayer.(*omci.ActivateSoftwareResponse).Result == me.Success {
2894 return true
2895 }
2896 case omci.LayerTypeCommitSoftwareResponse:
2897 if msgLayer.(*omci.CommitSoftwareResponse).Result == me.Success {
2898 return true
2899 }
2900 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002901 }
2902 }
2903 return false
2904}