Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 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 Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 17 | //Package common provides global definitions |
| 18 | package common |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 19 | |
| 20 | import ( |
| 21 | "container/list" |
| 22 | "context" |
| 23 | "encoding/binary" |
| 24 | "encoding/hex" |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 25 | "fmt" |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 26 | "strconv" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 27 | "sync" |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 28 | "time" //by now for testing |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 29 | |
| 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 | |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 34 | "github.com/opencord/omci-lib-go/v2" |
| 35 | me "github.com/opencord/omci-lib-go/v2/generated" |
| 36 | oframe "github.com/opencord/omci-lib-go/v2/meframe" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 37 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 38 | vgrpc "github.com/opencord/voltha-lib-go/v7/pkg/grpc" |
| 39 | |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 40 | "github.com/opencord/voltha-lib-go/v7/pkg/log" |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 41 | "github.com/opencord/voltha-protos/v5/go/common" |
| 42 | ia "github.com/opencord/voltha-protos/v5/go/inter_adapter" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 43 | ) |
| 44 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 45 | // ### OMCI related definitions - retrieved from Python adapter code/trace #### |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 46 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 47 | const maxGemPayloadSize = uint16(48) |
| 48 | const connectivityModeValue = uint8(5) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 49 | |
| 50 | //const defaultTPID = uint16(0x8100) |
| 51 | //const broadComDefaultVID = uint16(4091) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 52 | |
| 53 | // UnusedTcontAllocID - TODO: add comment |
| 54 | const UnusedTcontAllocID = uint16(0xFFFF) //common unused AllocId for G.984 and G.987 systems |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 55 | |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 56 | const cOmciBaseMessageTrailerLen = 40 |
| 57 | |
| 58 | // tOmciReceiveError - enum type for detected problems/errors in the received OMCI message (format) |
| 59 | type tOmciReceiveError uint8 |
| 60 | |
| 61 | const ( |
| 62 | // cOmciMessageReceiveNoError - default start state |
| 63 | cOmciMessageReceiveNoError tOmciReceiveError = iota |
| 64 | // Error indication wrong trailer length within the message |
| 65 | cOmciMessageReceiveErrorTrailerLen |
| 66 | // Error indication missing trailer within the message |
| 67 | cOmciMessageReceiveErrorMissTrailer |
| 68 | ) |
| 69 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 70 | // CDefaultRetries - TODO: add comment |
| 71 | const CDefaultRetries = 2 |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 72 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 73 | // ### OMCI related definitions - end |
| 74 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 75 | //CallbackPairEntry to be used for OMCI send/receive correlation |
| 76 | type CallbackPairEntry struct { |
| 77 | CbRespChannel chan Message |
| 78 | CbFunction func(context.Context, *omci.OMCI, *gp.Packet, chan Message) error |
| 79 | FramePrint bool //true for printing |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 82 | //CallbackPair to be used for ReceiveCallback init |
| 83 | type CallbackPair struct { |
| 84 | CbKey uint16 |
| 85 | CbEntry CallbackPairEntry |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 88 | // OmciTransferStructure - TODO: add comment |
| 89 | type OmciTransferStructure struct { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 90 | txFrame []byte |
| 91 | timeout int |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 92 | retries int |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 93 | highPrio bool |
| 94 | withFramePrint bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 95 | cbPair CallbackPair |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 96 | chSuccess chan bool |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 97 | OnuSwWindow *ia.OmciMessages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 100 | //OmciCC structure holds information needed for OMCI communication (to/from OLT Adapter) |
| 101 | type OmciCC struct { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 102 | enabled bool |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 103 | pBaseDeviceHandler IdeviceHandler |
| 104 | pOnuDeviceEntry IonuDeviceEntry |
| 105 | pOnuAlarmManager IonuAlarmManager |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 106 | deviceID string |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 107 | coreClient *vgrpc.Client |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 108 | supportExtMsg bool |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 109 | rxOmciFrameError tOmciReceiveError |
| 110 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 111 | txFrames, txOnuFrames uint32 |
| 112 | rxFrames, rxOnuFrames, rxOnuDiscards uint32 |
| 113 | |
| 114 | // OMCI params |
| 115 | mutexTid sync.Mutex |
| 116 | tid uint16 |
| 117 | mutexHpTid sync.Mutex |
| 118 | hpTid uint16 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 119 | UploadSequNo uint16 |
| 120 | UploadNoOfCmds uint16 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 121 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 122 | mutexSendQueuedRequests sync.Mutex |
| 123 | mutexLowPrioTxQueue sync.Mutex |
| 124 | lowPrioTxQueue *list.List |
| 125 | mutexHighPrioTxQueue sync.Mutex |
| 126 | highPrioTxQueue *list.List |
| 127 | mutexRxSchedMap sync.Mutex |
| 128 | rxSchedulerMap map[uint16]CallbackPairEntry |
| 129 | mutexMonReq sync.RWMutex |
| 130 | monitoredRequests map[uint16]OmciTransferStructure |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 133 | var responsesWithMibDataSync = []omci.MessageType{ |
| 134 | omci.CreateResponseType, |
| 135 | omci.DeleteResponseType, |
| 136 | omci.SetResponseType, |
| 137 | omci.StartSoftwareDownloadResponseType, |
| 138 | omci.EndSoftwareDownloadResponseType, |
| 139 | omci.ActivateSoftwareResponseType, |
| 140 | omci.CommitSoftwareResponseType, |
| 141 | } |
| 142 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 143 | //NewOmciCC constructor returns a new instance of a OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 144 | //mib_db (as well as not inluded alarm_db not really used in this code? VERIFY!!) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 145 | func NewOmciCC(ctx context.Context, deviceID string, deviceHandler IdeviceHandler, |
| 146 | onuDeviceEntry IonuDeviceEntry, onuAlarmManager IonuAlarmManager, |
| 147 | coreClient *vgrpc.Client) *OmciCC { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 148 | logger.Debugw(ctx, "init-omciCC", log.Fields{"device-id": deviceID}) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 149 | var omciCC OmciCC |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 150 | omciCC.enabled = false |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 151 | omciCC.pBaseDeviceHandler = deviceHandler |
| 152 | omciCC.pOnuAlarmManager = onuAlarmManager |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 153 | omciCC.pOnuDeviceEntry = onuDeviceEntry |
| 154 | omciCC.deviceID = deviceID |
khenaidoo | 7d3c558 | 2021-08-11 18:09:44 -0400 | [diff] [blame] | 155 | omciCC.coreClient = coreClient |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 156 | omciCC.supportExtMsg = false |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 157 | omciCC.rxOmciFrameError = cOmciMessageReceiveNoError |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 158 | omciCC.txFrames = 0 |
| 159 | omciCC.txOnuFrames = 0 |
| 160 | omciCC.rxFrames = 0 |
| 161 | omciCC.rxOnuFrames = 0 |
| 162 | omciCC.rxOnuDiscards = 0 |
| 163 | omciCC.tid = 0x1 |
| 164 | omciCC.hpTid = 0x8000 |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 165 | omciCC.UploadSequNo = 0 |
| 166 | omciCC.UploadNoOfCmds = 0 |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 167 | omciCC.lowPrioTxQueue = list.New() |
| 168 | omciCC.highPrioTxQueue = list.New() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 169 | omciCC.rxSchedulerMap = make(map[uint16]CallbackPairEntry) |
| 170 | omciCC.monitoredRequests = make(map[uint16]OmciTransferStructure) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 171 | |
| 172 | return &omciCC |
| 173 | } |
| 174 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 175 | //Stop stops/resets the omciCC |
| 176 | func (oo *OmciCC) Stop(ctx context.Context) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 177 | logger.Debugw(ctx, "omciCC-stopping", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 178 | //reseting all internal data, which might also be helpful for discarding any lingering tx/rx requests |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 179 | oo.CancelRequestMonitoring(ctx) |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 180 | // clear the tx queues |
| 181 | oo.mutexHighPrioTxQueue.Lock() |
| 182 | oo.highPrioTxQueue.Init() |
| 183 | oo.mutexHighPrioTxQueue.Unlock() |
| 184 | oo.mutexLowPrioTxQueue.Lock() |
| 185 | oo.lowPrioTxQueue.Init() |
| 186 | oo.mutexLowPrioTxQueue.Unlock() |
| 187 | //clear the scheduler map |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 188 | oo.mutexRxSchedMap.Lock() |
| 189 | for k := range oo.rxSchedulerMap { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 190 | delete(oo.rxSchedulerMap, k) |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 191 | } |
| 192 | oo.mutexRxSchedMap.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 193 | //reset the high prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 194 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 195 | oo.hpTid = 0x8000 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 196 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 197 | //reset the low prio transactionId |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 198 | oo.mutexTid.Lock() |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 199 | oo.tid = 1 |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 200 | oo.mutexTid.Unlock() |
| 201 | //reset control values |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 202 | oo.UploadSequNo = 0 |
| 203 | oo.UploadNoOfCmds = 0 |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 204 | oo.rxOmciFrameError = cOmciMessageReceiveNoError |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 205 | //reset the stats counter - which might be topic of discussion ... |
| 206 | oo.txFrames = 0 |
| 207 | oo.txOnuFrames = 0 |
| 208 | oo.rxFrames = 0 |
| 209 | oo.rxOnuFrames = 0 |
| 210 | oo.rxOnuDiscards = 0 |
| 211 | |
| 212 | return nil |
| 213 | } |
| 214 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 215 | // Rx handler for omci messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 216 | func (oo *OmciCC) receiveOnuMessage(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 217 | logger.Debugw(ctx, "rx-onu-autonomous-message", log.Fields{"omciMsgType": omciMsg.MessageType, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 218 | "payload": hex.EncodeToString(omciMsg.Payload)}) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 219 | switch omciMsg.MessageType { |
| 220 | case omci.AlarmNotificationType: |
| 221 | data := OmciMessage{ |
| 222 | OmciMsg: omciMsg, |
| 223 | OmciPacket: packet, |
| 224 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 225 | go oo.pOnuAlarmManager.HandleOmciAlarmNotificationMessage(ctx, data) |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 226 | return nil |
| 227 | default: |
| 228 | return fmt.Errorf("receiveOnuMessageType %s unimplemented", omciMsg.MessageType.String()) |
| 229 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 230 | /* |
| 231 | msgType = rxFrame.fields["message_type"] //assumed OmciOperationsValue |
| 232 | rxOnuFrames++ |
| 233 | |
| 234 | switch msgType { |
| 235 | case AlarmNotification: |
| 236 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 237 | logger.Info("Unhandled: received-onu-alarm-message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 238 | // python code was: |
| 239 | //if msg_type == EntityOperations.AlarmNotification.value: |
| 240 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Alarm_Notification) |
| 241 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 242 | // |
| 243 | return errors.New("RxAlarmNotification unimplemented") |
| 244 | } |
| 245 | case AttributeValueChange: |
| 246 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 247 | logger.Info("Unhandled: received-attribute-value-change") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 248 | // python code was: |
| 249 | //elif msg_type == EntityOperations.AttributeValueChange.value: |
| 250 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.AVC_Notification) |
| 251 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 252 | // |
| 253 | return errors.New("RxAttributeValueChange unimplemented") |
| 254 | } |
| 255 | case TestResult: |
| 256 | { |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 257 | logger.Info("Unhandled: received-test-result") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 258 | // python code was: |
| 259 | //elif msg_type == EntityOperations.TestResult.value: |
| 260 | // topic = OMCI_CC.event_bus_topic(self._device_id, RxEvent.Test_Result) |
| 261 | // self.reactor.callLater(0, self.event_bus.publish, topic, msg) |
| 262 | // |
| 263 | return errors.New("RxTestResult unimplemented") |
| 264 | } |
| 265 | default: |
| 266 | { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 267 | logger.Errorw(ctx,"rx-onu-unsupported-autonomous-message", log.Fields{"msgType": msgType}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 268 | rxOnuDiscards++ |
| 269 | return errors.New("RxOnuMsgType unimplemented") |
| 270 | } |
| 271 | } |
| 272 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 275 | func (oo *OmciCC) printRxMessage(ctx context.Context, rxMsg []byte) { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 276 | //assuming omci message content is hex coded! |
| 277 | // with restricted output of 16bytes would be ...rxMsg[:16] |
| 278 | logger.Debugw(ctx, "omci-message-received:", log.Fields{ |
| 279 | "RxOmciMessage": hex.EncodeToString(rxMsg), |
| 280 | "device-id": oo.deviceID}) |
| 281 | } |
| 282 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 283 | // ReceiveMessage - Rx handler for onu messages |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 284 | // e.g. would call ReceiveOnuMessage() in case of TID=0 or Action=test ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 285 | func (oo *OmciCC) ReceiveMessage(ctx context.Context, rxMsg []byte) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 286 | //logger.Debugw(ctx,"cc-receive-omci-message", log.Fields{"RxOmciMessage-x2s": hex.EncodeToString(rxMsg)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 287 | if len(rxMsg) >= 44 { // then it should normally include the BaseFormat trailer Len |
| 288 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 289 | // (an extendedFormat message could be destroyed this way!) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 290 | trailerLenData := rxMsg[42:44] |
| 291 | trailerLen := binary.BigEndian.Uint16(trailerLenData) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 292 | //logger.Debugw(ctx,"omci-received-trailer-len", log.Fields{"Length": trailerLen}) |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 293 | if trailerLen != cOmciBaseMessageTrailerLen { // invalid base Format entry -> autocorrect |
| 294 | binary.BigEndian.PutUint16(rxMsg[42:44], cOmciBaseMessageTrailerLen) |
| 295 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorTrailerLen { |
| 296 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 297 | logger.Errorw(ctx, "wrong omci-message trailer length: trailer len auto-corrected", |
| 298 | log.Fields{"trailer-length": trailerLen, "device-id": oo.deviceID}) |
| 299 | oo.rxOmciFrameError = cOmciMessageReceiveErrorTrailerLen |
| 300 | } |
| 301 | } |
| 302 | } else if len(rxMsg) >= cOmciBaseMessageTrailerLen { // workaround for Adtran OLT Sim, which currently does not send trailer bytes at all! |
| 303 | // NOTE: autocorrection only valid for OmciBaseFormat, which is not specifically verified here!!! |
| 304 | // (an extendedFormat message could be destroyed this way!) |
| 305 | // extend/overwrite with trailer |
| 306 | trailer := make([]byte, 8) |
| 307 | binary.BigEndian.PutUint16(trailer[2:], cOmciBaseMessageTrailerLen) //set the defined baseline length |
| 308 | rxMsg = append(rxMsg[:cOmciBaseMessageTrailerLen], trailer...) |
| 309 | if oo.rxOmciFrameError != cOmciMessageReceiveErrorMissTrailer { |
| 310 | //do just one error log, expectation is: if seen once it should appear regularly - avoid to many log entries |
| 311 | logger.Errorw(ctx, "omci-message to short to include trailer len: trailer auto-corrected (added)", |
| 312 | log.Fields{"message-length": len(rxMsg), "device-id": oo.deviceID}) |
| 313 | oo.rxOmciFrameError = cOmciMessageReceiveErrorMissTrailer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 314 | } |
| 315 | } else { |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 316 | logger.Errorw(ctx, "received omci-message too small for OmciBaseFormat - abort", |
| 317 | log.Fields{"Length": len(rxMsg), "device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 318 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 319 | return fmt.Errorf("rxOmciMessage too small for BaseFormat %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | packet := gopacket.NewPacket(rxMsg, omci.LayerTypeOMCI, gopacket.NoCopy) |
| 323 | if packet == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 324 | logger.Errorw(ctx, "omci-message could not be decoded", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 325 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 326 | return fmt.Errorf("could not decode rxMsg as OMCI %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 327 | } |
| 328 | omciLayer := packet.Layer(omci.LayerTypeOMCI) |
| 329 | if omciLayer == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 330 | logger.Errorw(ctx, "omci-message could not decode omci layer", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 331 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 332 | return fmt.Errorf("could not decode omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 333 | } |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 334 | // insert some check on detected OMCI decoding issues and log them |
| 335 | // e.g. should indicate problems when detecting some unknown attribute mask content (independent from message type) |
| 336 | // even though allowed from omci-lib due to set relaxed decoding |
| 337 | // application may dig into further details if wanted/needed on their own [but info is not transferred from here so far] |
| 338 | // (compare mib_sync.go unknownAttrLayer) |
| 339 | errLayer := packet.Layer(gopacket.LayerTypeDecodeFailure) |
| 340 | if failure, decodeOk := errLayer.(*gopacket.DecodeFailure); decodeOk { |
| 341 | errMsg := failure.Error() |
| 342 | logger.Warnw(ctx, "Detected decode issue on received OMCI frame", log.Fields{ |
| 343 | "device-id": oo.deviceID, "issue": errMsg}) |
| 344 | } |
| 345 | //anyway try continue OMCI decoding further on message type layer |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 346 | omciMsg, ok := omciLayer.(*omci.OMCI) |
| 347 | if !ok { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 348 | logger.Errorw(ctx, "omci-message could not assign omci layer", log.Fields{"device-id": oo.deviceID}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 349 | oo.printRxMessage(ctx, rxMsg) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 350 | return fmt.Errorf("could not assign omci layer %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 351 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 352 | logger.Debugw(ctx, "omci-message-decoded:", log.Fields{"omciMsgType": omciMsg.MessageType, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 353 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "DeviceIdent": omciMsg.DeviceIdentifier}) |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 354 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 355 | // TestResult is asynchronous indication that carries the same TID as the TestResponse. |
| 356 | // We expect to find the TID in the oo.rxSchedulerMap |
| 357 | if byte(omciMsg.MessageType)&me.AK == 0 && omciMsg.MessageType != omci.TestResultType { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 358 | // Not a response |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 359 | oo.printRxMessage(ctx, rxMsg) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 360 | logger.Debug(ctx, "RxMsg is no Omci Response Message") |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 361 | if omciMsg.TransactionID == 0 { |
Himani Chawla | ac1f5ad | 2021-02-04 21:21:54 +0530 | [diff] [blame] | 362 | return oo.receiveOnuMessage(ctx, omciMsg, &packet) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 363 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 364 | logger.Errorw(ctx, "Unexpected TransCorrId != 0 not accepted for autonomous messages", |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 365 | log.Fields{"msgType": omciMsg.MessageType, "payload": hex.EncodeToString(omciMsg.Payload), |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 366 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 367 | return fmt.Errorf("autonomous Omci Message with TranSCorrId != 0 not acccepted %s", oo.deviceID) |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 368 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 369 | //logger.Debug(ctx,"RxMsg is a Omci Response Message: try to schedule it to the requester") |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 370 | oo.mutexRxSchedMap.Lock() |
| 371 | rxCallbackEntry, ok := oo.rxSchedulerMap[omciMsg.TransactionID] |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 372 | if ok && rxCallbackEntry.CbFunction != nil { |
| 373 | if rxCallbackEntry.FramePrint { |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 374 | oo.printRxMessage(ctx, rxMsg) |
| 375 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 376 | //disadvantage of decoupling: error verification made difficult, but anyway the question is |
| 377 | // how to react on erroneous frame reception, maybe can simply be ignored |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 378 | go rxCallbackEntry.CbFunction(ctx, omciMsg, &packet, rxCallbackEntry.CbRespChannel) |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 379 | if isSuccessfulResponseWithMibDataSync(omciMsg, &packet) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 380 | oo.pOnuDeviceEntry.IncrementMibDataSync(ctx) |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 381 | } |
mpagenko | c8bba41 | 2021-01-15 15:38:44 +0000 | [diff] [blame] | 382 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 383 | // If omciMsg.MessageType is omci.TestResponseType, we still expect the TestResult OMCI message, |
| 384 | // so do not clean up the TransactionID in that case. |
| 385 | if omciMsg.MessageType != omci.TestResponseType { |
| 386 | // having posted the response the request is regarded as 'done' |
| 387 | delete(oo.rxSchedulerMap, omciMsg.TransactionID) |
| 388 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 389 | oo.mutexRxSchedMap.Unlock() |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 390 | return nil |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 391 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 392 | oo.mutexRxSchedMap.Unlock() |
| 393 | logger.Errorw(ctx, "omci-message-response for not registered transCorrId", log.Fields{"device-id": oo.deviceID}) |
| 394 | oo.printRxMessage(ctx, rxMsg) |
| 395 | return fmt.Errorf("could not find registered response handler tor transCorrId %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 396 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 397 | /* py code was: |
| 398 | Receive and OMCI message from the proxy channel to the OLT. |
| 399 | |
| 400 | Call this from your ONU Adapter on a new OMCI Rx on the proxy channel |
| 401 | :param msg: (str) OMCI binary message (used as input to Scapy packet decoder) |
| 402 | """ |
| 403 | if not self.enabled: |
| 404 | return |
| 405 | |
| 406 | try: |
| 407 | now = arrow.utcnow() |
| 408 | d = None |
| 409 | |
| 410 | # NOTE: Since we may need to do an independent ME map on a per-ONU basis |
| 411 | # save the current value of the entity_id_to_class_map, then |
| 412 | # replace it with our custom one before decode, and then finally |
| 413 | # restore it later. Tried other ways but really made the code messy. |
| 414 | saved_me_map = omci_entities.entity_id_to_class_map |
| 415 | omci_entities.entity_id_to_class_map = self._me_map |
| 416 | |
| 417 | try: |
| 418 | rx_frame = msg if isinstance(msg, OmciFrame) else OmciFrame(msg) |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 419 | self.logger.debug('recv-omci-msg', omci_msg=hexlify(msg)) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 420 | except KeyError as e: |
| 421 | # Unknown, Unsupported, or vendor-specific ME. Key is the unknown classID |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 422 | self.logger.debug('frame-decode-key-error', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 423 | rx_frame = self._decode_unknown_me(msg) |
| 424 | self._rx_unknown_me += 1 |
| 425 | |
| 426 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 427 | self.logger.exception('frame-decode', omci_msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 428 | return |
| 429 | |
| 430 | finally: |
| 431 | omci_entities.entity_id_to_class_map = saved_me_map # Always restore it. |
| 432 | |
| 433 | rx_tid = rx_frame.fields['transaction_id'] |
| 434 | msg_type = rx_frame.fields['message_type'] |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 435 | self.logger.debug('Received message for rx_tid', rx_tid = rx_tid, msg_type = msg_type) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 436 | # Filter the Test Result frame and route through receive onu |
| 437 | # message method. |
| 438 | if rx_tid == 0 or msg_type == EntityOperations.TestResult.value: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 439 | self.logger.debug('Receive ONU message', rx_tid=0) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 440 | return self._receive_onu_message(rx_frame) |
| 441 | |
| 442 | # Previously unreachable if this is the very first round-trip Rx or we |
| 443 | # have been running consecutive errors |
| 444 | if self._rx_frames == 0 or self._consecutive_errors != 0: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 445 | self.logger.debug('Consecutive errors for rx', err = self._consecutive_errors) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 446 | self.reactor.callLater(0, self._publish_connectivity_event, True) |
| 447 | |
| 448 | self._rx_frames += 1 |
| 449 | self._consecutive_errors = 0 |
| 450 | |
| 451 | try: |
| 452 | high_priority = self._tid_is_high_priority(rx_tid) |
| 453 | index = self._get_priority_index(high_priority) |
| 454 | |
| 455 | # (timestamp, defer, frame, timeout, retry, delayedCall) |
| 456 | last_tx_tuple = self._tx_request[index] |
| 457 | |
| 458 | if last_tx_tuple is None or \ |
| 459 | last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id') != rx_tid: |
| 460 | # Possible late Rx on a message that timed-out |
| 461 | if last_tx_tuple: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 462 | self.logger.debug('Unknown message', rx_tid=rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 463 | tx_id=last_tx_tuple[OMCI_CC.REQUEST_FRAME].fields.get('transaction_id')) |
| 464 | self._rx_unknown_tid += 1 |
| 465 | self._rx_late += 1 |
| 466 | return |
| 467 | |
| 468 | ts, d, tx_frame, timeout, retry, dc = last_tx_tuple |
| 469 | if dc is not None and not dc.cancelled and not dc.called: |
| 470 | dc.cancel() |
| 471 | |
| 472 | _secs = self._update_rx_tx_stats(now, ts) |
| 473 | |
| 474 | # Late arrival already serviced by a timeout? |
| 475 | if d.called: |
| 476 | self._rx_late += 1 |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 477 | self.logger.debug('Serviced by timeout. Late arrival', rx_late = self._rx_late) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 478 | return |
| 479 | |
| 480 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 481 | self.logger.exception('frame-match', msg=hexlify(msg), e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 482 | if d is not None: |
| 483 | return d.errback(failure.Failure(e)) |
| 484 | return |
| 485 | |
| 486 | # Publish Rx event to listeners in a different task |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 487 | self.logger.debug('Publish rx event', rx_tid = rx_tid, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 488 | tx_tid = tx_frame.fields['transaction_id']) |
| 489 | reactor.callLater(0, self._publish_rx_frame, tx_frame, rx_frame) |
| 490 | |
| 491 | # begin success callback chain (will cancel timeout and queue next Tx message) |
| 492 | self._rx_response[index] = rx_frame |
| 493 | d.callback(rx_frame) |
| 494 | |
| 495 | except Exception as e: |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 496 | self.logger.exception('rx-msg', e=e) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 497 | */ |
| 498 | } |
| 499 | |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 500 | /* |
| 501 | func (oo *omciCC) publishRxResponseFrame(ctx context.Context, txFrame []byte, rxFrame []byte) error { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 502 | return errors.New("publishRxResponseFrame unimplemented") |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 503 | //def _publish_rx_frame(self, tx_frame, rx_frame): |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 504 | } |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 505 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 506 | |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 507 | // ReleaseTid releases OMCI transaction identifier from rxSchedulerMap |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 508 | func (oo *OmciCC) ReleaseTid(ctx context.Context, tid uint16) { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 509 | logger.Debugw(ctx, "releasing tid from rxSchedulerMap", log.Fields{"tid": tid}) |
| 510 | delete(oo.rxSchedulerMap, tid) |
| 511 | } |
| 512 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 513 | // Send - Queue the OMCI Frame for a transmit to the ONU via the proxy_channel |
| 514 | func (oo *OmciCC) Send(ctx context.Context, txFrame []byte, timeout int, retry int, highPrio bool, |
| 515 | receiveCallbackPair CallbackPair) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 516 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 517 | if timeout != 0 { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 518 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": receiveCallbackPair.CbKey}) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 519 | oo.mutexRxSchedMap.Lock() |
| 520 | // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 521 | oo.rxSchedulerMap[receiveCallbackPair.CbKey] = receiveCallbackPair.CbEntry |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 522 | oo.mutexRxSchedMap.Unlock() |
| 523 | } //else timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 524 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 525 | printFrame := receiveCallbackPair.CbEntry.FramePrint //printFrame true means debug print of frame is requested |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 526 | //just use a simple list for starting - might need some more effort, especially for multi source write access |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 527 | omciTxRequest := OmciTransferStructure{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 528 | txFrame, |
| 529 | timeout, |
| 530 | retry, |
| 531 | highPrio, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 532 | printFrame, |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 533 | receiveCallbackPair, |
| 534 | nil, |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 535 | nil, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 536 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 537 | oo.mutexMonReq.Lock() |
| 538 | defer oo.mutexMonReq.Unlock() |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 539 | if _, exist := oo.monitoredRequests[receiveCallbackPair.CbKey]; !exist { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 540 | // do not call processRequestMonitoring in background here to ensure correct sequencing |
| 541 | // of requested messages into txQueue (especially for non-response-supervised messages) |
| 542 | oo.processRequestMonitoring(ctx, omciTxRequest) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 543 | return nil |
| 544 | } |
| 545 | logger.Errorw(ctx, "A message with this tid is processed already!", |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 546 | log.Fields{"tid": receiveCallbackPair.CbKey, "device-id": oo.deviceID}) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 547 | return fmt.Errorf("message with tid is processed already %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 550 | func (oo *OmciCC) sendQueuedRequests(ctx context.Context) { |
| 551 | // Avoid accessing the txQueues from parallel send routines to block |
| 552 | // parallel omci send requests at least until SendIAP is 'committed'. |
| 553 | // To guarantee window size 1 for one ONU it would be necessary to wait |
| 554 | // for the corresponding response too (t.b.d.). |
| 555 | oo.mutexSendQueuedRequests.Lock() |
| 556 | defer oo.mutexSendQueuedRequests.Unlock() |
| 557 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 558 | logger.Errorw(ctx, "Error during sending high prio requests!", |
| 559 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 560 | return |
| 561 | } |
| 562 | if err := oo.sendQueuedLowPrioRequests(ctx); err != nil { |
| 563 | logger.Errorw(ctx, "Error during sending low prio requests!", |
| 564 | log.Fields{"err": err, "device-id": oo.deviceID}) |
| 565 | return |
| 566 | } |
| 567 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 568 | |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 569 | func (oo *OmciCC) sendQueuedHighPrioRequests(ctx context.Context) error { |
| 570 | oo.mutexHighPrioTxQueue.Lock() |
| 571 | defer oo.mutexHighPrioTxQueue.Unlock() |
| 572 | for oo.highPrioTxQueue.Len() > 0 { |
| 573 | queueElement := oo.highPrioTxQueue.Front() // First element |
| 574 | if err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)); err != nil { |
| 575 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 576 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 577 | oo.highPrioTxQueue.Remove(queueElement) // Dequeue |
| 578 | } |
| 579 | return nil |
| 580 | } |
| 581 | |
| 582 | func (oo *OmciCC) sendQueuedLowPrioRequests(ctx context.Context) error { |
| 583 | oo.mutexLowPrioTxQueue.Lock() |
| 584 | for oo.lowPrioTxQueue.Len() > 0 { |
| 585 | queueElement := oo.lowPrioTxQueue.Front() // First element |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 586 | // check if the element is for onu sw section |
| 587 | aOmciTxReq := queueElement.Value.(OmciTransferStructure) |
| 588 | if aOmciTxReq.OnuSwWindow != nil { |
| 589 | if err := oo.sendOnuSwSectionsOfWindow(ctx, aOmciTxReq); err != nil { |
| 590 | oo.mutexLowPrioTxQueue.Unlock() |
| 591 | return err |
| 592 | } |
| 593 | } else { |
| 594 | err := oo.sendOMCIRequest(ctx, queueElement.Value.(OmciTransferStructure)) |
| 595 | if err != nil { |
| 596 | oo.mutexLowPrioTxQueue.Unlock() |
| 597 | return err |
| 598 | } |
amit.ghosh | 58b704b | 2021-06-18 03:45:52 +0200 | [diff] [blame] | 599 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 600 | oo.lowPrioTxQueue.Remove(queueElement) // Dequeue |
| 601 | // Interrupt the sending of low priority requests to process any high priority requests |
| 602 | // that may have arrived in the meantime |
| 603 | oo.mutexLowPrioTxQueue.Unlock() |
| 604 | if err := oo.sendQueuedHighPrioRequests(ctx); err != nil { |
| 605 | return err |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 606 | } |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 607 | oo.mutexLowPrioTxQueue.Lock() |
| 608 | } |
| 609 | |
| 610 | oo.mutexLowPrioTxQueue.Unlock() |
| 611 | return nil |
| 612 | } |
| 613 | |
| 614 | func (oo *OmciCC) sendOMCIRequest(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 615 | if omciTxRequest.withFramePrint { |
| 616 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 617 | "TxOmciMessage": hex.EncodeToString(omciTxRequest.txFrame), |
| 618 | "device-id": oo.deviceID, |
| 619 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 620 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 621 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 622 | } |
khenaidoo | 42dcdfd | 2021-10-19 17:34:12 -0400 | [diff] [blame] | 623 | omciMsg := &ia.OmciMessage{ |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 624 | ParentDeviceId: oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 625 | ChildDeviceId: oo.deviceID, |
| 626 | Message: omciTxRequest.txFrame, |
| 627 | ProxyAddress: oo.pBaseDeviceHandler.GetProxyAddress(), |
| 628 | ConnectStatus: common.ConnectStatus_REACHABLE, // If we are sending OMCI messages means we are connected, else we should not be here |
| 629 | } |
| 630 | sendErr := oo.pBaseDeviceHandler.SendOMCIRequest(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciMsg) |
| 631 | if sendErr != nil { |
| 632 | logger.Errorw(ctx, "send omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
| 633 | return sendErr |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 634 | } |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 635 | return nil |
| 636 | } |
| 637 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 638 | // GetNextTid - TODO: add comment |
| 639 | func (oo *OmciCC) GetNextTid(highPriority bool) uint16 { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 640 | var next uint16 |
| 641 | if highPriority { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 642 | oo.mutexHpTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 643 | next = oo.hpTid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 644 | oo.hpTid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 645 | if oo.hpTid < 0x8000 { |
| 646 | oo.hpTid = 0x8000 |
| 647 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 648 | oo.mutexHpTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 649 | } else { |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 650 | oo.mutexTid.Lock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 651 | next = oo.tid |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 652 | oo.tid++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 653 | if oo.tid >= 0x8000 { |
| 654 | oo.tid = 1 |
| 655 | } |
mpagenko | 900ee4b | 2020-10-12 11:56:34 +0000 | [diff] [blame] | 656 | oo.mutexTid.Unlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 657 | } |
| 658 | return next |
| 659 | } |
| 660 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 661 | //GetOnuSwSecNextTid get the next low prio tid for the onu sw sections |
| 662 | //onu sw sections uses only low priority tids |
| 663 | //The mutexTid lock should be taken prior to using this function |
| 664 | func (oo *OmciCC) GetOnuSwSecNextTid() uint16 { |
| 665 | next := oo.tid |
| 666 | oo.tid++ |
| 667 | if oo.tid >= 0x8000 { |
| 668 | oo.tid = 1 |
| 669 | } |
| 670 | return next |
| 671 | } |
| 672 | |
| 673 | //GetOnuSwSecLastTid gets the last allocated tid |
| 674 | //The mutexTid lock should be taken prior to using this function |
| 675 | func (oo *OmciCC) GetOnuSwSecLastTid() uint16 { |
| 676 | next := oo.tid |
| 677 | lastAllocatedTid := next - 1 |
| 678 | return lastAllocatedTid |
| 679 | } |
| 680 | |
| 681 | //LockMutexTID locks mutexTid |
| 682 | func (oo *OmciCC) LockMutexTID() { |
| 683 | oo.mutexTid.Lock() |
| 684 | } |
| 685 | |
| 686 | //UnLockMutexTID unlocks mutexTid |
| 687 | func (oo *OmciCC) UnLockMutexTID() { |
| 688 | oo.mutexTid.Unlock() |
| 689 | } |
| 690 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 691 | // ################################################################################### |
| 692 | // # utility methods provided to work on OMCI messages |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 693 | |
| 694 | // Serialize - TODO: add comment |
| 695 | func Serialize(ctx context.Context, msgType omci.MessageType, request gopacket.SerializableLayer, tid uint16) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 696 | omciLayer := &omci.OMCI{ |
| 697 | TransactionID: tid, |
| 698 | MessageType: msgType, |
| 699 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 700 | return serializeOmciLayer(ctx, omciLayer, request) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 701 | } |
| 702 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 703 | func serializeOmciLayer(ctx context.Context, aOmciLayer *omci.OMCI, aRequest gopacket.SerializableLayer) ([]byte, error) { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 704 | var options gopacket.SerializeOptions |
| 705 | options.FixLengths = true |
| 706 | |
| 707 | buffer := gopacket.NewSerializeBuffer() |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 708 | err := gopacket.SerializeLayers(buffer, options, aOmciLayer, aRequest) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 709 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 710 | logger.Errorw(ctx, "Could not create goPacket Omci serial buffer", log.Fields{"Err": err}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 711 | return nil, err |
| 712 | } |
| 713 | return buffer.Bytes(), nil |
| 714 | } |
| 715 | |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 716 | /* |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 717 | func hexEncode(omciPkt []byte) ([]byte, error) { |
| 718 | dst := make([]byte, hex.EncodedLen(len(omciPkt))) |
| 719 | hex.Encode(dst, omciPkt) |
| 720 | return dst, nil |
| 721 | } |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 722 | */ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 723 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 724 | //supply a response handler for omci response messages to be transferred to the requested FSM |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 725 | func (oo *OmciCC) receiveOmciResponse(ctx context.Context, omciMsg *omci.OMCI, packet *gp.Packet, respChan chan Message) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 726 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 727 | logger.Debugw(ctx, "omci-message-response - transfer on omciRespChannel", log.Fields{"omciMsgType": omciMsg.MessageType, |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 728 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 729 | |
| 730 | if oo.pOnuDeviceEntry == nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 731 | logger.Errorw(ctx, "Abort receiving OMCI response, DeviceEntryPointer is nil", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 732 | "device-id": oo.deviceID}) |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 733 | return fmt.Errorf("deviceEntryPointer is nil %s", oo.deviceID) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 734 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 735 | oo.mutexMonReq.RLock() |
| 736 | if _, exist := oo.monitoredRequests[omciMsg.TransactionID]; exist { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 737 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 738 | select { |
| 739 | case oo.monitoredRequests[omciMsg.TransactionID].chSuccess <- true: |
| 740 | default: |
| 741 | logger.Debugw(ctx, "response not send on omciRespChannel (no receiver)", log.Fields{ |
| 742 | "transCorrId": strconv.FormatInt(int64(omciMsg.TransactionID), 16), "device-id": oo.deviceID}) |
| 743 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 744 | } else { |
| 745 | logger.Infow(ctx, "reqMon: map entry does not exist!", |
| 746 | log.Fields{"tid": omciMsg.TransactionID, "device-id": oo.deviceID}) |
| 747 | } |
| 748 | oo.mutexMonReq.RUnlock() |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 749 | |
| 750 | // no further test on SeqNo is done here, assignment from rxScheduler is trusted |
| 751 | // MibSync responses are simply transferred via deviceEntry to MibSync, no specific analysis here |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 752 | omciRespMsg := Message{ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 753 | Type: OMCI, |
| 754 | Data: OmciMessage{ |
| 755 | OmciMsg: omciMsg, |
| 756 | OmciPacket: packet, |
| 757 | }, |
| 758 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 759 | //logger.Debugw(ctx,"Message to be sent into channel:", log.Fields{"mibSyncMsg": mibSyncMsg}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 760 | respChan <- omciRespMsg |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 761 | |
| 762 | return nil |
| 763 | } |
| 764 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 765 | // SendMibReset sends MibResetRequest |
| 766 | func (oo *OmciCC) SendMibReset(ctx context.Context, timeout int, highPrio bool) error { |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 767 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 768 | logger.Debugw(ctx, "send MibReset-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 769 | request := &omci.MibResetRequest{ |
| 770 | MeBasePacket: omci.MeBasePacket{ |
| 771 | EntityClass: me.OnuDataClassID, |
| 772 | }, |
| 773 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 774 | tid := oo.GetNextTid(highPrio) |
| 775 | pkt, err := Serialize(ctx, omci.MibResetRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 776 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 777 | logger.Errorw(ctx, "Cannot serialize MibResetRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 778 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 779 | return err |
| 780 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 781 | omciRxCallbackPair := CallbackPair{ |
| 782 | CbKey: tid, |
| 783 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 784 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 785 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 786 | } |
| 787 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 788 | // SendReboot sends RebootRequest |
| 789 | func (oo *OmciCC) SendReboot(ctx context.Context, timeout int, highPrio bool, responseChannel chan Message) error { |
| 790 | logger.Debugw(ctx, "send reboot-msg to:", log.Fields{"device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 791 | request := &omci.RebootRequest{ |
| 792 | MeBasePacket: omci.MeBasePacket{ |
| 793 | EntityClass: me.OnuGClassID, |
| 794 | }, |
| 795 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 796 | tid := oo.GetNextTid(highPrio) |
| 797 | pkt, err := Serialize(ctx, omci.RebootRequestType, request, tid) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 798 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 799 | logger.Errorw(ctx, "Cannot serialize RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 800 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 801 | return err |
| 802 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 803 | omciRxCallbackPair := CallbackPair{ |
| 804 | CbKey: tid, |
| 805 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetOmciRebootMsgRevChan(), oo.receiveOmciResponse, true}, |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 806 | } |
| 807 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 808 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 809 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 810 | logger.Errorw(ctx, "Cannot send RebootRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 811 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 812 | return err |
| 813 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 814 | err = oo.pOnuDeviceEntry.WaitForRebootResponse(ctx, responseChannel) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 815 | if err != nil { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 816 | logger.Errorw(ctx, "aborting ONU reboot!", log.Fields{ |
Andrea Campanella | 6515c58 | 2020-10-05 11:25:00 +0200 | [diff] [blame] | 817 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | e11479f | 2020-07-06 09:44:47 +0300 | [diff] [blame] | 818 | return err |
| 819 | } |
| 820 | return nil |
| 821 | } |
| 822 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 823 | // SendMibUpload sends MibUploadRequest |
| 824 | func (oo *OmciCC) SendMibUpload(ctx context.Context, timeout int, highPrio bool) error { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 825 | logger.Debugw(ctx, "send MibUpload-msg to:", log.Fields{"device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 826 | request := &omci.MibUploadRequest{ |
| 827 | MeBasePacket: omci.MeBasePacket{ |
| 828 | EntityClass: me.OnuDataClassID, |
| 829 | }, |
| 830 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 831 | tid := oo.GetNextTid(highPrio) |
| 832 | pkt, err := Serialize(ctx, omci.MibUploadRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 833 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 834 | logger.Errorw(ctx, "Cannot serialize MibUploadRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 835 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 836 | return err |
| 837 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 838 | oo.UploadSequNo = 0 |
| 839 | oo.UploadNoOfCmds = 0 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 840 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 841 | omciRxCallbackPair := CallbackPair{ |
| 842 | CbKey: tid, |
| 843 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 844 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 845 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 846 | } |
| 847 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 848 | // SendMibUploadNext sends MibUploadNextRequest |
| 849 | func (oo *OmciCC) SendMibUploadNext(ctx context.Context, timeout int, highPrio bool) error { |
| 850 | logger.Debugw(ctx, "send MibUploadNext-msg to:", log.Fields{"device-id": oo.deviceID, "UploadSequNo": oo.UploadSequNo}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 851 | request := &omci.MibUploadNextRequest{ |
| 852 | MeBasePacket: omci.MeBasePacket{ |
| 853 | EntityClass: me.OnuDataClassID, |
| 854 | }, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 855 | CommandSequenceNumber: oo.UploadSequNo, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 856 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 857 | tid := oo.GetNextTid(highPrio) |
| 858 | pkt, err := Serialize(ctx, omci.MibUploadNextRequestType, request, tid) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 859 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 860 | logger.Errorw(ctx, "Cannot serialize MibUploadNextRequest", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 861 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 862 | return err |
| 863 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 864 | oo.UploadSequNo++ |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 865 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 866 | omciRxCallbackPair := CallbackPair{ |
| 867 | CbKey: tid, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 868 | //frame printing for MibUpload frames disabled now per default to avoid log file abort situations (size/speed?) |
| 869 | // if wanted, rx frame printing should be specifically done within the MibUpload FSM or controlled via extra parameter |
| 870 | // compare also software upgrade download section handling |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 871 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibUploadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 872 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 873 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 874 | } |
| 875 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 876 | // SendGetAllAlarm gets all alarm ME instances |
| 877 | func (oo *OmciCC) SendGetAllAlarm(ctx context.Context, alarmRetreivalMode uint8, timeout int, highPrio bool) error { |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 878 | logger.Debugw(ctx, "send GetAllAlarms-msg to:", log.Fields{"device-id": oo.deviceID}) |
| 879 | request := &omci.GetAllAlarmsRequest{ |
| 880 | MeBasePacket: omci.MeBasePacket{ |
| 881 | EntityClass: me.OnuDataClassID, |
| 882 | }, |
| 883 | AlarmRetrievalMode: byte(alarmRetreivalMode), |
| 884 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 885 | tid := oo.GetNextTid(highPrio) |
| 886 | pkt, err := Serialize(ctx, omci.GetAllAlarmsRequestType, request, tid) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 887 | if err != nil { |
| 888 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsRequest", log.Fields{ |
| 889 | "Err": err, "device-id": oo.deviceID}) |
| 890 | return err |
| 891 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 892 | oo.pOnuAlarmManager.ResetAlarmUploadCounters() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 893 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 894 | omciRxCallbackPair := CallbackPair{ |
| 895 | CbKey: tid, |
| 896 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 897 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 898 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 899 | } |
| 900 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 901 | // SendGetAllAlarmNext gets next alarm ME instance |
| 902 | func (oo *OmciCC) SendGetAllAlarmNext(ctx context.Context, timeout int, highPrio bool) error { |
| 903 | alarmUploadSeqNo := oo.pOnuAlarmManager.GetAlarmUploadSeqNo() |
| 904 | logger.Debugw(ctx, "send SendGetAllAlarmNext-msg to:", log.Fields{"device-id": oo.deviceID, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 905 | "alarmUploadSeqNo": alarmUploadSeqNo}) |
| 906 | request := &omci.GetAllAlarmsNextRequest{ |
| 907 | MeBasePacket: omci.MeBasePacket{ |
| 908 | EntityClass: me.OnuDataClassID, |
| 909 | }, |
| 910 | CommandSequenceNumber: alarmUploadSeqNo, |
| 911 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 912 | tid := oo.GetNextTid(highPrio) |
| 913 | pkt, err := Serialize(ctx, omci.GetAllAlarmsNextRequestType, request, tid) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 914 | if err != nil { |
| 915 | logger.Errorw(ctx, "Cannot serialize GetAllAlarmsNextRequest", log.Fields{ |
| 916 | "Err": err, "device-id": oo.deviceID}) |
| 917 | return err |
| 918 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 919 | oo.pOnuAlarmManager.IncrementAlarmUploadSeqNo() |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 920 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 921 | omciRxCallbackPair := CallbackPair{ |
| 922 | CbKey: tid, |
| 923 | CbEntry: CallbackPairEntry{oo.pOnuAlarmManager.GetAlarmMgrEventChannel(), oo.receiveOmciResponse, true}, |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 924 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 925 | return oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | d3dac42 | 2021-03-13 02:31:31 +0530 | [diff] [blame] | 926 | } |
| 927 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 928 | // SendCreateGalEthernetProfile creates GalEthernetProfile ME instance |
| 929 | func (oo *OmciCC) SendCreateGalEthernetProfile(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 930 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 931 | logger.Debugw(ctx, "send GalEnetProfile-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 932 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 933 | |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 934 | meParams := me.ParamData{ |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 935 | EntityID: GalEthernetEID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 936 | Attributes: me.AttributeValueMap{me.GalEthernetProfile_MaximumGemPayloadSize: maxGemPayloadSize}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 937 | } |
| 938 | meInstance, omciErr := me.NewGalEthernetProfile(meParams) |
| 939 | if omciErr.GetError() == nil { |
| 940 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 941 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 942 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 943 | logger.Errorw(ctx, "Cannot encode GalEnetProfileInstance for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 944 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 945 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 946 | } |
| 947 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 948 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 949 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 950 | logger.Errorw(ctx, "Cannot serialize GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 951 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 952 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 953 | } |
| 954 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 955 | omciRxCallbackPair := CallbackPair{ |
| 956 | CbKey: tid, |
| 957 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 958 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 959 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 960 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 961 | logger.Errorw(ctx, "Cannot send GalEnetProfile create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 962 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 963 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 964 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 965 | logger.Debug(ctx, "send GalEnetProfile-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 966 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 967 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 968 | logger.Errorw(ctx, "Cannot generate GalEnetProfileInstance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 969 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 970 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 971 | } |
| 972 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 973 | // SendSetOnu2g sets Onu2G ME instance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 974 | // might be needed to extend for parameter arguments, here just for setting the ConnectivityMode!! |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 975 | func (oo *OmciCC) SendSetOnu2g(ctx context.Context, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 976 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 977 | logger.Debugw(ctx, "send ONU2-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 978 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 979 | |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 980 | // ONU-G ME-ID is defined to be 0, but we could verify, if the ONU really supports the desired |
| 981 | // connectivity mode 5 (in ConnCap) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 982 | // By now we just use fix values to fire - this is anyway what the python adapter does |
| 983 | // read ONU-2G from DB ???? //TODO!!! |
| 984 | meParams := me.ParamData{ |
| 985 | EntityID: 0, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 986 | Attributes: me.AttributeValueMap{me.Onu2G_CurrentConnectivityMode: connectivityModeValue}, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 987 | } |
| 988 | meInstance, omciErr := me.NewOnu2G(meParams) |
| 989 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 990 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 991 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 992 | logger.Errorw(ctx, "Cannot encode ONU2-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 993 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 994 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 995 | } |
| 996 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 997 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 998 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 999 | logger.Errorw(ctx, "Cannot serialize ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1000 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1001 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1002 | } |
| 1003 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1004 | omciRxCallbackPair := CallbackPair{ |
| 1005 | CbKey: tid, |
| 1006 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1007 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1008 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1009 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1010 | logger.Errorw(ctx, "Cannot send ONU2-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1011 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1012 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1013 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1014 | logger.Debug(ctx, "send ONU2-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1015 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1016 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1017 | logger.Errorw(ctx, "Cannot generate ONU2-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1018 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1019 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1022 | // SendCreateMBServiceProfile creates MacBridgeServiceProfile ME instance |
| 1023 | func (oo *OmciCC) SendCreateMBServiceProfile(ctx context.Context, |
| 1024 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1025 | tid := oo.GetNextTid(highPrio) |
| 1026 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1027 | logger.Debugw(ctx, "send MBSP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1028 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1029 | |
| 1030 | meParams := me.ParamData{ |
| 1031 | EntityID: instID, |
| 1032 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1033 | me.MacBridgeServiceProfile_Priority: 0x8000, |
| 1034 | me.MacBridgeServiceProfile_MaxAge: 20 * 256, //20s |
| 1035 | me.MacBridgeServiceProfile_HelloTime: 2 * 256, //2s |
| 1036 | me.MacBridgeServiceProfile_ForwardDelay: 15 * 256, //15s |
| 1037 | me.MacBridgeServiceProfile_DynamicFilteringAgeingTime: 0, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1038 | }, |
| 1039 | } |
| 1040 | |
| 1041 | meInstance, omciErr := me.NewMacBridgeServiceProfile(meParams) |
| 1042 | if omciErr.GetError() == nil { |
| 1043 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1044 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1045 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1046 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1047 | logger.Errorw(ctx, "Cannot encode MBSP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1048 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1049 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1050 | } |
| 1051 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1052 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1053 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1054 | logger.Errorw(ctx, "Cannot serialize MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1055 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1056 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1057 | } |
| 1058 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1059 | omciRxCallbackPair := CallbackPair{ |
| 1060 | CbKey: tid, |
| 1061 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1062 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1063 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1064 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1065 | logger.Errorw(ctx, "Cannot send MBSP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1066 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1067 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1068 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1069 | logger.Debug(ctx, "send MBSP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1070 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1071 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1072 | logger.Errorw(ctx, "Cannot generate MBSP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1073 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1074 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1077 | // SendCreateMBPConfigDataUniSide creates MacBridgePortConfigurationData ME instance |
| 1078 | func (oo *OmciCC) SendCreateMBPConfigDataUniSide(ctx context.Context, |
| 1079 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1080 | tid := oo.GetNextTid(highPrio) |
| 1081 | instID, idErr := GenerateUNISideMBPCDEID(uint16(aPUniPort.MacBpNo)) |
Mahir Gunyel | 6781f96 | 2021-05-16 23:30:08 -0700 | [diff] [blame] | 1082 | if idErr != nil { |
| 1083 | logger.Errorw(ctx, "Cannot generate MBPCD entity id", log.Fields{ |
| 1084 | "Err": idErr, "device-id": oo.deviceID}) |
| 1085 | return nil, idErr |
| 1086 | } |
| 1087 | logger.Debugw(ctx, "send MBPCD-Create-msg for uni side:", log.Fields{"device-id": oo.deviceID, |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1088 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16), "macBpNo": aPUniPort.MacBpNo}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1089 | |
| 1090 | meParams := me.ParamData{ |
| 1091 | EntityID: instID, |
| 1092 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1093 | me.MacBridgePortConfigurationData_BridgeIdPointer: MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo), |
| 1094 | me.MacBridgePortConfigurationData_PortNum: aPUniPort.MacBpNo, |
| 1095 | me.MacBridgePortConfigurationData_TpType: uint8(aPUniPort.PortType), |
| 1096 | me.MacBridgePortConfigurationData_TpPointer: aPUniPort.EntityID, |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1097 | }, |
| 1098 | } |
| 1099 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 1100 | if omciErr.GetError() == nil { |
| 1101 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1102 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1103 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1104 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1105 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1106 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1107 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1108 | } |
| 1109 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1110 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1111 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1112 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1113 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1114 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1115 | } |
| 1116 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1117 | omciRxCallbackPair := CallbackPair{ |
| 1118 | CbKey: tid, |
| 1119 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1120 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1121 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1122 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1123 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1124 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1125 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1126 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1127 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1128 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1129 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1130 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1131 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1132 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1133 | } |
| 1134 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1135 | // SendCreateEVTOConfigData creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1136 | func (oo *OmciCC) SendCreateEVTOConfigData(ctx context.Context, |
| 1137 | aPUniPort *OnuUniPort, timeout int, highPrio bool) (*me.ManagedEntity, error) { |
| 1138 | tid := oo.GetNextTid(highPrio) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1139 | //same entityId is used as for MBSP (see there), but just arbitrary ... |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1140 | instID := MacBridgeServiceProfileEID + uint16(aPUniPort.MacBpNo) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1141 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1142 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(instID), 16)}) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1143 | |
| 1144 | // compare python adapter code WA VOL-1311: this is not done here! |
| 1145 | // (setting TPID values for the create would probably anyway be ignored by the omci lib) |
| 1146 | // but perhaps we have to be aware of possible problems at get(Next) Request handling for EVTOOCD tables later ... |
| 1147 | assType := uint8(2) // default AssociationType is PPTPEthUni |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1148 | if aPUniPort.PortType == UniVEIP { |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1149 | assType = uint8(10) // for VEIP |
| 1150 | } |
| 1151 | meParams := me.ParamData{ |
| 1152 | EntityID: instID, |
| 1153 | Attributes: me.AttributeValueMap{ |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1154 | me.ExtendedVlanTaggingOperationConfigurationData_AssociationType: assType, |
| 1155 | me.ExtendedVlanTaggingOperationConfigurationData_AssociatedMePointer: aPUniPort.EntityID, |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1156 | //EnhancedMode not yet supported, used with default options |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1157 | }, |
| 1158 | } |
| 1159 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(meParams) |
| 1160 | if omciErr.GetError() == nil { |
| 1161 | //all setByCreate parameters already set, no default option required ... |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1162 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1163 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1164 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1165 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1166 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1167 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1170 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1171 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1172 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1173 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1174 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1175 | } |
| 1176 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1177 | omciRxCallbackPair := CallbackPair{ |
| 1178 | CbKey: tid, |
| 1179 | CbEntry: CallbackPairEntry{oo.pOnuDeviceEntry.GetMibDownloadFsmCommChan(), oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1180 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1181 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1182 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1183 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1184 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1185 | return nil, err |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1186 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1187 | logger.Debug(ctx, "send EVTOCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1188 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1189 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1190 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1191 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1192 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1193 | } |
| 1194 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1195 | // SendSetOnuGLS sets OnuG ME instance |
| 1196 | func (oo *OmciCC) SendSetOnuGLS(ctx context.Context, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1197 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1198 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1199 | logger.Debugw(ctx, "send ONU-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1200 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1201 | |
| 1202 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1203 | meParams := me.ParamData{ |
| 1204 | EntityID: 0, |
| 1205 | Attributes: requestedAttributes, |
| 1206 | } |
| 1207 | meInstance, omciErr := me.NewOnuG(meParams) |
| 1208 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1209 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1210 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1211 | logger.Errorw(ctx, "Cannot encode ONU-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1212 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1213 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1216 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1217 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1218 | logger.Errorw(ctx, "Cannot serialize ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1219 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1220 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1221 | } |
| 1222 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1223 | omciRxCallbackPair := CallbackPair{ |
| 1224 | CbKey: tid, |
| 1225 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1226 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1227 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1228 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1229 | logger.Errorw(ctx, "Cannot send ONU-G set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1230 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1231 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1232 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1233 | logger.Debug(ctx, "send ONU-G-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1234 | return meInstance, nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1235 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1236 | logger.Errorw(ctx, "Cannot generate ONU-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1237 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1238 | return nil, omciErr.GetError() |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1239 | } |
| 1240 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1241 | // SendSetPptpEthUniLS sets PhysicalPathTerminationPointEthernetUni ME instance |
| 1242 | func (oo *OmciCC) SendSetPptpEthUniLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1243 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1244 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1245 | logger.Debugw(ctx, "send PPTPEthUni-Set-msg:", log.Fields{"device-id": oo.deviceID, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1246 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1247 | |
| 1248 | // PPTPEthUni ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1249 | meParams := me.ParamData{ |
| 1250 | EntityID: aInstNo, |
| 1251 | Attributes: requestedAttributes, |
| 1252 | } |
| 1253 | meInstance, omciErr := me.NewPhysicalPathTerminationPointEthernetUni(meParams) |
| 1254 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1255 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1256 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1257 | logger.Errorw(ctx, "Cannot encode PPTPEthUni instance for set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1258 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1259 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1260 | } |
| 1261 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1262 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1263 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1264 | logger.Errorw(ctx, "Cannot serialize PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1265 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1266 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1267 | } |
| 1268 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1269 | omciRxCallbackPair := CallbackPair{ |
| 1270 | CbKey: tid, |
| 1271 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1272 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1273 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1274 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1275 | logger.Errorw(ctx, "Cannot send PPTPEthUni-Set", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1276 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1277 | return nil, err |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1278 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1279 | logger.Debug(ctx, "send PPTPEthUni-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1280 | return meInstance, nil |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1281 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1282 | logger.Errorw(ctx, "Cannot generate PPTPEthUni", log.Fields{ |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1283 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1284 | return nil, omciErr.GetError() |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | /* UniG obsolete by now, left here in case it should be needed once again |
| 1288 | UniG AdminState anyway should be ignored by ONU acc. to G988 |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 1289 | func (oo *omciCC) sendSetUniGLS(ctx context.Context, aInstNo uint16, timeout int, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1290 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) *me.ManagedEntity { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1291 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1292 | logger.Debugw(ctx,"send UNI-G-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1293 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1294 | |
| 1295 | // UNI-G ME-ID is taken from Mib Upload stored OnuUniPort instance (argument) |
| 1296 | meParams := me.ParamData{ |
| 1297 | EntityID: aInstNo, |
| 1298 | Attributes: requestedAttributes, |
| 1299 | } |
| 1300 | meInstance, omciErr := me.NewUniG(meParams) |
| 1301 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1302 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1303 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1304 | logger.Errorw(ctx,"Cannot encode UNI-G instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1305 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1306 | return nil |
| 1307 | } |
| 1308 | |
| 1309 | pkt, err := serializeOmciLayer(omciLayer, msgLayer) |
| 1310 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1311 | logger.Errorw(ctx,"Cannot serialize UNI-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1312 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1313 | return nil |
| 1314 | } |
| 1315 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1316 | omciRxCallbackPair := CallbackPair{ |
| 1317 | CbKey: tid, |
| 1318 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1319 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1320 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1321 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1322 | logger.Errorw(ctx,"Cannot send UNIG-G-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1323 | "Err": err, "device-id": oo.deviceID}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1324 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1325 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1326 | logger.Debug(ctx,"send UNI-G-Set-msg done") |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1327 | return meInstance |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1328 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1329 | logger.Errorw(ctx,"Cannot generate UNI-G", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1330 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1331 | return nil |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1332 | } |
Holger Hildebrandt | 2fb7089 | 2020-10-28 11:53:18 +0000 | [diff] [blame] | 1333 | */ |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1334 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1335 | // SendSetVeipLS sets VirtualEthernetInterfacePoint ME instance |
| 1336 | func (oo *OmciCC) SendSetVeipLS(ctx context.Context, aInstNo uint16, timeout int, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1337 | highPrio bool, requestedAttributes me.AttributeValueMap, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1338 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1339 | logger.Debugw(ctx, "send VEIP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1340 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1341 | |
| 1342 | // ONU-G ME-ID is defined to be 0, no need to perform a DB lookup |
| 1343 | meParams := me.ParamData{ |
| 1344 | EntityID: aInstNo, |
| 1345 | Attributes: requestedAttributes, |
| 1346 | } |
| 1347 | meInstance, omciErr := me.NewVirtualEthernetInterfacePoint(meParams) |
| 1348 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1349 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1350 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1351 | logger.Errorw(ctx, "Cannot encode VEIP instance for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1352 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1353 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1354 | } |
| 1355 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1356 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1357 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1358 | logger.Errorw(ctx, "Cannot serialize VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1359 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1360 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1361 | } |
| 1362 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1363 | omciRxCallbackPair := CallbackPair{ |
| 1364 | CbKey: tid, |
| 1365 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1366 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1367 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1368 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1369 | logger.Errorw(ctx, "Cannot send VEIP-Set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1370 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1371 | return nil, err |
Holger Hildebrandt | ccd390c | 2020-05-29 13:49:04 +0000 | [diff] [blame] | 1372 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1373 | logger.Debug(ctx, "send VEIP-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1374 | return meInstance, nil |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1375 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1376 | logger.Errorw(ctx, "Cannot generate VEIP", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1377 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1378 | return nil, omciErr.GetError() |
Holger Hildebrandt | dd23cc2 | 2020-05-19 13:32:18 +0000 | [diff] [blame] | 1379 | } |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1380 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1381 | // SendGetMe gets ME instance |
| 1382 | func (oo *OmciCC) SendGetMe(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributes me.AttributeValueMap, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1383 | timeout int, highPrio bool, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1384 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1385 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1386 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1387 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1388 | |
| 1389 | meParams := me.ParamData{ |
| 1390 | EntityID: entityID, |
| 1391 | Attributes: requestedAttributes, |
| 1392 | } |
| 1393 | meInstance, omciErr := me.LoadManagedEntityDefinition(classID, meParams) |
| 1394 | if omciErr.GetError() == nil { |
Himani Chawla | 4d90833 | 2020-08-31 12:30:20 +0530 | [diff] [blame] | 1395 | meClassIDName := meInstance.GetName() |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1396 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.GetRequestType, oframe.TransactionID(tid)) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1397 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1398 | logger.Errorf(ctx, "Cannot encode instance for get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1399 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1400 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1401 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1402 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1403 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1404 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1405 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1406 | omciRxCallbackPair := CallbackPair{ |
| 1407 | CbKey: tid, |
| 1408 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1409 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1410 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1411 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1412 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": meClassIDName, "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1413 | return nil, err |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1414 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1415 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": meClassIDName, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1416 | return meInstance, nil |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1417 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1418 | logger.Errorw(ctx, "Cannot generate meDefinition", log.Fields{"classID": classID, "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1419 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1420 | } |
| 1421 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1422 | // SendGetMeWithAttributeMask gets ME instance with attribute mask |
| 1423 | func (oo *OmciCC) SendGetMeWithAttributeMask(ctx context.Context, classID me.ClassID, entityID uint16, requestedAttributesMask uint16, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1424 | timeout int, highPrio bool, rxChan chan Message) error { |
| 1425 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1426 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1427 | logger.Debugw(ctx, "send get-request-msg", log.Fields{"classID": classID, "device-id": oo.deviceID, |
| 1428 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 1429 | |
| 1430 | request := &omci.GetRequest{ |
| 1431 | MeBasePacket: omci.MeBasePacket{ |
| 1432 | EntityInstance: entityID, |
| 1433 | EntityClass: classID, |
| 1434 | }, |
| 1435 | AttributeMask: requestedAttributesMask, |
| 1436 | } |
| 1437 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1438 | pkt, err := Serialize(ctx, omci.GetRequestType, request, tid) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1439 | if err != nil { |
| 1440 | logger.Errorw(ctx, "Cannot serialize get-request", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1441 | return err |
| 1442 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1443 | omciRxCallbackPair := CallbackPair{ |
| 1444 | CbKey: tid, |
| 1445 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1446 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1447 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 1448 | if err != nil { |
| 1449 | logger.Errorw(ctx, "Cannot send get-request-msg", log.Fields{"meClassIDName": classID, "Err": err, "device-id": oo.deviceID}) |
| 1450 | return err |
| 1451 | } |
| 1452 | logger.Debugw(ctx, "send get-request-msg done", log.Fields{"meClassIDName": classID, "device-id": oo.deviceID}) |
| 1453 | return nil |
| 1454 | } |
| 1455 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1456 | // SendCreateDot1PMapper creates Ieee8021PMapperServiceProfile ME instance |
| 1457 | func (oo *OmciCC) SendCreateDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1458 | aInstID uint16, rxChan chan Message) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1459 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1460 | logger.Debugw(ctx, "send .1pMapper-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1461 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 1462 | |
| 1463 | meParams := me.ParamData{ |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1464 | EntityID: aInstID, |
| 1465 | Attributes: me.AttributeValueMap{ |
| 1466 | //workaround for unsuitable omci-lib default values, cmp VOL-3729 |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 1467 | me.Ieee8021PMapperServiceProfile_TpPointer: 0xFFFF, |
| 1468 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority0: 0xFFFF, |
| 1469 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority1: 0xFFFF, |
| 1470 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority2: 0xFFFF, |
| 1471 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority3: 0xFFFF, |
| 1472 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority4: 0xFFFF, |
| 1473 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority5: 0xFFFF, |
| 1474 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority6: 0xFFFF, |
| 1475 | me.Ieee8021PMapperServiceProfile_InterworkTpPointerForPBitPriority7: 0xFFFF, |
mpagenko | 8b5fdd2 | 2020-12-17 17:58:32 +0000 | [diff] [blame] | 1476 | }, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1477 | } |
| 1478 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 1479 | if omciErr.GetError() == nil { |
| 1480 | //we have to set all 'untouched' parameters to default by some additional option parameter!! |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1481 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1482 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1483 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1484 | logger.Errorw(ctx, "Cannot encode .1pMapper for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1485 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1486 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1487 | } |
| 1488 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1489 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1490 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1491 | logger.Errorw(ctx, "Cannot serialize .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1492 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1493 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1494 | } |
| 1495 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1496 | omciRxCallbackPair := CallbackPair{ |
| 1497 | CbKey: tid, |
| 1498 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1499 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1500 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1501 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1502 | logger.Errorw(ctx, "Cannot send .1pMapper create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1503 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1504 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1505 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1506 | logger.Debug(ctx, "send .1pMapper-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1507 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1508 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1509 | logger.Errorw(ctx, "Cannot generate .1pMapper", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1510 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1511 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1512 | } |
| 1513 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1514 | // SendCreateMBPConfigDataVar creates MacBridgePortConfigurationData ME instance |
| 1515 | func (oo *OmciCC) SendCreateMBPConfigDataVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1516 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1517 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1518 | logger.Debugw(ctx, "send MBPCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1519 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1520 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1521 | |
| 1522 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(params[0]) |
| 1523 | if omciErr.GetError() == nil { |
| 1524 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1525 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1526 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1527 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1528 | logger.Errorw(ctx, "Cannot encode MBPCD for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1529 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1530 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1531 | } |
| 1532 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1533 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1534 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1535 | logger.Errorw(ctx, "Cannot serialize MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1536 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1537 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1538 | } |
| 1539 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1540 | omciRxCallbackPair := CallbackPair{ |
| 1541 | CbKey: tid, |
| 1542 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1543 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1544 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1545 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1546 | logger.Errorw(ctx, "Cannot send MBPCD create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1547 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1548 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1549 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1550 | logger.Debug(ctx, "send MBPCD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1551 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1552 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1553 | logger.Errorw(ctx, "Cannot generate MBPCD Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1554 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1555 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1556 | } |
| 1557 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1558 | // SendCreateGemNCTPVar creates GemPortNetworkCtp ME instance |
| 1559 | func (oo *OmciCC) SendCreateGemNCTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1560 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1561 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1562 | logger.Debugw(ctx, "send GemNCTP-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1563 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1564 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1565 | |
| 1566 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1567 | if omciErr.GetError() == nil { |
| 1568 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1569 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1570 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1571 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1572 | logger.Errorw(ctx, "Cannot encode GemNCTP for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1573 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1574 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1575 | } |
| 1576 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1577 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1578 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1579 | logger.Errorw(ctx, "Cannot serialize GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1580 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1581 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1582 | } |
| 1583 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1584 | omciRxCallbackPair := CallbackPair{ |
| 1585 | CbKey: tid, |
| 1586 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1587 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1588 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1589 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1590 | logger.Errorw(ctx, "Cannot send GemNCTP create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1591 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1592 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1593 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1594 | logger.Debug(ctx, "send GemNCTP-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1595 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1596 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1597 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1598 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1599 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1600 | } |
| 1601 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1602 | // SendSetGemNCTPVar sets GemPortNetworkCtp ME instance |
| 1603 | func (oo *OmciCC) SendSetGemNCTPVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 1604 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1605 | logger.Debugw(ctx, "send GemNCTP-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 1606 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1607 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1608 | |
| 1609 | meInstance, omciErr := me.NewGemPortNetworkCtp(params[0]) |
| 1610 | if omciErr.GetError() == nil { |
| 1611 | //obviously we have to set all 'untouched' parameters to default by some additional option parameter!! |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1612 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1613 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1614 | if err != nil { |
| 1615 | logger.Errorw(ctx, "Cannot encode GemNCTP for set", log.Fields{ |
| 1616 | "Err": err, "device-id": oo.deviceID}) |
| 1617 | return nil, err |
| 1618 | } |
| 1619 | |
| 1620 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 1621 | if err != nil { |
| 1622 | logger.Errorw(ctx, "Cannot serialize GemNCTP set", log.Fields{ |
| 1623 | "Err": err, "device-id": oo.deviceID}) |
| 1624 | return nil, err |
| 1625 | } |
| 1626 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1627 | omciRxCallbackPair := CallbackPair{ |
| 1628 | CbKey: tid, |
| 1629 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1630 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1631 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 82b91a6 | 2021-05-21 18:54:49 +0300 | [diff] [blame] | 1632 | if err != nil { |
| 1633 | logger.Errorw(ctx, "Cannot send GemNCTP set", log.Fields{ |
| 1634 | "Err": err, "device-id": oo.deviceID}) |
| 1635 | return nil, err |
| 1636 | } |
| 1637 | logger.Debug(ctx, "send GemNCTP-Set-msg done", log.Fields{"device-id": oo.deviceID}) |
| 1638 | return meInstance, nil |
| 1639 | } |
| 1640 | logger.Errorw(ctx, "Cannot generate GemNCTP Instance", log.Fields{ |
| 1641 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 1642 | return nil, omciErr.GetError() |
| 1643 | } |
| 1644 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1645 | // SendCreateGemIWTPVar creates GemInterworkingTerminationPoint ME instance |
| 1646 | func (oo *OmciCC) SendCreateGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1647 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1648 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1649 | logger.Debugw(ctx, "send GemIwTp-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1650 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1651 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1652 | |
| 1653 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(params[0]) |
| 1654 | if omciErr.GetError() == nil { |
| 1655 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1656 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1657 | oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1658 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1659 | logger.Errorw(ctx, "Cannot encode GemIwTp for create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1660 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1661 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1662 | } |
| 1663 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1664 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1665 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1666 | logger.Errorw(ctx, "Cannot serialize GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1667 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1668 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1669 | } |
| 1670 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1671 | omciRxCallbackPair := CallbackPair{ |
| 1672 | CbKey: tid, |
| 1673 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1674 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1675 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1676 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1677 | logger.Errorw(ctx, "Cannot send GemIwTp create", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1678 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1679 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1680 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1681 | logger.Debug(ctx, "send GemIwTp-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1682 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1683 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1684 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1685 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1686 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1687 | } |
| 1688 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1689 | // SendSetTcontVar sets TCont ME instance |
| 1690 | func (oo *OmciCC) SendSetTcontVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1691 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1692 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1693 | logger.Debugw(ctx, "send TCont-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1694 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1695 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1696 | |
| 1697 | meInstance, omciErr := me.NewTCont(params[0]) |
| 1698 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1699 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1700 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1701 | logger.Errorw(ctx, "Cannot encode TCont for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1702 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1703 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1704 | } |
| 1705 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1706 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1707 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1708 | logger.Errorw(ctx, "Cannot serialize TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1709 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1710 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1711 | } |
| 1712 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1713 | omciRxCallbackPair := CallbackPair{ |
| 1714 | CbKey: tid, |
| 1715 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1716 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1717 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1718 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1719 | logger.Errorw(ctx, "Cannot send TCont set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1720 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1721 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1722 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1723 | logger.Debug(ctx, "send TCont-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1724 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1725 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1726 | logger.Errorw(ctx, "Cannot generate TCont Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1727 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1728 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1729 | } |
| 1730 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1731 | // SendSetPrioQueueVar sets PriorityQueue ME instance |
| 1732 | func (oo *OmciCC) SendSetPrioQueueVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1733 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1734 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1735 | logger.Debugw(ctx, "send PrioQueue-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1736 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1737 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1738 | |
| 1739 | meInstance, omciErr := me.NewPriorityQueue(params[0]) |
| 1740 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1741 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1742 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1743 | logger.Errorw(ctx, "Cannot encode PrioQueue for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1744 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1745 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1746 | } |
| 1747 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1748 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1749 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1750 | logger.Errorw(ctx, "Cannot serialize PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1751 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1752 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1753 | } |
| 1754 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1755 | omciRxCallbackPair := CallbackPair{ |
| 1756 | CbKey: tid, |
| 1757 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1758 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1759 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1760 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1761 | logger.Errorw(ctx, "Cannot send PrioQueue set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1762 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1763 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1764 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1765 | logger.Debug(ctx, "send PrioQueue-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1766 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1767 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1768 | logger.Errorw(ctx, "Cannot generate PrioQueue Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1769 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1770 | return nil, omciErr.GetError() |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1771 | } |
| 1772 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1773 | // SendSetDot1PMapperVar sets Ieee8021PMapperServiceProfile ME instance |
| 1774 | func (oo *OmciCC) SendSetDot1PMapperVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1775 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1776 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1777 | logger.Debugw(ctx, "send 1PMapper-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1778 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1779 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1780 | |
| 1781 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(params[0]) |
| 1782 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1783 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1784 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1785 | logger.Errorw(ctx, "Cannot encode 1PMapper for set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1786 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1787 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1788 | } |
| 1789 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1790 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1791 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1792 | logger.Errorw(ctx, "Cannot serialize 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1793 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1794 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1795 | } |
| 1796 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1797 | omciRxCallbackPair := CallbackPair{ |
| 1798 | CbKey: tid, |
| 1799 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1800 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1801 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1802 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1803 | logger.Errorw(ctx, "Cannot send 1PMapper set", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1804 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1805 | return nil, err |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1806 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1807 | logger.Debug(ctx, "send 1PMapper-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1808 | return meInstance, nil |
mpagenko | 3dbcdd2 | 2020-07-22 07:38:45 +0000 | [diff] [blame] | 1809 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1810 | logger.Errorw(ctx, "Cannot generate 1PMapper Instance", log.Fields{ |
divyadesai | 4d29955 | 2020-08-18 07:13:49 +0000 | [diff] [blame] | 1811 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1812 | return nil, omciErr.GetError() |
Holger Hildebrandt | c54939a | 2020-06-17 08:14:27 +0000 | [diff] [blame] | 1813 | } |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1814 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1815 | // SendCreateVtfdVar creates VlanTaggingFilterData ME instance |
| 1816 | func (oo *OmciCC) SendCreateVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1817 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1818 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1819 | logger.Debugw(ctx, "send VTFD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1820 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1821 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1822 | |
| 1823 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1824 | if omciErr.GetError() == nil { |
| 1825 | //all SetByCreate Parameters (assumed to be) set here, for optimisation no 'AddDefaults' |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1826 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1827 | oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1828 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1829 | logger.Errorw(ctx, "Cannot encode VTFD for create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1830 | "Err": err, "device-id": oo.deviceID}) |
| 1831 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1832 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1833 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1834 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1835 | } |
| 1836 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1837 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1838 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1839 | logger.Errorw(ctx, "Cannot serialize VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1840 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1841 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1842 | } |
| 1843 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1844 | omciRxCallbackPair := CallbackPair{ |
| 1845 | CbKey: tid, |
| 1846 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1847 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1848 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1849 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1850 | logger.Errorw(ctx, "Cannot send VTFD create", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1851 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1852 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1853 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1854 | logger.Debug(ctx, "send VTFD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1855 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1856 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1857 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1858 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1859 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1860 | } |
| 1861 | |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1862 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1863 | func (oo *OmciCC) sendSetVtfdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1864 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1865 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1866 | logger.Debugw(ctx, "send VTFD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1867 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1868 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1869 | |
| 1870 | meInstance, omciErr := me.NewVlanTaggingFilterData(params[0]) |
| 1871 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1872 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, |
| 1873 | oframe.TransactionID(tid)) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1874 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1875 | logger.Errorw(ctx, "Cannot encode VTFD for set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1876 | "Err": err, "device-id": oo.deviceID}) |
| 1877 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 1878 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 1879 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1880 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1881 | } |
| 1882 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1883 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1884 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1885 | logger.Errorw(ctx, "Cannot serialize VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1886 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1887 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1888 | } |
| 1889 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1890 | omciRxCallbackPair := CallbackPair{ |
| 1891 | CbKey: tid, |
| 1892 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1893 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1894 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1895 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1896 | logger.Errorw(ctx, "Cannot send VTFD set", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1897 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1898 | return nil, err |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1899 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1900 | logger.Debug(ctx, "send VTFD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1901 | return meInstance, nil |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1902 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1903 | logger.Errorw(ctx, "Cannot generate VTFD Instance", log.Fields{ |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1904 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1905 | return nil, omciErr.GetError() |
Holger Hildebrandt | 394c552 | 2020-09-11 11:23:01 +0000 | [diff] [blame] | 1906 | } |
| 1907 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1908 | // SendCreateEvtocdVar creates ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1909 | func (oo *OmciCC) SendCreateEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1910 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1911 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1912 | logger.Debugw(ctx, "send EVTOCD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1913 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1914 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1915 | |
| 1916 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1917 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1918 | //EnhancedMode not yet supported, used with default options |
| 1919 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, |
| 1920 | oframe.TransactionID(tid), oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1921 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1922 | logger.Errorw(ctx, "Cannot encode EVTOCD for create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1923 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1924 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1925 | } |
| 1926 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1927 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1928 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1929 | logger.Errorw(ctx, "Cannot serialize EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1930 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1931 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1932 | } |
| 1933 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1934 | omciRxCallbackPair := CallbackPair{ |
| 1935 | CbKey: tid, |
| 1936 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1937 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1938 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1939 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1940 | logger.Errorw(ctx, "Cannot send EVTOCD create", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1941 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1942 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1943 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1944 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1945 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1946 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1947 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1948 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1949 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1950 | } |
| 1951 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1952 | // SendSetEvtocdVar sets ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1953 | func (oo *OmciCC) SendSetEvtocdVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1954 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1955 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1956 | logger.Debugw(ctx, "send EVTOCD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1957 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 1958 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 1959 | |
| 1960 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 1961 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 1962 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1963 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1964 | logger.Errorw(ctx, "Cannot encode EVTOCD for set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1965 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1966 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1967 | } |
| 1968 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1969 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1970 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1971 | logger.Errorw(ctx, "Cannot serialize EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1972 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1973 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1974 | } |
| 1975 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1976 | omciRxCallbackPair := CallbackPair{ |
| 1977 | CbKey: tid, |
| 1978 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1979 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1980 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1981 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1982 | logger.Errorw(ctx, "Cannot send EVTOCD set", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1983 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1984 | return nil, err |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1985 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1986 | logger.Debug(ctx, "send EVTOCD-set msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1987 | return meInstance, nil |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1988 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1989 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1990 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1991 | return nil, omciErr.GetError() |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 1992 | } |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 1993 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1994 | // SendDeleteEvtocd deletes ExtendedVlanTaggingOperationConfigurationData ME instance |
| 1995 | func (oo *OmciCC) SendDeleteEvtocd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 1996 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 1997 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 1998 | logger.Debugw(ctx, "send EVTOCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 1999 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2000 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2001 | |
| 2002 | meInstance, omciErr := me.NewExtendedVlanTaggingOperationConfigurationData(params[0]) |
| 2003 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2004 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2005 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2006 | logger.Errorw(ctx, "Cannot encode EVTOCD for delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2007 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2008 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2009 | } |
| 2010 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2011 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2012 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2013 | logger.Errorw(ctx, "Cannot serialize EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2014 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2015 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2016 | } |
| 2017 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2018 | omciRxCallbackPair := CallbackPair{ |
| 2019 | CbKey: tid, |
| 2020 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2021 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2022 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2023 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2024 | logger.Errorw(ctx, "Cannot send EVTOCD delete", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2025 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2026 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2027 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2028 | logger.Debug(ctx, "send EVTOCD-delete msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2029 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2030 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2031 | logger.Errorw(ctx, "Cannot generate EVTOCD Instance", log.Fields{ |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2032 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2033 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2034 | } |
| 2035 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2036 | // SendDeleteVtfd deletes VlanTaggingFilterData ME instance |
| 2037 | func (oo *OmciCC) SendDeleteVtfd(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2038 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2039 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2040 | logger.Debugw(ctx, "send VTFD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2041 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2042 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2043 | |
| 2044 | meParams := me.ParamData{EntityID: aInstID} |
| 2045 | meInstance, omciErr := me.NewVlanTaggingFilterData(meParams) |
| 2046 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2047 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2048 | oframe.TransactionID(tid)) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2049 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2050 | logger.Errorw(ctx, "Cannot encode VTFD for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2051 | "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) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2055 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2056 | } |
| 2057 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2058 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2059 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2060 | logger.Errorw(ctx, "Cannot serialize VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2061 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2062 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2063 | } |
| 2064 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2065 | omciRxCallbackPair := CallbackPair{ |
| 2066 | CbKey: tid, |
| 2067 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2068 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2069 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2070 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2071 | logger.Errorw(ctx, "Cannot send VTFD delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2072 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2073 | return nil, err |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2074 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2075 | logger.Debug(ctx, "send VTFD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2076 | return meInstance, nil |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2077 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2078 | logger.Errorw(ctx, "Cannot generate VTFD Instance for delete", log.Fields{ |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2079 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2080 | return nil, omciErr.GetError() |
mpagenko | 01e726e | 2020-10-23 09:45:29 +0000 | [diff] [blame] | 2081 | } |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2082 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2083 | // SendCreateTDVar creates TrafficDescriptor ME instance |
| 2084 | func (oo *OmciCC) SendCreateTDVar(ctx context.Context, timeout int, highPrio bool, rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2085 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2086 | logger.Debugw(ctx, "send TD-Create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2087 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2088 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2089 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2090 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2091 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2092 | if err != nil { |
| 2093 | logger.Errorw(ctx, "Cannot encode TD for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2094 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2095 | } |
| 2096 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2097 | if err != nil { |
| 2098 | logger.Errorw(ctx, "Cannot serialize TD create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2099 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2100 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2101 | omciRxCallbackPair := CallbackPair{ |
| 2102 | CbKey: tid, |
| 2103 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2104 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2105 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2106 | if err != nil { |
| 2107 | logger.Errorw(ctx, "Cannot send TD create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2108 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2109 | } |
| 2110 | logger.Debug(ctx, "send TD-Create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2111 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2112 | } |
| 2113 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2114 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2115 | } |
| 2116 | |
| 2117 | // nolint: unused |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2118 | func (oo *OmciCC) sendSetTDVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2119 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2120 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2121 | logger.Debugw(ctx, "send TD-Set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2122 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2123 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2124 | |
| 2125 | meInstance, omciErr := me.NewTrafficDescriptor(params[0]) |
| 2126 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2127 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2128 | if err != nil { |
| 2129 | logger.Errorw(ctx, "Cannot encode TD for set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2130 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2131 | } |
| 2132 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2133 | if err != nil { |
| 2134 | logger.Errorw(ctx, "Cannot serialize TD set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2135 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2136 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2137 | omciRxCallbackPair := CallbackPair{ |
| 2138 | CbKey: tid, |
| 2139 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2140 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2141 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2142 | if err != nil { |
| 2143 | logger.Errorw(ctx, "Cannot send TD set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2144 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2145 | } |
| 2146 | logger.Debug(ctx, "send TD-Set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2147 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2148 | } |
| 2149 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2150 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2151 | |
| 2152 | } |
| 2153 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2154 | // SendDeleteTD - TODO: add comment |
| 2155 | func (oo *OmciCC) SendDeleteTD(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2156 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2157 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2158 | logger.Debugw(ctx, "send TD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2159 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2160 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2161 | |
| 2162 | meParams := me.ParamData{EntityID: aInstID} |
| 2163 | meInstance, omciErr := me.NewTrafficDescriptor(meParams) |
| 2164 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2165 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid)) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2166 | if err != nil { |
| 2167 | logger.Errorw(ctx, "Cannot encode TD for delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2168 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2169 | } |
| 2170 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2171 | if err != nil { |
| 2172 | logger.Errorw(ctx, "Cannot serialize TD delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2173 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2174 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2175 | omciRxCallbackPair := CallbackPair{ |
| 2176 | CbKey: tid, |
| 2177 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2178 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2179 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2180 | if err != nil { |
| 2181 | logger.Errorw(ctx, "Cannot send TD delete", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2182 | return nil, err |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2183 | } |
| 2184 | logger.Debug(ctx, "send TD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2185 | return meInstance, nil |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2186 | } |
| 2187 | logger.Errorw(ctx, "Cannot generate TD Instance", log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2188 | return nil, omciErr.GetError() |
ozgecanetsia | b644196 | 2021-03-10 10:58:48 +0300 | [diff] [blame] | 2189 | |
| 2190 | } |
| 2191 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2192 | // SendDeleteGemIWTP deletes GemInterworkingTerminationPoint ME instance |
| 2193 | func (oo *OmciCC) SendDeleteGemIWTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2194 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2195 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2196 | logger.Debugw(ctx, "send GemIwTp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2197 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2198 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2199 | |
| 2200 | meParams := me.ParamData{EntityID: aInstID} |
| 2201 | meInstance, omciErr := me.NewGemInterworkingTerminationPoint(meParams) |
| 2202 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2203 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2204 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2205 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2206 | logger.Errorw(ctx, "Cannot encode GemIwTp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2207 | "Err": err, "device-id": oo.deviceID}) |
| 2208 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2209 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2210 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2211 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2212 | } |
| 2213 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2214 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2215 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2216 | logger.Errorw(ctx, "Cannot serialize GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2217 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2218 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2219 | } |
| 2220 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2221 | omciRxCallbackPair := CallbackPair{ |
| 2222 | CbKey: tid, |
| 2223 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2224 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2225 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2226 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2227 | logger.Errorw(ctx, "Cannot send GemIwTp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2228 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2229 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2230 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2231 | logger.Debug(ctx, "send GemIwTp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2232 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2233 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2234 | logger.Errorw(ctx, "Cannot generate GemIwTp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2235 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2236 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2237 | } |
| 2238 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2239 | // SendDeleteGemNCTP deletes GemPortNetworkCtp ME instance |
| 2240 | func (oo *OmciCC) SendDeleteGemNCTP(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2241 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2242 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2243 | logger.Debugw(ctx, "send GemNCtp-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2244 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2245 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2246 | |
| 2247 | meParams := me.ParamData{EntityID: aInstID} |
| 2248 | meInstance, omciErr := me.NewGemPortNetworkCtp(meParams) |
| 2249 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2250 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2251 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2252 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2253 | logger.Errorw(ctx, "Cannot encode GemNCtp for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2254 | "Err": err, "device-id": oo.deviceID}) |
| 2255 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2256 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2257 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2258 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2259 | } |
| 2260 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2261 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2262 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2263 | logger.Errorw(ctx, "Cannot serialize GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2264 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2265 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2266 | } |
| 2267 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2268 | omciRxCallbackPair := CallbackPair{ |
| 2269 | CbKey: tid, |
| 2270 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2271 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2272 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2273 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2274 | logger.Errorw(ctx, "Cannot send GemNCtp delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2275 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2276 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2277 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2278 | logger.Debug(ctx, "send GemNCtp-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2279 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2280 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2281 | logger.Errorw(ctx, "Cannot generate GemNCtp Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2282 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2283 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2284 | } |
| 2285 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2286 | // SendDeleteDot1PMapper deletes Ieee8021PMapperServiceProfile ME instance |
| 2287 | func (oo *OmciCC) SendDeleteDot1PMapper(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2288 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2289 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2290 | logger.Debugw(ctx, "send .1pMapper-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2291 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2292 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2293 | |
| 2294 | meParams := me.ParamData{EntityID: aInstID} |
| 2295 | meInstance, omciErr := me.NewIeee8021PMapperServiceProfile(meParams) |
| 2296 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2297 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2298 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2299 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2300 | logger.Errorw(ctx, "Cannot encode .1pMapper for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2301 | "Err": err, "device-id": oo.deviceID}) |
| 2302 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2303 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2304 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2305 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2306 | } |
| 2307 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2308 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2309 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2310 | logger.Errorw(ctx, "Cannot serialize .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2311 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2312 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2313 | } |
| 2314 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2315 | omciRxCallbackPair := CallbackPair{ |
| 2316 | CbKey: tid, |
| 2317 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2318 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2319 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2320 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2321 | logger.Errorw(ctx, "Cannot send .1pMapper delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2322 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2323 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2324 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2325 | logger.Debug(ctx, "send .1pMapper-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2326 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2327 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2328 | logger.Errorw(ctx, "Cannot generate .1pMapper Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2329 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2330 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2331 | } |
| 2332 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2333 | // SendDeleteMBPConfigData deletes MacBridgePortConfigurationData ME instance |
| 2334 | func (oo *OmciCC) SendDeleteMBPConfigData(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2335 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2336 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2337 | logger.Debugw(ctx, "send MBPCD-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2338 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2339 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2340 | |
| 2341 | meParams := me.ParamData{EntityID: aInstID} |
| 2342 | meInstance, omciErr := me.NewMacBridgePortConfigurationData(meParams) |
| 2343 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2344 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2345 | oframe.TransactionID(tid)) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2346 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2347 | logger.Errorw(ctx, "Cannot encode MBPCD for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2348 | "Err": err, "device-id": oo.deviceID}) |
| 2349 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2350 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2351 | // (relevant to all used sendXX() methods and their error conditions) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2352 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2353 | } |
| 2354 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2355 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2356 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2357 | logger.Errorw(ctx, "Cannot serialize MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2358 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2359 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2360 | } |
| 2361 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2362 | omciRxCallbackPair := CallbackPair{ |
| 2363 | CbKey: tid, |
| 2364 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2365 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2366 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2367 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2368 | logger.Errorw(ctx, "Cannot send MBPCD delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2369 | "Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2370 | return nil, err |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2371 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2372 | logger.Debug(ctx, "send MBPCD-Delete-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2373 | return meInstance, nil |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2374 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2375 | logger.Errorw(ctx, "Cannot generate MBPCD Instance for delete", log.Fields{ |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2376 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2377 | return nil, omciErr.GetError() |
mpagenko | 8b07c1b | 2020-11-26 10:36:31 +0000 | [diff] [blame] | 2378 | } |
| 2379 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2380 | // SendCreateMulticastGemIWTPVar creates MulticastGemInterworkingTerminationPoint ME instance |
| 2381 | func (oo *OmciCC) SendCreateMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2382 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2383 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2384 | logger.Debugw(ctx, "send MulticastGemIWTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2385 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2386 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2387 | |
| 2388 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2389 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2390 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2391 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2392 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2393 | logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2394 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2395 | } |
| 2396 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2397 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2398 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2399 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2400 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2401 | } |
| 2402 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2403 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2404 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2405 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2406 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2407 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2408 | logger.Errorw(ctx, "Cannot send MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2409 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2410 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2411 | logger.Debug(ctx, "send MulticastGEMIWTP-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2412 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2413 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2414 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2415 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2416 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2417 | } |
| 2418 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2419 | // SendSetMulticastGemIWTPVar sets MulticastGemInterworkingTerminationPoint ME instance |
| 2420 | func (oo *OmciCC) SendSetMulticastGemIWTPVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2421 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2422 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2423 | logger.Debugw(ctx, "send MulticastGemIWTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2424 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2425 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2426 | |
| 2427 | meInstance, omciErr := me.NewMulticastGemInterworkingTerminationPoint(params[0]) |
| 2428 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2429 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2430 | oframe.AddDefaults(true)) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2431 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2432 | logger.Errorw(ctx, "Cannot encode MulticastGEMIWTP for set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2433 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2434 | } |
| 2435 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2436 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2437 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2438 | logger.Errorw(ctx, "Cannot serialize MulticastGEMIWTP create", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2439 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2440 | } |
| 2441 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2442 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2443 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2444 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2445 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2446 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2447 | logger.Errorw(ctx, "Cannot send MulticastGEMIWTP set", log.Fields{"Err": err, "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2448 | return nil, err |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2449 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2450 | logger.Debug(ctx, "send MulticastGEMIWTP-set-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2451 | return meInstance, nil |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2452 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2453 | logger.Errorw(ctx, "Cannot generate MulticastGEMIWTP Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2454 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2455 | return nil, omciErr.GetError() |
ozgecanetsia | b5000ef | 2020-11-27 14:38:20 +0300 | [diff] [blame] | 2456 | } |
| 2457 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2458 | // SendCreateMulticastOperationProfileVar creates MulticastOperationsProfile ME instance |
| 2459 | func (oo *OmciCC) SendCreateMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2460 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2461 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2462 | logger.Debugw(ctx, "send MulticastOperationProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2463 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2464 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2465 | |
| 2466 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2467 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2468 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2469 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2470 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2471 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2472 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2473 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2474 | } |
| 2475 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2476 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2477 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2478 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2479 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2480 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2481 | } |
| 2482 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2483 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2484 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2485 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2486 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2487 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2488 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2489 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2490 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2491 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2492 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2493 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2494 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2495 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2496 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2497 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2498 | } |
| 2499 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2500 | // SendSetMulticastOperationProfileVar sets MulticastOperationsProfile ME instance |
| 2501 | func (oo *OmciCC) SendSetMulticastOperationProfileVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2502 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2503 | tid := oo.GetNextTid(highPrio) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2504 | logger.Debugw(ctx, "send MulticastOperationProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2505 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2506 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2507 | |
| 2508 | meInstance, omciErr := me.NewMulticastOperationsProfile(params[0]) |
| 2509 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2510 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2511 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2512 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2513 | logger.Errorw(ctx, "Cannot encode MulticastOperationProfile for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2514 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2515 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2516 | } |
| 2517 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2518 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2519 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2520 | logger.Errorw(ctx, "Cannot serialize MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2521 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2522 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2523 | } |
| 2524 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2525 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2526 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2527 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2528 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2529 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2530 | logger.Errorw(ctx, "Cannot send MulticastOperationProfile create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2531 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2532 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2533 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2534 | logger.Debug(ctx, "send MulticastOperationProfile-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2535 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2536 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2537 | logger.Errorw(ctx, "Cannot generate MulticastOperationProfile Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2538 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2539 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2540 | } |
| 2541 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2542 | // SendCreateMulticastSubConfigInfoVar creates MulticastSubscriberConfigInfo ME instance |
| 2543 | func (oo *OmciCC) SendCreateMulticastSubConfigInfoVar(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2544 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2545 | tid := oo.GetNextTid(highPrio) |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2546 | logger.Debugw(ctx, "send MulticastSubConfigInfo-create-msg:", log.Fields{"device-id": oo.deviceID, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2547 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2548 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2549 | |
| 2550 | meInstance, omciErr := me.NewMulticastSubscriberConfigInfo(params[0]) |
| 2551 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2552 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2553 | oframe.AddDefaults(true)) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2554 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2555 | logger.Errorw(ctx, "Cannot encode MulticastSubConfigInfo for create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2556 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2557 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2558 | } |
| 2559 | |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2560 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2561 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2562 | logger.Errorw(ctx, "Cannot serialize MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2563 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2564 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2565 | } |
| 2566 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2567 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2568 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2569 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 2570 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2571 | if err != nil { |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2572 | logger.Errorw(ctx, "Cannot send MulticastSubConfigInfo create", log.Fields{"Err": err, |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2573 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2574 | return nil, err |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2575 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2576 | logger.Debug(ctx, "send MulticastSubConfigInfo-create-msg done") |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2577 | return meInstance, nil |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2578 | } |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 2579 | logger.Errorw(ctx, "Cannot generate MulticastSubConfigInfo Instance", log.Fields{"Err": omciErr.GetError(), |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2580 | "device-id": oo.deviceID}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 2581 | return nil, omciErr.GetError() |
ozgecanetsia | 422dbf3 | 2020-10-28 14:07:19 +0300 | [diff] [blame] | 2582 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 2583 | |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2584 | // SendCreateVoipVoiceCTP nolint: unused |
| 2585 | func (oo *OmciCC) SendCreateVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2586 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2587 | tid := oo.GetNextTid(highPrio) |
| 2588 | logger.Debugw(ctx, "send VoipVoiceCTP-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2589 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2590 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2591 | |
| 2592 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2593 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2594 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2595 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2596 | if err != nil { |
| 2597 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for create", log.Fields{"Err": err, |
| 2598 | "device-id": oo.deviceID}) |
| 2599 | return nil, err |
| 2600 | } |
| 2601 | |
| 2602 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2603 | if err != nil { |
| 2604 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP create", log.Fields{"Err": err, |
| 2605 | "device-id": oo.deviceID}) |
| 2606 | return nil, err |
| 2607 | } |
| 2608 | |
| 2609 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2610 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2611 | } |
| 2612 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2613 | if err != nil { |
| 2614 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP create", log.Fields{"Err": err, |
| 2615 | "device-id": oo.deviceID}) |
| 2616 | return nil, err |
| 2617 | } |
| 2618 | logger.Debug(ctx, "send VoipVoiceCTP-create-msg done") |
| 2619 | return meInstance, nil |
| 2620 | } |
| 2621 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2622 | "device-id": oo.deviceID}) |
| 2623 | return nil, omciErr.GetError() |
| 2624 | } |
| 2625 | |
| 2626 | // SendSetVoipVoiceCTP nolint: unused |
| 2627 | func (oo *OmciCC) SendSetVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2628 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2629 | tid := oo.GetNextTid(highPrio) |
| 2630 | logger.Debugw(ctx, "send VoipVoiceCTP-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2631 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2632 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2633 | |
| 2634 | meInstance, omciErr := me.NewVoipVoiceCtp(params[0]) |
| 2635 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2636 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2637 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2638 | if err != nil { |
| 2639 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for set", log.Fields{"Err": err, |
| 2640 | "device-id": oo.deviceID}) |
| 2641 | return nil, err |
| 2642 | } |
| 2643 | |
| 2644 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2645 | if err != nil { |
| 2646 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP set", log.Fields{"Err": err, |
| 2647 | "device-id": oo.deviceID}) |
| 2648 | return nil, err |
| 2649 | } |
| 2650 | |
| 2651 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2652 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2653 | } |
| 2654 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2655 | if err != nil { |
| 2656 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP set", log.Fields{"Err": err, |
| 2657 | "device-id": oo.deviceID}) |
| 2658 | return nil, err |
| 2659 | } |
| 2660 | logger.Debug(ctx, "send VoipVoiceCTP-set-msg done") |
| 2661 | return meInstance, nil |
| 2662 | } |
| 2663 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance", log.Fields{"Err": omciErr.GetError(), |
| 2664 | "device-id": oo.deviceID}) |
| 2665 | return nil, omciErr.GetError() |
| 2666 | } |
| 2667 | |
| 2668 | // SendDeleteVoipVoiceCTP nolint: unused |
| 2669 | func (oo *OmciCC) SendDeleteVoipVoiceCTP(ctx context.Context, timeout int, highPrio bool, |
| 2670 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2671 | tid := oo.GetNextTid(highPrio) |
| 2672 | logger.Debugw(ctx, "send VoipVoiceCTP-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2673 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2674 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2675 | |
| 2676 | meParams := me.ParamData{EntityID: aInstID} |
| 2677 | meInstance, omciErr := me.NewVoipVoiceCtp(meParams) |
| 2678 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2679 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2680 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2681 | if err != nil { |
| 2682 | logger.Errorw(ctx, "Cannot encode VoipVoiceCTP for delete", log.Fields{ |
| 2683 | "Err": err, "device-id": oo.deviceID}) |
| 2684 | //TODO!!: refactoring improvement requested, here as an example for [VOL-3457]: |
| 2685 | // return (dual format) error code that can be used at caller for immediate error treatment |
| 2686 | // (relevant to all used sendXX() methods and their error conditions) |
| 2687 | return nil, err |
| 2688 | } |
| 2689 | |
| 2690 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2691 | if err != nil { |
| 2692 | logger.Errorw(ctx, "Cannot serialize VoipVoiceCTP delete", log.Fields{ |
| 2693 | "Err": err, "device-id": oo.deviceID}) |
| 2694 | return nil, err |
| 2695 | } |
| 2696 | |
| 2697 | omciRxCallbackPair := CallbackPair{ |
| 2698 | CbKey: tid, |
| 2699 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2700 | } |
| 2701 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2702 | if err != nil { |
| 2703 | logger.Errorw(ctx, "Cannot send VoipVoiceCTP delete", log.Fields{ |
| 2704 | "Err": err, "device-id": oo.deviceID}) |
| 2705 | return nil, err |
| 2706 | } |
| 2707 | logger.Debug(ctx, "send VoipVoiceCTP-Delete-msg done") |
| 2708 | return meInstance, nil |
| 2709 | } |
| 2710 | logger.Errorw(ctx, "Cannot generate VoipVoiceCTP Instance for delete", log.Fields{ |
| 2711 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2712 | return nil, omciErr.GetError() |
| 2713 | } |
| 2714 | |
| 2715 | // SendCreateVoipMediaProfile nolint: unused |
| 2716 | func (oo *OmciCC) SendCreateVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2717 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2718 | tid := oo.GetNextTid(highPrio) |
| 2719 | logger.Debugw(ctx, "send VoipMediaProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2720 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2721 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2722 | |
| 2723 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2724 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2725 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2726 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2727 | if err != nil { |
| 2728 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for create", log.Fields{"Err": err, |
| 2729 | "device-id": oo.deviceID}) |
| 2730 | return nil, err |
| 2731 | } |
| 2732 | |
| 2733 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2734 | if err != nil { |
| 2735 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile create", log.Fields{"Err": err, |
| 2736 | "device-id": oo.deviceID}) |
| 2737 | return nil, err |
| 2738 | } |
| 2739 | |
| 2740 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2741 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2742 | } |
| 2743 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2744 | if err != nil { |
| 2745 | logger.Errorw(ctx, "Cannot send VoipMediaProfile create", log.Fields{"Err": err, |
| 2746 | "device-id": oo.deviceID}) |
| 2747 | return nil, err |
| 2748 | } |
| 2749 | logger.Debug(ctx, "send VoipMediaProfile-create-msg done") |
| 2750 | return meInstance, nil |
| 2751 | } |
| 2752 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2753 | "device-id": oo.deviceID}) |
| 2754 | return nil, omciErr.GetError() |
| 2755 | } |
| 2756 | |
| 2757 | // SendSetVoipMediaProfile nolint: unused |
| 2758 | func (oo *OmciCC) SendSetVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2759 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2760 | tid := oo.GetNextTid(highPrio) |
| 2761 | logger.Debugw(ctx, "send VoipMediaProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2762 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2763 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2764 | |
| 2765 | meInstance, omciErr := me.NewVoipMediaProfile(params[0]) |
| 2766 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2767 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2768 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2769 | if err != nil { |
| 2770 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for set", log.Fields{"Err": err, |
| 2771 | "device-id": oo.deviceID}) |
| 2772 | return nil, err |
| 2773 | } |
| 2774 | |
| 2775 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2776 | if err != nil { |
| 2777 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile set", log.Fields{"Err": err, |
| 2778 | "device-id": oo.deviceID}) |
| 2779 | return nil, err |
| 2780 | } |
| 2781 | |
| 2782 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2783 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2784 | } |
| 2785 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2786 | if err != nil { |
| 2787 | logger.Errorw(ctx, "Cannot send VoipMediaProfile set", log.Fields{"Err": err, |
| 2788 | "device-id": oo.deviceID}) |
| 2789 | return nil, err |
| 2790 | } |
| 2791 | logger.Debug(ctx, "send VoipMediaProfile-set-msg done") |
| 2792 | return meInstance, nil |
| 2793 | } |
| 2794 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2795 | "device-id": oo.deviceID}) |
| 2796 | return nil, omciErr.GetError() |
| 2797 | } |
| 2798 | |
| 2799 | // SendDeleteVoipMediaProfile nolint: unused |
| 2800 | func (oo *OmciCC) SendDeleteVoipMediaProfile(ctx context.Context, timeout int, highPrio bool, |
| 2801 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2802 | tid := oo.GetNextTid(highPrio) |
| 2803 | logger.Debugw(ctx, "send VoipMediaProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2804 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2805 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2806 | |
| 2807 | meParams := me.ParamData{EntityID: aInstID} |
| 2808 | meInstance, omciErr := me.NewVoipMediaProfile(meParams) |
| 2809 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2810 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2811 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2812 | if err != nil { |
| 2813 | logger.Errorw(ctx, "Cannot encode VoipMediaProfile for delete", log.Fields{ |
| 2814 | "Err": err, "device-id": oo.deviceID}) |
| 2815 | return nil, err |
| 2816 | } |
| 2817 | |
| 2818 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2819 | if err != nil { |
| 2820 | logger.Errorw(ctx, "Cannot serialize VoipMediaProfile delete", log.Fields{ |
| 2821 | "Err": err, "device-id": oo.deviceID}) |
| 2822 | return nil, err |
| 2823 | } |
| 2824 | |
| 2825 | omciRxCallbackPair := CallbackPair{ |
| 2826 | CbKey: tid, |
| 2827 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2828 | } |
| 2829 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2830 | if err != nil { |
| 2831 | logger.Errorw(ctx, "Cannot send VoipMediaProfile delete", log.Fields{ |
| 2832 | "Err": err, "device-id": oo.deviceID}) |
| 2833 | return nil, err |
| 2834 | } |
| 2835 | logger.Debug(ctx, "send VoipMediaProfile-Delete-msg done") |
| 2836 | return meInstance, nil |
| 2837 | } |
| 2838 | logger.Errorw(ctx, "Cannot generate VoipMediaProfile Instance for delete", log.Fields{ |
| 2839 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2840 | return nil, omciErr.GetError() |
| 2841 | } |
| 2842 | |
| 2843 | // SendCreateVoiceServiceProfile nolint: unused |
| 2844 | func (oo *OmciCC) SendCreateVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2845 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2846 | tid := oo.GetNextTid(highPrio) |
| 2847 | logger.Debugw(ctx, "send VoiceServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2848 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2849 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2850 | |
| 2851 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 2852 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2853 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2854 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2855 | if err != nil { |
| 2856 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for create", log.Fields{"Err": err, |
| 2857 | "device-id": oo.deviceID}) |
| 2858 | return nil, err |
| 2859 | } |
| 2860 | |
| 2861 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2862 | if err != nil { |
| 2863 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile create", log.Fields{"Err": err, |
| 2864 | "device-id": oo.deviceID}) |
| 2865 | return nil, err |
| 2866 | } |
| 2867 | |
| 2868 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2869 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2870 | } |
| 2871 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2872 | if err != nil { |
| 2873 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile create", log.Fields{"Err": err, |
| 2874 | "device-id": oo.deviceID}) |
| 2875 | return nil, err |
| 2876 | } |
| 2877 | logger.Debug(ctx, "send VoiceServiceProfile-create-msg done") |
| 2878 | return meInstance, nil |
| 2879 | } |
| 2880 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2881 | "device-id": oo.deviceID}) |
| 2882 | return nil, omciErr.GetError() |
| 2883 | } |
| 2884 | |
| 2885 | // SendSetVoiceServiceProfile nolint: unused |
| 2886 | func (oo *OmciCC) SendSetVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2887 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2888 | tid := oo.GetNextTid(highPrio) |
| 2889 | logger.Debugw(ctx, "send VoiceServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 2890 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2891 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2892 | |
| 2893 | meInstance, omciErr := me.NewVoiceServiceProfile(params[0]) |
| 2894 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2895 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 2896 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2897 | if err != nil { |
| 2898 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for set", log.Fields{"Err": err, |
| 2899 | "device-id": oo.deviceID}) |
| 2900 | return nil, err |
| 2901 | } |
| 2902 | |
| 2903 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2904 | if err != nil { |
| 2905 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile set", log.Fields{"Err": err, |
| 2906 | "device-id": oo.deviceID}) |
| 2907 | return nil, err |
| 2908 | } |
| 2909 | |
| 2910 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2911 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2912 | } |
| 2913 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2914 | if err != nil { |
| 2915 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile set", log.Fields{"Err": err, |
| 2916 | "device-id": oo.deviceID}) |
| 2917 | return nil, err |
| 2918 | } |
| 2919 | logger.Debug(ctx, "send VoiceServiceProfile-set-msg done") |
| 2920 | return meInstance, nil |
| 2921 | } |
| 2922 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 2923 | "device-id": oo.deviceID}) |
| 2924 | return nil, omciErr.GetError() |
| 2925 | } |
| 2926 | |
| 2927 | // SendDeleteVoiceServiceProfile nolint: unused |
| 2928 | func (oo *OmciCC) SendDeleteVoiceServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 2929 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 2930 | tid := oo.GetNextTid(highPrio) |
| 2931 | logger.Debugw(ctx, "send VoiceServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 2932 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2933 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 2934 | |
| 2935 | meParams := me.ParamData{EntityID: aInstID} |
| 2936 | meInstance, omciErr := me.NewVoiceServiceProfile(meParams) |
| 2937 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2938 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 2939 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2940 | if err != nil { |
| 2941 | logger.Errorw(ctx, "Cannot encode VoiceServiceProfile for delete", log.Fields{ |
| 2942 | "Err": err, "device-id": oo.deviceID}) |
| 2943 | return nil, err |
| 2944 | } |
| 2945 | |
| 2946 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2947 | if err != nil { |
| 2948 | logger.Errorw(ctx, "Cannot serialize VoiceServiceProfile delete", log.Fields{ |
| 2949 | "Err": err, "device-id": oo.deviceID}) |
| 2950 | return nil, err |
| 2951 | } |
| 2952 | |
| 2953 | omciRxCallbackPair := CallbackPair{ |
| 2954 | CbKey: tid, |
| 2955 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2956 | } |
| 2957 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 2958 | if err != nil { |
| 2959 | logger.Errorw(ctx, "Cannot send VoiceServiceProfile delete", log.Fields{ |
| 2960 | "Err": err, "device-id": oo.deviceID}) |
| 2961 | return nil, err |
| 2962 | } |
| 2963 | logger.Debug(ctx, "send VoiceServiceProfile-Delete-msg done") |
| 2964 | return meInstance, nil |
| 2965 | } |
| 2966 | logger.Errorw(ctx, "Cannot generate VoiceServiceProfile Instance for delete", log.Fields{ |
| 2967 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 2968 | return nil, omciErr.GetError() |
| 2969 | } |
| 2970 | |
| 2971 | // SendCreateSIPUserData nolint: unused |
| 2972 | func (oo *OmciCC) SendCreateSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 2973 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 2974 | tid := oo.GetNextTid(highPrio) |
| 2975 | logger.Debugw(ctx, "send SIPUserData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 2976 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 2977 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 2978 | |
| 2979 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 2980 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 2981 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 2982 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 2983 | if err != nil { |
| 2984 | logger.Errorw(ctx, "Cannot encode SIPUserData for create", log.Fields{"Err": err, |
| 2985 | "device-id": oo.deviceID}) |
| 2986 | return nil, err |
| 2987 | } |
| 2988 | |
| 2989 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 2990 | if err != nil { |
| 2991 | logger.Errorw(ctx, "Cannot serialize SIPUserData create", log.Fields{"Err": err, |
| 2992 | "device-id": oo.deviceID}) |
| 2993 | return nil, err |
| 2994 | } |
| 2995 | |
| 2996 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 2997 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 2998 | } |
| 2999 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3000 | if err != nil { |
| 3001 | logger.Errorw(ctx, "Cannot send SIPUserData create", log.Fields{"Err": err, |
| 3002 | "device-id": oo.deviceID}) |
| 3003 | return nil, err |
| 3004 | } |
| 3005 | logger.Debug(ctx, "send SIPUserData-create-msg done") |
| 3006 | return meInstance, nil |
| 3007 | } |
| 3008 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3009 | "device-id": oo.deviceID}) |
| 3010 | return nil, omciErr.GetError() |
| 3011 | } |
| 3012 | |
| 3013 | // SendSetSIPUserData nolint: unused |
| 3014 | func (oo *OmciCC) SendSetSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3015 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3016 | tid := oo.GetNextTid(highPrio) |
| 3017 | logger.Debugw(ctx, "send SIPUserData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3018 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3019 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3020 | |
| 3021 | meInstance, omciErr := me.NewSipUserData(params[0]) |
| 3022 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3023 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3024 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3025 | if err != nil { |
| 3026 | logger.Errorw(ctx, "Cannot encode SIPUserData for set", log.Fields{"Err": err, |
| 3027 | "device-id": oo.deviceID}) |
| 3028 | return nil, err |
| 3029 | } |
| 3030 | |
| 3031 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3032 | if err != nil { |
| 3033 | logger.Errorw(ctx, "Cannot serialize SIPUserData set", log.Fields{"Err": err, |
| 3034 | "device-id": oo.deviceID}) |
| 3035 | return nil, err |
| 3036 | } |
| 3037 | |
| 3038 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3039 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3040 | } |
| 3041 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3042 | if err != nil { |
| 3043 | logger.Errorw(ctx, "Cannot send SIPUserData set", log.Fields{"Err": err, |
| 3044 | "device-id": oo.deviceID}) |
| 3045 | return nil, err |
| 3046 | } |
| 3047 | logger.Debug(ctx, "send SIPUserData-set-msg done") |
| 3048 | return meInstance, nil |
| 3049 | } |
| 3050 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3051 | "device-id": oo.deviceID}) |
| 3052 | return nil, omciErr.GetError() |
| 3053 | } |
| 3054 | |
| 3055 | // SendDeleteSIPUserData nolint: unused |
| 3056 | func (oo *OmciCC) SendDeleteSIPUserData(ctx context.Context, timeout int, highPrio bool, |
| 3057 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3058 | tid := oo.GetNextTid(highPrio) |
| 3059 | logger.Debugw(ctx, "send SIPUserData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3060 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3061 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3062 | |
| 3063 | meParams := me.ParamData{EntityID: aInstID} |
| 3064 | meInstance, omciErr := me.NewSipUserData(meParams) |
| 3065 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3066 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3067 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3068 | if err != nil { |
| 3069 | logger.Errorw(ctx, "Cannot encode SIPUserData for delete", log.Fields{ |
| 3070 | "Err": err, "device-id": oo.deviceID}) |
| 3071 | return nil, err |
| 3072 | } |
| 3073 | |
| 3074 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3075 | if err != nil { |
| 3076 | logger.Errorw(ctx, "Cannot serialize SIPUserData delete", log.Fields{ |
| 3077 | "Err": err, "device-id": oo.deviceID}) |
| 3078 | return nil, err |
| 3079 | } |
| 3080 | |
| 3081 | omciRxCallbackPair := CallbackPair{ |
| 3082 | CbKey: tid, |
| 3083 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3084 | } |
| 3085 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3086 | if err != nil { |
| 3087 | logger.Errorw(ctx, "Cannot send SIPUserData delete", log.Fields{ |
| 3088 | "Err": err, "device-id": oo.deviceID}) |
| 3089 | return nil, err |
| 3090 | } |
| 3091 | logger.Debug(ctx, "send SIPUserData-Delete-msg done") |
| 3092 | return meInstance, nil |
| 3093 | } |
| 3094 | logger.Errorw(ctx, "Cannot generate SIPUserData Instance for delete", log.Fields{ |
| 3095 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3096 | return nil, omciErr.GetError() |
| 3097 | } |
| 3098 | |
| 3099 | // SendCreateVoipApplicationServiceProfile nolint: unused |
| 3100 | func (oo *OmciCC) SendCreateVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3101 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3102 | tid := oo.GetNextTid(highPrio) |
| 3103 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3104 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3105 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3106 | |
| 3107 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3108 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3109 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3110 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3111 | if err != nil { |
| 3112 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for create", log.Fields{"Err": err, |
| 3113 | "device-id": oo.deviceID}) |
| 3114 | return nil, err |
| 3115 | } |
| 3116 | |
| 3117 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3118 | if err != nil { |
| 3119 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3120 | "device-id": oo.deviceID}) |
| 3121 | return nil, err |
| 3122 | } |
| 3123 | |
| 3124 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3125 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3126 | } |
| 3127 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3128 | if err != nil { |
| 3129 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile create", log.Fields{"Err": err, |
| 3130 | "device-id": oo.deviceID}) |
| 3131 | return nil, err |
| 3132 | } |
| 3133 | logger.Debug(ctx, "send VoipApplicationServiceProfile-create-msg done") |
| 3134 | return meInstance, nil |
| 3135 | } |
| 3136 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3137 | "device-id": oo.deviceID}) |
| 3138 | return nil, omciErr.GetError() |
| 3139 | } |
| 3140 | |
| 3141 | // SendSetVoipApplicationServiceProfile nolint: unused |
| 3142 | func (oo *OmciCC) SendSetVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3143 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3144 | tid := oo.GetNextTid(highPrio) |
| 3145 | logger.Debugw(ctx, "send VoipApplicationServiceProfile-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3146 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3147 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3148 | |
| 3149 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(params[0]) |
| 3150 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3151 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3152 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3153 | if err != nil { |
| 3154 | logger.Errorw(ctx, "Cannot encode VoipApplicationServiceProfile for set", log.Fields{"Err": err, |
| 3155 | "device-id": oo.deviceID}) |
| 3156 | return nil, err |
| 3157 | } |
| 3158 | |
| 3159 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3160 | if err != nil { |
| 3161 | logger.Errorw(ctx, "Cannot serialize VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3162 | "device-id": oo.deviceID}) |
| 3163 | return nil, err |
| 3164 | } |
| 3165 | |
| 3166 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3167 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3168 | } |
| 3169 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3170 | if err != nil { |
| 3171 | logger.Errorw(ctx, "Cannot send VoipApplicationServiceProfile set", log.Fields{"Err": err, |
| 3172 | "device-id": oo.deviceID}) |
| 3173 | return nil, err |
| 3174 | } |
| 3175 | logger.Debug(ctx, "send VoipApplicationServiceProfile-set-msg done") |
| 3176 | return meInstance, nil |
| 3177 | } |
| 3178 | logger.Errorw(ctx, "Cannot generate VoipApplicationServiceProfile Instance", log.Fields{"Err": omciErr.GetError(), |
| 3179 | "device-id": oo.deviceID}) |
| 3180 | return nil, omciErr.GetError() |
| 3181 | } |
| 3182 | |
| 3183 | // SendDeleteVoipApplicationServiceProfile nolint: unused |
| 3184 | func (oo *OmciCC) SendDeleteVoipApplicationServiceProfile(ctx context.Context, timeout int, highPrio bool, |
| 3185 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3186 | tid := oo.GetNextTid(highPrio) |
| 3187 | logger.Debugw(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3188 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3189 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3190 | |
| 3191 | meParams := me.ParamData{EntityID: aInstID} |
| 3192 | meInstance, omciErr := me.NewVoipApplicationServiceProfile(meParams) |
| 3193 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3194 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3195 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3196 | if err != nil { |
| 3197 | logger.Errorw(ctx, "Cannot encode SIPVoipApplicationServiceProfile for delete", log.Fields{ |
| 3198 | "Err": err, "device-id": oo.deviceID}) |
| 3199 | return nil, err |
| 3200 | } |
| 3201 | |
| 3202 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3203 | if err != nil { |
| 3204 | logger.Errorw(ctx, "Cannot serialize SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3205 | "Err": err, "device-id": oo.deviceID}) |
| 3206 | return nil, err |
| 3207 | } |
| 3208 | |
| 3209 | omciRxCallbackPair := CallbackPair{ |
| 3210 | CbKey: tid, |
| 3211 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3212 | } |
| 3213 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3214 | if err != nil { |
| 3215 | logger.Errorw(ctx, "Cannot send SIPVoipApplicationServiceProfile delete", log.Fields{ |
| 3216 | "Err": err, "device-id": oo.deviceID}) |
| 3217 | return nil, err |
| 3218 | } |
| 3219 | logger.Debug(ctx, "send SIPVoipApplicationServiceProfile-Delete-msg done") |
| 3220 | return meInstance, nil |
| 3221 | } |
| 3222 | logger.Errorw(ctx, "Cannot generate SIPVoipApplicationServiceProfile Instance for delete", log.Fields{ |
| 3223 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3224 | return nil, omciErr.GetError() |
| 3225 | } |
| 3226 | |
| 3227 | // SendCreateSIPAgentConfigData nolint: unused |
| 3228 | func (oo *OmciCC) SendCreateSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3229 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3230 | tid := oo.GetNextTid(highPrio) |
| 3231 | logger.Debugw(ctx, "send SIPAgentConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3232 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3233 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3234 | |
| 3235 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3236 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3237 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3238 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3239 | if err != nil { |
| 3240 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for create", log.Fields{"Err": err, |
| 3241 | "device-id": oo.deviceID}) |
| 3242 | return nil, err |
| 3243 | } |
| 3244 | |
| 3245 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3246 | if err != nil { |
| 3247 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData create", log.Fields{"Err": err, |
| 3248 | "device-id": oo.deviceID}) |
| 3249 | return nil, err |
| 3250 | } |
| 3251 | |
| 3252 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3253 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3254 | } |
| 3255 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3256 | if err != nil { |
| 3257 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData create", log.Fields{"Err": err, |
| 3258 | "device-id": oo.deviceID}) |
| 3259 | return nil, err |
| 3260 | } |
| 3261 | logger.Debug(ctx, "send SIPAgentConfigData-create-msg done") |
| 3262 | return meInstance, nil |
| 3263 | } |
| 3264 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3265 | "device-id": oo.deviceID}) |
| 3266 | return nil, omciErr.GetError() |
| 3267 | } |
| 3268 | |
| 3269 | // SendSetSIPAgentConfigData nolint: unused |
| 3270 | func (oo *OmciCC) SendSetSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3271 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3272 | tid := oo.GetNextTid(highPrio) |
| 3273 | logger.Debugw(ctx, "send SIPAgentConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3274 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3275 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3276 | |
| 3277 | meInstance, omciErr := me.NewSipAgentConfigData(params[0]) |
| 3278 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3279 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3280 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3281 | if err != nil { |
| 3282 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for set", log.Fields{"Err": err, |
| 3283 | "device-id": oo.deviceID}) |
| 3284 | return nil, err |
| 3285 | } |
| 3286 | |
| 3287 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3288 | if err != nil { |
| 3289 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData set", log.Fields{"Err": err, |
| 3290 | "device-id": oo.deviceID}) |
| 3291 | return nil, err |
| 3292 | } |
| 3293 | |
| 3294 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3295 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3296 | } |
| 3297 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3298 | if err != nil { |
| 3299 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData set", log.Fields{"Err": err, |
| 3300 | "device-id": oo.deviceID}) |
| 3301 | return nil, err |
| 3302 | } |
| 3303 | logger.Debug(ctx, "send SIPAgentConfigData-set-msg done") |
| 3304 | return meInstance, nil |
| 3305 | } |
| 3306 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3307 | "device-id": oo.deviceID}) |
| 3308 | return nil, omciErr.GetError() |
| 3309 | } |
| 3310 | |
| 3311 | // SendDeleteSIPAgentConfigData nolint: unused |
| 3312 | func (oo *OmciCC) SendDeleteSIPAgentConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3313 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3314 | tid := oo.GetNextTid(highPrio) |
| 3315 | logger.Debugw(ctx, "send SIPAgentConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3316 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3317 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3318 | |
| 3319 | meParams := me.ParamData{EntityID: aInstID} |
| 3320 | meInstance, omciErr := me.NewSipAgentConfigData(meParams) |
| 3321 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3322 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3323 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3324 | if err != nil { |
| 3325 | logger.Errorw(ctx, "Cannot encode SIPAgentConfigData for delete", log.Fields{ |
| 3326 | "Err": err, "device-id": oo.deviceID}) |
| 3327 | return nil, err |
| 3328 | } |
| 3329 | |
| 3330 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3331 | if err != nil { |
| 3332 | logger.Errorw(ctx, "Cannot serialize SIPAgentConfigData delete", log.Fields{ |
| 3333 | "Err": err, "device-id": oo.deviceID}) |
| 3334 | return nil, err |
| 3335 | } |
| 3336 | |
| 3337 | omciRxCallbackPair := CallbackPair{ |
| 3338 | CbKey: tid, |
| 3339 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3340 | } |
| 3341 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3342 | if err != nil { |
| 3343 | logger.Errorw(ctx, "Cannot send SIPAgentConfigData delete", log.Fields{ |
| 3344 | "Err": err, "device-id": oo.deviceID}) |
| 3345 | return nil, err |
| 3346 | } |
| 3347 | logger.Debug(ctx, "send SIPAgentConfigData-Delete-msg done") |
| 3348 | return meInstance, nil |
| 3349 | } |
| 3350 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3351 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3352 | return nil, omciErr.GetError() |
| 3353 | } |
| 3354 | |
| 3355 | // SendCreateTCPUDPConfigData nolint: unused |
| 3356 | func (oo *OmciCC) SendCreateTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3357 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3358 | tid := oo.GetNextTid(highPrio) |
| 3359 | logger.Debugw(ctx, "send TCPUDPConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3360 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3361 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3362 | |
| 3363 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3364 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3365 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3366 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3367 | if err != nil { |
| 3368 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for create", log.Fields{"Err": err, |
| 3369 | "device-id": oo.deviceID}) |
| 3370 | return nil, err |
| 3371 | } |
| 3372 | |
| 3373 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3374 | if err != nil { |
| 3375 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData create", log.Fields{"Err": err, |
| 3376 | "device-id": oo.deviceID}) |
| 3377 | return nil, err |
| 3378 | } |
| 3379 | |
| 3380 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3381 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3382 | } |
| 3383 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3384 | if err != nil { |
| 3385 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData create", log.Fields{"Err": err, |
| 3386 | "device-id": oo.deviceID}) |
| 3387 | return nil, err |
| 3388 | } |
| 3389 | logger.Debug(ctx, "send TCPUDPConfigData-create-msg done") |
| 3390 | return meInstance, nil |
| 3391 | } |
| 3392 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3393 | "device-id": oo.deviceID}) |
| 3394 | return nil, omciErr.GetError() |
| 3395 | } |
| 3396 | |
| 3397 | // SendSetTCPUDPConfigData nolint: unused |
| 3398 | func (oo *OmciCC) SendSetTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3399 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3400 | tid := oo.GetNextTid(highPrio) |
| 3401 | logger.Debugw(ctx, "send TCPUDPConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3402 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3403 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3404 | |
| 3405 | meInstance, omciErr := me.NewTcpUdpConfigData(params[0]) |
| 3406 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3407 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3408 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3409 | if err != nil { |
| 3410 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for set", log.Fields{"Err": err, |
| 3411 | "device-id": oo.deviceID}) |
| 3412 | return nil, err |
| 3413 | } |
| 3414 | |
| 3415 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3416 | if err != nil { |
| 3417 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData set", log.Fields{"Err": err, |
| 3418 | "device-id": oo.deviceID}) |
| 3419 | return nil, err |
| 3420 | } |
| 3421 | |
| 3422 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3423 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3424 | } |
| 3425 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3426 | if err != nil { |
| 3427 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData set", log.Fields{"Err": err, |
| 3428 | "device-id": oo.deviceID}) |
| 3429 | return nil, err |
| 3430 | } |
| 3431 | logger.Debug(ctx, "send TCPUDPConfigData-set-msg done") |
| 3432 | return meInstance, nil |
| 3433 | } |
| 3434 | logger.Errorw(ctx, "Cannot generate TCPUDPConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3435 | "device-id": oo.deviceID}) |
| 3436 | return nil, omciErr.GetError() |
| 3437 | } |
| 3438 | |
| 3439 | // SendDeleteTCPUDPConfigData nolint: unused |
| 3440 | func (oo *OmciCC) SendDeleteTCPUDPConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3441 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3442 | tid := oo.GetNextTid(highPrio) |
| 3443 | logger.Debugw(ctx, "send TCPUDPConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3444 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3445 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3446 | |
| 3447 | meParams := me.ParamData{EntityID: aInstID} |
| 3448 | meInstance, omciErr := me.NewTcpUdpConfigData(meParams) |
| 3449 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3450 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3451 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3452 | if err != nil { |
| 3453 | logger.Errorw(ctx, "Cannot encode TCPUDPConfigData for delete", log.Fields{ |
| 3454 | "Err": err, "device-id": oo.deviceID}) |
| 3455 | return nil, err |
| 3456 | } |
| 3457 | |
| 3458 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3459 | if err != nil { |
| 3460 | logger.Errorw(ctx, "Cannot serialize TCPUDPConfigData delete", log.Fields{ |
| 3461 | "Err": err, "device-id": oo.deviceID}) |
| 3462 | return nil, err |
| 3463 | } |
| 3464 | |
| 3465 | omciRxCallbackPair := CallbackPair{ |
| 3466 | CbKey: tid, |
| 3467 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3468 | } |
| 3469 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3470 | if err != nil { |
| 3471 | logger.Errorw(ctx, "Cannot send TCPUDPConfigData delete", log.Fields{ |
| 3472 | "Err": err, "device-id": oo.deviceID}) |
| 3473 | return nil, err |
| 3474 | } |
| 3475 | logger.Debug(ctx, "send TCPUDPConfigData-Delete-msg done") |
| 3476 | return meInstance, nil |
| 3477 | } |
| 3478 | logger.Errorw(ctx, "Cannot generate SIPAgentConfigData Instance for delete", log.Fields{ |
| 3479 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3480 | return nil, omciErr.GetError() |
| 3481 | } |
| 3482 | |
| 3483 | // SendCreateIPHostConfigData nolint: unused |
| 3484 | func (oo *OmciCC) SendCreateIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3485 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3486 | tid := oo.GetNextTid(highPrio) |
| 3487 | logger.Debugw(ctx, "send IPHostConfigData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3488 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3489 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3490 | |
| 3491 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3492 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3493 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3494 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3495 | if err != nil { |
| 3496 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for create", log.Fields{"Err": err, |
| 3497 | "device-id": oo.deviceID}) |
| 3498 | return nil, err |
| 3499 | } |
| 3500 | |
| 3501 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3502 | if err != nil { |
| 3503 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData create", log.Fields{"Err": err, |
| 3504 | "device-id": oo.deviceID}) |
| 3505 | return nil, err |
| 3506 | } |
| 3507 | |
| 3508 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3509 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3510 | } |
| 3511 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3512 | if err != nil { |
| 3513 | logger.Errorw(ctx, "Cannot send IPHostConfigData create", log.Fields{"Err": err, |
| 3514 | "device-id": oo.deviceID}) |
| 3515 | return nil, err |
| 3516 | } |
| 3517 | logger.Debug(ctx, "send IPHostConfigData-create-msg done") |
| 3518 | return meInstance, nil |
| 3519 | } |
| 3520 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3521 | "device-id": oo.deviceID}) |
| 3522 | return nil, omciErr.GetError() |
| 3523 | } |
| 3524 | |
| 3525 | // SendSetIPHostConfigData nolint: unused |
| 3526 | func (oo *OmciCC) SendSetIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3527 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3528 | tid := oo.GetNextTid(highPrio) |
| 3529 | logger.Debugw(ctx, "send IPHostConfigData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3530 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3531 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3532 | |
| 3533 | meInstance, omciErr := me.NewIpHostConfigData(params[0]) |
| 3534 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3535 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3536 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3537 | if err != nil { |
| 3538 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for set", log.Fields{"Err": err, |
| 3539 | "device-id": oo.deviceID}) |
| 3540 | return nil, err |
| 3541 | } |
| 3542 | |
| 3543 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3544 | if err != nil { |
| 3545 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData set", log.Fields{"Err": err, |
| 3546 | "device-id": oo.deviceID}) |
| 3547 | return nil, err |
| 3548 | } |
| 3549 | |
| 3550 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3551 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3552 | } |
| 3553 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3554 | if err != nil { |
| 3555 | logger.Errorw(ctx, "Cannot send IPHostConfigData set", log.Fields{"Err": err, |
| 3556 | "device-id": oo.deviceID}) |
| 3557 | return nil, err |
| 3558 | } |
| 3559 | logger.Debug(ctx, "send IPHostConfigData-set-msg done") |
| 3560 | return meInstance, nil |
| 3561 | } |
| 3562 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3563 | "device-id": oo.deviceID}) |
| 3564 | return nil, omciErr.GetError() |
| 3565 | } |
| 3566 | |
| 3567 | // SendDeleteIPHostConfigData nolint: unused |
| 3568 | func (oo *OmciCC) SendDeleteIPHostConfigData(ctx context.Context, timeout int, highPrio bool, |
| 3569 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3570 | tid := oo.GetNextTid(highPrio) |
| 3571 | logger.Debugw(ctx, "send IPHostConfigData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3572 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3573 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3574 | |
| 3575 | meParams := me.ParamData{EntityID: aInstID} |
| 3576 | meInstance, omciErr := me.NewIpHostConfigData(meParams) |
| 3577 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3578 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3579 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3580 | if err != nil { |
| 3581 | logger.Errorw(ctx, "Cannot encode IPHostConfigData for delete", log.Fields{ |
| 3582 | "Err": err, "device-id": oo.deviceID}) |
| 3583 | return nil, err |
| 3584 | } |
| 3585 | |
| 3586 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3587 | if err != nil { |
| 3588 | logger.Errorw(ctx, "Cannot serialize IPHostConfigData delete", log.Fields{ |
| 3589 | "Err": err, "device-id": oo.deviceID}) |
| 3590 | return nil, err |
| 3591 | } |
| 3592 | |
| 3593 | omciRxCallbackPair := CallbackPair{ |
| 3594 | CbKey: tid, |
| 3595 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3596 | } |
| 3597 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3598 | if err != nil { |
| 3599 | logger.Errorw(ctx, "Cannot send IPHostConfigData delete", log.Fields{ |
| 3600 | "Err": err, "device-id": oo.deviceID}) |
| 3601 | return nil, err |
| 3602 | } |
| 3603 | logger.Debug(ctx, "send IPHostConfigData-Delete-msg done") |
| 3604 | return meInstance, nil |
| 3605 | } |
| 3606 | logger.Errorw(ctx, "Cannot generate IPHostConfigData Instance for delete", log.Fields{ |
| 3607 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3608 | return nil, omciErr.GetError() |
| 3609 | } |
| 3610 | |
| 3611 | // SendCreateRTPProfileData nolint: unused |
| 3612 | func (oo *OmciCC) SendCreateRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3613 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3614 | tid := oo.GetNextTid(highPrio) |
| 3615 | logger.Debugw(ctx, "send RTPProfileData-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3616 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3617 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3618 | |
| 3619 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3620 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3621 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3622 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3623 | if err != nil { |
| 3624 | logger.Errorw(ctx, "Cannot encode RTPProfileData for create", log.Fields{"Err": err, |
| 3625 | "device-id": oo.deviceID}) |
| 3626 | return nil, err |
| 3627 | } |
| 3628 | |
| 3629 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3630 | if err != nil { |
| 3631 | logger.Errorw(ctx, "Cannot serialize RTPProfileData create", log.Fields{"Err": err, |
| 3632 | "device-id": oo.deviceID}) |
| 3633 | return nil, err |
| 3634 | } |
| 3635 | |
| 3636 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3637 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3638 | } |
| 3639 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3640 | if err != nil { |
| 3641 | logger.Errorw(ctx, "Cannot send RTPProfileData create", log.Fields{"Err": err, |
| 3642 | "device-id": oo.deviceID}) |
| 3643 | return nil, err |
| 3644 | } |
| 3645 | logger.Debug(ctx, "send RTPProfileData-create-msg done") |
| 3646 | return meInstance, nil |
| 3647 | } |
| 3648 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3649 | "device-id": oo.deviceID}) |
| 3650 | return nil, omciErr.GetError() |
| 3651 | } |
| 3652 | |
| 3653 | // SendSetRTPProfileData nolint: unused |
| 3654 | func (oo *OmciCC) SendSetRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3655 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3656 | tid := oo.GetNextTid(highPrio) |
| 3657 | logger.Debugw(ctx, "send RTPProfileData-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3658 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3659 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3660 | |
| 3661 | meInstance, omciErr := me.NewRtpProfileData(params[0]) |
| 3662 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3663 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3664 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3665 | if err != nil { |
| 3666 | logger.Errorw(ctx, "Cannot encode RTPProfileData for set", log.Fields{"Err": err, |
| 3667 | "device-id": oo.deviceID}) |
| 3668 | return nil, err |
| 3669 | } |
| 3670 | |
| 3671 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3672 | if err != nil { |
| 3673 | logger.Errorw(ctx, "Cannot serialize RTPProfileData set", log.Fields{"Err": err, |
| 3674 | "device-id": oo.deviceID}) |
| 3675 | return nil, err |
| 3676 | } |
| 3677 | |
| 3678 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3679 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3680 | } |
| 3681 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3682 | if err != nil { |
| 3683 | logger.Errorw(ctx, "Cannot send RTPProfileData set", log.Fields{"Err": err, |
| 3684 | "device-id": oo.deviceID}) |
| 3685 | return nil, err |
| 3686 | } |
| 3687 | logger.Debug(ctx, "send RTPProfileData-set-msg done") |
| 3688 | return meInstance, nil |
| 3689 | } |
| 3690 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance", log.Fields{"Err": omciErr.GetError(), |
| 3691 | "device-id": oo.deviceID}) |
| 3692 | return nil, omciErr.GetError() |
| 3693 | } |
| 3694 | |
| 3695 | // SendDeleteRTPProfileData nolint: unused |
| 3696 | func (oo *OmciCC) SendDeleteRTPProfileData(ctx context.Context, timeout int, highPrio bool, |
| 3697 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3698 | tid := oo.GetNextTid(highPrio) |
| 3699 | logger.Debugw(ctx, "send RTPProfileData-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3700 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3701 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3702 | |
| 3703 | meParams := me.ParamData{EntityID: aInstID} |
| 3704 | meInstance, omciErr := me.NewRtpProfileData(meParams) |
| 3705 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3706 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3707 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3708 | if err != nil { |
| 3709 | logger.Errorw(ctx, "Cannot encode RTPProfileData for delete", log.Fields{ |
| 3710 | "Err": err, "device-id": oo.deviceID}) |
| 3711 | return nil, err |
| 3712 | } |
| 3713 | |
| 3714 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3715 | if err != nil { |
| 3716 | logger.Errorw(ctx, "Cannot serialize RTPProfileData delete", log.Fields{ |
| 3717 | "Err": err, "device-id": oo.deviceID}) |
| 3718 | return nil, err |
| 3719 | } |
| 3720 | |
| 3721 | omciRxCallbackPair := CallbackPair{ |
| 3722 | CbKey: tid, |
| 3723 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3724 | } |
| 3725 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3726 | if err != nil { |
| 3727 | logger.Errorw(ctx, "Cannot send RTPProfileData delete", log.Fields{ |
| 3728 | "Err": err, "device-id": oo.deviceID}) |
| 3729 | return nil, err |
| 3730 | } |
| 3731 | logger.Debug(ctx, "send RTPProfileData-Delete-msg done") |
| 3732 | return meInstance, nil |
| 3733 | } |
| 3734 | logger.Errorw(ctx, "Cannot generate RTPProfileData Instance for delete", log.Fields{ |
| 3735 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3736 | return nil, omciErr.GetError() |
| 3737 | } |
| 3738 | |
| 3739 | // SendCreateNetworkDialPlanTable nolint: unused |
| 3740 | func (oo *OmciCC) SendCreateNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3741 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3742 | tid := oo.GetNextTid(highPrio) |
| 3743 | logger.Debugw(ctx, "send NetworkDialPlanTable-create-msg:", log.Fields{"device-id": oo.deviceID, |
| 3744 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3745 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3746 | |
| 3747 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3748 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3749 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3750 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3751 | if err != nil { |
| 3752 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for create", log.Fields{"Err": err, |
| 3753 | "device-id": oo.deviceID}) |
| 3754 | return nil, err |
| 3755 | } |
| 3756 | |
| 3757 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3758 | if err != nil { |
| 3759 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3760 | "device-id": oo.deviceID}) |
| 3761 | return nil, err |
| 3762 | } |
| 3763 | |
| 3764 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3765 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3766 | } |
| 3767 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3768 | if err != nil { |
| 3769 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable create", log.Fields{"Err": err, |
| 3770 | "device-id": oo.deviceID}) |
| 3771 | return nil, err |
| 3772 | } |
| 3773 | logger.Debug(ctx, "send NetworkDialPlanTable-create-msg done") |
| 3774 | return meInstance, nil |
| 3775 | } |
| 3776 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3777 | "device-id": oo.deviceID}) |
| 3778 | return nil, omciErr.GetError() |
| 3779 | } |
| 3780 | |
| 3781 | // SendSetNetworkDialPlanTable nolint: unused |
| 3782 | func (oo *OmciCC) SendSetNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3783 | rxChan chan Message, params ...me.ParamData) (*me.ManagedEntity, error) { |
| 3784 | tid := oo.GetNextTid(highPrio) |
| 3785 | logger.Debugw(ctx, "send NetworkDialPlanTable-set-msg:", log.Fields{"device-id": oo.deviceID, |
| 3786 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3787 | "InstId": strconv.FormatInt(int64(params[0].EntityID), 16)}) |
| 3788 | |
| 3789 | meInstance, omciErr := me.NewNetworkDialPlanTable(params[0]) |
| 3790 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3791 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid), |
| 3792 | oframe.AddDefaults(true)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3793 | if err != nil { |
| 3794 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for set", log.Fields{"Err": err, |
| 3795 | "device-id": oo.deviceID}) |
| 3796 | return nil, err |
| 3797 | } |
| 3798 | |
| 3799 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3800 | if err != nil { |
| 3801 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3802 | "device-id": oo.deviceID}) |
| 3803 | return nil, err |
| 3804 | } |
| 3805 | |
| 3806 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3807 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3808 | } |
| 3809 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3810 | if err != nil { |
| 3811 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable set", log.Fields{"Err": err, |
| 3812 | "device-id": oo.deviceID}) |
| 3813 | return nil, err |
| 3814 | } |
| 3815 | logger.Debug(ctx, "send NetworkDialPlanTable-set-msg done") |
| 3816 | return meInstance, nil |
| 3817 | } |
| 3818 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance", log.Fields{"Err": omciErr.GetError(), |
| 3819 | "device-id": oo.deviceID}) |
| 3820 | return nil, omciErr.GetError() |
| 3821 | } |
| 3822 | |
| 3823 | // SendDeleteNetworkDialPlanTable nolint: unused |
| 3824 | func (oo *OmciCC) SendDeleteNetworkDialPlanTable(ctx context.Context, timeout int, highPrio bool, |
| 3825 | rxChan chan Message, aInstID uint16) (*me.ManagedEntity, error) { |
| 3826 | tid := oo.GetNextTid(highPrio) |
| 3827 | logger.Debugw(ctx, "send NetworkDialPlanTable-Delete-msg:", log.Fields{"device-id": oo.deviceID, |
| 3828 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 3829 | "InstId": strconv.FormatInt(int64(aInstID), 16)}) |
| 3830 | |
| 3831 | meParams := me.ParamData{EntityID: aInstID} |
| 3832 | meInstance, omciErr := me.NewNetworkDialPlanTable(meParams) |
| 3833 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3834 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.DeleteRequestType, |
| 3835 | oframe.TransactionID(tid)) |
ozgecanetsia | 0e3111f | 2021-10-19 18:04:15 +0300 | [diff] [blame] | 3836 | if err != nil { |
| 3837 | logger.Errorw(ctx, "Cannot encode NetworkDialPlanTable for delete", log.Fields{ |
| 3838 | "Err": err, "device-id": oo.deviceID}) |
| 3839 | return nil, err |
| 3840 | } |
| 3841 | |
| 3842 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3843 | if err != nil { |
| 3844 | logger.Errorw(ctx, "Cannot serialize NetworkDialPlanTable delete", log.Fields{ |
| 3845 | "Err": err, "device-id": oo.deviceID}) |
| 3846 | return nil, err |
| 3847 | } |
| 3848 | |
| 3849 | omciRxCallbackPair := CallbackPair{ |
| 3850 | CbKey: tid, |
| 3851 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 3852 | } |
| 3853 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 3854 | if err != nil { |
| 3855 | logger.Errorw(ctx, "Cannot send NetworkDialPlanTable delete", log.Fields{ |
| 3856 | "Err": err, "device-id": oo.deviceID}) |
| 3857 | return nil, err |
| 3858 | } |
| 3859 | logger.Debug(ctx, "send NetworkDialPlanTable-Delete-msg done") |
| 3860 | return meInstance, nil |
| 3861 | } |
| 3862 | logger.Errorw(ctx, "Cannot generate NetworkDialPlanTable Instance for delete", log.Fields{ |
| 3863 | "Err": omciErr.GetError(), "device-id": oo.deviceID}) |
| 3864 | return nil, omciErr.GetError() |
| 3865 | } |
| 3866 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3867 | // SendSyncTime sends SynchronizeTimeRequest |
| 3868 | func (oo *OmciCC) SendSyncTime(ctx context.Context, timeout int, highPrio bool, rxChan chan Message) error { |
| 3869 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3870 | logger.Debugw(ctx, "send synchronize time request:", log.Fields{"device-id": oo.deviceID, |
| 3871 | "SequNo": strconv.FormatInt(int64(tid), 16)}) |
| 3872 | |
| 3873 | omciLayer := &omci.OMCI{ |
| 3874 | TransactionID: tid, |
| 3875 | MessageType: omci.SynchronizeTimeRequestType, |
| 3876 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 3877 | // Length: 0x28, // Optional, defaults to 40 octets |
| 3878 | } |
| 3879 | utcTime := time.Now().UTC() |
| 3880 | request := &omci.SynchronizeTimeRequest{ |
| 3881 | MeBasePacket: omci.MeBasePacket{ |
| 3882 | EntityClass: me.OnuGClassID, |
| 3883 | // Default Instance ID is 0 |
| 3884 | }, |
| 3885 | Year: uint16(utcTime.Year()), |
| 3886 | Month: uint8(utcTime.Month()), |
| 3887 | Day: uint8(utcTime.Day()), |
| 3888 | Hour: uint8(utcTime.Hour()), |
| 3889 | Minute: uint8(utcTime.Minute()), |
| 3890 | Second: uint8(utcTime.Second()), |
| 3891 | } |
| 3892 | |
| 3893 | pkt, err := serializeOmciLayer(ctx, omciLayer, request) |
| 3894 | if err != nil { |
| 3895 | logger.Errorw(ctx, "Cannot serialize synchronize time request", log.Fields{"Err": err, |
| 3896 | "device-id": oo.deviceID}) |
| 3897 | return err |
| 3898 | } |
| 3899 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3900 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3901 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3902 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3903 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3904 | if err != nil { |
| 3905 | logger.Errorw(ctx, "Cannot send synchronize time request", log.Fields{"Err": err, |
| 3906 | "device-id": oo.deviceID}) |
| 3907 | return err |
| 3908 | } |
| 3909 | logger.Debug(ctx, "send synchronize time request done") |
| 3910 | return nil |
| 3911 | } |
| 3912 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3913 | // SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME creates or deletes EthernetFramePerformanceMonitoringHistoryData ME instance |
| 3914 | func (oo *OmciCC) SendCreateOrDeleteEthernetPerformanceMonitoringHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3915 | upstream bool, create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3916 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3917 | logger.Debugw(ctx, "send ethernet-performance-monitoring-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3918 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 3919 | meParam := me.ParamData{EntityID: entityID} |
| 3920 | var meInstance *me.ManagedEntity |
| 3921 | var omciErr me.OmciErrors |
| 3922 | if upstream { |
| 3923 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataUpstream(meParam) |
| 3924 | } else { |
| 3925 | meInstance, omciErr = me.NewEthernetFramePerformanceMonitoringHistoryDataDownstream(meParam) |
| 3926 | } |
| 3927 | if omciErr.GetError() == nil { |
| 3928 | var omciLayer *omci.OMCI |
| 3929 | var msgLayer gopacket.SerializableLayer |
| 3930 | var err error |
| 3931 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3932 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3933 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3934 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3935 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 3936 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3937 | } |
| 3938 | if err != nil { |
| 3939 | logger.Errorw(ctx, "Cannot encode ethernet frame performance monitoring history data ME", |
| 3940 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3941 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3942 | } |
| 3943 | |
| 3944 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3945 | if err != nil { |
| 3946 | logger.Errorw(ctx, "Cannot serialize ethernet frame performance monitoring history data ME", |
| 3947 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3948 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3949 | } |
| 3950 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3951 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 3952 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3953 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3954 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3955 | if err != nil { |
| 3956 | logger.Errorw(ctx, "Cannot send ethernet frame performance monitoring history data ME", |
| 3957 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3958 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3959 | } |
| 3960 | logger.Debugw(ctx, "send ethernet frame performance monitoring history data ME done", |
| 3961 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3962 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3963 | } |
| 3964 | logger.Errorw(ctx, "Cannot generate ethernet frame performance monitoring history data ME Instance", |
| 3965 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3966 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3967 | } |
| 3968 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3969 | // SendCreateOrDeleteEthernetUniHistoryME creates or deletes EthernetPerformanceMonitoringHistoryData ME instance |
| 3970 | func (oo *OmciCC) SendCreateOrDeleteEthernetUniHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3971 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 3972 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3973 | logger.Debugw(ctx, "send ethernet-uni-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 3974 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 3975 | meParam := me.ParamData{EntityID: entityID} |
| 3976 | var meInstance *me.ManagedEntity |
| 3977 | var omciErr me.OmciErrors |
| 3978 | meInstance, omciErr = me.NewEthernetPerformanceMonitoringHistoryData(meParam) |
| 3979 | |
| 3980 | if omciErr.GetError() == nil { |
| 3981 | var omciLayer *omci.OMCI |
| 3982 | var msgLayer gopacket.SerializableLayer |
| 3983 | var err error |
| 3984 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3985 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 3986 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3987 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 3988 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 3989 | oframe.AddDefaults(true)) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3990 | } |
| 3991 | if err != nil { |
| 3992 | logger.Errorw(ctx, "Cannot encode ethernet uni history data ME", |
| 3993 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 3994 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 3995 | } |
| 3996 | |
| 3997 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 3998 | if err != nil { |
| 3999 | logger.Errorw(ctx, "Cannot serialize ethernet uni history data ME", |
| 4000 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4001 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4002 | } |
| 4003 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4004 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4005 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4006 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4007 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4008 | if err != nil { |
| 4009 | logger.Errorw(ctx, "Cannot send ethernet uni history data ME", |
| 4010 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4011 | return nil, err |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4012 | } |
| 4013 | logger.Debugw(ctx, "send ethernet uni history data ME done", |
| 4014 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4015 | return meInstance, nil |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4016 | } |
| 4017 | logger.Errorw(ctx, "Cannot generate ethernet uni history data ME Instance", |
| 4018 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4019 | return nil, omciErr.GetError() |
Girish Gowdra | e0140f0 | 2021-02-02 16:55:09 -0800 | [diff] [blame] | 4020 | } |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4021 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4022 | // SendCreateOrDeleteFecHistoryME creates or deletes FecPerformanceMonitoringHistoryData ME instance |
| 4023 | func (oo *OmciCC) SendCreateOrDeleteFecHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4024 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4025 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4026 | logger.Debugw(ctx, "send fec-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4027 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4028 | meParam := me.ParamData{EntityID: entityID} |
| 4029 | var meInstance *me.ManagedEntity |
| 4030 | var omciErr me.OmciErrors |
| 4031 | meInstance, omciErr = me.NewFecPerformanceMonitoringHistoryData(meParam) |
| 4032 | |
| 4033 | if omciErr.GetError() == nil { |
| 4034 | var omciLayer *omci.OMCI |
| 4035 | var msgLayer gopacket.SerializableLayer |
| 4036 | var err error |
| 4037 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4038 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4039 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4040 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4041 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4042 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4043 | } |
| 4044 | if err != nil { |
| 4045 | logger.Errorw(ctx, "Cannot encode fec history data ME", |
| 4046 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4047 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4048 | } |
| 4049 | |
| 4050 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4051 | if err != nil { |
| 4052 | logger.Errorw(ctx, "Cannot serialize fec history data ME", |
| 4053 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4054 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4055 | } |
| 4056 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4057 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4058 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4059 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4060 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4061 | if err != nil { |
| 4062 | logger.Errorw(ctx, "Cannot send fec history data ME", |
| 4063 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4064 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4065 | } |
| 4066 | logger.Debugw(ctx, "send fec history data ME done", |
| 4067 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4068 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4069 | } |
| 4070 | logger.Errorw(ctx, "Cannot generate fec history data ME Instance", |
| 4071 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4072 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4073 | } |
| 4074 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4075 | // SendCreateOrDeleteGemPortHistoryME deletes GemPortNetworkCtpPerformanceMonitoringHistoryData ME instance |
| 4076 | func (oo *OmciCC) SendCreateOrDeleteGemPortHistoryME(ctx context.Context, timeout int, highPrio bool, |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4077 | create bool, rxChan chan Message, entityID uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4078 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4079 | logger.Debugw(ctx, "send gemport-history-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4080 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create}) |
| 4081 | meParam := me.ParamData{EntityID: entityID} |
| 4082 | var meInstance *me.ManagedEntity |
| 4083 | var omciErr me.OmciErrors |
| 4084 | meInstance, omciErr = me.NewGemPortNetworkCtpPerformanceMonitoringHistoryData(meParam) |
| 4085 | |
| 4086 | if omciErr.GetError() == nil { |
| 4087 | var omciLayer *omci.OMCI |
| 4088 | var msgLayer gopacket.SerializableLayer |
| 4089 | var err error |
| 4090 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4091 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4092 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4093 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4094 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4095 | oframe.AddDefaults(true)) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4096 | } |
| 4097 | if err != nil { |
| 4098 | logger.Errorw(ctx, "Cannot encode gemport history data ME", |
| 4099 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4100 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4101 | } |
| 4102 | |
| 4103 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4104 | if err != nil { |
| 4105 | logger.Errorw(ctx, "Cannot serialize gemport history data ME", |
| 4106 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4107 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4108 | } |
| 4109 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4110 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4111 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4112 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4113 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4114 | if err != nil { |
| 4115 | logger.Errorw(ctx, "Cannot send gemport history data ME", |
| 4116 | log.Fields{"Err": err, "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4117 | return nil, err |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4118 | } |
| 4119 | logger.Debugw(ctx, "send gemport history data ME done", |
| 4120 | log.Fields{"device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4121 | return meInstance, nil |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4122 | } |
| 4123 | logger.Errorw(ctx, "Cannot generate gemport history data ME Instance", |
| 4124 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "create": create, "InstId": strconv.FormatInt(int64(entityID), 16)}) |
ozgecanetsia | b36ed57 | 2021-04-01 10:38:48 +0300 | [diff] [blame] | 4125 | return nil, omciErr.GetError() |
Girish Gowdra | 5c5aaf4 | 2021-02-17 19:40:50 -0800 | [diff] [blame] | 4126 | } |
| 4127 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4128 | // SendStartSoftwareDownload sends StartSoftwareDownloadRequest |
| 4129 | func (oo *OmciCC) SendStartSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4130 | rxChan chan Message, aImageMeID uint16, aDownloadWindowSize uint8, aFileLen uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4131 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4132 | logger.Debugw(ctx, "send StartSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4133 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4134 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4135 | |
| 4136 | omciLayer := &omci.OMCI{ |
| 4137 | TransactionID: tid, |
| 4138 | MessageType: omci.StartSoftwareDownloadRequestType, |
| 4139 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4140 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4141 | } |
| 4142 | request := &omci.StartSoftwareDownloadRequest{ |
| 4143 | MeBasePacket: omci.MeBasePacket{ |
| 4144 | EntityClass: me.SoftwareImageClassID, |
| 4145 | EntityInstance: aImageMeID, //inactive image |
| 4146 | }, |
| 4147 | WindowSize: aDownloadWindowSize, |
| 4148 | ImageSize: aFileLen, |
| 4149 | NumberOfCircuitPacks: 1, //parallel download to multiple circuit packs not supported |
| 4150 | CircuitPacks: []uint16{0}, //circuit pack indication don't care for NumberOfCircuitPacks=1, but needed by omci-lib |
| 4151 | } |
| 4152 | |
| 4153 | var options gopacket.SerializeOptions |
| 4154 | options.FixLengths = true |
| 4155 | buffer := gopacket.NewSerializeBuffer() |
| 4156 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4157 | if err != nil { |
| 4158 | logger.Errorw(ctx, "Cannot serialize StartSwDlRequest", log.Fields{"Err": err, |
| 4159 | "device-id": oo.deviceID}) |
| 4160 | return err |
| 4161 | } |
| 4162 | outgoingPacket := buffer.Bytes() |
| 4163 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4164 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4165 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4166 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4167 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4168 | if err != nil { |
| 4169 | logger.Errorw(ctx, "Cannot send StartSwDlRequest", log.Fields{"Err": err, |
| 4170 | "device-id": oo.deviceID}) |
| 4171 | return err |
| 4172 | } |
| 4173 | logger.Debug(ctx, "send StartSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4174 | return nil |
| 4175 | } |
| 4176 | |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4177 | // PrepareOnuSectionsOfWindow prepares a list of sections for each window |
| 4178 | //Before invoking this function the oo.mutexTid needs to be be locked so that |
| 4179 | //GetOnuSwSecNextTid can be invoked without further locking |
| 4180 | func (oo *OmciCC) PrepareOnuSectionsOfWindow(ctx context.Context, |
| 4181 | aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, |
| 4182 | omciMsgsPerWindow *ia.OmciMessages) (OmciTransferStructure, error) { |
| 4183 | //onuswsections uses only low prioirity tids |
| 4184 | tid := oo.GetOnuSwSecNextTid() |
| 4185 | logger.Infow(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4186 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4187 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest, "sectionNo": aDownloadSectionNo, "sectionData": aSection}) |
| 4188 | |
| 4189 | var omciTxReq OmciTransferStructure |
| 4190 | msgType := omci.DownloadSectionRequestType |
| 4191 | |
| 4192 | if aAckRequest > 0 { |
| 4193 | msgType = omci.DownloadSectionRequestWithResponseType |
| 4194 | |
| 4195 | } |
| 4196 | omciLayer := &omci.OMCI{ |
| 4197 | TransactionID: tid, |
| 4198 | MessageType: msgType, |
| 4199 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4200 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4201 | } |
| 4202 | localSectionData := make([]byte, len(aSection)) |
| 4203 | |
| 4204 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
| 4205 | request := &omci.DownloadSectionRequest{ |
| 4206 | MeBasePacket: omci.MeBasePacket{ |
| 4207 | EntityClass: me.SoftwareImageClassID, |
| 4208 | EntityInstance: aImageMeID, //inactive image |
| 4209 | }, |
| 4210 | SectionNumber: aDownloadSectionNo, |
| 4211 | SectionData: localSectionData, |
| 4212 | } |
| 4213 | |
| 4214 | var options gopacket.SerializeOptions |
| 4215 | options.FixLengths = true |
| 4216 | buffer := gopacket.NewSerializeBuffer() |
| 4217 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4218 | if err != nil { |
| 4219 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4220 | "device-id": oo.deviceID}) |
| 4221 | return omciTxReq, err |
| 4222 | } |
| 4223 | outgoingPacket := buffer.Bytes() |
| 4224 | |
| 4225 | omciMsgsPerWindow.Messages = append(omciMsgsPerWindow.Messages, outgoingPacket) |
| 4226 | |
| 4227 | if aAckRequest > 0 { |
| 4228 | // only the last section should have a timeout as an ack is required only for the last section of the window |
| 4229 | omciTxReq = OmciTransferStructure{ |
| 4230 | withFramePrint: true, |
| 4231 | OnuSwWindow: omciMsgsPerWindow, |
| 4232 | } |
| 4233 | return omciTxReq, nil |
| 4234 | } |
| 4235 | |
| 4236 | return omciTxReq, nil |
| 4237 | } |
| 4238 | |
| 4239 | //SendOnuSwSectionsWindowWithRxSupervision sends onu swd sections |
| 4240 | func (oo *OmciCC) SendOnuSwSectionsWindowWithRxSupervision(ctx context.Context, |
| 4241 | aOmciTxRequest OmciTransferStructure, aTimeout int, rxChan chan Message) { |
| 4242 | if aOmciTxRequest.OnuSwWindow == nil { |
| 4243 | logger.Errorw(ctx, "SendOnuSwSectionsWindowWithRxSupervision: omciTxRequest.OnuSwWindow is nil", |
| 4244 | log.Fields{"device-id": oo.deviceID}) |
| 4245 | return |
| 4246 | |
| 4247 | } |
| 4248 | |
| 4249 | tid := oo.GetOnuSwSecLastTid() |
| 4250 | logger.Debugw(ctx, "SendOnuSwSectionsWindowWithRxSupervision tid for the last segment is ", log.Fields{"TID": tid}) |
| 4251 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4252 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4253 | } |
| 4254 | |
| 4255 | aOmciTxRequest.cbPair = omciRxCallbackPair |
| 4256 | logger.Debugw(ctx, "register-response-callback:", log.Fields{"for TansCorrId": aOmciTxRequest.cbPair.CbKey}) |
| 4257 | oo.mutexRxSchedMap.Lock() |
| 4258 | // it could be checked, if the callback key is already registered - but simply overwrite may be acceptable ... |
| 4259 | oo.rxSchedulerMap[aOmciTxRequest.cbPair.CbKey] = aOmciTxRequest.cbPair.CbEntry |
| 4260 | oo.mutexRxSchedMap.Unlock() |
| 4261 | |
| 4262 | chSuccess := make(chan bool) |
| 4263 | aOmciTxRequest.chSuccess = chSuccess |
| 4264 | aOmciTxRequest.timeout = aTimeout |
| 4265 | aOmciTxRequest.retries = CDefaultRetries |
| 4266 | |
| 4267 | //tid := aOmciTxRequest.cbPair.CbKey |
| 4268 | oo.mutexMonReq.Lock() |
| 4269 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4270 | oo.mutexMonReq.Unlock() |
| 4271 | |
| 4272 | retries := aOmciTxRequest.retries |
| 4273 | retryCounter := 0 |
| 4274 | if aTimeout == 0 { |
| 4275 | logger.Errorw(ctx, "no timeout present for last section of window", log.Fields{"device-id": oo.deviceID}) |
| 4276 | return |
| 4277 | } |
| 4278 | loop: |
| 4279 | for retryCounter <= retries { |
| 4280 | // the onu sw sections are enqueued only to the low priority queue |
| 4281 | oo.mutexLowPrioTxQueue.Lock() |
| 4282 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4283 | oo.mutexLowPrioTxQueue.Unlock() |
| 4284 | |
| 4285 | go oo.sendQueuedRequests(ctx) |
| 4286 | |
| 4287 | select { |
| 4288 | case success := <-chSuccess: |
| 4289 | if success { |
| 4290 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4291 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4292 | } else { |
| 4293 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4294 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4295 | } |
| 4296 | break loop |
| 4297 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4298 | if retryCounter == retries { |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4299 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4300 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4301 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureSwUpgrade, OnuOmciCommunicationFailureSwUpgradeDesc) |
kesavand | 011d516 | 2021-11-25 19:21:06 +0530 | [diff] [blame] | 4302 | break loop |
| 4303 | } else { |
| 4304 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4305 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4306 | } |
| 4307 | } |
| 4308 | retryCounter++ |
| 4309 | } |
| 4310 | oo.mutexMonReq.Lock() |
| 4311 | delete(oo.monitoredRequests, tid) |
| 4312 | oo.mutexMonReq.Unlock() |
| 4313 | } |
| 4314 | |
| 4315 | func (oo *OmciCC) sendOnuSwSectionsOfWindow(ctx context.Context, omciTxRequest OmciTransferStructure) error { |
| 4316 | if omciTxRequest.withFramePrint && omciTxRequest.OnuSwWindow != nil { |
| 4317 | lastSection := omciTxRequest.OnuSwWindow.Messages[len(omciTxRequest.OnuSwWindow.Messages)-1] |
| 4318 | logger.Debugw(ctx, "omci-message-to-send:", log.Fields{ |
| 4319 | "TxOmciMessage": hex.EncodeToString(lastSection), |
| 4320 | "device-id": oo.deviceID, |
| 4321 | "toDeviceType": oo.pBaseDeviceHandler.GetProxyAddressType(), |
| 4322 | "proxyDeviceID": oo.pBaseDeviceHandler.GetProxyAddressID(), |
| 4323 | "proxyAddress": oo.pBaseDeviceHandler.GetProxyAddress()}) |
| 4324 | } |
| 4325 | sendErr := oo.pBaseDeviceHandler.SendOnuSwSectionsOfWindow(ctx, oo.pBaseDeviceHandler.GetProxyAddress().AdapterEndpoint, omciTxRequest.OnuSwWindow) |
| 4326 | if sendErr != nil { |
| 4327 | logger.Errorw(ctx, "send onu sw sections omci request error", log.Fields{"ChildId": oo.deviceID, "error": sendErr}) |
| 4328 | return sendErr |
| 4329 | } |
| 4330 | return nil |
| 4331 | } |
| 4332 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4333 | // SendDownloadSection sends DownloadSectionRequestWithResponse |
| 4334 | func (oo *OmciCC) SendDownloadSection(ctx context.Context, aTimeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4335 | rxChan chan Message, aImageMeID uint16, aAckRequest uint8, aDownloadSectionNo uint8, aSection []byte, aPrint bool) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4336 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4337 | logger.Debugw(ctx, "send DlSectionRequest:", log.Fields{"device-id": oo.deviceID, |
| 4338 | "SequNo": strconv.FormatInt(int64(tid), 16), |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4339 | "InstId": strconv.FormatInt(int64(aImageMeID), 16), "omci-ack": aAckRequest}) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4340 | |
| 4341 | //TODO!!!: don't know by now on how to generate the possibly needed AR (or enforce it to 0) with current omci-lib |
| 4342 | // by now just try to send it as defined by omci-lib |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4343 | msgType := omci.DownloadSectionRequestType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4344 | var timeout int = 0 //default value for no response expected |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4345 | if aAckRequest > 0 { |
| 4346 | msgType = omci.DownloadSectionRequestWithResponseType |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4347 | timeout = aTimeout |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4348 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4349 | omciLayer := &omci.OMCI{ |
| 4350 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4351 | MessageType: msgType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4352 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4353 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4354 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4355 | localSectionData := make([]byte, len(aSection)) |
| 4356 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4357 | copy(localSectionData[:], aSection) // as long as DownloadSectionRequest defines array for SectionData we need to copy into the array |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4358 | request := &omci.DownloadSectionRequest{ |
| 4359 | MeBasePacket: omci.MeBasePacket{ |
| 4360 | EntityClass: me.SoftwareImageClassID, |
| 4361 | EntityInstance: aImageMeID, //inactive image |
| 4362 | }, |
| 4363 | SectionNumber: aDownloadSectionNo, |
| 4364 | SectionData: localSectionData, |
| 4365 | } |
| 4366 | |
| 4367 | var options gopacket.SerializeOptions |
| 4368 | options.FixLengths = true |
| 4369 | buffer := gopacket.NewSerializeBuffer() |
| 4370 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4371 | if err != nil { |
| 4372 | logger.Errorw(ctx, "Cannot serialize DlSectionRequest", log.Fields{"Err": err, |
| 4373 | "device-id": oo.deviceID}) |
| 4374 | return err |
| 4375 | } |
| 4376 | outgoingPacket := buffer.Bytes() |
| 4377 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4378 | //for initial debug purpose overrule the requested print state for some frames |
| 4379 | printFrame := aPrint |
| 4380 | if aAckRequest > 0 || aDownloadSectionNo == 0 { |
| 4381 | printFrame = true |
| 4382 | } |
| 4383 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4384 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4385 | // the callback is set even though no response might be required here, the tid (key) setting is needed here anyway |
| 4386 | // (used to avoid retransmission of frames with the same TID) |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4387 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, printFrame /*aPrint*/}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4388 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4389 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4390 | if err != nil { |
| 4391 | logger.Errorw(ctx, "Cannot send DlSectionRequest", log.Fields{"Err": err, |
| 4392 | "device-id": oo.deviceID}) |
| 4393 | return err |
| 4394 | } |
| 4395 | logger.Debug(ctx, "send DlSectionRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4396 | return nil |
| 4397 | } |
| 4398 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4399 | //SendEndSoftwareDownload sends EndSoftwareDownloadRequest |
| 4400 | func (oo *OmciCC) SendEndSoftwareDownload(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4401 | rxChan chan Message, aImageMeID uint16, aFileLen uint32, aImageCrc uint32) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4402 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4403 | logger.Debugw(ctx, "send EndSwDlRequest:", log.Fields{"device-id": oo.deviceID, |
| 4404 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4405 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4406 | |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4407 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4408 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4409 | MessageType: omci.EndSoftwareDownloadRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4410 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4411 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4412 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4413 | request := &omci.EndSoftwareDownloadRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4414 | MeBasePacket: omci.MeBasePacket{ |
| 4415 | EntityClass: me.SoftwareImageClassID, |
| 4416 | EntityInstance: aImageMeID, //inactive image |
| 4417 | }, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4418 | CRC32: aImageCrc, |
| 4419 | ImageSize: aFileLen, |
| 4420 | NumberOfInstances: 1, //parallel download to multiple circuit packs not supported |
| 4421 | ImageInstances: []uint16{0}, //don't care for NumberOfInstances=1, but probably needed by omci-lib as in startSwDlRequest |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4422 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4423 | |
| 4424 | var options gopacket.SerializeOptions |
| 4425 | options.FixLengths = true |
| 4426 | buffer := gopacket.NewSerializeBuffer() |
| 4427 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4428 | if err != nil { |
| 4429 | logger.Errorw(ctx, "Cannot serialize EndSwDlRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4430 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4431 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4432 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4433 | outgoingPacket := buffer.Bytes() |
| 4434 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4435 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4436 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4437 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4438 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4439 | if err != nil { |
| 4440 | logger.Errorw(ctx, "Cannot send EndSwDlRequest", log.Fields{"Err": err, |
| 4441 | "device-id": oo.deviceID}) |
| 4442 | return err |
| 4443 | } |
| 4444 | logger.Debug(ctx, "send EndSwDlRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4445 | return nil |
| 4446 | } |
| 4447 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4448 | // SendActivateSoftware sends ActivateSoftwareRequest |
| 4449 | func (oo *OmciCC) SendActivateSoftware(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4450 | rxChan chan Message, aImageMeID uint16) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4451 | tid := oo.GetNextTid(highPrio) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4452 | logger.Debugw(ctx, "send ActivateSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4453 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4454 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4455 | |
| 4456 | omciLayer := &omci.OMCI{ |
| 4457 | TransactionID: tid, |
| 4458 | MessageType: omci.ActivateSoftwareRequestType, |
| 4459 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4460 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4461 | } |
| 4462 | request := &omci.ActivateSoftwareRequest{ |
| 4463 | MeBasePacket: omci.MeBasePacket{ |
| 4464 | EntityClass: me.SoftwareImageClassID, |
| 4465 | EntityInstance: aImageMeID, //inactive image |
| 4466 | }, |
| 4467 | ActivateFlags: 0, //unconditionally reset as the only relevant option here (regardless of VOIP) |
| 4468 | } |
| 4469 | |
| 4470 | var options gopacket.SerializeOptions |
| 4471 | options.FixLengths = true |
| 4472 | buffer := gopacket.NewSerializeBuffer() |
| 4473 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4474 | if err != nil { |
| 4475 | logger.Errorw(ctx, "Cannot serialize ActivateSwRequest", log.Fields{"Err": err, |
| 4476 | "device-id": oo.deviceID}) |
| 4477 | return err |
| 4478 | } |
| 4479 | outgoingPacket := buffer.Bytes() |
| 4480 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4481 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4482 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4483 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4484 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4485 | if err != nil { |
| 4486 | logger.Errorw(ctx, "Cannot send ActivateSwRequest", log.Fields{"Err": err, |
| 4487 | "device-id": oo.deviceID}) |
| 4488 | return err |
| 4489 | } |
| 4490 | logger.Debug(ctx, "send ActivateSwRequest done") |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4491 | return nil |
| 4492 | } |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4493 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4494 | // SendCommitSoftware sends CommitSoftwareRequest |
| 4495 | func (oo *OmciCC) SendCommitSoftware(ctx context.Context, timeout int, highPrio bool, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4496 | rxChan chan Message, aImageMeID uint16) error { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4497 | tid := oo.GetNextTid(highPrio) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4498 | logger.Debugw(ctx, "send CommitSwRequest:", log.Fields{"device-id": oo.deviceID, |
| 4499 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4500 | "InstId": strconv.FormatInt(int64(aImageMeID), 16)}) |
| 4501 | |
| 4502 | omciLayer := &omci.OMCI{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4503 | TransactionID: tid, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4504 | MessageType: omci.CommitSoftwareRequestType, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4505 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4506 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4507 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4508 | request := &omci.CommitSoftwareRequest{ |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4509 | MeBasePacket: omci.MeBasePacket{ |
| 4510 | EntityClass: me.SoftwareImageClassID, |
| 4511 | EntityInstance: aImageMeID, //inactive image |
| 4512 | }, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4513 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4514 | |
| 4515 | var options gopacket.SerializeOptions |
| 4516 | options.FixLengths = true |
| 4517 | buffer := gopacket.NewSerializeBuffer() |
| 4518 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4519 | if err != nil { |
| 4520 | logger.Errorw(ctx, "Cannot serialize CommitSwRequest", log.Fields{"Err": err, |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4521 | "device-id": oo.deviceID}) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4522 | return err |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4523 | } |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4524 | outgoingPacket := buffer.Bytes() |
| 4525 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4526 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4527 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4528 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4529 | err = oo.Send(ctx, outgoingPacket, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
mpagenko | 15ff4a5 | 2021-03-02 10:09:20 +0000 | [diff] [blame] | 4530 | if err != nil { |
| 4531 | logger.Errorw(ctx, "Cannot send CommitSwRequest", log.Fields{"Err": err, |
| 4532 | "device-id": oo.deviceID}) |
| 4533 | return err |
| 4534 | } |
| 4535 | logger.Debug(ctx, "send CommitSwRequest done") |
mpagenko | 80622a5 | 2021-02-09 16:53:23 +0000 | [diff] [blame] | 4536 | return nil |
| 4537 | } |
| 4538 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4539 | //SendSelfTestReq sends TestRequest |
| 4540 | func (oo *OmciCC) SendSelfTestReq(ctx context.Context, classID me.ClassID, instdID uint16, timeout int, highPrio bool, rxChan chan Message) error { |
| 4541 | tid := oo.GetNextTid(highPrio) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4542 | logger.Debugw(ctx, "send self test request:", log.Fields{"device-id": oo.deviceID, |
| 4543 | "SequNo": strconv.FormatInt(int64(tid), 16), |
| 4544 | "InstId": strconv.FormatInt(int64(instdID), 16)}) |
| 4545 | omciLayer := &omci.OMCI{ |
| 4546 | TransactionID: tid, |
| 4547 | MessageType: omci.TestRequestType, |
| 4548 | // DeviceIdentifier: omci.BaselineIdent, // Optional, defaults to Baseline |
| 4549 | // Length: 0x28, // Optional, defaults to 40 octets |
| 4550 | } |
| 4551 | |
| 4552 | var request *omci.OpticalLineSupervisionTestRequest |
| 4553 | switch classID { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4554 | case me.AniGClassID: |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4555 | request = &omci.OpticalLineSupervisionTestRequest{ |
| 4556 | MeBasePacket: omci.MeBasePacket{ |
| 4557 | EntityClass: classID, |
| 4558 | EntityInstance: instdID, |
| 4559 | }, |
| 4560 | SelectTest: uint8(7), // self test |
| 4561 | GeneralPurposeBuffer: uint16(0), |
| 4562 | VendorSpecificParameters: uint16(0), |
| 4563 | } |
| 4564 | default: |
| 4565 | logger.Errorw(ctx, "unsupported class id for self test request", log.Fields{"device-id": oo.deviceID, "classID": classID}) |
| 4566 | return fmt.Errorf("unsupported-class-id-for-self-test-request-%v", classID) |
| 4567 | } |
| 4568 | // Test serialization back to former string |
| 4569 | var options gopacket.SerializeOptions |
| 4570 | options.FixLengths = true |
| 4571 | |
| 4572 | buffer := gopacket.NewSerializeBuffer() |
| 4573 | err := gopacket.SerializeLayers(buffer, options, omciLayer, request) |
| 4574 | if err != nil { |
| 4575 | logger.Errorw(ctx, "Cannot serialize self test request", log.Fields{"Err": err, |
| 4576 | "device-id": oo.deviceID}) |
| 4577 | return err |
| 4578 | } |
| 4579 | outgoingPacket := buffer.Bytes() |
| 4580 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4581 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4582 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4583 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4584 | err = oo.Send(ctx, outgoingPacket, timeout, 0, highPrio, omciRxCallbackPair) |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4585 | if err != nil { |
| 4586 | logger.Errorw(ctx, "Cannot send self test request", log.Fields{"Err": err, |
| 4587 | "device-id": oo.deviceID}) |
| 4588 | return err |
| 4589 | } |
| 4590 | logger.Debug(ctx, "send self test request done") |
| 4591 | return nil |
| 4592 | } |
| 4593 | |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4594 | //nolint: gocyclo |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4595 | func isSuccessfulResponseWithMibDataSync(omciMsg *omci.OMCI, packet *gp.Packet) bool { |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4596 | for _, v := range responsesWithMibDataSync { |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4597 | if v == omciMsg.MessageType { |
Girish Gowdra | 6afb56a | 2021-04-27 17:47:57 -0700 | [diff] [blame] | 4598 | nextLayer, _ := omci.MsgTypeToNextLayer(v, false) |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4599 | msgLayer := (*packet).Layer(nextLayer) |
| 4600 | switch nextLayer { |
| 4601 | case omci.LayerTypeCreateResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4602 | if resp := msgLayer.(*omci.CreateResponse); resp != nil { |
| 4603 | if resp.Result == me.Success { |
| 4604 | return true |
| 4605 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4606 | } |
| 4607 | case omci.LayerTypeDeleteResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4608 | if resp := msgLayer.(*omci.DeleteResponse); resp != nil { |
| 4609 | if resp.Result == me.Success { |
| 4610 | return true |
| 4611 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4612 | } |
| 4613 | case omci.LayerTypeSetResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4614 | if resp := msgLayer.(*omci.SetResponse); resp != nil { |
| 4615 | if resp.Result == me.Success { |
| 4616 | return true |
| 4617 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4618 | } |
| 4619 | case omci.LayerTypeStartSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4620 | if resp := msgLayer.(*omci.StartSoftwareDownloadResponse); resp != nil { |
| 4621 | if resp.Result == me.Success { |
| 4622 | return true |
| 4623 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4624 | } |
| 4625 | case omci.LayerTypeEndSoftwareDownloadResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4626 | if resp := msgLayer.(*omci.EndSoftwareDownloadResponse); resp != nil { |
| 4627 | if resp.Result == me.Success { |
| 4628 | return true |
| 4629 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4630 | } |
| 4631 | case omci.LayerTypeActivateSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4632 | if resp := msgLayer.(*omci.ActivateSoftwareResponse); resp != nil { |
| 4633 | if resp.Result == me.Success { |
| 4634 | return true |
| 4635 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4636 | } |
| 4637 | case omci.LayerTypeCommitSoftwareResponse: |
Holger Hildebrandt | 8680ca3 | 2021-05-19 10:30:53 +0000 | [diff] [blame] | 4638 | if resp := msgLayer.(*omci.CommitSoftwareResponse); resp != nil { |
| 4639 | if resp.Result == me.Success { |
| 4640 | return true |
| 4641 | } |
Holger Hildebrandt | 3124e30 | 2021-03-23 12:47:03 +0000 | [diff] [blame] | 4642 | } |
| 4643 | } |
Holger Hildebrandt | 0bd45f8 | 2021-01-11 13:29:37 +0000 | [diff] [blame] | 4644 | } |
| 4645 | } |
| 4646 | return false |
| 4647 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4648 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4649 | func (oo *OmciCC) processRequestMonitoring(ctx context.Context, aOmciTxRequest OmciTransferStructure) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4650 | timeout := aOmciTxRequest.timeout |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4651 | if timeout == 0 { |
| 4652 | //timeout 0 indicates that no response is expected - fire and forget |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4653 | // enqueue |
| 4654 | if aOmciTxRequest.highPrio { |
| 4655 | oo.mutexHighPrioTxQueue.Lock() |
| 4656 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4657 | oo.mutexHighPrioTxQueue.Unlock() |
| 4658 | } else { |
| 4659 | oo.mutexLowPrioTxQueue.Lock() |
| 4660 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4661 | oo.mutexLowPrioTxQueue.Unlock() |
| 4662 | } |
| 4663 | go oo.sendQueuedRequests(ctx) |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 4664 | } else { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4665 | //the supervised sending with waiting on the response (based on TID) is called in background |
| 4666 | // to avoid blocking of the sender for the complete OMCI handshake procedure |
| 4667 | // to stay consistent with the processing tested so far, sending of next messages of the same control procedure |
| 4668 | // is ensured by the according control instances (FSM's etc.) (by waiting for the respective responses there) |
| 4669 | go oo.sendWithRxSupervision(ctx, aOmciTxRequest, timeout) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4670 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4671 | } |
| 4672 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4673 | func (oo *OmciCC) sendWithRxSupervision(ctx context.Context, aOmciTxRequest OmciTransferStructure, aTimeout int) { |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4674 | chSuccess := make(chan bool) |
| 4675 | aOmciTxRequest.chSuccess = chSuccess |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4676 | tid := aOmciTxRequest.cbPair.CbKey |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4677 | oo.mutexMonReq.Lock() |
| 4678 | oo.monitoredRequests[tid] = aOmciTxRequest |
| 4679 | oo.mutexMonReq.Unlock() |
| 4680 | |
| 4681 | retries := aOmciTxRequest.retries |
| 4682 | retryCounter := 0 |
| 4683 | loop: |
| 4684 | for retryCounter <= retries { |
Holger Hildebrandt | 3455551 | 2021-10-01 16:26:59 +0000 | [diff] [blame] | 4685 | // enqueue |
| 4686 | if aOmciTxRequest.highPrio { |
| 4687 | oo.mutexHighPrioTxQueue.Lock() |
| 4688 | oo.highPrioTxQueue.PushBack(aOmciTxRequest) |
| 4689 | oo.mutexHighPrioTxQueue.Unlock() |
| 4690 | } else { |
| 4691 | oo.mutexLowPrioTxQueue.Lock() |
| 4692 | oo.lowPrioTxQueue.PushBack(aOmciTxRequest) |
| 4693 | oo.mutexLowPrioTxQueue.Unlock() |
| 4694 | } |
| 4695 | go oo.sendQueuedRequests(ctx) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4696 | |
| 4697 | select { |
| 4698 | case success := <-chSuccess: |
| 4699 | if success { |
| 4700 | logger.Debugw(ctx, "reqMon: response received in time", |
| 4701 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4702 | } else { |
| 4703 | logger.Debugw(ctx, "reqMon: wait for response aborted", |
| 4704 | log.Fields{"tid": tid, "device-id": oo.deviceID}) |
| 4705 | } |
| 4706 | break loop |
| 4707 | case <-time.After(time.Duration(aTimeout) * time.Second): |
| 4708 | if retryCounter == retries { |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4709 | logger.Errorw(ctx, "reqMon: timeout waiting for response - no of max retries reached - send ONU device event!", |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4710 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
Holger Hildebrandt | c56febd | 2022-02-09 13:23:30 +0000 | [diff] [blame] | 4711 | oo.pOnuDeviceEntry.SendOnuDeviceEvent(ctx, OnuOmciCommunicationFailureConfig, OnuOmciCommunicationFailureConfigDesc) |
mpagenko | 7455fd4 | 2021-06-10 16:25:55 +0000 | [diff] [blame] | 4712 | break loop |
| 4713 | } else { |
| 4714 | logger.Infow(ctx, "reqMon: timeout waiting for response - retry", |
| 4715 | log.Fields{"tid": tid, "retries": retryCounter, "device-id": oo.deviceID}) |
| 4716 | } |
| 4717 | } |
| 4718 | retryCounter++ |
| 4719 | } |
| 4720 | oo.mutexMonReq.Lock() |
| 4721 | delete(oo.monitoredRequests, tid) |
| 4722 | oo.mutexMonReq.Unlock() |
| 4723 | } |
| 4724 | |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4725 | //CancelRequestMonitoring terminates monitoring of outstanding omci requests |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4726 | func (oo *OmciCC) CancelRequestMonitoring(ctx context.Context) { |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4727 | oo.mutexMonReq.RLock() |
| 4728 | for k := range oo.monitoredRequests { |
mpagenko | 8cd1bf7 | 2021-06-22 10:11:19 +0000 | [diff] [blame] | 4729 | //implement non-blocking channel send to avoid blocking on mutexMonReq later |
| 4730 | select { |
| 4731 | case oo.monitoredRequests[k].chSuccess <- false: |
| 4732 | default: |
| 4733 | logger.Debugw(ctx, "cancel not send on omciRespChannel (no receiver)", log.Fields{ |
| 4734 | "index": k, "device-id": oo.deviceID}) |
| 4735 | } |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4736 | } |
| 4737 | oo.mutexMonReq.RUnlock() |
| 4738 | } |
| 4739 | |
| 4740 | //GetMaxOmciTimeoutWithRetries provides a timeout value greater than the maximum |
| 4741 | //time consumed for retry processing of a particular OMCI-request |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4742 | func (oo *OmciCC) GetMaxOmciTimeoutWithRetries() time.Duration { |
| 4743 | return time.Duration((CDefaultRetries+1)*oo.pBaseDeviceHandler.GetOmciTimeout() + 1) |
Holger Hildebrandt | 366ef19 | 2021-05-05 11:07:44 +0000 | [diff] [blame] | 4744 | } |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4745 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4746 | // SendCreateOrDeleteEthernetFrameExtendedPMME deletes EthernetFrameExtendedPm ME instance |
| 4747 | func (oo *OmciCC) SendCreateOrDeleteEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4748 | upstream bool, create bool, rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4749 | tid := oo.GetNextTid(highPrio) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4750 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-msg:", log.Fields{"device-id": oo.deviceID, |
| 4751 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16), "create": create, "upstream": upstream}) |
| 4752 | |
| 4753 | meParam := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 4754 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4755 | } |
| 4756 | var meInstance *me.ManagedEntity |
| 4757 | var omciErr me.OmciErrors |
| 4758 | if classID == me.EthernetFrameExtendedPmClassID { |
| 4759 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParam) |
| 4760 | } else { |
| 4761 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParam) |
| 4762 | } |
| 4763 | |
| 4764 | if omciErr.GetError() == nil { |
| 4765 | var omciLayer *omci.OMCI |
| 4766 | var msgLayer gopacket.SerializableLayer |
| 4767 | var err error |
| 4768 | if create { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4769 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.CreateRequestType, oframe.TransactionID(tid), |
| 4770 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4771 | } else { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4772 | omciLayer, msgLayer, err = oframe.EncodeFrame(meInstance, omci.DeleteRequestType, oframe.TransactionID(tid), |
| 4773 | oframe.AddDefaults(true)) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4774 | } |
| 4775 | if err != nil { |
| 4776 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 4777 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4778 | return nil, err |
| 4779 | } |
| 4780 | |
| 4781 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4782 | if err != nil { |
| 4783 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me", |
| 4784 | log.Fields{"err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4785 | return nil, err |
| 4786 | } |
| 4787 | |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4788 | omciRxCallbackPair := CallbackPair{CbKey: tid, |
| 4789 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4790 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4791 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
Himani Chawla | 43f95ff | 2021-06-03 00:24:12 +0530 | [diff] [blame] | 4792 | if err != nil { |
| 4793 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 4794 | log.Fields{"Err": err, "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4795 | return nil, err |
| 4796 | } |
| 4797 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-done", |
| 4798 | log.Fields{"device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4799 | return meInstance, nil |
| 4800 | } |
| 4801 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 4802 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "upstream": upstream, "create": create, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4803 | return nil, omciErr.GetError() |
| 4804 | } |
Holger Hildebrandt | 4b5e73f | 2021-08-19 06:51:21 +0000 | [diff] [blame] | 4805 | |
| 4806 | // RLockMutexMonReq lock read access to monitoredRequests |
| 4807 | func (oo *OmciCC) RLockMutexMonReq() { |
| 4808 | oo.mutexMonReq.RLock() |
| 4809 | } |
| 4810 | |
| 4811 | // RUnlockMutexMonReq unlock read access to monitoredRequests |
| 4812 | func (oo *OmciCC) RUnlockMutexMonReq() { |
| 4813 | oo.mutexMonReq.RUnlock() |
| 4814 | } |
| 4815 | |
| 4816 | // GetMonitoredRequest get OmciTransferStructure for an omciTransID |
| 4817 | func (oo *OmciCC) GetMonitoredRequest(omciTransID uint16) (value OmciTransferStructure, exist bool) { |
| 4818 | value, exist = oo.monitoredRequests[omciTransID] |
| 4819 | return value, exist |
| 4820 | } |
| 4821 | |
| 4822 | // SetChMonitoredRequest sets chSuccess to indicate whether response was received or not |
| 4823 | func (oo *OmciCC) SetChMonitoredRequest(omciTransID uint16, chVal bool) { |
| 4824 | oo.monitoredRequests[omciTransID].chSuccess <- chVal |
| 4825 | } |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4826 | |
| 4827 | // SendSetEthernetFrameExtendedPMME sends the set request for ethernet frame extended type me |
| 4828 | func (oo *OmciCC) SendSetEthernetFrameExtendedPMME(ctx context.Context, timeout int, highPrio bool, |
| 4829 | rxChan chan Message, entityID uint16, classID me.ClassID, controlBlock []uint16) (*me.ManagedEntity, error) { |
| 4830 | tid := oo.GetNextTid(highPrio) |
| 4831 | logger.Debugw(ctx, "send-set-ethernet-frame-extended-pm-me-control-block:", log.Fields{"device-id": oo.deviceID, |
| 4832 | "SequNo": strconv.FormatInt(int64(tid), 16), "InstId": strconv.FormatInt(int64(entityID), 16)}) |
| 4833 | |
| 4834 | meParams := me.ParamData{EntityID: entityID, |
Holger Hildebrandt | 3ac49bd | 2022-02-07 17:46:43 +0000 | [diff] [blame] | 4835 | Attributes: me.AttributeValueMap{me.EthernetFrameExtendedPm_ControlBlock: controlBlock}, |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4836 | } |
| 4837 | var meInstance *me.ManagedEntity |
| 4838 | var omciErr me.OmciErrors |
| 4839 | if classID == me.EthernetFrameExtendedPmClassID { |
| 4840 | meInstance, omciErr = me.NewEthernetFrameExtendedPm(meParams) |
| 4841 | } else { |
| 4842 | meInstance, omciErr = me.NewEthernetFrameExtendedPm64Bit(meParams) |
| 4843 | } |
| 4844 | |
| 4845 | if omciErr.GetError() == nil { |
mpagenko | 836a1fd | 2021-11-01 16:12:42 +0000 | [diff] [blame] | 4846 | omciLayer, msgLayer, err := oframe.EncodeFrame(meInstance, omci.SetRequestType, oframe.TransactionID(tid)) |
Himani Chawla | ee10b54 | 2021-09-20 16:46:40 +0530 | [diff] [blame] | 4847 | if err != nil { |
| 4848 | logger.Errorw(ctx, "cannot-encode-ethernet-frame-extended-pm-me", |
| 4849 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4850 | return nil, err |
| 4851 | } |
| 4852 | pkt, err := serializeOmciLayer(ctx, omciLayer, msgLayer) |
| 4853 | if err != nil { |
| 4854 | logger.Errorw(ctx, "cannot-serialize-ethernet-frame-extended-pm-me-set-msg", |
| 4855 | log.Fields{"err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4856 | return nil, err |
| 4857 | } |
| 4858 | omciRxCallbackPair := CallbackPair{ |
| 4859 | CbKey: tid, |
| 4860 | CbEntry: CallbackPairEntry{rxChan, oo.receiveOmciResponse, true}, |
| 4861 | } |
| 4862 | err = oo.Send(ctx, pkt, timeout, CDefaultRetries, highPrio, omciRxCallbackPair) |
| 4863 | if err != nil { |
| 4864 | logger.Errorw(ctx, "Cannot send ethernet-frame-extended-pm-me", |
| 4865 | log.Fields{"Err": err, "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4866 | return nil, err |
| 4867 | } |
| 4868 | logger.Debugw(ctx, "send-ethernet-frame-extended-pm-me-set-msg-done", |
| 4869 | log.Fields{"device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4870 | return meInstance, nil |
| 4871 | } |
| 4872 | logger.Errorw(ctx, "cannot-generate-ethernet-frame-extended-pm-me-instance", |
| 4873 | log.Fields{"Err": omciErr.GetError(), "device-id": oo.deviceID, "inst-id": strconv.FormatInt(int64(entityID), 16)}) |
| 4874 | return nil, omciErr.GetError() |
| 4875 | } |
Holger Hildebrandt | e7cc609 | 2022-02-01 11:37:03 +0000 | [diff] [blame] | 4876 | |
| 4877 | // PrepareForGarbageCollection - remove references to prepare for garbage collection |
| 4878 | func (oo *OmciCC) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) { |
| 4879 | logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID}) |
| 4880 | oo.pBaseDeviceHandler = nil |
| 4881 | oo.pOnuDeviceEntry = nil |
| 4882 | oo.pOnuAlarmManager = nil |
| 4883 | } |