blob: 58082a3b007d04d3f3b9b13074353338d6d57a69 [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 */
564 device, err := oo.coreProxy.GetDevice(ctx,
565 oo.pBaseDeviceHandler.deviceID, oo.deviceID) //parent, child
566 if err != nil || device == nil {
567 /*TODO: needs to handle error scenarios */
dbainbri4d3a0dc2020-12-02 00:33:42 +0000568 logger.Errorw(ctx, "Failed to fetch device", log.Fields{"err": err, "ParentId": oo.pBaseDeviceHandler.deviceID,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000569 "ChildId": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200570 return fmt.Errorf("failed to fetch device %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000571 }
572
mpagenko80622a52021-02-09 16:53:23 +0000573 if omciTxRequest.withFramePrint {
574 logger.Debugw(ctx, "omci-message-to-send:", log.Fields{
575 "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame),
576 "device-id": oo.deviceID,
577 "toDeviceType": oo.pBaseDeviceHandler.ProxyAddressType,
578 "proxyDeviceID": oo.pBaseDeviceHandler.ProxyAddressID})
579 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000580 omciMsg := &ic.InterAdapterOmciMessage{Message: omciTxRequest.txFrame}
dbainbri4d3a0dc2020-12-02 00:33:42 +0000581 if sendErr := oo.adapterProxy.SendInterAdapterMessage(log.WithSpanFromContext(context.Background(), ctx), omciMsg,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000582 ic.InterAdapterMessageType_OMCI_REQUEST,
Matteo Scandoloefbec272020-11-17 10:33:09 -0800583 //fromTopic,toType,toDevId, ProxyDevId
584 oo.pOnuDeviceEntry.baseDeviceHandler.pOpenOnuAc.config.Topic, oo.pBaseDeviceHandler.ProxyAddressType,
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000585 oo.deviceID, oo.pBaseDeviceHandler.ProxyAddressID, ""); sendErr != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000586 logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000587 return sendErr
588 }
589 oo.txQueue.Remove(queueElement) // Dequeue
590 }
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000591 return nil
592}
593
Himani Chawla6d2ae152020-09-02 13:11:20 +0530594func (oo *omciCC) getNextTid(highPriority bool) uint16 {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000595 var next uint16
596 if highPriority {
mpagenko900ee4b2020-10-12 11:56:34 +0000597 oo.mutexHpTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000598 next = oo.hpTid
Himani Chawla4d908332020-08-31 12:30:20 +0530599 oo.hpTid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000600 if oo.hpTid < 0x8000 {
601 oo.hpTid = 0x8000
602 }
mpagenko900ee4b2020-10-12 11:56:34 +0000603 oo.mutexHpTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000604 } else {
mpagenko900ee4b2020-10-12 11:56:34 +0000605 oo.mutexTid.Lock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000606 next = oo.tid
Himani Chawla4d908332020-08-31 12:30:20 +0530607 oo.tid++
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000608 if oo.tid >= 0x8000 {
609 oo.tid = 1
610 }
mpagenko900ee4b2020-10-12 11:56:34 +0000611 oo.mutexTid.Unlock()
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000612 }
613 return next
614}
615
616// ###################################################################################
617// # utility methods provided to work on OMCI messages
dbainbri4d3a0dc2020-12-02 00:33:42 +0000618func serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000619 omciLayer := &omci.OMCI{
620 TransactionID: tid,
621 MessageType: msgType,
622 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000623 return serializeOmciLayer(ctx, omciLayer, request)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000624}
625
dbainbri4d3a0dc2020-12-02 00:33:42 +0000626func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000627 var options gopacket.SerializeOptions
628 options.FixLengths = true
629
630 buffer := gopacket.NewSerializeBuffer()
Himani Chawla4d908332020-08-31 12:30:20 +0530631 err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000632 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000633 logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000634 return nil, err
635 }
636 return buffer.Bytes(), nil
637}
638
Himani Chawla4d908332020-08-31 12:30:20 +0530639/*
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000640func hexEncode(omciPkt []byte) ([]byte, error) {
641 dst := make([]byte, hex.EncodedLen(len(omciPkt)))
642 hex.Encode(dst, omciPkt)
643 return dst, nil
644}
Himani Chawla4d908332020-08-31 12:30:20 +0530645*/
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000646
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000647//supply a response handler for omci response messages to be transferred to the requested FSM
dbainbri4d3a0dc2020-12-02 00:33:42 +0000648func (oo *omciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000649
dbainbri4d3a0dc2020-12-02 00:33:42 +0000650 logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType,
divyadesai4d299552020-08-18 07:13:49 +0000651 "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000652
653 if oo.pOnuDeviceEntry == nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000654 logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000655 "device-id": oo.deviceID})
Andrea Campanella6515c582020-10-05 11:25:00 +0200656 return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000657 }
658
659 // no further test on SeqNo is done here, assignment from rxScheduler is trusted
660 // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000661 omciRespMsg := Message{
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000662 Type: OMCI,
663 Data: OmciMessage{
664 OmciMsg: omciMsg,
665 OmciPacket: packet,
666 },
667 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000668 //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000669 respChan <- omciRespMsg
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000670
671 return nil
672}
673
Himani Chawla6d2ae152020-09-02 13:11:20 +0530674func (oo *omciCC) sendMibReset(ctx context.Context, timeout int, highPrio bool) error {
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000675
dbainbri4d3a0dc2020-12-02 00:33:42 +0000676 logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000677 request := &omci.MibResetRequest{
678 MeBasePacket: omci.MeBasePacket{
679 EntityClass: me.OnuDataClassID,
680 },
681 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530682 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000683 pkt, err := serialize(ctx, omci.MibResetRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000684 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000685 logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000686 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000687 return err
688 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530689 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000690 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000691 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000692 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530693 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000694}
695
Himani Chawla6d2ae152020-09-02 13:11:20 +0530696func (oo *omciCC) sendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000697 logger.Debugw(ctx, "send Reboot-msg to:", log.Fields{"device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300698 request := &omci.RebootRequest{
699 MeBasePacket: omci.MeBasePacket{
700 EntityClass: me.OnuGClassID,
701 },
702 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530703 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000704 pkt, err := serialize(ctx, omci.RebootRequestType, request, tid)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300705 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000706 logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000707 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300708 return err
709 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530710 omciRxCallbackPair := callbackPair{
ozgecanetsiae11479f2020-07-06 09:44:47 +0300711 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000712 cbEntry: callbackPairEntry{oo.pOnuDeviceEntry.omciRebootMessageReceivedChannel, oo.receiveOmciResponse, true},
ozgecanetsiae11479f2020-07-06 09:44:47 +0300713 }
714
Himani Chawla6d2ae152020-09-02 13:11:20 +0530715 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300716 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000717 logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000718 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300719 return err
720 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000721 err = oo.pOnuDeviceEntry.waitForRebootResponse(ctx, responseChannel)
ozgecanetsiae11479f2020-07-06 09:44:47 +0300722 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000723 logger.Errorw(ctx, "aborting ONU Reboot!", log.Fields{
Andrea Campanella6515c582020-10-05 11:25:00 +0200724 "Err": err, "device-id": oo.deviceID})
ozgecanetsiae11479f2020-07-06 09:44:47 +0300725 return err
726 }
727 return nil
728}
729
Himani Chawla6d2ae152020-09-02 13:11:20 +0530730func (oo *omciCC) sendMibUpload(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000731 logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000732 request := &omci.MibUploadRequest{
733 MeBasePacket: omci.MeBasePacket{
734 EntityClass: me.OnuDataClassID,
735 },
736 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530737 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000738 pkt, err := serialize(ctx, omci.MibUploadRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000739 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000740 logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000741 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000742 return err
743 }
744 oo.uploadSequNo = 0
745 oo.uploadNoOfCmds = 0
746
Himani Chawla6d2ae152020-09-02 13:11:20 +0530747 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000748 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000749 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000750 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530751 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000752}
753
Himani Chawla6d2ae152020-09-02 13:11:20 +0530754func (oo *omciCC) sendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000755 logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "uploadSequNo": oo.uploadSequNo})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000756 request := &omci.MibUploadNextRequest{
757 MeBasePacket: omci.MeBasePacket{
758 EntityClass: me.OnuDataClassID,
759 },
760 CommandSequenceNumber: oo.uploadSequNo,
761 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530762 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000763 pkt, err := serialize(ctx, omci.MibUploadNextRequestType, request, tid)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000764 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000765 logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000766 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000767 return err
768 }
769 oo.uploadSequNo++
770
Himani Chawla6d2ae152020-09-02 13:11:20 +0530771 omciRxCallbackPair := callbackPair{
mpagenko80622a52021-02-09 16:53:23 +0000772 cbKey: tid,
773 //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?)
774 // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter
775 // compare also software upgrade download section handling
776 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibUploadFsm.commChan, oo.receiveOmciResponse, false},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000777 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530778 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000779}
780
Himani Chawlad3dac422021-03-13 02:31:31 +0530781func (oo *omciCC) sendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error {
782 logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID})
783 request := &omci.GetAllAlarmsRequest{
784 MeBasePacket: omci.MeBasePacket{
785 EntityClass: me.OnuDataClassID,
786 },
787 AlarmRetrievalMode: byte(alarmRetreivalMode),
788 }
789 tid := oo.getNextTid(highPrio)
790 pkt, err := serialize(ctx, omci.GetAllAlarmsRequestType, request, tid)
791 if err != nil {
792 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{
793 "Err": err, "device-id": oo.deviceID})
794 return err
795 }
796 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo = 0
797 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadNoOfCmds = 0
798
799 omciRxCallbackPair := callbackPair{
800 cbKey: tid,
801 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel,
802 oo.receiveOmciResponse, true},
803 }
804 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
805}
806
807func (oo *omciCC) sendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error {
808 alarmUploadSeqNo := oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo
809 logger.Debugw(ctx, "send sendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID,
810 "alarmUploadSeqNo": alarmUploadSeqNo})
811 request := &omci.GetAllAlarmsNextRequest{
812 MeBasePacket: omci.MeBasePacket{
813 EntityClass: me.OnuDataClassID,
814 },
815 CommandSequenceNumber: alarmUploadSeqNo,
816 }
817 tid := oo.getNextTid(highPrio)
818 pkt, err := serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid)
819 if err != nil {
820 logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{
821 "Err": err, "device-id": oo.deviceID})
822 return err
823 }
824 oo.pBaseDeviceHandler.pAlarmMgr.alarmUploadSeqNo++
825
826 omciRxCallbackPair := callbackPair{
827 cbKey: tid,
828 cbEntry: callbackPairEntry{(*oo.pBaseDeviceHandler.pAlarmMgr).eventChannel, oo.receiveOmciResponse, true},
829 }
830 return oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
831}
832
Himani Chawla6d2ae152020-09-02 13:11:20 +0530833func (oo *omciCC) sendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
834 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000835 logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000836 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtfa074992020-03-27 15:42:06 +0000837
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000838 meParams := me.ParamData{
839 EntityID: galEthernetEID,
840 Attributes: me.AttributeValueMap{"MaximumGemPayloadSize": maxGemPayloadSize},
841 }
842 meInstance, omciErr := me.NewGalEthernetProfile(meParams)
843 if omciErr.GetError() == nil {
844 //all setByCreate parameters already set, no default option required ...
845 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
846 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000847 logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000848 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000849 return nil
850 }
851
dbainbri4d3a0dc2020-12-02 00:33:42 +0000852 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000853 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000854 logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000855 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000856 return nil
857 }
858
Himani Chawla6d2ae152020-09-02 13:11:20 +0530859 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000860 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000861 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000862 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530863 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000864 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000865 logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000866 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000867 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000868 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000869 logger.Debug(ctx, "send GalEnetProfile-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000870 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000871 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000872 logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000873 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000874 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000875}
876
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000877// might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!!
Himani Chawla6d2ae152020-09-02 13:11:20 +0530878func (oo *omciCC) sendSetOnu2g(ctx context.Context, timeout int, highPrio bool) *me.ManagedEntity {
879 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000880 logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000881 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000882
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000883 // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired
884 // connectivity mode 5 (in ConnCap)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000885 // By now we just use fix values to fire - this is anyway what the python adapter does
886 // read ONU-2G from DB ???? //TODO!!!
887 meParams := me.ParamData{
888 EntityID: 0,
889 Attributes: me.AttributeValueMap{"CurrentConnectivityMode": connectivityModeValue},
890 }
891 meInstance, omciErr := me.NewOnu2G(meParams)
892 if omciErr.GetError() == nil {
893 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
894 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000895 logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000896 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000897 return nil
898 }
899
dbainbri4d3a0dc2020-12-02 00:33:42 +0000900 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000901 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000902 logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000903 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000904 return nil
905 }
906
Himani Chawla6d2ae152020-09-02 13:11:20 +0530907 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000908 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000909 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000910 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530911 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000912 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000913 logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000914 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000915 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000916 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000917 logger.Debug(ctx, "send ONU2-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000918 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000919 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000920 logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000921 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000922 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000923}
924
Himani Chawla6d2ae152020-09-02 13:11:20 +0530925func (oo *omciCC) sendCreateMBServiceProfile(ctx context.Context,
926 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
927 tid := oo.getNextTid(highPrio)
Himani Chawla4d908332020-08-31 12:30:20 +0530928 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +0000929 logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000930 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000931
932 meParams := me.ParamData{
933 EntityID: instID,
934 Attributes: me.AttributeValueMap{
ozgecanetsiab5000ef2020-11-27 14:38:20 +0300935 "Priority": 0x8000,
936 "MaxAge": 20 * 256, //20s
937 "HelloTime": 2 * 256, //2s
938 "ForwardDelay": 15 * 256, //15s
939 "DynamicFilteringAgeingTime": 0,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000940 },
941 }
942
943 meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams)
944 if omciErr.GetError() == nil {
945 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
946 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
947 omci.TransactionID(tid), omci.AddDefaults(true))
948 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000949 logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000950 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000951 return nil
952 }
953
dbainbri4d3a0dc2020-12-02 00:33:42 +0000954 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000955 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000956 logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000957 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000958 return nil
959 }
960
Himani Chawla6d2ae152020-09-02 13:11:20 +0530961 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000962 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +0000963 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +0000964 }
Himani Chawla6d2ae152020-09-02 13:11:20 +0530965 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000966 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +0000967 logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000968 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000969 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000970 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000971 logger.Debug(ctx, "send MBSP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +0000972 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000973 }
dbainbri4d3a0dc2020-12-02 00:33:42 +0000974 logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +0000975 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +0000976 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000977}
978
Himani Chawla6d2ae152020-09-02 13:11:20 +0530979func (oo *omciCC) sendCreateMBPConfigData(ctx context.Context,
980 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
981 tid := oo.getNextTid(highPrio)
Himani Chawla26e555c2020-08-31 12:30:20 +0530982 instID := macBridgePortAniEID + aPUniPort.entityID
dbainbri4d3a0dc2020-12-02 00:33:42 +0000983 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +0000984 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000985
986 meParams := me.ParamData{
987 EntityID: instID,
988 Attributes: me.AttributeValueMap{
Himani Chawla4d908332020-08-31 12:30:20 +0530989 "BridgeIdPointer": macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo),
990 "PortNum": aPUniPort.macBpNo,
991 "TpType": uint8(aPUniPort.portType),
Himani Chawla26e555c2020-08-31 12:30:20 +0530992 "TpPointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +0000993 },
994 }
995 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
996 if omciErr.GetError() == nil {
997 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
998 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
999 omci.TransactionID(tid), omci.AddDefaults(true))
1000 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001001 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001002 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001003 return nil
1004 }
1005
dbainbri4d3a0dc2020-12-02 00:33:42 +00001006 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001007 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001008 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001009 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001010 return nil
1011 }
1012
Himani Chawla6d2ae152020-09-02 13:11:20 +05301013 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001014 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001015 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001016 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301017 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001018 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001019 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001020 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001021 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001022 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001023 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001024 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001025 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001026 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001027 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001028 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001029}
1030
Himani Chawla6d2ae152020-09-02 13:11:20 +05301031func (oo *omciCC) sendCreateEVTOConfigData(ctx context.Context,
1032 aPUniPort *onuUniPort, timeout int, highPrio bool) *me.ManagedEntity {
1033 tid := oo.getNextTid(highPrio)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001034 //same entityId is used as for MBSP (see there), but just arbitrary ...
Himani Chawla4d908332020-08-31 12:30:20 +05301035 instID := macBridgeServiceProfileEID + uint16(aPUniPort.macBpNo)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001036 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001037 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001038
1039 // compare python adapter code WA VOL-1311: this is not done here!
1040 // (setting TPID values for the create would probably anyway be ignored by the omci lib)
1041 // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ...
1042 assType := uint8(2) // default AssociationType is PPTPEthUni
Himani Chawla6d2ae152020-09-02 13:11:20 +05301043 if aPUniPort.portType == uniVEIP {
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001044 assType = uint8(10) // for VEIP
1045 }
1046 meParams := me.ParamData{
1047 EntityID: instID,
1048 Attributes: me.AttributeValueMap{
1049 "AssociationType": assType,
Himani Chawla26e555c2020-08-31 12:30:20 +05301050 "AssociatedMePointer": aPUniPort.entityID,
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001051 },
1052 }
1053 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams)
1054 if omciErr.GetError() == nil {
1055 //all setByCreate parameters already set, no default option required ...
1056 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1057 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001058 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001059 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001060 return nil
1061 }
1062
dbainbri4d3a0dc2020-12-02 00:33:42 +00001063 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001064 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001065 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001066 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001067 return nil
1068 }
1069
Himani Chawla6d2ae152020-09-02 13:11:20 +05301070 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001071 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001072 cbEntry: callbackPairEntry{(*oo.pOnuDeviceEntry).pMibDownloadFsm.commChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001073 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301074 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001075 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001076 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001077 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001078 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001079 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001080 logger.Debug(ctx, "send EVTOCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001081 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001082 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001083 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001084 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001085 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001086}
1087
Himani Chawla6d2ae152020-09-02 13:11:20 +05301088func (oo *omciCC) sendSetOnuGLS(ctx context.Context, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001089 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301090 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001091 logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001092 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001093
1094 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1095 meParams := me.ParamData{
1096 EntityID: 0,
1097 Attributes: requestedAttributes,
1098 }
1099 meInstance, omciErr := me.NewOnuG(meParams)
1100 if omciErr.GetError() == nil {
1101 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1102 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001103 logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001104 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001105 return nil
1106 }
1107
dbainbri4d3a0dc2020-12-02 00:33:42 +00001108 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001109 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001110 logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001111 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001112 return nil
1113 }
1114
Himani Chawla6d2ae152020-09-02 13:11:20 +05301115 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001116 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001117 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001118 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301119 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001120 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001121 logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001122 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001123 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001124 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001125 logger.Debug(ctx, "send ONU-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001126 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001127 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001128 logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001129 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001130 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001131}
1132
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001133func (oo *omciCC) sendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int,
1134 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
1135 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001136 logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001137 "SequNo": strconv.FormatInt(int64(tid), 16)})
1138
1139 // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1140 meParams := me.ParamData{
1141 EntityID: aInstNo,
1142 Attributes: requestedAttributes,
1143 }
1144 meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
1145 if omciErr.GetError() == nil {
1146 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1147 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001148 logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001149 "Err": err, "device-id": oo.deviceID})
1150 return nil
1151 }
1152
dbainbri4d3a0dc2020-12-02 00:33:42 +00001153 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001154 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001155 logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001156 "Err": err, "device-id": oo.deviceID})
1157 return nil
1158 }
1159
1160 omciRxCallbackPair := callbackPair{
1161 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001162 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001163 }
1164 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1165 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001166 logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001167 "Err": err, "device-id": oo.deviceID})
1168 return nil
1169 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001170 logger.Debug(ctx, "send PPTPEthUni-Set-msg done")
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001171 return meInstance
1172 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001173 logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001174 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1175 return nil
1176}
1177
1178/* UniG obsolete by now, left here in case it should be needed once again
1179 UniG AdminState anyway should be ignored by ONU acc. to G988
Himani Chawla6d2ae152020-09-02 13:11:20 +05301180func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001181 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301182 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001183 logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001184 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001185
1186 // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument)
1187 meParams := me.ParamData{
1188 EntityID: aInstNo,
1189 Attributes: requestedAttributes,
1190 }
1191 meInstance, omciErr := me.NewUniG(meParams)
1192 if omciErr.GetError() == nil {
1193 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1194 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001195 logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001196 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001197 return nil
1198 }
1199
1200 pkt, err := serializeOmciLayer(omciLayer, msgLayer)
1201 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001202 logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001203 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001204 return nil
1205 }
1206
Himani Chawla6d2ae152020-09-02 13:11:20 +05301207 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001208 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001209 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001210 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301211 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001212 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001213 logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001214 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001215 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001216 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001217 logger.Debug(ctx,"send UNI-G-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001218 return meInstance
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001219 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001220 logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001221 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001222 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001223}
Holger Hildebrandt2fb70892020-10-28 11:53:18 +00001224*/
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001225
Himani Chawla6d2ae152020-09-02 13:11:20 +05301226func (oo *omciCC) sendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int,
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001227 highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301228 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001229 logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001230 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001231
1232 // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup
1233 meParams := me.ParamData{
1234 EntityID: aInstNo,
1235 Attributes: requestedAttributes,
1236 }
1237 meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams)
1238 if omciErr.GetError() == nil {
1239 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1240 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001241 logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001242 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001243 return nil
1244 }
1245
dbainbri4d3a0dc2020-12-02 00:33:42 +00001246 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001247 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001248 logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001249 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001250 return nil
1251 }
1252
Himani Chawla6d2ae152020-09-02 13:11:20 +05301253 omciRxCallbackPair := callbackPair{
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001254 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001255 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001256 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301257 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001258 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001259 logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001260 "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001261 return nil
Holger Hildebrandtccd390c2020-05-29 13:49:04 +00001262 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001263 logger.Debug(ctx, "send VEIP-Set-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001264 return meInstance
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001265 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001266 logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001267 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001268 return nil
Holger Hildebrandtdd23cc22020-05-19 13:32:18 +00001269}
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001270
Himani Chawla6d2ae152020-09-02 13:11:20 +05301271func (oo *omciCC) sendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap,
Girish Gowdrae09a6202021-01-12 18:10:59 -08001272 timeout int, highPrio bool, rxChan chan Message) *me.ManagedEntity {
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001273
Himani Chawla6d2ae152020-09-02 13:11:20 +05301274 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001275 logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001276 "SequNo": strconv.FormatInt(int64(tid), 16)})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001277
1278 meParams := me.ParamData{
1279 EntityID: entityID,
1280 Attributes: requestedAttributes,
1281 }
1282 meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams)
1283 if omciErr.GetError() == nil {
Himani Chawla4d908332020-08-31 12:30:20 +05301284 meClassIDName := meInstance.GetName()
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001285 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.GetRequestType, omci.TransactionID(tid))
1286 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001287 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 +00001288 return nil
1289 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001290 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001291 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001292 logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID})
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001293 return nil
1294 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301295 omciRxCallbackPair := callbackPair{
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001296 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001297 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001298 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301299 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001300 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001301 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 +00001302 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001303 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001304 logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001305 return meInstance
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001306 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001307 logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001308 return nil
1309}
1310
Himani Chawla6d2ae152020-09-02 13:11:20 +05301311func (oo *omciCC) sendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001312 aInstID uint16, rxChan chan Message) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301313 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001314 logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001315 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)})
1316
1317 meParams := me.ParamData{
mpagenko8b5fdd22020-12-17 17:58:32 +00001318 EntityID: aInstID,
1319 Attributes: me.AttributeValueMap{
1320 //workaround for unsuitable omci-lib default values, cmp VOL-3729
1321 "TpPointer": 0xFFFF,
1322 "InterworkTpPointerForPBitPriority0": 0xFFFF,
1323 "InterworkTpPointerForPBitPriority1": 0xFFFF,
1324 "InterworkTpPointerForPBitPriority2": 0xFFFF,
1325 "InterworkTpPointerForPBitPriority3": 0xFFFF,
1326 "InterworkTpPointerForPBitPriority4": 0xFFFF,
1327 "InterworkTpPointerForPBitPriority5": 0xFFFF,
1328 "InterworkTpPointerForPBitPriority6": 0xFFFF,
1329 "InterworkTpPointerForPBitPriority7": 0xFFFF,
1330 },
mpagenko3dbcdd22020-07-22 07:38:45 +00001331 }
1332 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
1333 if omciErr.GetError() == nil {
1334 //we have to set all 'untouched' parameters to default by some additional option parameter!!
1335 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1336 omci.TransactionID(tid), omci.AddDefaults(true))
1337 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001338 logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001339 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001340 return nil
1341 }
1342
dbainbri4d3a0dc2020-12-02 00:33:42 +00001343 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001344 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001345 logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001346 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001347 return nil
1348 }
1349
Himani Chawla6d2ae152020-09-02 13:11:20 +05301350 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001351 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001352 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001353 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301354 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001355 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001356 logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001357 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001358 return nil
1359 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001360 logger.Debug(ctx, "send .1pMapper-create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001361 return meInstance
1362 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001363 logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001364 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001365 return nil
1366}
1367
Himani Chawla6d2ae152020-09-02 13:11:20 +05301368func (oo *omciCC) sendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001369 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301370 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001371 logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001372 "SequNo": strconv.FormatInt(int64(tid), 16),
1373 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1374
1375 meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0])
1376 if omciErr.GetError() == nil {
1377 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1378 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1379 omci.TransactionID(tid), omci.AddDefaults(true))
1380 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001381 logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001382 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001383 return nil
1384 }
1385
dbainbri4d3a0dc2020-12-02 00:33:42 +00001386 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001387 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001388 logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001389 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001390 return nil
1391 }
1392
Himani Chawla6d2ae152020-09-02 13:11:20 +05301393 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001394 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001395 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001396 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301397 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001398 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001399 logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001400 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001401 return nil
1402 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001403 logger.Debug(ctx, "send MBPCD-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001404 return meInstance
1405 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001406 logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001407 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001408 return nil
1409}
1410
Himani Chawla6d2ae152020-09-02 13:11:20 +05301411func (oo *omciCC) sendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001412 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301413 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001414 logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001415 "SequNo": strconv.FormatInt(int64(tid), 16),
1416 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1417
1418 meInstance, omciErr := me.NewGemPortNetworkCtp(params[0])
1419 if omciErr.GetError() == nil {
1420 //obviously we have to set all 'untouched' parameters to default by some additional option parameter!!
1421 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1422 omci.TransactionID(tid), omci.AddDefaults(true))
1423 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001424 logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001425 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001426 return nil
1427 }
1428
dbainbri4d3a0dc2020-12-02 00:33:42 +00001429 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001430 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001431 logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001432 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001433 return nil
1434 }
1435
Himani Chawla6d2ae152020-09-02 13:11:20 +05301436 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001437 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001438 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001439 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301440 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001441 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001442 logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001443 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001444 return nil
1445 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001446 logger.Debug(ctx, "send GemNCTP-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001447 return meInstance
1448 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001449 logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001450 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001451 return nil
1452}
1453
Himani Chawla6d2ae152020-09-02 13:11:20 +05301454func (oo *omciCC) sendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001455 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301456 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001457 logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001458 "SequNo": strconv.FormatInt(int64(tid), 16),
1459 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1460
1461 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0])
1462 if omciErr.GetError() == nil {
1463 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1464 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1465 omci.TransactionID(tid))
1466 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001467 logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001468 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001469 return nil
1470 }
1471
dbainbri4d3a0dc2020-12-02 00:33:42 +00001472 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001473 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001474 logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001475 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001476 return nil
1477 }
1478
Himani Chawla6d2ae152020-09-02 13:11:20 +05301479 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001480 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001481 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001482 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301483 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001484 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001485 logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001486 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001487 return nil
1488 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001489 logger.Debug(ctx, "send GemIwTp-Create-msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001490 return meInstance
1491 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001492 logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001493 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001494 return nil
1495}
1496
Himani Chawla6d2ae152020-09-02 13:11:20 +05301497func (oo *omciCC) sendSetTcontVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001498 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301499 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001500 logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001501 "SequNo": strconv.FormatInt(int64(tid), 16),
1502 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1503
1504 meInstance, omciErr := me.NewTCont(params[0])
1505 if omciErr.GetError() == nil {
1506 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1507 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001508 logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001509 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001510 return nil
1511 }
1512
dbainbri4d3a0dc2020-12-02 00:33:42 +00001513 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001514 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001515 logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001516 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001517 return nil
1518 }
1519
Himani Chawla6d2ae152020-09-02 13:11:20 +05301520 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001521 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001522 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001523 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301524 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001525 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001526 logger.Errorw(ctx, "Cannot send TCont set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001527 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001528 return nil
1529 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001530 logger.Debug(ctx, "send TCont-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001531 return meInstance
1532 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001533 logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001534 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001535 return nil
1536}
1537
Himani Chawla6d2ae152020-09-02 13:11:20 +05301538func (oo *omciCC) sendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001539 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301540 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001541 logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001542 "SequNo": strconv.FormatInt(int64(tid), 16),
1543 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1544
1545 meInstance, omciErr := me.NewPriorityQueue(params[0])
1546 if omciErr.GetError() == nil {
1547 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1548 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001549 logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001550 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001551 return nil
1552 }
1553
dbainbri4d3a0dc2020-12-02 00:33:42 +00001554 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001555 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001556 logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001557 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001558 return nil
1559 }
1560
Himani Chawla6d2ae152020-09-02 13:11:20 +05301561 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001562 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001563 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001564 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301565 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001566 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001567 logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001568 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001569 return nil
1570 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001571 logger.Debug(ctx, "send PrioQueue-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001572 return meInstance
1573 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001574 logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001575 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001576 return nil
1577}
1578
Himani Chawla6d2ae152020-09-02 13:11:20 +05301579func (oo *omciCC) sendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool,
mpagenko3dbcdd22020-07-22 07:38:45 +00001580 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301581 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001582 logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko3dbcdd22020-07-22 07:38:45 +00001583 "SequNo": strconv.FormatInt(int64(tid), 16),
1584 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1585
1586 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0])
1587 if omciErr.GetError() == nil {
1588 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1589 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001590 logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001591 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001592 return nil
1593 }
1594
dbainbri4d3a0dc2020-12-02 00:33:42 +00001595 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko3dbcdd22020-07-22 07:38:45 +00001596 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001597 logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001598 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001599 return nil
1600 }
1601
Himani Chawla6d2ae152020-09-02 13:11:20 +05301602 omciRxCallbackPair := callbackPair{
mpagenko3dbcdd22020-07-22 07:38:45 +00001603 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001604 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko3dbcdd22020-07-22 07:38:45 +00001605 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301606 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenko3dbcdd22020-07-22 07:38:45 +00001607 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001608 logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001609 "Err": err, "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001610 return nil
1611 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001612 logger.Debug(ctx, "send 1PMapper-set msg done")
mpagenko3dbcdd22020-07-22 07:38:45 +00001613 return meInstance
1614 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001615 logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{
divyadesai4d299552020-08-18 07:13:49 +00001616 "Err": omciErr.GetError(), "device-id": oo.deviceID})
mpagenko3dbcdd22020-07-22 07:38:45 +00001617 return nil
Holger Hildebrandtc54939a2020-06-17 08:14:27 +00001618}
mpagenkodff5dda2020-08-28 11:52:01 +00001619
Himani Chawla6d2ae152020-09-02 13:11:20 +05301620func (oo *omciCC) sendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001621 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301622 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001623 logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001624 "SequNo": strconv.FormatInt(int64(tid), 16),
1625 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1626
1627 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1628 if omciErr.GetError() == nil {
1629 //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults'
1630 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType,
1631 omci.TransactionID(tid))
1632 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001633 logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001634 "Err": err, "device-id": oo.deviceID})
1635 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1636 // return (dual format) error code that can be used at caller for immediate error treatment
1637 // (relevant to all used sendXX() methods and their error conditions)
1638 return nil
1639 }
1640
dbainbri4d3a0dc2020-12-02 00:33:42 +00001641 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001642 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001643 logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001644 "Err": err, "device-id": oo.deviceID})
1645 return nil
1646 }
1647
Himani Chawla6d2ae152020-09-02 13:11:20 +05301648 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001649 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001650 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001651 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301652 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001653 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001654 logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001655 "Err": err, "device-id": oo.deviceID})
1656 return nil
1657 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001658 logger.Debug(ctx, "send VTFD-Create-msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001659 return meInstance
1660 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001661 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001662 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1663 return nil
1664}
1665
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001666// nolint: unused
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001667func (oo *omciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool,
1668 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1669 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001670 logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID,
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001671 "SequNo": strconv.FormatInt(int64(tid), 16),
1672 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1673
1674 meInstance, omciErr := me.NewVlanTaggingFilterData(params[0])
1675 if omciErr.GetError() == nil {
1676 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType,
1677 omci.TransactionID(tid))
1678 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001679 logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001680 "Err": err, "device-id": oo.deviceID})
1681 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1682 // return (dual format) error code that can be used at caller for immediate error treatment
1683 // (relevant to all used sendXX() methods and their error conditions)
1684 return nil
1685 }
1686
dbainbri4d3a0dc2020-12-02 00:33:42 +00001687 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001688 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001689 logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001690 "Err": err, "device-id": oo.deviceID})
1691 return nil
1692 }
1693
1694 omciRxCallbackPair := callbackPair{
1695 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001696 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001697 }
1698 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1699 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001700 logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001701 "Err": err, "device-id": oo.deviceID})
1702 return nil
1703 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001704 logger.Debug(ctx, "send VTFD-Set-msg done")
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001705 return meInstance
1706 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001707 logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{
Holger Hildebrandt394c5522020-09-11 11:23:01 +00001708 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1709 return nil
1710}
1711
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001712func (oo *omciCC) sendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool,
1713 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1714 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001715 logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001716 "SequNo": strconv.FormatInt(int64(tid), 16),
1717 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1718
1719 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1720 if omciErr.GetError() == nil {
1721 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1722 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001723 logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001724 "Err": err, "device-id": oo.deviceID})
1725 return nil
1726 }
1727
dbainbri4d3a0dc2020-12-02 00:33:42 +00001728 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001729 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001730 logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001731 "Err": err, "device-id": oo.deviceID})
1732 return nil
1733 }
1734
1735 omciRxCallbackPair := callbackPair{
1736 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001737 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001738 }
1739 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1740 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001741 logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001742 "Err": err, "device-id": oo.deviceID})
1743 return nil
1744 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001745 logger.Debug(ctx, "send EVTOCD-set msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001746 return meInstance
1747 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001748 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001749 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1750 return nil
1751}
1752
Himani Chawla6d2ae152020-09-02 13:11:20 +05301753func (oo *omciCC) sendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool,
mpagenkodff5dda2020-08-28 11:52:01 +00001754 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
Himani Chawla6d2ae152020-09-02 13:11:20 +05301755 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001756 logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID,
mpagenkodff5dda2020-08-28 11:52:01 +00001757 "SequNo": strconv.FormatInt(int64(tid), 16),
1758 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1759
1760 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1761 if omciErr.GetError() == nil {
1762 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1763 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001764 logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001765 "Err": err, "device-id": oo.deviceID})
1766 return nil
1767 }
1768
dbainbri4d3a0dc2020-12-02 00:33:42 +00001769 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenkodff5dda2020-08-28 11:52:01 +00001770 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001771 logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001772 "Err": err, "device-id": oo.deviceID})
1773 return nil
1774 }
1775
Himani Chawla6d2ae152020-09-02 13:11:20 +05301776 omciRxCallbackPair := callbackPair{
mpagenkodff5dda2020-08-28 11:52:01 +00001777 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001778 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenkodff5dda2020-08-28 11:52:01 +00001779 }
Himani Chawla6d2ae152020-09-02 13:11:20 +05301780 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
mpagenkodff5dda2020-08-28 11:52:01 +00001781 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001782 logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001783 "Err": err, "device-id": oo.deviceID})
1784 return nil
1785 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001786 logger.Debug(ctx, "send EVTOCD-set msg done")
mpagenkodff5dda2020-08-28 11:52:01 +00001787 return meInstance
1788 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001789 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
mpagenkodff5dda2020-08-28 11:52:01 +00001790 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1791 return nil
1792}
mpagenko01e726e2020-10-23 09:45:29 +00001793
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001794func (oo *omciCC) sendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool,
1795 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1796 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001797 logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001798 "SequNo": strconv.FormatInt(int64(tid), 16),
1799 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1800
1801 meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0])
1802 if omciErr.GetError() == nil {
1803 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1804 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001805 logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001806 "Err": err, "device-id": oo.deviceID})
1807 return nil
1808 }
1809
dbainbri4d3a0dc2020-12-02 00:33:42 +00001810 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001811 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001812 logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001813 "Err": err, "device-id": oo.deviceID})
1814 return nil
1815 }
1816
1817 omciRxCallbackPair := callbackPair{
1818 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001819 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001820 }
1821 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1822 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001823 logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001824 "Err": err, "device-id": oo.deviceID})
1825 return nil
1826 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001827 logger.Debug(ctx, "send EVTOCD-delete msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001828 return meInstance
1829 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001830 logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{
ozgecanetsiab5000ef2020-11-27 14:38:20 +03001831 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1832 return nil
1833}
1834
mpagenko01e726e2020-10-23 09:45:29 +00001835func (oo *omciCC) sendDeleteVtfd(ctx context.Context, timeout int, highPrio bool,
1836 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1837 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001838 logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko01e726e2020-10-23 09:45:29 +00001839 "SequNo": strconv.FormatInt(int64(tid), 16),
1840 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1841
1842 meParams := me.ParamData{EntityID: aInstID}
1843 meInstance, omciErr := me.NewVlanTaggingFilterData(meParams)
1844 if omciErr.GetError() == nil {
1845 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
1846 omci.TransactionID(tid))
1847 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001848 logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001849 "Err": err, "device-id": oo.deviceID})
1850 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
1851 // return (dual format) error code that can be used at caller for immediate error treatment
1852 // (relevant to all used sendXX() methods and their error conditions)
1853 return nil
1854 }
1855
dbainbri4d3a0dc2020-12-02 00:33:42 +00001856 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko01e726e2020-10-23 09:45:29 +00001857 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001858 logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001859 "Err": err, "device-id": oo.deviceID})
1860 return nil
1861 }
1862
1863 omciRxCallbackPair := callbackPair{
1864 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00001865 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko01e726e2020-10-23 09:45:29 +00001866 }
1867 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1868 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00001869 logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001870 "Err": err, "device-id": oo.deviceID})
1871 return nil
1872 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001873 logger.Debug(ctx, "send VTFD-Delete-msg done")
mpagenko01e726e2020-10-23 09:45:29 +00001874 return meInstance
1875 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00001876 logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{
mpagenko01e726e2020-10-23 09:45:29 +00001877 "Err": omciErr.GetError(), "device-id": oo.deviceID})
1878 return nil
1879}
ozgecanetsia422dbf32020-10-28 14:07:19 +03001880
ozgecanetsiab6441962021-03-10 10:58:48 +03001881// nolint: unused
1882func (oo *omciCC) sendCreateTDVar(ctx context.Context, timeout int, highPrio bool,
1883 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1884 tid := oo.getNextTid(highPrio)
1885 logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID,
1886 "SequNo": strconv.FormatInt(int64(tid), 16),
1887 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1888 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1889 if omciErr.GetError() == nil {
1890 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid))
1891 if err != nil {
1892 logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID})
1893 return nil
1894 }
1895 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1896 if err != nil {
1897 logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
1898 return nil
1899 }
1900 omciRxCallbackPair := callbackPair{
1901 cbKey: tid,
1902 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1903 }
1904 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1905 if err != nil {
1906 logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID})
1907 return nil
1908 }
1909 logger.Debug(ctx, "send TD-Create-msg done")
1910 return meInstance
1911 }
1912 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1913 return nil
1914}
1915
1916// nolint: unused
1917func (oo *omciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool,
1918 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
1919 tid := oo.getNextTid(highPrio)
1920 logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID,
1921 "SequNo": strconv.FormatInt(int64(tid), 16),
1922 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
1923
1924 meInstance, omciErr := me.NewTrafficDescriptor(params[0])
1925 if omciErr.GetError() == nil {
1926 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid))
1927 if err != nil {
1928 logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID})
1929 return nil
1930 }
1931 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1932 if err != nil {
1933 logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
1934 return nil
1935 }
1936 omciRxCallbackPair := callbackPair{
1937 cbKey: tid,
1938 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1939 }
1940 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1941 if err != nil {
1942 logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID})
1943 return nil
1944 }
1945 logger.Debug(ctx, "send TD-Set-msg done")
1946 return meInstance
1947 }
1948 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1949 return nil
1950
1951}
1952
1953// nolint: unused
1954func (oo *omciCC) sendDeleteTD(ctx context.Context, timeout int, highPrio bool,
1955 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1956 tid := oo.getNextTid(highPrio)
1957 logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
1958 "SequNo": strconv.FormatInt(int64(tid), 16),
1959 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1960
1961 meParams := me.ParamData{EntityID: aInstID}
1962 meInstance, omciErr := me.NewTrafficDescriptor(meParams)
1963 if omciErr.GetError() == nil {
1964 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid))
1965 if err != nil {
1966 logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1967 return nil
1968 }
1969 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
1970 if err != nil {
1971 logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1972 return nil
1973 }
1974 omciRxCallbackPair := callbackPair{
1975 cbKey: tid,
1976 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
1977 }
1978 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
1979 if err != nil {
1980 logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID})
1981 return nil
1982 }
1983 logger.Debug(ctx, "send TD-Delete-msg done")
1984 return meInstance
1985 }
1986 logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID})
1987 return nil
1988
1989}
1990
mpagenko8b07c1b2020-11-26 10:36:31 +00001991func (oo *omciCC) sendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool,
1992 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
1993 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00001994 logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00001995 "SequNo": strconv.FormatInt(int64(tid), 16),
1996 "InstId": strconv.FormatInt(int64(aInstID), 16)})
1997
1998 meParams := me.ParamData{EntityID: aInstID}
1999 meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams)
2000 if omciErr.GetError() == nil {
2001 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2002 omci.TransactionID(tid))
2003 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002004 logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002005 "Err": err, "device-id": oo.deviceID})
2006 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2007 // return (dual format) error code that can be used at caller for immediate error treatment
2008 // (relevant to all used sendXX() methods and their error conditions)
2009 return nil
2010 }
2011
dbainbri4d3a0dc2020-12-02 00:33:42 +00002012 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002013 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002014 logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002015 "Err": err, "device-id": oo.deviceID})
2016 return nil
2017 }
2018
2019 omciRxCallbackPair := callbackPair{
2020 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002021 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002022 }
2023 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2024 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002025 logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002026 "Err": err, "device-id": oo.deviceID})
2027 return nil
2028 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002029 logger.Debug(ctx, "send GemIwTp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002030 return meInstance
2031 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002032 logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002033 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2034 return nil
2035}
2036
2037func (oo *omciCC) sendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool,
2038 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2039 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002040 logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002041 "SequNo": strconv.FormatInt(int64(tid), 16),
2042 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2043
2044 meParams := me.ParamData{EntityID: aInstID}
2045 meInstance, omciErr := me.NewGemPortNetworkCtp(meParams)
2046 if omciErr.GetError() == nil {
2047 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2048 omci.TransactionID(tid))
2049 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002050 logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002051 "Err": err, "device-id": oo.deviceID})
2052 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2053 // return (dual format) error code that can be used at caller for immediate error treatment
2054 // (relevant to all used sendXX() methods and their error conditions)
2055 return nil
2056 }
2057
dbainbri4d3a0dc2020-12-02 00:33:42 +00002058 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002059 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002060 logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002061 "Err": err, "device-id": oo.deviceID})
2062 return nil
2063 }
2064
2065 omciRxCallbackPair := callbackPair{
2066 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002067 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002068 }
2069 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2070 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002071 logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002072 "Err": err, "device-id": oo.deviceID})
2073 return nil
2074 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002075 logger.Debug(ctx, "send GemNCtp-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002076 return meInstance
2077 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002078 logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002079 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2080 return nil
2081}
2082
2083func (oo *omciCC) sendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool,
2084 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2085 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002086 logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002087 "SequNo": strconv.FormatInt(int64(tid), 16),
2088 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2089
2090 meParams := me.ParamData{EntityID: aInstID}
2091 meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams)
2092 if omciErr.GetError() == nil {
2093 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2094 omci.TransactionID(tid))
2095 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002096 logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002097 "Err": err, "device-id": oo.deviceID})
2098 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2099 // return (dual format) error code that can be used at caller for immediate error treatment
2100 // (relevant to all used sendXX() methods and their error conditions)
2101 return nil
2102 }
2103
dbainbri4d3a0dc2020-12-02 00:33:42 +00002104 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002105 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002106 logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002107 "Err": err, "device-id": oo.deviceID})
2108 return nil
2109 }
2110
2111 omciRxCallbackPair := callbackPair{
2112 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002113 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002114 }
2115 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2116 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002117 logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002118 "Err": err, "device-id": oo.deviceID})
2119 return nil
2120 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002121 logger.Debug(ctx, "send .1pMapper-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002122 return meInstance
2123 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002124 logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002125 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2126 return nil
2127}
2128
2129func (oo *omciCC) sendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool,
2130 rxChan chan Message, aInstID uint16) *me.ManagedEntity {
2131 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002132 logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID,
mpagenko8b07c1b2020-11-26 10:36:31 +00002133 "SequNo": strconv.FormatInt(int64(tid), 16),
2134 "InstId": strconv.FormatInt(int64(aInstID), 16)})
2135
2136 meParams := me.ParamData{EntityID: aInstID}
2137 meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams)
2138 if omciErr.GetError() == nil {
2139 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.DeleteRequestType,
2140 omci.TransactionID(tid))
2141 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002142 logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002143 "Err": err, "device-id": oo.deviceID})
2144 //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]:
2145 // return (dual format) error code that can be used at caller for immediate error treatment
2146 // (relevant to all used sendXX() methods and their error conditions)
2147 return nil
2148 }
2149
dbainbri4d3a0dc2020-12-02 00:33:42 +00002150 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
mpagenko8b07c1b2020-11-26 10:36:31 +00002151 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002152 logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002153 "Err": err, "device-id": oo.deviceID})
2154 return nil
2155 }
2156
2157 omciRxCallbackPair := callbackPair{
2158 cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002159 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
mpagenko8b07c1b2020-11-26 10:36:31 +00002160 }
2161 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2162 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002163 logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002164 "Err": err, "device-id": oo.deviceID})
2165 return nil
2166 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002167 logger.Debug(ctx, "send MBPCD-Delete-msg done")
mpagenko8b07c1b2020-11-26 10:36:31 +00002168 return meInstance
2169 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002170 logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{
mpagenko8b07c1b2020-11-26 10:36:31 +00002171 "Err": omciErr.GetError(), "device-id": oo.deviceID})
2172 return nil
2173}
2174
ozgecanetsia422dbf32020-10-28 14:07:19 +03002175func (oo *omciCC) sendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2176 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2177 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002178 logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002179 "SequNo": strconv.FormatInt(int64(tid), 16),
2180 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2181
2182 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2183 if omciErr.GetError() == nil {
2184 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2185 omci.AddDefaults(true))
2186 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002187 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002188 return nil
2189 }
2190
dbainbri4d3a0dc2020-12-02 00:33:42 +00002191 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002192 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002193 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002194 return nil
2195 }
2196
2197 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002198 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002199 }
2200 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2201 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002202 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsia422dbf32020-10-28 14:07:19 +03002203 return nil
2204 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002205 logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002206 return meInstance
2207 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002208 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002209 "device-id": oo.deviceID})
2210 return nil
2211}
2212
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002213func (oo *omciCC) sendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool,
2214 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2215 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002216 logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002217 "SequNo": strconv.FormatInt(int64(tid), 16),
2218 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2219
2220 meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0])
2221 if omciErr.GetError() == nil {
2222 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2223 omci.AddDefaults(true))
2224 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002225 logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002226 return nil
2227 }
2228
dbainbri4d3a0dc2020-12-02 00:33:42 +00002229 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002230 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002231 logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002232 return nil
2233 }
2234
2235 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002236 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002237 }
2238 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2239 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002240 logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID})
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002241 return nil
2242 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002243 logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done")
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002244 return meInstance
2245 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002246 logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsiab5000ef2020-11-27 14:38:20 +03002247 "device-id": oo.deviceID})
2248 return nil
2249}
2250
ozgecanetsia422dbf32020-10-28 14:07:19 +03002251func (oo *omciCC) sendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2252 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2253 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002254 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002255 "SequNo": strconv.FormatInt(int64(tid), 16),
2256 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2257
2258 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2259 if omciErr.GetError() == nil {
2260 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2261 omci.AddDefaults(true))
2262 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002263 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002264 "device-id": oo.deviceID})
2265 return nil
2266 }
2267
dbainbri4d3a0dc2020-12-02 00:33:42 +00002268 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002269 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002270 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002271 "device-id": oo.deviceID})
2272 return nil
2273 }
2274
2275 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002276 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002277 }
2278 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2279 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002280 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002281 "device-id": oo.deviceID})
2282 return nil
2283 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002284 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002285 return meInstance
2286 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002287 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002288 "device-id": oo.deviceID})
2289 return nil
2290}
2291
2292func (oo *omciCC) sendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool,
2293 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2294 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002295 logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002296 "SequNo": strconv.FormatInt(int64(tid), 16),
2297 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2298
2299 meInstance, omciErr := me.NewMulticastOperationsProfile(params[0])
2300 if omciErr.GetError() == nil {
2301 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.SetRequestType, omci.TransactionID(tid),
2302 omci.AddDefaults(true))
2303 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002304 logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002305 "device-id": oo.deviceID})
2306 return nil
2307 }
2308
dbainbri4d3a0dc2020-12-02 00:33:42 +00002309 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002310 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002311 logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002312 "device-id": oo.deviceID})
2313 return nil
2314 }
2315
2316 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002317 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002318 }
2319 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2320 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002321 logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002322 "device-id": oo.deviceID})
2323 return nil
2324 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002325 logger.Debug(ctx, "send MulticastOperationProfile-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002326 return meInstance
2327 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002328 logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002329 "device-id": oo.deviceID})
2330 return nil
2331}
2332
2333func (oo *omciCC) sendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool,
2334 rxChan chan Message, params ...me.ParamData) *me.ManagedEntity {
2335 tid := oo.getNextTid(highPrio)
dbainbri4d3a0dc2020-12-02 00:33:42 +00002336 logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002337 "SequNo": strconv.FormatInt(int64(tid), 16),
2338 "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)})
2339
2340 meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0])
2341 if omciErr.GetError() == nil {
2342 omciLayer, msgLayer, err := omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2343 omci.AddDefaults(true))
2344 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002345 logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002346 "device-id": oo.deviceID})
2347 return nil
2348 }
2349
dbainbri4d3a0dc2020-12-02 00:33:42 +00002350 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
ozgecanetsia422dbf32020-10-28 14:07:19 +03002351 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002352 logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002353 "device-id": oo.deviceID})
2354 return nil
2355 }
2356
2357 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002358 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
ozgecanetsia422dbf32020-10-28 14:07:19 +03002359 }
2360 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2361 if err != nil {
dbainbri4d3a0dc2020-12-02 00:33:42 +00002362 logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err,
ozgecanetsia422dbf32020-10-28 14:07:19 +03002363 "device-id": oo.deviceID})
2364 return nil
2365 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002366 logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done")
ozgecanetsia422dbf32020-10-28 14:07:19 +03002367 return meInstance
2368 }
dbainbri4d3a0dc2020-12-02 00:33:42 +00002369 logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(),
ozgecanetsia422dbf32020-10-28 14:07:19 +03002370 "device-id": oo.deviceID})
2371 return nil
2372}
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002373
Girish Gowdrae0140f02021-02-02 16:55:09 -08002374func (oo *omciCC) sendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error {
2375 tid := oo.getNextTid(highPrio)
2376 logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID,
2377 "SequNo": strconv.FormatInt(int64(tid), 16)})
2378
2379 omciLayer := &omci.OMCI{
2380 TransactionID: tid,
2381 MessageType: omci.SynchronizeTimeRequestType,
2382 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2383 // Length: 0x28, // Optional, defaults to 40 octets
2384 }
2385 utcTime := time.Now().UTC()
2386 request := &omci.SynchronizeTimeRequest{
2387 MeBasePacket: omci.MeBasePacket{
2388 EntityClass: me.OnuGClassID,
2389 // Default Instance ID is 0
2390 },
2391 Year: uint16(utcTime.Year()),
2392 Month: uint8(utcTime.Month()),
2393 Day: uint8(utcTime.Day()),
2394 Hour: uint8(utcTime.Hour()),
2395 Minute: uint8(utcTime.Minute()),
2396 Second: uint8(utcTime.Second()),
2397 }
2398
2399 pkt, err := serializeOmciLayer(ctx, omciLayer, request)
2400 if err != nil {
2401 logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err,
2402 "device-id": oo.deviceID})
2403 return err
2404 }
2405
2406 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002407 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002408 }
2409 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2410 if err != nil {
2411 logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err,
2412 "device-id": oo.deviceID})
2413 return err
2414 }
2415 logger.Debug(ctx, "send synchronize time request done")
2416 return nil
2417}
2418
2419func (oo *omciCC) sendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool,
2420 upstream bool, create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2421 tid := oo.getNextTid(highPrio)
2422 logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2423 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream})
2424 meParam := me.ParamData{EntityID: entityID}
2425 var meInstance *me.ManagedEntity
2426 var omciErr me.OmciErrors
2427 if upstream {
2428 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam)
2429 } else {
2430 meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam)
2431 }
2432 if omciErr.GetError() == nil {
2433 var omciLayer *omci.OMCI
2434 var msgLayer gopacket.SerializableLayer
2435 var err error
2436 if create {
2437 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2438 omci.AddDefaults(true))
2439 } else {
2440 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2441 omci.AddDefaults(true))
2442 }
2443 if err != nil {
2444 logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME",
2445 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2446 return nil
2447 }
2448
2449 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2450 if err != nil {
2451 logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME",
2452 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2453 return nil
2454 }
2455
2456 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002457 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002458 }
2459 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2460 if err != nil {
2461 logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME",
2462 log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2463 return nil
2464 }
2465 logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done",
2466 log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2467 return meInstance
2468 }
2469 logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance",
2470 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2471 return nil
2472}
2473
2474func (oo *omciCC) sendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool,
2475 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2476 tid := oo.getNextTid(highPrio)
2477 logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2478 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2479 meParam := me.ParamData{EntityID: entityID}
2480 var meInstance *me.ManagedEntity
2481 var omciErr me.OmciErrors
2482 meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam)
2483
2484 if omciErr.GetError() == nil {
2485 var omciLayer *omci.OMCI
2486 var msgLayer gopacket.SerializableLayer
2487 var err error
2488 if create {
2489 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2490 omci.AddDefaults(true))
2491 } else {
2492 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2493 omci.AddDefaults(true))
2494 }
2495 if err != nil {
2496 logger.Errorw(ctx, "Cannot encode ethernet uni history data ME",
2497 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2498 return nil
2499 }
2500
2501 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2502 if err != nil {
2503 logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME",
2504 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2505 return nil
2506 }
2507
2508 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002509 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdrae0140f02021-02-02 16:55:09 -08002510 }
2511 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2512 if err != nil {
2513 logger.Errorw(ctx, "Cannot send ethernet uni history data ME",
2514 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2515 return nil
2516 }
2517 logger.Debugw(ctx, "send ethernet uni history data ME done",
2518 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2519 return meInstance
2520 }
2521 logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance",
2522 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2523 return nil
2524}
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002525
2526func (oo *omciCC) sendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool,
2527 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2528 tid := oo.getNextTid(highPrio)
2529 logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2530 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2531 meParam := me.ParamData{EntityID: entityID}
2532 var meInstance *me.ManagedEntity
2533 var omciErr me.OmciErrors
2534 meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam)
2535
2536 if omciErr.GetError() == nil {
2537 var omciLayer *omci.OMCI
2538 var msgLayer gopacket.SerializableLayer
2539 var err error
2540 if create {
2541 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2542 omci.AddDefaults(true))
2543 } else {
2544 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2545 omci.AddDefaults(true))
2546 }
2547 if err != nil {
2548 logger.Errorw(ctx, "Cannot encode fec history data ME",
2549 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2550 return nil
2551 }
2552
2553 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2554 if err != nil {
2555 logger.Errorw(ctx, "Cannot serialize fec history data ME",
2556 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2557 return nil
2558 }
2559
2560 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002561 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002562 }
2563 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2564 if err != nil {
2565 logger.Errorw(ctx, "Cannot send fec history data ME",
2566 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2567 return nil
2568 }
2569 logger.Debugw(ctx, "send fec history data ME done",
2570 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2571 return meInstance
2572 }
2573 logger.Errorw(ctx, "Cannot generate fec history data ME Instance",
2574 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2575 return nil
2576}
2577
2578func (oo *omciCC) sendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool,
2579 create bool, rxChan chan Message, entityID uint16) *me.ManagedEntity {
2580 tid := oo.getNextTid(highPrio)
2581 logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID,
2582 "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create})
2583 meParam := me.ParamData{EntityID: entityID}
2584 var meInstance *me.ManagedEntity
2585 var omciErr me.OmciErrors
2586 meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam)
2587
2588 if omciErr.GetError() == nil {
2589 var omciLayer *omci.OMCI
2590 var msgLayer gopacket.SerializableLayer
2591 var err error
2592 if create {
2593 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.CreateRequestType, omci.TransactionID(tid),
2594 omci.AddDefaults(true))
2595 } else {
2596 omciLayer, msgLayer, err = omci.EncodeFrame(meInstance, omci.DeleteRequestType, omci.TransactionID(tid),
2597 omci.AddDefaults(true))
2598 }
2599 if err != nil {
2600 logger.Errorw(ctx, "Cannot encode gemport history data ME",
2601 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2602 return nil
2603 }
2604
2605 pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer)
2606 if err != nil {
2607 logger.Errorw(ctx, "Cannot serialize gemport history data ME",
2608 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2609 return nil
2610 }
2611
2612 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko80622a52021-02-09 16:53:23 +00002613 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
Girish Gowdra5c5aaf42021-02-17 19:40:50 -08002614 }
2615 err = oo.send(ctx, pkt, timeout, 0, highPrio, omciRxCallbackPair)
2616 if err != nil {
2617 logger.Errorw(ctx, "Cannot send gemport history data ME",
2618 log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2619 return nil
2620 }
2621 logger.Debugw(ctx, "send gemport history data ME done",
2622 log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2623 return meInstance
2624 }
2625 logger.Errorw(ctx, "Cannot generate gemport history data ME Instance",
2626 log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)})
2627 return nil
2628}
2629
mpagenko80622a52021-02-09 16:53:23 +00002630func (oo *omciCC) sendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2631 rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error {
2632 tid := oo.getNextTid(highPrio)
2633 logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2634 "SequNo": strconv.FormatInt(int64(tid), 16),
2635 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2636
2637 omciLayer := &omci.OMCI{
2638 TransactionID: tid,
2639 MessageType: omci.StartSoftwareDownloadRequestType,
2640 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2641 // Length: 0x28, // Optional, defaults to 40 octets
2642 }
2643 request := &omci.StartSoftwareDownloadRequest{
2644 MeBasePacket: omci.MeBasePacket{
2645 EntityClass: me.SoftwareImageClassID,
2646 EntityInstance: aImageMeID, //inactive image
2647 },
2648 WindowSize: aDownloadWindowSize,
2649 ImageSize: aFileLen,
2650 NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported
2651 CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib
2652 }
2653
2654 var options gopacket.SerializeOptions
2655 options.FixLengths = true
2656 buffer := gopacket.NewSerializeBuffer()
2657 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2658 if err != nil {
2659 logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err,
2660 "device-id": oo.deviceID})
2661 return err
2662 }
2663 outgoingPacket := buffer.Bytes()
2664
2665 omciRxCallbackPair := callbackPair{cbKey: tid,
2666 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2667 }
2668 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2669 if err != nil {
2670 logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err,
2671 "device-id": oo.deviceID})
2672 return err
2673 }
2674 logger.Debug(ctx, "send StartSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002675 return nil
2676}
2677
2678func (oo *omciCC) sendDownloadSection(ctx context.Context, timeout int, highPrio bool,
2679 rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error {
2680 tid := oo.getNextTid(highPrio)
2681 logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID,
2682 "SequNo": strconv.FormatInt(int64(tid), 16),
mpagenko15ff4a52021-03-02 10:09:20 +00002683 "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest})
mpagenko80622a52021-02-09 16:53:23 +00002684
2685 //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib
2686 // by now just try to send it as defined by omci-lib
mpagenko15ff4a52021-03-02 10:09:20 +00002687 msgType := omci.DownloadSectionRequestType
2688 if aAckRequest > 0 {
2689 msgType = omci.DownloadSectionRequestWithResponseType
2690 }
mpagenko80622a52021-02-09 16:53:23 +00002691 omciLayer := &omci.OMCI{
2692 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002693 MessageType: msgType,
mpagenko80622a52021-02-09 16:53:23 +00002694 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2695 // Length: 0x28, // Optional, defaults to 40 octets
2696 }
Girish Gowdra8a7b4562021-02-23 16:27:42 -08002697 var localSectionData [31]byte
mpagenko15ff4a52021-03-02 10:09:20 +00002698 copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array
mpagenko80622a52021-02-09 16:53:23 +00002699 request := &omci.DownloadSectionRequest{
2700 MeBasePacket: omci.MeBasePacket{
2701 EntityClass: me.SoftwareImageClassID,
2702 EntityInstance: aImageMeID, //inactive image
2703 },
2704 SectionNumber: aDownloadSectionNo,
2705 SectionData: localSectionData,
2706 }
2707
2708 var options gopacket.SerializeOptions
2709 options.FixLengths = true
2710 buffer := gopacket.NewSerializeBuffer()
2711 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2712 if err != nil {
2713 logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err,
2714 "device-id": oo.deviceID})
2715 return err
2716 }
2717 outgoingPacket := buffer.Bytes()
2718
mpagenko15ff4a52021-03-02 10:09:20 +00002719 //for initial debug purpose overrule the requested print state for some frames
2720 printFrame := aPrint
2721 if aAckRequest > 0 || aDownloadSectionNo == 0 {
2722 printFrame = true
2723 }
2724
mpagenko80622a52021-02-09 16:53:23 +00002725 omciRxCallbackPair := callbackPair{cbKey: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002726 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/},
mpagenko80622a52021-02-09 16:53:23 +00002727 }
2728 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2729 if err != nil {
2730 logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err,
2731 "device-id": oo.deviceID})
2732 return err
2733 }
2734 logger.Debug(ctx, "send DlSectionRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002735 return nil
2736}
2737
2738func (oo *omciCC) sendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool,
2739 rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error {
2740 tid := oo.getNextTid(highPrio)
2741 logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID,
2742 "SequNo": strconv.FormatInt(int64(tid), 16),
2743 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2744
mpagenko15ff4a52021-03-02 10:09:20 +00002745 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002746 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002747 MessageType: omci.EndSoftwareDownloadRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002748 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2749 // Length: 0x28, // Optional, defaults to 40 octets
2750 }
mpagenko15ff4a52021-03-02 10:09:20 +00002751 request := &omci.EndSoftwareDownloadRequest{
mpagenko80622a52021-02-09 16:53:23 +00002752 MeBasePacket: omci.MeBasePacket{
2753 EntityClass: me.SoftwareImageClassID,
2754 EntityInstance: aImageMeID, //inactive image
2755 },
mpagenko15ff4a52021-03-02 10:09:20 +00002756 CRC32: aImageCrc,
2757 ImageSize: aFileLen,
2758 NumberOfInstances: 1, //parallel download to multiple circuit packs not supported
2759 ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest
mpagenko80622a52021-02-09 16:53:23 +00002760 }
mpagenko15ff4a52021-03-02 10:09:20 +00002761
2762 var options gopacket.SerializeOptions
2763 options.FixLengths = true
2764 buffer := gopacket.NewSerializeBuffer()
2765 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2766 if err != nil {
2767 logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002768 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002769 return err
mpagenko80622a52021-02-09 16:53:23 +00002770 }
mpagenko15ff4a52021-03-02 10:09:20 +00002771 outgoingPacket := buffer.Bytes()
2772
2773 omciRxCallbackPair := callbackPair{cbKey: tid,
2774 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2775 }
2776 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2777 if err != nil {
2778 logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err,
2779 "device-id": oo.deviceID})
2780 return err
2781 }
2782 logger.Debug(ctx, "send EndSwDlRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002783 return nil
2784}
2785
2786func (oo *omciCC) sendActivateSoftware(ctx context.Context, timeout int, highPrio bool,
2787 rxChan chan Message, aImageMeID uint16) error {
2788 tid := oo.getNextTid(highPrio)
2789 logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID,
2790 "SequNo": strconv.FormatInt(int64(tid), 16),
2791 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2792
2793 omciLayer := &omci.OMCI{
2794 TransactionID: tid,
2795 MessageType: omci.ActivateSoftwareRequestType,
2796 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2797 // Length: 0x28, // Optional, defaults to 40 octets
2798 }
2799 request := &omci.ActivateSoftwareRequest{
2800 MeBasePacket: omci.MeBasePacket{
2801 EntityClass: me.SoftwareImageClassID,
2802 EntityInstance: aImageMeID, //inactive image
2803 },
2804 ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP)
2805 }
2806
2807 var options gopacket.SerializeOptions
2808 options.FixLengths = true
2809 buffer := gopacket.NewSerializeBuffer()
2810 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2811 if err != nil {
2812 logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err,
2813 "device-id": oo.deviceID})
2814 return err
2815 }
2816 outgoingPacket := buffer.Bytes()
2817
2818 omciRxCallbackPair := callbackPair{cbKey: tid,
2819 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2820 }
2821 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2822 if err != nil {
2823 logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err,
2824 "device-id": oo.deviceID})
2825 return err
2826 }
2827 logger.Debug(ctx, "send ActivateSwRequest done")
mpagenko15ff4a52021-03-02 10:09:20 +00002828 return nil
2829}
mpagenko80622a52021-02-09 16:53:23 +00002830
mpagenko15ff4a52021-03-02 10:09:20 +00002831func (oo *omciCC) sendCommitSoftware(ctx context.Context, timeout int, highPrio bool,
2832 rxChan chan Message, aImageMeID uint16) error {
2833 tid := oo.getNextTid(highPrio)
2834 logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID,
2835 "SequNo": strconv.FormatInt(int64(tid), 16),
2836 "InstId": strconv.FormatInt(int64(aImageMeID), 16)})
2837
2838 omciLayer := &omci.OMCI{
mpagenko80622a52021-02-09 16:53:23 +00002839 TransactionID: tid,
mpagenko15ff4a52021-03-02 10:09:20 +00002840 MessageType: omci.CommitSoftwareRequestType,
mpagenko80622a52021-02-09 16:53:23 +00002841 // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline
2842 // Length: 0x28, // Optional, defaults to 40 octets
2843 }
mpagenko15ff4a52021-03-02 10:09:20 +00002844 request := &omci.CommitSoftwareRequest{
mpagenko80622a52021-02-09 16:53:23 +00002845 MeBasePacket: omci.MeBasePacket{
2846 EntityClass: me.SoftwareImageClassID,
2847 EntityInstance: aImageMeID, //inactive image
2848 },
mpagenko80622a52021-02-09 16:53:23 +00002849 }
mpagenko15ff4a52021-03-02 10:09:20 +00002850
2851 var options gopacket.SerializeOptions
2852 options.FixLengths = true
2853 buffer := gopacket.NewSerializeBuffer()
2854 err := gopacket.SerializeLayers(buffer, options, omciLayer, request)
2855 if err != nil {
2856 logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err,
mpagenko80622a52021-02-09 16:53:23 +00002857 "device-id": oo.deviceID})
mpagenko15ff4a52021-03-02 10:09:20 +00002858 return err
mpagenko80622a52021-02-09 16:53:23 +00002859 }
mpagenko15ff4a52021-03-02 10:09:20 +00002860 outgoingPacket := buffer.Bytes()
2861
2862 omciRxCallbackPair := callbackPair{cbKey: tid,
2863 cbEntry: callbackPairEntry{rxChan, oo.receiveOmciResponse, true},
2864 }
2865 err = oo.send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair)
2866 if err != nil {
2867 logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err,
2868 "device-id": oo.deviceID})
2869 return err
2870 }
2871 logger.Debug(ctx, "send CommitSwRequest done")
mpagenko80622a52021-02-09 16:53:23 +00002872 return nil
2873}
2874
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002875func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool {
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002876 for _, v := range responsesWithMibDataSync {
Holger Hildebrandt3124e302021-03-23 12:47:03 +00002877 if v == omciMsg.MessageType {
2878 nextLayer, _ := omci.MsgTypeToNextLayer(v)
2879 msgLayer := (*packet).Layer(nextLayer)
2880 switch nextLayer {
2881 case omci.LayerTypeCreateResponse:
2882 if msgLayer.(*omci.CreateResponse).Result == me.Success {
2883 return true
2884 }
2885 case omci.LayerTypeDeleteResponse:
2886 if msgLayer.(*omci.DeleteResponse).Result == me.Success {
2887 return true
2888 }
2889 case omci.LayerTypeSetResponse:
2890 if msgLayer.(*omci.SetResponse).Result == me.Success {
2891 return true
2892 }
2893 case omci.LayerTypeStartSoftwareDownloadResponse:
2894 if msgLayer.(*omci.StartSoftwareDownloadResponse).Result == me.Success {
2895 return true
2896 }
2897 case omci.LayerTypeEndSoftwareDownloadResponse:
2898 if msgLayer.(*omci.EndSoftwareDownloadResponse).Result == me.Success {
2899 return true
2900 }
2901 case omci.LayerTypeActivateSoftwareResponse:
2902 if msgLayer.(*omci.ActivateSoftwareResponse).Result == me.Success {
2903 return true
2904 }
2905 case omci.LayerTypeCommitSoftwareResponse:
2906 if msgLayer.(*omci.CommitSoftwareResponse).Result == me.Success {
2907 return true
2908 }
2909 }
Holger Hildebrandt0bd45f82021-01-11 13:29:37 +00002910 }
2911 }
2912 return false
2913}